Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove expected: arg. move back to _tokenKindNameTab

  • Loading branch information...
commit af33a8b133f4cb683b9ff5aa673783e13fda967c 1 parent d0034af
@itod authored
Showing with 878 additions and 336 deletions.
  1. +1 −1  include/ParseKit/PKSParser.h
  2. +3 −0  res/PKSClassImplementationTemplate.txt
  3. +1 −1  res/PKSMatchCallTemplate.txt
  4. +1 −1  res/PKSMatchDelimitedStringTemplate.txt
  5. +1 −1  res/PKSMatchPatternTemplate.txt
  6. +1 −1  res/PKSNegationPredictTemplate.txt
  7. +1 −1  res/PKSNegationSpeculateTemplate.txt
  8. +193 −0 res/minimath.md
  9. +57 −24 src/PKSParser.m
  10. +0 −1  src/PKSParserGenVisitor.m
  11. +8 −3 test/AltParser.m
  12. +42 −20 test/CSSParser.m
  13. +4 −1 test/DelimitedParser.m
  14. +4 −1 test/DotQuestionParser.m
  15. +6 −2 test/DreadedParser.m
  16. +14 −6 test/ElementAssignParser.m
  17. +8 −3 test/ElementParser.m
  18. +38 −20 test/ExpressionActionsParser.m
  19. +30 −14 test/ExpressionParser.m
  20. +14 −14 test/ExpressionSyntaxParser.m
  21. +6 −2 test/GreedParser.m
  22. +20 −10 test/HTMLParser.m
  23. +20 −9 test/JSONParser.m
  24. +140 −69 test/JavaScriptParser.m
  25. +11 −6 test/LabelEBNFParser.m
  26. +10 −5 test/LabelRecursiveParser.m
  27. +20 −10 test/MethodsFactoredParser.m
  28. +24 −14 test/MethodsParser.m
  29. +11 −6 test/MiniMathParser.m
  30. +6 −2 test/MultipleParser.m
  31. +6 −2 test/NamedActionParser.m
  32. +5 −2 test/NegationParser.m
  33. +6 −2 test/OptionalParser.m
  34. +83 −43 test/ParseKitParser.m
  35. +1 −1  test/PatternParser.m
  36. +2 −0  test/SemanticPredicateParser.m
  37. +74 −36 test/TDNSPredicateParser.m
  38. +6 −2 test/UnfinishedSeqParser.m
  39. BIN  test/expressionsyntax.parsergen
View
2  include/ParseKit/PKSParser.h
@@ -63,7 +63,7 @@ enum {
- (void)consume:(PKToken *)tok;
- (BOOL)predicts:(NSInteger)tokenKind, ...;
- (BOOL)speculate:(PKSSpeculateBlock)block;
-- (void)match:(NSInteger)tokenKind expecting:(NSString *)expecting discard:(BOOL)discard;
+- (void)match:(NSInteger)tokenKind discard:(BOOL)discard;
// error reporting
- (void)raise:(NSString *)msg;
View
3  res/PKSClassImplementationTemplate.txt
@@ -29,6 +29,7 @@
@interface PKSParser ()
@property (nonatomic, retain) NSMutableDictionary *_tokenKindTab;
+@property (nonatomic, retain) NSMutableArray *_tokenKindNameTab;
- (BOOL)_popBool;
- (NSInteger)_popInteger;
@@ -56,6 +57,8 @@
{%/if%}{%for kind in tokenKinds %} self._tokenKindTab[@"{{kind.stringValue}}"] = @({{kind.name}});
{%/for%}
+{%for kind in tokenKinds %} self._tokenKindNameTab[{{kind.name}}] = @"{{kind.stringValue}}";
+{%/for%}
{%if enableMemoization %}{%for methodName in ruleMethodNames %} self.{{methodName}}_memo = [NSMutableDictionary dictionary];
{%/for%}{%/if%} }
return self;
View
2  res/PKSMatchCallTemplate.txt
@@ -1 +1 @@
-{%for 1 to depth %} {%/for%}[self match:{{tokenKind.name}} expecting:@"{{methodName}}" discard:{%if discard %}YES{%else%}NO{%/if%}];
+{%for 1 to depth %} {%/for%}[self match:{{tokenKind.name}} discard:{%if discard %}YES{%else%}NO{%/if%}];
View
2  res/PKSMatchDelimitedStringTemplate.txt
@@ -1 +1 @@
-{%for 1 to depth %} {%/for%}[self match:{{tokenKind.name}} expecting:@"{{methodName}}" discard:{%if discard %}YES{%else%}NO{%/if%}];
+{%for 1 to depth %} {%/for%}[self match:{{tokenKind.name}} discard:{%if discard %}YES{%else%}NO{%/if%}];
View
2  res/PKSMatchPatternTemplate.txt
@@ -10,7 +10,7 @@
{%for 1 to depth %} {%/for%}NSString *str = LS(1);
{%for 1 to depth %} {%/for%}
{%for 1 to depth %} {%/for%}if ({%if predicate %}{{predicate}} && ({%/if%}[regex numberOfMatchesInString:str options:0 range:NSMakeRange(0, [str length])]{%if predicate %}){%/if%}) {
-{%for 1 to depth %} {%/for%} [self match:TOKEN_KIND_BUILTIN_ANY expecting:@"{{methodName}}" discard:{%if discard %}YES{%else%}NO{%/if%}];
+{%for 1 to depth %} {%/for%} [self match:TOKEN_KIND_BUILTIN_ANY discard:{%if discard %}YES{%else%}NO{%/if%}];
{%for 1 to depth %} {%/for%}} else {
{%for 1 to depth %} {%/for%} [self raise:@"pattern test failed in {{methodName}}"];
{%for 1 to depth %} {%/for%}}
View
2  res/PKSNegationPredictTemplate.txt
@@ -1,5 +1,5 @@
{%for 1 to depth %} {%/for%}if ({%if predicate %}{{predicate}} && ({%/if%}{%for tokenKind in lookaheadSet%}![self predicts:{{tokenKind.name}}, 0]{%if currentLoop.currentIndex != last %} && {%/if%}{%/for%}{%if predicate %}){%/if%}) {
-{%for 1 to depth %} {%/for%} [self match:TOKEN_KIND_BUILTIN_ANY expecting:@"{{methodName}}" discard:{%if discard %}YES{%else%}NO{%/if%}];
+{%for 1 to depth %} {%/for%} [self match:TOKEN_KIND_BUILTIN_ANY discard:{%if discard %}YES{%else%}NO{%/if%}];
{%for 1 to depth %} {%/for%}} else {
{%for 1 to depth %} {%/for%} [self raise:@"negation test failed in {{methodName}}"];
{%for 1 to depth %} {%/for%}}
View
2  res/PKSNegationSpeculateTemplate.txt
@@ -1,5 +1,5 @@
{%for 1 to depth %} {%/for%}if (![self speculate:^{ {%if predicate %}{{predicate}}; {%/if%}{{ifTest}}}]) {
-{%for 1 to depth %} {%/for%} [self match:TOKEN_KIND_BUILTIN_ANY expecting:@"{{methodName}}" discard:{%if discard %}YES{%else%}NO{%/if%}];
+{%for 1 to depth %} {%/for%} [self match:TOKEN_KIND_BUILTIN_ANY discard:{%if discard %}YES{%else%}NO{%/if%}];
{%for 1 to depth %} {%/for%}} else {
{%for 1 to depth %} {%/for%} [self raise:@"negation test failed in {{methodName}}"];
{%for 1 to depth %} {%/for%}}
View
193 res/minimath.md
@@ -0,0 +1,193 @@
+Hey there, it looks like you're trying to parse text input in Objective-C. You've come to the right place.
+
+ParseKit is a parser generator implemented in Objective-C, which converts grammars into parsers intended for use in Cocoa applications running on iOS or Mac OS X.
+
+With ParseKit, you can define your language with a high-level, easy-to-use, BNF-style grammar, and ParseKit will generate source code for a parser for your language.
+
+Specifically, parsers produced by ParseKit are **recursive descent**, **deterministic**, **packrat**, **LL(k)** (this is, *infinite-lookahead*) parsers written in Objective-C. That's a mouthful, but what it means in practice is that ParseKit offers you a great deal of flexibility and expressive power when designing your grammars, but also produces parsers which exhibit good (linear) performance characteristics at runtime. Also, the Objective-C code produced by ParseKit is clean, readable, and easy to debug or tweak by hand.
+
+
+The design of ParseKit has been heavily influenced by [ANTLR](http://antlr.org) and a [book by Stephen J Metsker](http://www.amazon.com/Building-Parsers-Java-Steven-Metsker/dp/0201719622).
+
+In this tutorial, I'll show how to use ParseKit to implement a small "MiniMath" expression language in an iOS application.
+
+### Desginging the Grammar
+
+First, let's design a ParseKit grammar for our "MiniMath" language. "MiniMath" should allow expressions like:
+
+ 1 // bare numbers
+ 2 + 2 + 42 // addition (including repetition)
+ 2 * (2 + 4) // multiplication and sub-expressions
+
+OK, now that we know what the expected input looks like, let's build the grammar. Every ParseKit grammar has to start with a rule called `@start`. Since MiniMath is an expression language, let's define our `@start` rule as an expression.
+
+ @start = expr;
+
+But how do we define `expr`?
+
+ expr = ??? // TODO
+
+Rather than designing our grammar from the top down, let's hold that thought, and work from the bottom up instead.
+
+Working from the bottom, we'll start with a rule called `atom`. And since MiniMath deals with numbers, we'll define `atom` as a `Number`.
+
+ atom = Number;
+
+Notice how the rules we define ourselves (like `expr` and `atom`) start with lowercase letters. There are also built-in terminal rules like `Number`, `Word`, `QuotedString` and more. The built-in rules always start with uppercase letters, while the rules we define ourselves must start with lowercase letters.
+
+The built-in `Number` rule matches a series of digits as you would expect. By default, it also matches optional floating-point and exponential parts of a number (this behavior is easily configurable).
+
+Now that we have defined an `atom` rule, let's define a primary expression.
+
+ primary = atom | '(' expr ')';
+
+A `primary` expression is either an atom or a parenthesized sub expression. The parentheses here can be used to alter operator precedence.
+
+Notice how we are using recursion to call our own `expr` rule. There is no problem with that (although in ParseKit grammars, you must always avoid [left recursion](http://en.wikipedia.org/wiki/Left_recursion)).
+
+Now let's move on to multiplication and addition. As usual, we want multiplication to bind more tightly than addition. Since we are working from the bottom up, we can make multiplication bind more tightly by defining it first.
+
+Let's define multiplication as a primary expression times a primary expression.
+
+ multExpr = primary '*' primary;
+
+But we want to allow repetition in our multiplication expressions, like `2 * 8 * 0`, so we'll change our `multExpr` rule by wrapping the operator and the right-hand side operand in an optional repetition using `*`.
+
+ multExpr = primary ('*' primary)*;
+
+Our addition rule will look very similar:
+
+ addExpr = multExpr ('+' multExpr)*;
+
+Since our addition rule is defined in terms of multiplication operands, this will force multiplication to bind more tightly than addition.
+
+Now we can define our `expr` rule as an addition expression:
+
+ @start = expr;
+ expr = addExpr;
+
+Finally, let's change our grammar to discard unnecessary tokens. The post-fix `!` operator can be used to discard a token which is not needed to compute a result. In the case of MiniMath, we'll want to discard any token that is not a number (all of the literal strings in our grammar).
+
+Here's the complete grammar:
+
+ @start = expr;
+ expr = addExpr;
+ addExpr = multExpr ('+'! multExpr)*;
+ multExpr = primary ('*'! primary)*;
+ primary = atom | '('! expr ')'!;
+ atom = Number;
+
+### Adding Actions to the Grammar
+
+OK, so we designed a grammar for our MiniMath language that can be fed to ParseKit to produce Objective-C source code for our parser.
+
+But we don't just want to parse input, we also want to compute a result. The easiest way to do this is to use **grammar actions**. Grammar actions are small pieces of Objective-C source code embedded directly in a ParseKit grammar.
+
+We'll start by adding an Action to the `atom` rule:
+
+ atom = Number
+ {
+ PKToken *tok = [self.assembly pop]; // pop the Number token
+ NSAssert(tok.isNumber, @"a number token just matched in `atom`");
+
+ NSNumber *n = @(tok.floatValue);
+ [self.assembly push:n]; // push an NSNumber object
+ };
+
+As you can see, actions are blocks of Objective-C code enclosed in curly braces and placed after any rule reference. In any action, there is an `assembly` object available which serves as a **stack**. The `assembly`'s stack contains the most recently parsed tokens (instances of `PKToken`), and also serves as a place to store your work as you compute the result.
+
+Actions are executed immediately after their preceeding rule matches. So tokens which have recently been matched are available at the top of the `assembly`'s stack.
+
+In this case, we are popping a number token off the stack, converting it to a float value, and pushing an `NSNumber` back onto the stack for later use.
+
+ParseKit includes some handy macros that can make this code more concise. Here's the `atom` rule and action rewritten using those macros:
+
+ atom = Number {
+ // pop a token off the stack and push it back as a float value
+ PUSH_FLOAT(POP_FLOAT());
+ };
+
+This shortened action is exactly equivalent to the more verbose version above.
+
+Now let's add an action to perform multiplication in the `multExpr` rule:
+
+ multExpr = primary ('*'! primary {
+ NSNumber *rhs = [self.assembly pop];
+ NSNumber *lhs = [self.assembly pop];
+ NSNumber *n = @([lhs floatValue] * [rhs floatValue]);
+ [self.assembly push:n];
+ })*;
+
+This action executes immediately after the multiply operator (`*`) and right-hand side `primary` operand have been matched. Since the `*` operator has been discarded, we can be assured that the top 2 objects on the stack are NSNumbers placed by our `atom` rule action.
+
+Again, we can use ParseKit's handy built-in macros to simplify our Objective-C action code. Here's the same action simplified:
+
+ multExpr = primary ('*'! primary {
+ PUSH_FLOAT(POP_FLOAT() * POP_FLOAT());
+ })*;
+
+Finally, we'll need a similar action for our addition expression rule. Here's the complete grammar including actions:
+
+ @start = expr;
+ expr = addExpr;
+ addExpr = multExpr ('+'! multExpr {
+ PUSH_FLOAT(POP_FLOAT() + POP_FLOAT());
+ })*;
+ multExpr = primary ('*'! primary {
+ PUSH_FLOAT(POP_FLOAT() * POP_FLOAT());
+ })*;
+ primary = atom | '('! expr ')'!;
+ atom = Number {
+ PUSH_FLOAT(POP_FLOAT());
+ };
+
+
+### Interlude: Checkout the Example Project (with ParseKit Dependency)
+
+OK, time to [checkout the ParseKit MiniMath Example](https://github.com/itod/ParseKitMiniMathExample/zipball/master) project. This project includes [ParseKit](https://github.com/itod/parsekit) as an external dependency.
+
+### Generating Parser Source Code
+
+Now that our MiniMath grammar is complete, we can use ParseKit to generate Objective-C source code for our parser.
+
+Open the MiniMath Xcode project, then select and run the **ParserGenApp** target.
+
+**ParserGenApp** is actually a target in the embedded ParseKit sub-project, and is the way you convert your ParseKit grammars into Objective-C source code.
+
+Paste the MiniMath grammar into the large text area at the bottom of the ParserGenApp window, and select the options shown below.
+
+![ParserGenApp](http://parsekit.com/github/parsergen.png)
+
+Click the **Generate** button and notice that a [MiniMathParser.h](https://github.com/itod/ParseKitMiniMathExample/blob/master/MiniMath/MiniMathParser.h) [MiniMathParser.m](https://github.com/itod/ParseKitMiniMathExample/blob/master/MiniMath/MiniMathParser.m) file have been created, and appear on your Desktop. You'll need to drag this source code into your app's Xcode project.
+
+![Produced Files](http://parsekit.com/github/files.png)
+
+### Run the MiniMath Example iOS App
+
+Now switch to the **MiniMath** target. This target is an example iOS app with an **input** textfield, **calc** button and a **result** textfield:
+
+![MiniMathApp](http://parsekit.com/github/app_empty.png)
+
+Here's the impelementation of the `calc:` Action attached to the **calc** button:
+
+ - (IBAction)calc:(id)sender {
+ NSString *input = [_inputField text];
+
+ MiniMathParser *parser = [[MiniMathParser alloc] init];
+
+ NSError *err = nil;
+ PKAssembly *result = [parser parseString:input assembler:self error:&err];
+
+ if (!result) {
+ if (err) NSLog(@"%@", err);
+ return;
+ }
+
+ // print the entire assembly in the result output field
+ [_outputField setText:[result description]];
+ }
+
+
+And here's the app after computing a result:
+
+![MiniMathApp](http://parsekit.com/github/app.png)
View
81 src/PKSParser.m
@@ -33,9 +33,11 @@ @interface PKSParser ()
@property (nonatomic, assign) NSInteger _skip;
@property (nonatomic, assign, readonly) BOOL _isSpeculating;
@property (nonatomic, retain) NSMutableDictionary *_tokenKindTab;
+@property (nonatomic, retain) NSMutableArray *_tokenKindNameTab;
@property (nonatomic, retain) NSCountedSet *_resyncSet;
-- (NSInteger)tokenKindForString:(NSString *)s;
+- (NSInteger)tokenKindForString:(NSString *)str;
+- (NSString *)stringForTokenKind:(NSInteger)tokenKind;
- (BOOL)lookahead:(NSInteger)x predicts:(NSInteger)tokenKind;
- (void)fireSyntaxSelector:(SEL)sel withRuleName:(NSString *)ruleName;
@@ -81,7 +83,25 @@ - (id)init {
self._exception = [[[PKSRecognitionException alloc] initWithName:NSStringFromClass([PKSRecognitionException class]) reason:nil userInfo:nil] autorelease];
self._tokenKindTab = [NSMutableDictionary dictionary];
- }
+
+ self._tokenKindNameTab = [NSMutableArray array];
+ self._tokenKindNameTab[TOKEN_KIND_BUILTIN_INVALID] = @"";
+ self._tokenKindNameTab[TOKEN_KIND_BUILTIN_NUMBER] = @"Number";
+ self._tokenKindNameTab[TOKEN_KIND_BUILTIN_QUOTEDSTRING] = @"Quoted String";
+ self._tokenKindNameTab[TOKEN_KIND_BUILTIN_SYMBOL] = @"Symbol";
+ self._tokenKindNameTab[TOKEN_KIND_BUILTIN_WORD] = @"Word";
+ self._tokenKindNameTab[TOKEN_KIND_BUILTIN_LOWERCASEWORD] = @"Lowercase Word";
+ self._tokenKindNameTab[TOKEN_KIND_BUILTIN_UPPERCASEWORD] = @"Uppercase Word";
+ self._tokenKindNameTab[TOKEN_KIND_BUILTIN_WHITESPACE] = @"Whitespace";
+ self._tokenKindNameTab[TOKEN_KIND_BUILTIN_COMMENT] = @"Comment";
+ self._tokenKindNameTab[TOKEN_KIND_BUILTIN_DELIMITEDSTRING] = @"Delimited String";
+ self._tokenKindNameTab[TOKEN_KIND_BUILTIN_URL] = @"URL";
+ self._tokenKindNameTab[TOKEN_KIND_BUILTIN_EMAIL] = @"Email";
+ self._tokenKindNameTab[TOKEN_KIND_BUILTIN_TWITTER] = @"Twitter";
+ self._tokenKindNameTab[TOKEN_KIND_BUILTIN_HASHTAG] = @"Hashtag";
+ self._tokenKindNameTab[TOKEN_KIND_BUILTIN_EMPTY] = @"Empty";
+ self._tokenKindNameTab[TOKEN_KIND_BUILTIN_ANY] = @"Any";
+}
return self;
}
@@ -94,6 +114,7 @@ - (void)dealloc {
self._lookahead = nil;
self._markers = nil;
self._tokenKindTab = nil;
+ self._tokenKindNameTab = nil;
self._resyncSet = nil;
[super dealloc];
}
@@ -108,15 +129,28 @@ - (NSInteger)tokenizer:(PKTokenizer *)t tokenKindForStringValue:(NSString *)str
}
-- (NSInteger)tokenKindForString:(NSString *)s {
- NSInteger x = TOKEN_KIND_BUILTIN_INVALID;
+- (NSInteger)tokenKindForString:(NSString *)str {
+ NSInteger tokenKind = TOKEN_KIND_BUILTIN_INVALID;
- id obj = self._tokenKindTab[s];
+ id obj = self._tokenKindTab[str];
if (obj) {
- x = [obj integerValue];
+ tokenKind = [obj integerValue];
}
- return x;
+ return tokenKind;
+}
+
+
+- (NSString *)stringForTokenKind:(NSInteger)tokenKind {
+ NSString *str = nil;
+
+ if (TOKEN_KIND_BUILTIN_EOF == tokenKind) {
+ str = [[PKToken EOFToken] stringValue];
+ } else {
+ str = self._tokenKindNameTab[tokenKind];
+ }
+
+ return str;
}
@@ -221,7 +255,7 @@ - (id)_parseWithTokenizer:(PKTokenizer *)t assembler:(id)a error:(NSError **)out
}
-- (void)match:(NSInteger)tokenKind expecting:(NSString *)expecting discard:(BOOL)discard {
+- (void)match:(NSInteger)tokenKind discard:(BOOL)discard {
NSParameterAssert(tokenKind != TOKEN_KIND_BUILTIN_INVALID);
NSAssert(_lookahead, @"");
@@ -248,7 +282,7 @@ - (void)match:(NSInteger)tokenKind expecting:(NSString *)expecting discard:(BOOL
if (discard) [self _discard];
}
} else {
- NSString *msg = [NSString stringWithFormat:@"Expected : %@", expecting];
+ NSString *msg = [NSString stringWithFormat:@"Expected : %@", [self stringForTokenKind:tokenKind]];
[self raise:msg];
}
}
@@ -440,12 +474,11 @@ - (void)raise:(NSString *)msg {
NSMutableString *after = [NSMutableString string];
NSString *delim = _silentlyConsumesWhitespace ? @"" : @" ";
- if ([_lookahead count]) {
- for (PKToken *tok in [_lookahead reverseObjectEnumerator]) {
- if (NSNotFound == tok.lineNumber || tok.lineNumber < lineNum - 1) break;
- if (tok.lineNumber == lineNum) {
- [after insertString:[NSString stringWithFormat:@"%@%@", tok.stringValue, delim] atIndex:0];
- }
+ for (PKToken *tok in [_lookahead reverseObjectEnumerator]) {
+ NSAssert(NSNotFound != tok.lineNumber, @"");
+ if (tok.lineNumber < lineNum - 1) break;
+ if (tok.lineNumber == lineNum) {
+ [after insertString:[NSString stringWithFormat:@"%@%@", tok.stringValue, delim] atIndex:0];
}
}
@@ -723,12 +756,12 @@ - (void)_start {
- (void)matchEOF:(BOOL)discard {
- [self match:TOKEN_KIND_BUILTIN_EOF expecting:@"XXX" discard:discard];
+ [self match:TOKEN_KIND_BUILTIN_EOF discard:discard];
}
- (void)matchAny:(BOOL)discard {
- [self match:TOKEN_KIND_BUILTIN_ANY expecting:@"Any" discard:discard];
+ [self match:TOKEN_KIND_BUILTIN_ANY discard:discard];
}
@@ -738,37 +771,37 @@ - (void)matchEmpty:(BOOL)discard {
- (void)matchWord:(BOOL)discard {
- [self match:TOKEN_KIND_BUILTIN_WORD expecting:@"Word" discard:discard];
+ [self match:TOKEN_KIND_BUILTIN_WORD discard:discard];
}
- (void)matchNumber:(BOOL)discard {
- [self match:TOKEN_KIND_BUILTIN_NUMBER expecting:@"Number" discard:discard];
+ [self match:TOKEN_KIND_BUILTIN_NUMBER discard:discard];
}
- (void)matchSymbol:(BOOL)discard {
- [self match:TOKEN_KIND_BUILTIN_SYMBOL expecting:@"Symbol" discard:discard];
+ [self match:TOKEN_KIND_BUILTIN_SYMBOL discard:discard];
}
- (void)matchComment:(BOOL)discard {
- [self match:TOKEN_KIND_BUILTIN_COMMENT expecting:@"Comment" discard:discard];
+ [self match:TOKEN_KIND_BUILTIN_COMMENT discard:discard];
}
- (void)matchWhitespace:(BOOL)discard {
- [self match:TOKEN_KIND_BUILTIN_WHITESPACE expecting:@"Whitespace" discard:discard];
+ [self match:TOKEN_KIND_BUILTIN_WHITESPACE discard:discard];
}
- (void)matchQuotedString:(BOOL)discard {
- [self match:TOKEN_KIND_BUILTIN_QUOTEDSTRING expecting:@"QuotedString" discard:discard];
+ [self match:TOKEN_KIND_BUILTIN_QUOTEDSTRING discard:discard];
}
- (void)matchDelimitedString:(BOOL)discard {
- [self match:TOKEN_KIND_BUILTIN_DELIMITEDSTRING expecting:@"DelimitedString" discard:discard];
+ [self match:TOKEN_KIND_BUILTIN_DELIMITEDSTRING discard:discard];
}
@synthesize _exception = _exception;
View
1  src/PKSParserGenVisitor.m
@@ -963,7 +963,6 @@ - (void)visitLiteral:(PKLiteralNode *)node {
vars[TOKEN_KIND] = node.tokenKind;
vars[DEPTH] = @(_depth);
vars[DISCARD] = @(node.discard);
- vars[METHOD_NAME] = node.token.stringValue;
// merge
NSMutableString *output = [NSMutableString string];
View
11 test/AltParser.m
@@ -29,6 +29,7 @@
@interface PKSParser ()
@property (nonatomic, retain) NSMutableDictionary *_tokenKindTab;
+@property (nonatomic, retain) NSMutableArray *_tokenKindNameTab;
- (BOOL)_popBool;
- (NSInteger)_popInteger;
@@ -59,6 +60,10 @@ - (id)init {
self._tokenKindTab[@"bar"] = @(ALT_TOKEN_KIND_BAR);
self._tokenKindTab[@"baz"] = @(ALT_TOKEN_KIND_BAZ);
+ self._tokenKindNameTab[ALT_TOKEN_KIND_FOO] = @"foo";
+ self._tokenKindNameTab[ALT_TOKEN_KIND_BAR] = @"bar";
+ self._tokenKindNameTab[ALT_TOKEN_KIND_BAZ] = @"baz";
+
self.s_memo = [NSMutableDictionary dictionary];
self.a_memo = [NSMutableDictionary dictionary];
self.b_memo = [NSMutableDictionary dictionary];
@@ -145,7 +150,7 @@ - (void)b {
- (void)__foo {
- [self match:ALT_TOKEN_KIND_FOO expecting:@"'foo'" discard:NO];
+ [self match:ALT_TOKEN_KIND_FOO discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchFoo:)];
}
@@ -156,7 +161,7 @@ - (void)foo {
- (void)__bar {
- [self match:ALT_TOKEN_KIND_BAR expecting:@"'bar'" discard:NO];
+ [self match:ALT_TOKEN_KIND_BAR discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchBar:)];
}
@@ -167,7 +172,7 @@ - (void)bar {
- (void)__baz {
- [self match:ALT_TOKEN_KIND_BAZ expecting:@"'baz'" discard:NO];
+ [self match:ALT_TOKEN_KIND_BAZ discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchBaz:)];
}
View
62 test/CSSParser.m
@@ -29,6 +29,7 @@
@interface PKSParser ()
@property (nonatomic, retain) NSMutableDictionary *_tokenKindTab;
+@property (nonatomic, retain) NSMutableArray *_tokenKindNameTab;
- (BOOL)_popBool;
- (NSInteger)_popInteger;
@@ -107,6 +108,27 @@ - (id)init {
self._tokenKindTab[@")"] = @(CSS_TOKEN_KIND_CLOSEPAREN);
self._tokenKindTab[@"}"] = @(CSS_TOKEN_KIND_CLOSECURLY);
+ self._tokenKindNameTab[CSS_TOKEN_KIND_COMMA] = @",";
+ self._tokenKindNameTab[CSS_TOKEN_KIND_COLON] = @":";
+ self._tokenKindNameTab[CSS_TOKEN_KIND_TILDE] = @"~";
+ self._tokenKindNameTab[CSS_TOKEN_KIND_SEMI] = @";";
+ self._tokenKindNameTab[CSS_TOKEN_KIND_DOT] = @".";
+ self._tokenKindNameTab[CSS_TOKEN_KIND_BANG] = @"!";
+ self._tokenKindNameTab[CSS_TOKEN_KIND_FWDSLASH] = @"/";
+ self._tokenKindNameTab[CSS_TOKEN_KIND_EQ] = @"=";
+ self._tokenKindNameTab[CSS_TOKEN_KIND_GT] = @">";
+ self._tokenKindNameTab[CSS_TOKEN_KIND_HASHSYM] = @"#";
+ self._tokenKindNameTab[CSS_TOKEN_KIND_OPENBRACKET] = @"[";
+ self._tokenKindNameTab[CSS_TOKEN_KIND_AT] = @"@";
+ self._tokenKindNameTab[CSS_TOKEN_KIND_CLOSEBRACKET] = @"]";
+ self._tokenKindNameTab[CSS_TOKEN_KIND_OPENPAREN] = @"(";
+ self._tokenKindNameTab[CSS_TOKEN_KIND_OPENCURLY] = @"{";
+ self._tokenKindNameTab[CSS_TOKEN_KIND_URLUPPER] = @"URL(,)";
+ self._tokenKindNameTab[CSS_TOKEN_KIND_URLLOWER] = @"url(,)";
+ self._tokenKindNameTab[CSS_TOKEN_KIND_PIPE] = @"|";
+ self._tokenKindNameTab[CSS_TOKEN_KIND_CLOSEPAREN] = @")";
+ self._tokenKindNameTab[CSS_TOKEN_KIND_CLOSECURLY] = @"}";
+
self.ruleset_memo = [NSMutableDictionary dictionary];
self.selectors_memo = [NSMutableDictionary dictionary];
self.selector_memo = [NSMutableDictionary dictionary];
@@ -490,7 +512,7 @@ - (void)url {
- (void)__urlLower {
- [self match:CSS_TOKEN_KIND_URLLOWER expecting:@"urlLower" discard:NO];
+ [self match:CSS_TOKEN_KIND_URLLOWER discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchUrlLower:)];
}
@@ -501,7 +523,7 @@ - (void)urlLower {
- (void)__urlUpper {
- [self match:CSS_TOKEN_KIND_URLUPPER expecting:@"urlUpper" discard:NO];
+ [self match:CSS_TOKEN_KIND_URLUPPER discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchUrlUpper:)];
}
@@ -562,7 +584,7 @@ - (void)constant {
- (void)__openCurly {
- [self match:CSS_TOKEN_KIND_OPENCURLY expecting:@"'{'" discard:NO];
+ [self match:CSS_TOKEN_KIND_OPENCURLY discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchOpenCurly:)];
}
@@ -573,7 +595,7 @@ - (void)openCurly {
- (void)__closeCurly {
- [self match:CSS_TOKEN_KIND_CLOSECURLY expecting:@"'}'" discard:NO];
+ [self match:CSS_TOKEN_KIND_CLOSECURLY discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchCloseCurly:)];
}
@@ -584,7 +606,7 @@ - (void)closeCurly {
- (void)__openBracket {
- [self match:CSS_TOKEN_KIND_OPENBRACKET expecting:@"'['" discard:NO];
+ [self match:CSS_TOKEN_KIND_OPENBRACKET discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchOpenBracket:)];
}
@@ -595,7 +617,7 @@ - (void)openBracket {
- (void)__closeBracket {
- [self match:CSS_TOKEN_KIND_CLOSEBRACKET expecting:@"']'" discard:NO];
+ [self match:CSS_TOKEN_KIND_CLOSEBRACKET discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchCloseBracket:)];
}
@@ -606,7 +628,7 @@ - (void)closeBracket {
- (void)__eq {
- [self match:CSS_TOKEN_KIND_EQ expecting:@"'='" discard:NO];
+ [self match:CSS_TOKEN_KIND_EQ discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchEq:)];
}
@@ -617,7 +639,7 @@ - (void)eq {
- (void)__comma {
- [self match:CSS_TOKEN_KIND_COMMA expecting:@"','" discard:NO];
+ [self match:CSS_TOKEN_KIND_COMMA discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchComma:)];
}
@@ -628,7 +650,7 @@ - (void)comma {
- (void)__colon {
- [self match:CSS_TOKEN_KIND_COLON expecting:@"':'" discard:NO];
+ [self match:CSS_TOKEN_KIND_COLON discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchColon:)];
}
@@ -639,7 +661,7 @@ - (void)colon {
- (void)__semi {
- [self match:CSS_TOKEN_KIND_SEMI expecting:@"';'" discard:NO];
+ [self match:CSS_TOKEN_KIND_SEMI discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchSemi:)];
}
@@ -650,7 +672,7 @@ - (void)semi {
- (void)__openParen {
- [self match:CSS_TOKEN_KIND_OPENPAREN expecting:@"'('" discard:NO];
+ [self match:CSS_TOKEN_KIND_OPENPAREN discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchOpenParen:)];
}
@@ -661,7 +683,7 @@ - (void)openParen {
- (void)__closeParen {
- [self match:CSS_TOKEN_KIND_CLOSEPAREN expecting:@"')'" discard:NO];
+ [self match:CSS_TOKEN_KIND_CLOSEPAREN discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchCloseParen:)];
}
@@ -672,7 +694,7 @@ - (void)closeParen {
- (void)__gt {
- [self match:CSS_TOKEN_KIND_GT expecting:@"'>'" discard:NO];
+ [self match:CSS_TOKEN_KIND_GT discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchGt:)];
}
@@ -683,7 +705,7 @@ - (void)gt {
- (void)__tilde {
- [self match:CSS_TOKEN_KIND_TILDE expecting:@"'~'" discard:NO];
+ [self match:CSS_TOKEN_KIND_TILDE discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchTilde:)];
}
@@ -694,7 +716,7 @@ - (void)tilde {
- (void)__pipe {
- [self match:CSS_TOKEN_KIND_PIPE expecting:@"'|'" discard:NO];
+ [self match:CSS_TOKEN_KIND_PIPE discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchPipe:)];
}
@@ -705,7 +727,7 @@ - (void)pipe {
- (void)__fwdSlash {
- [self match:CSS_TOKEN_KIND_FWDSLASH expecting:@"'/'" discard:NO];
+ [self match:CSS_TOKEN_KIND_FWDSLASH discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchFwdSlash:)];
}
@@ -716,7 +738,7 @@ - (void)fwdSlash {
- (void)__hashSym {
- [self match:CSS_TOKEN_KIND_HASHSYM expecting:@"'#'" discard:NO];
+ [self match:CSS_TOKEN_KIND_HASHSYM discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchHashSym:)];
}
@@ -727,7 +749,7 @@ - (void)hashSym {
- (void)__dot {
- [self match:CSS_TOKEN_KIND_DOT expecting:@"'.'" discard:NO];
+ [self match:CSS_TOKEN_KIND_DOT discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchDot:)];
}
@@ -738,7 +760,7 @@ - (void)dot {
- (void)__at {
- [self match:CSS_TOKEN_KIND_AT expecting:@"'@'" discard:NO];
+ [self match:CSS_TOKEN_KIND_AT discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchAt:)];
}
@@ -749,7 +771,7 @@ - (void)at {
- (void)__bang {
- [self match:CSS_TOKEN_KIND_BANG expecting:@"'!'" discard:NO];
+ [self match:CSS_TOKEN_KIND_BANG discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchBang:)];
}
View
5 test/DelimitedParser.m
@@ -29,6 +29,7 @@
@interface PKSParser ()
@property (nonatomic, retain) NSMutableDictionary *_tokenKindTab;
+@property (nonatomic, retain) NSMutableArray *_tokenKindNameTab;
- (BOOL)_popBool;
- (NSInteger)_popInteger;
@@ -52,6 +53,8 @@ - (id)init {
if (self) {
self._tokenKindTab[@"<,>"] = @(DELIMITED_TOKEN_KIND_S);
+ self._tokenKindNameTab[DELIMITED_TOKEN_KIND_S] = @"<,>";
+
self.s_memo = [NSMutableDictionary dictionary];
}
return self;
@@ -84,7 +87,7 @@ - (void)_start {
- (void)__s {
- [self match:DELIMITED_TOKEN_KIND_S expecting:@"s" discard:NO];
+ [self match:DELIMITED_TOKEN_KIND_S discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchS:)];
}
View
5 test/DotQuestionParser.m
@@ -29,6 +29,7 @@
@interface PKSParser ()
@property (nonatomic, retain) NSMutableDictionary *_tokenKindTab;
+@property (nonatomic, retain) NSMutableArray *_tokenKindNameTab;
- (BOOL)_popBool;
- (NSInteger)_popInteger;
@@ -52,6 +53,8 @@ - (id)init {
if (self) {
self._tokenKindTab[@"a"] = @(DOTQUESTION_TOKEN_KIND_A);
+ self._tokenKindNameTab[DOTQUESTION_TOKEN_KIND_A] = @"a";
+
self.a_memo = [NSMutableDictionary dictionary];
}
return self;
@@ -80,7 +83,7 @@ - (void)_start {
- (void)__a {
- [self match:DOTQUESTION_TOKEN_KIND_A expecting:@"'a'" discard:NO];
+ [self match:DOTQUESTION_TOKEN_KIND_A discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchA:)];
}
View
8 test/DreadedParser.m
@@ -29,6 +29,7 @@
@interface PKSParser ()
@property (nonatomic, retain) NSMutableDictionary *_tokenKindTab;
+@property (nonatomic, retain) NSMutableArray *_tokenKindNameTab;
- (BOOL)_popBool;
- (NSInteger)_popInteger;
@@ -55,6 +56,9 @@ - (id)init {
self._tokenKindTab[@"a"] = @(DREADED_TOKEN_KIND_A);
self._tokenKindTab[@"b"] = @(DREADED_TOKEN_KIND_B);
+ self._tokenKindNameTab[DREADED_TOKEN_KIND_A] = @"a";
+ self._tokenKindNameTab[DREADED_TOKEN_KIND_B] = @"b";
+
self.s_memo = [NSMutableDictionary dictionary];
self.a_memo = [NSMutableDictionary dictionary];
self.b_memo = [NSMutableDictionary dictionary];
@@ -103,7 +107,7 @@ - (void)s {
- (void)__a {
- [self match:DREADED_TOKEN_KIND_A expecting:@"'a'" discard:NO];
+ [self match:DREADED_TOKEN_KIND_A discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchA:)];
}
@@ -114,7 +118,7 @@ - (void)a {
- (void)__b {
- [self match:DREADED_TOKEN_KIND_B expecting:@"'b'" discard:NO];
+ [self match:DREADED_TOKEN_KIND_B discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchB:)];
}
View
20 test/ElementAssignParser.m
@@ -29,6 +29,7 @@
@interface PKSParser ()
@property (nonatomic, retain) NSMutableDictionary *_tokenKindTab;
+@property (nonatomic, retain) NSMutableArray *_tokenKindNameTab;
- (BOOL)_popBool;
- (NSInteger)_popInteger;
@@ -58,6 +59,13 @@ - (id)init {
self._tokenKindTab[@";"] = @(ELEMENTASSIGN_TOKEN_KIND_SEMI);
self._tokenKindTab[@"."] = @(ELEMENTASSIGN_TOKEN_KIND_DOT);
+ self._tokenKindNameTab[ELEMENTASSIGN_TOKEN_KIND_RBRACKET] = @"]";
+ self._tokenKindNameTab[ELEMENTASSIGN_TOKEN_KIND_LBRACKET] = @"[";
+ self._tokenKindNameTab[ELEMENTASSIGN_TOKEN_KIND_COMMA] = @",";
+ self._tokenKindNameTab[ELEMENTASSIGN_TOKEN_KIND_EQ] = @"=";
+ self._tokenKindNameTab[ELEMENTASSIGN_TOKEN_KIND_SEMI] = @";";
+ self._tokenKindNameTab[ELEMENTASSIGN_TOKEN_KIND_DOT] = @".";
+
}
return self;
}
@@ -155,42 +163,42 @@ - (void)element {
- (void)lbracket {
- [self match:ELEMENTASSIGN_TOKEN_KIND_LBRACKET expecting:@"'['" discard:NO];
+ [self match:ELEMENTASSIGN_TOKEN_KIND_LBRACKET discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchLbracket:)];
}
- (void)rbracket {
- [self match:ELEMENTASSIGN_TOKEN_KIND_RBRACKET expecting:@"']'" discard:YES];
+ [self match:ELEMENTASSIGN_TOKEN_KIND_RBRACKET discard:YES];
[self fireAssemblerSelector:@selector(parser:didMatchRbracket:)];
}
- (void)comma {
- [self match:ELEMENTASSIGN_TOKEN_KIND_COMMA expecting:@"','" discard:YES];
+ [self match:ELEMENTASSIGN_TOKEN_KIND_COMMA discard:YES];
[self fireAssemblerSelector:@selector(parser:didMatchComma:)];
}
- (void)eq {
- [self match:ELEMENTASSIGN_TOKEN_KIND_EQ expecting:@"'='" discard:NO];
+ [self match:ELEMENTASSIGN_TOKEN_KIND_EQ discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchEq:)];
}
- (void)dot {
- [self match:ELEMENTASSIGN_TOKEN_KIND_DOT expecting:@"'.'" discard:NO];
+ [self match:ELEMENTASSIGN_TOKEN_KIND_DOT discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchDot:)];
}
- (void)semi {
- [self match:ELEMENTASSIGN_TOKEN_KIND_SEMI expecting:@"';'" discard:NO];
+ [self match:ELEMENTASSIGN_TOKEN_KIND_SEMI discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchSemi:)];
}
View
11 test/ElementParser.m
@@ -29,6 +29,7 @@
@interface PKSParser ()
@property (nonatomic, retain) NSMutableDictionary *_tokenKindTab;
+@property (nonatomic, retain) NSMutableArray *_tokenKindNameTab;
- (BOOL)_popBool;
- (NSInteger)_popInteger;
@@ -59,6 +60,10 @@ - (id)init {
self._tokenKindTab[@"]"] = @(ELEMENT_TOKEN_KIND_RBRACKET);
self._tokenKindTab[@","] = @(ELEMENT_TOKEN_KIND_COMMA);
+ self._tokenKindNameTab[ELEMENT_TOKEN_KIND_LBRACKET] = @"[";
+ self._tokenKindNameTab[ELEMENT_TOKEN_KIND_RBRACKET] = @"]";
+ self._tokenKindNameTab[ELEMENT_TOKEN_KIND_COMMA] = @",";
+
self.list_memo = [NSMutableDictionary dictionary];
self.elements_memo = [NSMutableDictionary dictionary];
self.element_memo = [NSMutableDictionary dictionary];
@@ -147,7 +152,7 @@ - (void)element {
- (void)__lbracket {
- [self match:ELEMENT_TOKEN_KIND_LBRACKET expecting:@"'['" discard:NO];
+ [self match:ELEMENT_TOKEN_KIND_LBRACKET discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchLbracket:)];
}
@@ -158,7 +163,7 @@ - (void)lbracket {
- (void)__rbracket {
- [self match:ELEMENT_TOKEN_KIND_RBRACKET expecting:@"']'" discard:YES];
+ [self match:ELEMENT_TOKEN_KIND_RBRACKET discard:YES];
[self fireAssemblerSelector:@selector(parser:didMatchRbracket:)];
}
@@ -169,7 +174,7 @@ - (void)rbracket {
- (void)__comma {
- [self match:ELEMENT_TOKEN_KIND_COMMA expecting:@"','" discard:YES];
+ [self match:ELEMENT_TOKEN_KIND_COMMA discard:YES];
[self fireAssemblerSelector:@selector(parser:didMatchComma:)];
}
View
58 test/ExpressionActionsParser.m
@@ -29,6 +29,7 @@
@interface PKSParser ()
@property (nonatomic, retain) NSMutableDictionary *_tokenKindTab;
+@property (nonatomic, retain) NSMutableArray *_tokenKindNameTab;
- (BOOL)_popBool;
- (NSInteger)_popInteger;
@@ -83,6 +84,23 @@ - (id)init {
self._tokenKindTab[@"!="] = @(EXPRESSIONACTIONS_TOKEN_KIND_NE);
self._tokenKindTab[@"YES"] = @(EXPRESSIONACTIONS_TOKEN_KIND_YES_UPPER);
+ self._tokenKindNameTab[EXPRESSIONACTIONS_TOKEN_KIND_NO] = @"no";
+ self._tokenKindNameTab[EXPRESSIONACTIONS_TOKEN_KIND_NO_UPPER] = @"NO";
+ self._tokenKindNameTab[EXPRESSIONACTIONS_TOKEN_KIND_GE] = @">=";
+ self._tokenKindNameTab[EXPRESSIONACTIONS_TOKEN_KIND_COMMA] = @",";
+ self._tokenKindNameTab[EXPRESSIONACTIONS_TOKEN_KIND_OR] = @"or";
+ self._tokenKindNameTab[EXPRESSIONACTIONS_TOKEN_KIND_LT] = @"<";
+ self._tokenKindNameTab[EXPRESSIONACTIONS_TOKEN_KIND_LE] = @"<=";
+ self._tokenKindNameTab[EXPRESSIONACTIONS_TOKEN_KIND_EQUALS] = @"=";
+ self._tokenKindNameTab[EXPRESSIONACTIONS_TOKEN_KIND_DOT] = @".";
+ self._tokenKindNameTab[EXPRESSIONACTIONS_TOKEN_KIND_GT] = @">";
+ self._tokenKindNameTab[EXPRESSIONACTIONS_TOKEN_KIND_AND] = @"and";
+ self._tokenKindNameTab[EXPRESSIONACTIONS_TOKEN_KIND_OPEN_PAREN] = @"(";
+ self._tokenKindNameTab[EXPRESSIONACTIONS_TOKEN_KIND_YES] = @"yes";
+ self._tokenKindNameTab[EXPRESSIONACTIONS_TOKEN_KIND_CLOSE_PAREN] = @")";
+ self._tokenKindNameTab[EXPRESSIONACTIONS_TOKEN_KIND_NE] = @"!=";
+ self._tokenKindNameTab[EXPRESSIONACTIONS_TOKEN_KIND_YES_UPPER] = @"YES";
+
self.expr_memo = [NSMutableDictionary dictionary];
self.orExpr_memo = [NSMutableDictionary dictionary];
self.orTerm_memo = [NSMutableDictionary dictionary];
@@ -184,7 +202,7 @@ - (void)orExpr {
- (void)__orTerm {
- [self match:EXPRESSIONACTIONS_TOKEN_KIND_OR expecting:@"'or'" discard:YES];
+ [self match:EXPRESSIONACTIONS_TOKEN_KIND_OR discard:YES];
[self andExpr];
[self execute:(id)^{
@@ -221,7 +239,7 @@ - (void)andExpr {
- (void)__andTerm {
- [self match:EXPRESSIONACTIONS_TOKEN_KIND_AND expecting:@"'and'" discard:YES];
+ [self match:EXPRESSIONACTIONS_TOKEN_KIND_AND discard:YES];
[self relExpr];
[self execute:(id)^{
@@ -259,17 +277,17 @@ - (void)relExpr {
- (void)__relOp {
if ([self predicts:EXPRESSIONACTIONS_TOKEN_KIND_LT, 0]) {
- [self match:EXPRESSIONACTIONS_TOKEN_KIND_LT expecting:@"'<'" discard:NO];
+ [self match:EXPRESSIONACTIONS_TOKEN_KIND_LT discard:NO];
} else if ([self predicts:EXPRESSIONACTIONS_TOKEN_KIND_GT, 0]) {
- [self match:EXPRESSIONACTIONS_TOKEN_KIND_GT expecting:@"'>'" discard:NO];
+ [self match:EXPRESSIONACTIONS_TOKEN_KIND_GT discard:NO];
} else if ([self predicts:EXPRESSIONACTIONS_TOKEN_KIND_EQUALS, 0]) {
- [self match:EXPRESSIONACTIONS_TOKEN_KIND_EQUALS expecting:@"'='" discard:NO];
+ [self match:EXPRESSIONACTIONS_TOKEN_KIND_EQUALS discard:NO];
} else if ([self predicts:EXPRESSIONACTIONS_TOKEN_KIND_NE, 0]) {
- [self match:EXPRESSIONACTIONS_TOKEN_KIND_NE expecting:@"'!='" discard:NO];
+ [self match:EXPRESSIONACTIONS_TOKEN_KIND_NE discard:NO];
} else if ([self predicts:EXPRESSIONACTIONS_TOKEN_KIND_LE, 0]) {
- [self match:EXPRESSIONACTIONS_TOKEN_KIND_LE expecting:@"'<='" discard:NO];
+ [self match:EXPRESSIONACTIONS_TOKEN_KIND_LE discard:NO];
} else if ([self predicts:EXPRESSIONACTIONS_TOKEN_KIND_GE, 0]) {
- [self match:EXPRESSIONACTIONS_TOKEN_KIND_GE expecting:@"'>='" discard:NO];
+ [self match:EXPRESSIONACTIONS_TOKEN_KIND_GE discard:NO];
} else {
[self raise:@"No viable alternative found in rule 'relOp'."];
}
@@ -310,12 +328,12 @@ - (void)relOpTerm {
- (void)__callExpr {
[self primary];
- if ([self speculate:^{ [self match:EXPRESSIONACTIONS_TOKEN_KIND_OPEN_PAREN expecting:@"'('" discard:NO]; if ([self speculate:^{ [self argList]; }]) {[self argList]; }[self match:EXPRESSIONACTIONS_TOKEN_KIND_CLOSE_PAREN expecting:@"')'" discard:NO]; }]) {
- [self match:EXPRESSIONACTIONS_TOKEN_KIND_OPEN_PAREN expecting:@"'('" discard:NO];
+ if ([self speculate:^{ [self match:EXPRESSIONACTIONS_TOKEN_KIND_OPEN_PAREN discard:NO]; if ([self speculate:^{ [self argList]; }]) {[self argList]; }[self match:EXPRESSIONACTIONS_TOKEN_KIND_CLOSE_PAREN discard:NO]; }]) {
+ [self match:EXPRESSIONACTIONS_TOKEN_KIND_OPEN_PAREN discard:NO];
if ([self speculate:^{ [self argList]; }]) {
[self argList];
}
- [self match:EXPRESSIONACTIONS_TOKEN_KIND_CLOSE_PAREN expecting:@"')'" discard:NO];
+ [self match:EXPRESSIONACTIONS_TOKEN_KIND_CLOSE_PAREN discard:NO];
}
[self fireAssemblerSelector:@selector(parser:didMatchCallExpr:)];
@@ -329,8 +347,8 @@ - (void)__argList {
[self atom];
while ([self predicts:EXPRESSIONACTIONS_TOKEN_KIND_COMMA, 0]) {
- if ([self speculate:^{ [self match:EXPRESSIONACTIONS_TOKEN_KIND_COMMA expecting:@"','" discard:NO]; [self atom]; }]) {
- [self match:EXPRESSIONACTIONS_TOKEN_KIND_COMMA expecting:@"','" discard:NO];
+ if ([self speculate:^{ [self match:EXPRESSIONACTIONS_TOKEN_KIND_COMMA discard:NO]; [self atom]; }]) {
+ [self match:EXPRESSIONACTIONS_TOKEN_KIND_COMMA discard:NO];
[self atom];
} else {
break;
@@ -349,9 +367,9 @@ - (void)__primary {
if ([self predicts:EXPRESSIONACTIONS_TOKEN_KIND_NO, EXPRESSIONACTIONS_TOKEN_KIND_NO_UPPER, EXPRESSIONACTIONS_TOKEN_KIND_YES, EXPRESSIONACTIONS_TOKEN_KIND_YES_UPPER, TOKEN_KIND_BUILTIN_NUMBER, TOKEN_KIND_BUILTIN_QUOTEDSTRING, TOKEN_KIND_BUILTIN_WORD, 0]) {
[self atom];
} else if ([self predicts:EXPRESSIONACTIONS_TOKEN_KIND_OPEN_PAREN, 0]) {
- [self match:EXPRESSIONACTIONS_TOKEN_KIND_OPEN_PAREN expecting:@"'('" discard:NO];
+ [self match:EXPRESSIONACTIONS_TOKEN_KIND_OPEN_PAREN discard:NO];
[self expr];
- [self match:EXPRESSIONACTIONS_TOKEN_KIND_CLOSE_PAREN expecting:@"')'" discard:NO];
+ [self match:EXPRESSIONACTIONS_TOKEN_KIND_CLOSE_PAREN discard:NO];
} else {
[self raise:@"No viable alternative found in rule 'primary'."];
}
@@ -411,7 +429,7 @@ - (void)id {
- (void)__member {
- [self match:EXPRESSIONACTIONS_TOKEN_KIND_DOT expecting:@"'.'" discard:NO];
+ [self match:EXPRESSIONACTIONS_TOKEN_KIND_DOT discard:NO];
[self id];
[self fireAssemblerSelector:@selector(parser:didMatchMember:)];
@@ -453,14 +471,14 @@ - (void)literal {
- (void)__bool {
if ([self predicts:EXPRESSIONACTIONS_TOKEN_KIND_YES, 0]) {
- [self match:EXPRESSIONACTIONS_TOKEN_KIND_YES expecting:@"'yes'" discard:NO];
+ [self match:EXPRESSIONACTIONS_TOKEN_KIND_YES discard:NO];
} else if ([self predicts:EXPRESSIONACTIONS_TOKEN_KIND_YES_UPPER, 0]) {
- [self match:EXPRESSIONACTIONS_TOKEN_KIND_YES_UPPER expecting:@"'YES'" discard:NO];
+ [self match:EXPRESSIONACTIONS_TOKEN_KIND_YES_UPPER discard:NO];
} else if ([self predicts:EXPRESSIONACTIONS_TOKEN_KIND_NO, 0]) {
- [self match:EXPRESSIONACTIONS_TOKEN_KIND_NO expecting:@"'no'" discard:NO];
+ [self match:EXPRESSIONACTIONS_TOKEN_KIND_NO discard:NO];
} else if ([self predicts:EXPRESSIONACTIONS_TOKEN_KIND_NO_UPPER, 0]) {
[self testAndThrow:(id)^{ return NE(LS(1), @"NO"); }];
- [self match:EXPRESSIONACTIONS_TOKEN_KIND_NO_UPPER expecting:@"'NO'" discard:NO];
+ [self match:EXPRESSIONACTIONS_TOKEN_KIND_NO_UPPER discard:NO];
} else {
[self raise:@"No viable alternative found in rule 'bool'."];
}
View
44 test/ExpressionParser.m
@@ -29,6 +29,7 @@
@interface PKSParser ()
@property (nonatomic, retain) NSMutableDictionary *_tokenKindTab;
+@property (nonatomic, retain) NSMutableArray *_tokenKindNameTab;
- (BOOL)_popBool;
- (NSInteger)_popInteger;
@@ -94,6 +95,21 @@ - (id)init {
self._tokenKindTab[@"!="] = @(EXPRESSION_TOKEN_KIND_NE);
self._tokenKindTab[@"and"] = @(EXPRESSION_TOKEN_KIND_AND);
+ self._tokenKindNameTab[EXPRESSION_TOKEN_KIND_GE] = @">=";
+ self._tokenKindNameTab[EXPRESSION_TOKEN_KIND_COMMA] = @",";
+ self._tokenKindNameTab[EXPRESSION_TOKEN_KIND_OR] = @"or";
+ self._tokenKindNameTab[EXPRESSION_TOKEN_KIND_LT] = @"<";
+ self._tokenKindNameTab[EXPRESSION_TOKEN_KIND_LE] = @"<=";
+ self._tokenKindNameTab[EXPRESSION_TOKEN_KIND_EQ] = @"=";
+ self._tokenKindNameTab[EXPRESSION_TOKEN_KIND_DOT] = @".";
+ self._tokenKindNameTab[EXPRESSION_TOKEN_KIND_GT] = @">";
+ self._tokenKindNameTab[EXPRESSION_TOKEN_KIND_OPENPAREN] = @"(";
+ self._tokenKindNameTab[EXPRESSION_TOKEN_KIND_YES] = @"yes";
+ self._tokenKindNameTab[EXPRESSION_TOKEN_KIND_NO] = @"no";
+ self._tokenKindNameTab[EXPRESSION_TOKEN_KIND_CLOSEPAREN] = @")";
+ self._tokenKindNameTab[EXPRESSION_TOKEN_KIND_NE] = @"!=";
+ self._tokenKindNameTab[EXPRESSION_TOKEN_KIND_AND] = @"and";
+
self.expr_memo = [NSMutableDictionary dictionary];
self.orExpr_memo = [NSMutableDictionary dictionary];
self.orTerm_memo = [NSMutableDictionary dictionary];
@@ -470,7 +486,7 @@ - (void)bool {
- (void)__lt {
- [self match:EXPRESSION_TOKEN_KIND_LT expecting:@"'<'" discard:NO];
+ [self match:EXPRESSION_TOKEN_KIND_LT discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchLt:)];
}
@@ -481,7 +497,7 @@ - (void)lt {
- (void)__gt {
- [self match:EXPRESSION_TOKEN_KIND_GT expecting:@"'>'" discard:NO];
+ [self match:EXPRESSION_TOKEN_KIND_GT discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchGt:)];
}
@@ -492,7 +508,7 @@ - (void)gt {
- (void)__eq {
- [self match:EXPRESSION_TOKEN_KIND_EQ expecting:@"'='" discard:NO];
+ [self match:EXPRESSION_TOKEN_KIND_EQ discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchEq:)];
}
@@ -503,7 +519,7 @@ - (void)eq {
- (void)__ne {
- [self match:EXPRESSION_TOKEN_KIND_NE expecting:@"'!='" discard:NO];
+ [self match:EXPRESSION_TOKEN_KIND_NE discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchNe:)];
}
@@ -514,7 +530,7 @@ - (void)ne {
- (void)__le {
- [self match:EXPRESSION_TOKEN_KIND_LE expecting:@"'<='" discard:NO];
+ [self match:EXPRESSION_TOKEN_KIND_LE discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchLe:)];
}
@@ -525,7 +541,7 @@ - (void)le {
- (void)__ge {
- [self match:EXPRESSION_TOKEN_KIND_GE expecting:@"'>='" discard:NO];
+ [self match:EXPRESSION_TOKEN_KIND_GE discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchGe:)];
}
@@ -536,7 +552,7 @@ - (void)ge {
- (void)__openParen {
- [self match:EXPRESSION_TOKEN_KIND_OPENPAREN expecting:@"'('" discard:NO];
+ [self match:EXPRESSION_TOKEN_KIND_OPENPAREN discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchOpenParen:)];
}
@@ -547,7 +563,7 @@ - (void)openParen {
- (void)__closeParen {
- [self match:EXPRESSION_TOKEN_KIND_CLOSEPAREN expecting:@"')'" discard:YES];
+ [self match:EXPRESSION_TOKEN_KIND_CLOSEPAREN discard:YES];
[self fireAssemblerSelector:@selector(parser:didMatchCloseParen:)];
}
@@ -558,7 +574,7 @@ - (void)closeParen {
- (void)__yes {
- [self match:EXPRESSION_TOKEN_KIND_YES expecting:@"'yes'" discard:NO];
+ [self match:EXPRESSION_TOKEN_KIND_YES discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchYes:)];
}
@@ -569,7 +585,7 @@ - (void)yes {
- (void)__no {
- [self match:EXPRESSION_TOKEN_KIND_NO expecting:@"'no'" discard:NO];
+ [self match:EXPRESSION_TOKEN_KIND_NO discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchNo:)];
}
@@ -580,7 +596,7 @@ - (void)no {
- (void)__dot {
- [self match:EXPRESSION_TOKEN_KIND_DOT expecting:@"'.'" discard:NO];
+ [self match:EXPRESSION_TOKEN_KIND_DOT discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchDot:)];
}
@@ -591,7 +607,7 @@ - (void)dot {
- (void)__comma {
- [self match:EXPRESSION_TOKEN_KIND_COMMA expecting:@"','" discard:NO];
+ [self match:EXPRESSION_TOKEN_KIND_COMMA discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchComma:)];
}
@@ -602,7 +618,7 @@ - (void)comma {
- (void)__or {
- [self match:EXPRESSION_TOKEN_KIND_OR expecting:@"'or'" discard:NO];
+ [self match:EXPRESSION_TOKEN_KIND_OR discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchOr:)];
}
@@ -613,7 +629,7 @@ - (void)or {
- (void)__and {
- [self match:EXPRESSION_TOKEN_KIND_AND expecting:@"'and'" discard:NO];
+ [self match:EXPRESSION_TOKEN_KIND_AND discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchAnd:)];
}
View
28 test/ExpressionSyntaxParser.m
@@ -334,7 +334,7 @@ - (void)lt {
[self fireSyntaxSelector:@selector(parser:willMatchInterior:) withRuleName:@"lt"];
[self fireSyntaxSelector:@selector(parser:willMatchLeaf:) withRuleName:@"lt"];
- [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_LT expecting:@"'<'" discard:NO];
+ [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_LT discard:NO];
[self fireSyntaxSelector:@selector(parser:didMatchLeaf:) withRuleName:@"lt"];
[self fireSyntaxSelector:@selector(parser:didMatchInterior:) withRuleName:@"lt"];
@@ -345,7 +345,7 @@ - (void)gt {
[self fireSyntaxSelector:@selector(parser:willMatchInterior:) withRuleName:@"gt"];
[self fireSyntaxSelector:@selector(parser:willMatchLeaf:) withRuleName:@"gt"];
- [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_GT expecting:@"'>'" discard:NO];
+ [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_GT discard:NO];
[self fireSyntaxSelector:@selector(parser:didMatchLeaf:) withRuleName:@"gt"];
[self fireSyntaxSelector:@selector(parser:didMatchInterior:) withRuleName:@"gt"];
@@ -356,7 +356,7 @@ - (void)eq {
[self fireSyntaxSelector:@selector(parser:willMatchInterior:) withRuleName:@"eq"];
[self fireSyntaxSelector:@selector(parser:willMatchLeaf:) withRuleName:@"eq"];
- [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_EQ expecting:@"'='" discard:NO];
+ [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_EQ discard:NO];
[self fireSyntaxSelector:@selector(parser:didMatchLeaf:) withRuleName:@"eq"];
[self fireSyntaxSelector:@selector(parser:didMatchInterior:) withRuleName:@"eq"];
@@ -367,7 +367,7 @@ - (void)ne {
[self fireSyntaxSelector:@selector(parser:willMatchInterior:) withRuleName:@"ne"];
[self fireSyntaxSelector:@selector(parser:willMatchLeaf:) withRuleName:@"ne"];
- [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_NE expecting:@"'!='" discard:NO];
+ [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_NE discard:NO];
[self fireSyntaxSelector:@selector(parser:didMatchLeaf:) withRuleName:@"ne"];
[self fireSyntaxSelector:@selector(parser:didMatchInterior:) withRuleName:@"ne"];
@@ -378,7 +378,7 @@ - (void)le {
[self fireSyntaxSelector:@selector(parser:willMatchInterior:) withRuleName:@"le"];
[self fireSyntaxSelector:@selector(parser:willMatchLeaf:) withRuleName:@"le"];
- [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_LE expecting:@"'<='" discard:NO];
+ [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_LE discard:NO];
[self fireSyntaxSelector:@selector(parser:didMatchLeaf:) withRuleName:@"le"];
[self fireSyntaxSelector:@selector(parser:didMatchInterior:) withRuleName:@"le"];
@@ -389,7 +389,7 @@ - (void)ge {
[self fireSyntaxSelector:@selector(parser:willMatchInterior:) withRuleName:@"ge"];
[self fireSyntaxSelector:@selector(parser:willMatchLeaf:) withRuleName:@"ge"];
- [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_GE expecting:@"'>='" discard:NO];
+ [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_GE discard:NO];
[self fireSyntaxSelector:@selector(parser:didMatchLeaf:) withRuleName:@"ge"];
[self fireSyntaxSelector:@selector(parser:didMatchInterior:) withRuleName:@"ge"];
@@ -400,7 +400,7 @@ - (void)openParen {
[self fireSyntaxSelector:@selector(parser:willMatchInterior:) withRuleName:@"openParen"];
[self fireSyntaxSelector:@selector(parser:willMatchLeaf:) withRuleName:@"openParen"];
- [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_OPENPAREN expecting:@"'('" discard:NO];
+ [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_OPENPAREN discard:NO];
[self fireSyntaxSelector:@selector(parser:didMatchLeaf:) withRuleName:@"openParen"];
[self fireSyntaxSelector:@selector(parser:didMatchInterior:) withRuleName:@"openParen"];
@@ -411,7 +411,7 @@ - (void)closeParen {
[self fireSyntaxSelector:@selector(parser:willMatchInterior:) withRuleName:@"closeParen"];
[self fireSyntaxSelector:@selector(parser:willMatchLeaf:) withRuleName:@"closeParen"];
- [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_CLOSEPAREN expecting:@"')'" discard:YES];
+ [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_CLOSEPAREN discard:YES];
[self fireSyntaxSelector:@selector(parser:didMatchLeaf:) withRuleName:@"closeParen"];
[self fireSyntaxSelector:@selector(parser:didMatchInterior:) withRuleName:@"closeParen"];
@@ -422,7 +422,7 @@ - (void)yes {
[self fireSyntaxSelector:@selector(parser:willMatchInterior:) withRuleName:@"yes"];
[self fireSyntaxSelector:@selector(parser:willMatchLeaf:) withRuleName:@"yes"];
- [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_YES expecting:@"'yes'" discard:NO];
+ [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_YES discard:NO];
[self fireSyntaxSelector:@selector(parser:didMatchLeaf:) withRuleName:@"yes"];
[self fireSyntaxSelector:@selector(parser:didMatchInterior:) withRuleName:@"yes"];
@@ -433,7 +433,7 @@ - (void)no {
[self fireSyntaxSelector:@selector(parser:willMatchInterior:) withRuleName:@"no"];
[self fireSyntaxSelector:@selector(parser:willMatchLeaf:) withRuleName:@"no"];
- [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_NO expecting:@"'no'" discard:NO];
+ [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_NO discard:NO];
[self fireSyntaxSelector:@selector(parser:didMatchLeaf:) withRuleName:@"no"];
[self fireSyntaxSelector:@selector(parser:didMatchInterior:) withRuleName:@"no"];
@@ -444,7 +444,7 @@ - (void)dot {
[self fireSyntaxSelector:@selector(parser:willMatchInterior:) withRuleName:@"dot"];
[self fireSyntaxSelector:@selector(parser:willMatchLeaf:) withRuleName:@"dot"];
- [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_DOT expecting:@"'.'" discard:NO];
+ [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_DOT discard:NO];
[self fireSyntaxSelector:@selector(parser:didMatchLeaf:) withRuleName:@"dot"];
[self fireSyntaxSelector:@selector(parser:didMatchInterior:) withRuleName:@"dot"];
@@ -455,7 +455,7 @@ - (void)comma {
[self fireSyntaxSelector:@selector(parser:willMatchInterior:) withRuleName:@"comma"];
[self fireSyntaxSelector:@selector(parser:willMatchLeaf:) withRuleName:@"comma"];
- [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_COMMA expecting:@"','" discard:NO];
+ [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_COMMA discard:NO];
[self fireSyntaxSelector:@selector(parser:didMatchLeaf:) withRuleName:@"comma"];
[self fireSyntaxSelector:@selector(parser:didMatchInterior:) withRuleName:@"comma"];
@@ -466,7 +466,7 @@ - (void)or {
[self fireSyntaxSelector:@selector(parser:willMatchInterior:) withRuleName:@"or"];
[self fireSyntaxSelector:@selector(parser:willMatchLeaf:) withRuleName:@"or"];
- [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_OR expecting:@"'or'" discard:NO];
+ [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_OR discard:NO];
[self fireSyntaxSelector:@selector(parser:didMatchLeaf:) withRuleName:@"or"];
[self fireSyntaxSelector:@selector(parser:didMatchInterior:) withRuleName:@"or"];
@@ -477,7 +477,7 @@ - (void)and {
[self fireSyntaxSelector:@selector(parser:willMatchInterior:) withRuleName:@"and"];
[self fireSyntaxSelector:@selector(parser:willMatchLeaf:) withRuleName:@"and"];
- [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_AND expecting:@"'and'" discard:NO];
+ [self match:EXPRESSIONSYNTAXPARSER_TOKEN_KIND_AND discard:NO];
[self fireSyntaxSelector:@selector(parser:didMatchLeaf:) withRuleName:@"and"];
[self fireSyntaxSelector:@selector(parser:didMatchInterior:) withRuleName:@"and"];
View
8 test/GreedParser.m
@@ -29,6 +29,7 @@
@interface PKSParser ()
@property (nonatomic, retain) NSMutableDictionary *_tokenKindTab;
+@property (nonatomic, retain) NSMutableArray *_tokenKindNameTab;
- (BOOL)_popBool;
- (NSInteger)_popInteger;
@@ -54,6 +55,9 @@ - (id)init {
self._tokenKindTab[@"a"] = @(GREED_TOKEN_KIND_A);
self._tokenKindTab[@"b"] = @(GREED_TOKEN_KIND_B);
+ self._tokenKindNameTab[GREED_TOKEN_KIND_A] = @"a";
+ self._tokenKindNameTab[GREED_TOKEN_KIND_B] = @"b";
+
self.a_memo = [NSMutableDictionary dictionary];
self.b_memo = [NSMutableDictionary dictionary];
}
@@ -95,7 +99,7 @@ - (void)_start {
- (void)__a {
- [self match:GREED_TOKEN_KIND_A expecting:@"'a'" discard:NO];
+ [self match:GREED_TOKEN_KIND_A discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchA:)];
}
@@ -106,7 +110,7 @@ - (void)a {
- (void)__b {
- [self match:GREED_TOKEN_KIND_B expecting:@"'b'" discard:NO];
+ [self match:GREED_TOKEN_KIND_B discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchB:)];
}
View
30 test/HTMLParser.m
@@ -29,6 +29,7 @@
@interface PKSParser ()
@property (nonatomic, retain) NSMutableDictionary *_tokenKindTab;
+@property (nonatomic, retain) NSMutableArray *_tokenKindNameTab;
- (BOOL)_popBool;
- (NSInteger)_popInteger;
@@ -85,6 +86,15 @@ - (id)init {
self._tokenKindTab[@"/"] = @(HTML_TOKEN_KIND_FWDSLASH);
self._tokenKindTab[@">"] = @(HTML_TOKEN_KIND_GT);
+ self._tokenKindNameTab[HTML_TOKEN_KIND_SCRIPTTAGNAME] = @"script";
+ self._tokenKindNameTab[HTML_TOKEN_KIND_STYLETAGNAME] = @"style";
+ self._tokenKindNameTab[HTML_TOKEN_KIND_DOCTYPE] = @"<!DOCTYPE,>";
+ self._tokenKindNameTab[HTML_TOKEN_KIND_LT] = @"<";
+ self._tokenKindNameTab[HTML_TOKEN_KIND_PROCINSTR] = @"<?,?>";
+ self._tokenKindNameTab[HTML_TOKEN_KIND_EQ] = @"=";
+ self._tokenKindNameTab[HTML_TOKEN_KIND_FWDSLASH] = @"/";
+ self._tokenKindNameTab[HTML_TOKEN_KIND_GT] = @">";
+
self.anything_memo = [NSMutableDictionary dictionary];
self.scriptElement_memo = [NSMutableDictionary dictionary];
self.scriptStartTag_memo = [NSMutableDictionary dictionary];
@@ -293,7 +303,7 @@ - (void)scriptEndTag {
- (void)__scriptTagName {
- [self match:HTML_TOKEN_KIND_SCRIPTTAGNAME expecting:@"'script'" discard:NO];
+ [self match:HTML_TOKEN_KIND_SCRIPTTAGNAME discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchScriptTagName:)];
}
@@ -305,7 +315,7 @@ - (void)scriptTagName {
- (void)__scriptElementContent {
if (![self speculate:^{ [self scriptEndTag]; }]) {
- [self match:TOKEN_KIND_BUILTIN_ANY expecting:@"scriptElementContent" discard:NO];
+ [self match:TOKEN_KIND_BUILTIN_ANY discard:NO];
} else {
[self raise:@"negation test failed in scriptElementContent"];
}
@@ -362,7 +372,7 @@ - (void)styleEndTag {
- (void)__styleTagName {
- [self match:HTML_TOKEN_KIND_STYLETAGNAME expecting:@"'style'" discard:NO];
+ [self match:HTML_TOKEN_KIND_STYLETAGNAME discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchStyleTagName:)];
}
@@ -374,7 +384,7 @@ - (void)styleTagName {
- (void)__styleElementContent {
if (![self speculate:^{ [self styleEndTag]; }]) {
- [self match:TOKEN_KIND_BUILTIN_ANY expecting:@"styleElementContent" discard:NO];
+ [self match:TOKEN_KIND_BUILTIN_ANY discard:NO];
} else {
[self raise:@"negation test failed in styleElementContent"];
}
@@ -387,7 +397,7 @@ - (void)styleElementContent {
- (void)__procInstr {
- [self match:HTML_TOKEN_KIND_PROCINSTR expecting:@"procInstr" discard:NO];
+ [self match:HTML_TOKEN_KIND_PROCINSTR discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchProcInstr:)];
}
@@ -398,7 +408,7 @@ - (void)procInstr {
- (void)__doctype {
- [self match:HTML_TOKEN_KIND_DOCTYPE expecting:@"doctype" discard:NO];
+ [self match:HTML_TOKEN_KIND_DOCTYPE discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchDoctype:)];
}
@@ -544,7 +554,7 @@ - (void)attrValue {
- (void)__eq {
- [self match:HTML_TOKEN_KIND_EQ expecting:@"'='" discard:NO];
+ [self match:HTML_TOKEN_KIND_EQ discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchEq:)];
}
@@ -555,7 +565,7 @@ - (void)eq {
- (void)__lt {
- [self match:HTML_TOKEN_KIND_LT expecting:@"'<'" discard:NO];
+ [self match:HTML_TOKEN_KIND_LT discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchLt:)];
}
@@ -566,7 +576,7 @@ - (void)lt {
- (void)__gt {
- [self match:HTML_TOKEN_KIND_GT expecting:@"'>'" discard:NO];
+ [self match:HTML_TOKEN_KIND_GT discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchGt:)];
}
@@ -577,7 +587,7 @@ - (void)gt {
- (void)__fwdSlash {
- [self match:HTML_TOKEN_KIND_FWDSLASH expecting:@"'/'" discard:NO];
+ [self match:HTML_TOKEN_KIND_FWDSLASH discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchFwdSlash:)];
}
View
29 test/JSONParser.m
@@ -29,6 +29,7 @@
@interface PKSParser ()
@property (nonatomic, retain) NSMutableDictionary *_tokenKindTab;
+@property (nonatomic, retain) NSMutableArray *_tokenKindNameTab;
- (BOOL)_popBool;
- (NSInteger)_popInteger;
@@ -59,6 +60,16 @@ - (id)init {
self._tokenKindTab[@"{"] = @(JSON_TOKEN_KIND_OPENCURLY);
self._tokenKindTab[@":"] = @(JSON_TOKEN_KIND_COLON);
+ self._tokenKindNameTab[JSON_TOKEN_KIND_FALSELITERAL] = @"false";
+ self._tokenKindNameTab[JSON_TOKEN_KIND_CLOSECURLY] = @"}";
+ self._tokenKindNameTab[JSON_TOKEN_KIND_OPENBRACKET] = @"[";
+ self._tokenKindNameTab[JSON_TOKEN_KIND_NULLLITERAL] = @"null";
+ self._tokenKindNameTab[JSON_TOKEN_KIND_COMMA] = @",";
+ self._tokenKindNameTab[JSON_TOKEN_KIND_TRUELITERAL] = @"true";
+ self._tokenKindNameTab[JSON_TOKEN_KIND_CLOSEBRACKET] = @"]";
+ self._tokenKindNameTab[JSON_TOKEN_KIND_OPENCURLY] = @"{";
+ self._tokenKindNameTab[JSON_TOKEN_KIND_COLON] = @":";
+
}
return self;
}
@@ -244,63 +255,63 @@ - (void)number {
- (void)nullLiteral {
- [self match:JSON_TOKEN_KIND_NULLLITERAL expecting:@"'null'" discard:NO];
+ [self match:JSON_TOKEN_KIND_NULLLITERAL discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchNullLiteral:)];
}
- (void)trueLiteral {
- [self match:JSON_TOKEN_KIND_TRUELITERAL expecting:@"'true'" discard:NO];
+ [self match:JSON_TOKEN_KIND_TRUELITERAL discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchTrueLiteral:)];
}
- (void)falseLiteral {
- [self match:JSON_TOKEN_KIND_FALSELITERAL expecting:@"'false'" discard:NO];
+ [self match:JSON_TOKEN_KIND_FALSELITERAL discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchFalseLiteral:)];
}
- (void)openCurly {
- [self match:JSON_TOKEN_KIND_OPENCURLY expecting:@"'{'" discard:NO];
+ [self match:JSON_TOKEN_KIND_OPENCURLY discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchOpenCurly:)];
}
- (void)closeCurly {
- [self match:JSON_TOKEN_KIND_CLOSECURLY expecting:@"'}'" discard:NO];
+ [self match:JSON_TOKEN_KIND_CLOSECURLY discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchCloseCurly:)];
}
- (void)openBracket {
- [self match:JSON_TOKEN_KIND_OPENBRACKET expecting:@"'['" discard:NO];
+ [self match:JSON_TOKEN_KIND_OPENBRACKET discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchOpenBracket:)];
}
- (void)closeBracket {
- [self match:JSON_TOKEN_KIND_CLOSEBRACKET expecting:@"']'" discard:NO];
+ [self match:JSON_TOKEN_KIND_CLOSEBRACKET discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchCloseBracket:)];
}
- (void)comma {
- [self match:JSON_TOKEN_KIND_COMMA expecting:@"','" discard:NO];
+ [self match:JSON_TOKEN_KIND_COMMA discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchComma:)];
}
- (void)colon {
- [self match:JSON_TOKEN_KIND_COLON expecting:@"':'" discard:NO];
+ [self match:JSON_TOKEN_KIND_COLON discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchColon:)];
}
View
209 test/JavaScriptParser.m
@@ -29,6 +29,7 @@
@interface PKSParser ()
@property (nonatomic, retain) NSMutableDictionary *_tokenKindTab;
+@property (nonatomic, retain) NSMutableArray *_tokenKindNameTab;
- (BOOL)_popBool;
- (NSInteger)_popInteger;
@@ -121,6 +122,76 @@ - (id)init {
self._tokenKindTab[@"&"] = @(JAVASCRIPT_TOKEN_KIND_AMP);
self._tokenKindTab[@"{"] = @(JAVASCRIPT_TOKEN_KIND_OPENCURLY);
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_PIPE] = @"|";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_NE] = @"!=";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_OPENPAREN] = @"(";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_CLOSECURLY] = @"}";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_RETURNSYM] = @"return";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_TILDE] = @"~";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_CLOSEPAREN] = @")";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_TIMES] = @"*";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_DELETE] = @"delete";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_ISNOT] = @"!==";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_PLUS] = @"+";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_TIMESEQ] = @"*=";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_INSTANCEOF] = @"instanceof";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_COMMA] = @",";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_SHIFTLEFTEQ] = @"<<=";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_IFSYM] = @"if";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_MINUS] = @"-";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_NULL] = @"null";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_FALSELITERAL] = @"false";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_DOT] = @".";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_SHIFTLEFT] = @"<<";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_DIV] = @"/";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_PLUSEQ] = @"+=";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_LE] = @"<=";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_XOREQ] = @"^=";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_OPENBRACKET] = @"[";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_UNDEFINED] = @"undefined";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_TYPEOF] = @"typeof";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_OR] = @"||";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_FUNCTION] = @"function";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_CLOSEBRACKET] = @"]";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_CARET] = @"^";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_EQ] = @"==";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_CONTINUESYM] = @"continue";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_BREAKSYM] = @"break";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_MINUSEQ] = @"-=";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_GE] = @">=";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_COLON] = @":";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_INSYM] = @"in";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_SEMI] = @";";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_FORSYM] = @"for";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_PLUSPLUS] = @"++";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_LT] = @"<";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_MODEQ] = @"%=";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_SHIFTRIGHT] = @">>";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_EQUALS] = @"=";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_GT] = @">";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_VOID] = @"void";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_QUESTION] = @"?";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_WHILESYM] = @"while";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_ANDEQ] = @"&=";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_SHIFTRIGHTEXTEQ] = @">>>=";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_ELSESYM] = @"else";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_DIVEQ] = @"/=";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_AND] = @"&&";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_VAR] = @"var";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_OREQ] = @"|=";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_SHIFTRIGHTEQ] = @">>=";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_MINUSMINUS] = @"--";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_KEYWORDNEW] = @"new";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_NOT] = @"!";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_SHIFTRIGHTEXT] = @">>>";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_TRUELITERAL] = @"true";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_THIS] = @"this";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_WITH] = @"with";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_IS] = @"===";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_MOD] = @"%";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_AMP] = @"&";
+ self._tokenKindNameTab[JAVASCRIPT_TOKEN_KIND_OPENCURLY] = @"{";
+
}
return self;
}
@@ -180,483 +251,483 @@ - (void)_start {
- (void)ifSym {
- [self match:JAVASCRIPT_TOKEN_KIND_IFSYM expecting:@"'if'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_IFSYM discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchIfSym:)];
}
- (void)elseSym {
- [self match:JAVASCRIPT_TOKEN_KIND_ELSESYM expecting:@"'else'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_ELSESYM discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchElseSym:)];
}
- (void)whileSym {
- [self match:JAVASCRIPT_TOKEN_KIND_WHILESYM expecting:@"'while'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_WHILESYM discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchWhileSym:)];
}
- (void)forSym {
- [self match:JAVASCRIPT_TOKEN_KIND_FORSYM expecting:@"'for'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_FORSYM discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchForSym:)];
}
- (void)inSym {
- [self match:JAVASCRIPT_TOKEN_KIND_INSYM expecting:@"'in'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_INSYM discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchInSym:)];
}
- (void)breakSym {
- [self match:JAVASCRIPT_TOKEN_KIND_BREAKSYM expecting:@"'break'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_BREAKSYM discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchBreakSym:)];
}
- (void)continueSym {
- [self match:JAVASCRIPT_TOKEN_KIND_CONTINUESYM expecting:@"'continue'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_CONTINUESYM discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchContinueSym:)];
}
- (void)with {
- [self match:JAVASCRIPT_TOKEN_KIND_WITH expecting:@"'with'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_WITH discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchWith:)];
}
- (void)returnSym {
- [self match:JAVASCRIPT_TOKEN_KIND_RETURNSYM expecting:@"'return'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_RETURNSYM discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchReturnSym:)];
}
- (void)var {
- [self match:JAVASCRIPT_TOKEN_KIND_VAR expecting:@"'var'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_VAR discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchVar:)];
}
- (void)delete {
- [self match:JAVASCRIPT_TOKEN_KIND_DELETE expecting:@"'delete'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_DELETE discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchDelete:)];
}
- (void)keywordNew {
- [self match:JAVASCRIPT_TOKEN_KIND_KEYWORDNEW expecting:@"'new'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_KEYWORDNEW discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchKeywordNew:)];
}
- (void)this {
- [self match:JAVASCRIPT_TOKEN_KIND_THIS expecting:@"'this'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_THIS discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchThis:)];
}
- (void)falseLiteral {
- [self match:JAVASCRIPT_TOKEN_KIND_FALSELITERAL expecting:@"'false'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_FALSELITERAL discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchFalseLiteral:)];
}
- (void)trueLiteral {
- [self match:JAVASCRIPT_TOKEN_KIND_TRUELITERAL expecting:@"'true'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_TRUELITERAL discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchTrueLiteral:)];
}
- (void)null {
- [self match:JAVASCRIPT_TOKEN_KIND_NULL expecting:@"'null'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_NULL discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchNull:)];
}
- (void)undefined {
- [self match:JAVASCRIPT_TOKEN_KIND_UNDEFINED expecting:@"'undefined'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_UNDEFINED discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchUndefined:)];
}
- (void)void {
- [self match:JAVASCRIPT_TOKEN_KIND_VOID expecting:@"'void'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_VOID discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchVoid:)];
}
- (void)typeof {
- [self match:JAVASCRIPT_TOKEN_KIND_TYPEOF expecting:@"'typeof'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_TYPEOF discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchTypeof:)];
}
- (void)instanceof {
- [self match:JAVASCRIPT_TOKEN_KIND_INSTANCEOF expecting:@"'instanceof'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_INSTANCEOF discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchInstanceof:)];
}
- (void)function {
- [self match:JAVASCRIPT_TOKEN_KIND_FUNCTION expecting:@"'function'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_FUNCTION discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchFunction:)];
}
- (void)openCurly {
- [self match:JAVASCRIPT_TOKEN_KIND_OPENCURLY expecting:@"'{'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_OPENCURLY discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchOpenCurly:)];
}
- (void)closeCurly {
- [self match:JAVASCRIPT_TOKEN_KIND_CLOSECURLY expecting:@"'}'" discard:NO];
+ [self match:JAVASCRIPT_TOKEN_KIND_CLOSECURLY discard:NO];
[self fireAssemblerSelector:@selector(parser:didMatchCloseCurly:)];
}