@@ -15,11 +15,13 @@ - (id)initWithDelegate:(id)d {
15
15
self.startRuleName = @" start" ;
16
16
self.tokenKindTab [@" NONE" ] = @(DUPELITERALS_TOKEN_KIND_NONE_1);
17
17
self.tokenKindTab [@" None" ] = @(DUPELITERALS_TOKEN_KIND_NONE_2);
18
+ self.tokenKindTab [@" |" ] = @(DUPELITERALS_TOKEN_KIND_PIPE);
18
19
self.tokenKindTab [@" none" ] = @(DUPELITERALS_TOKEN_KIND_NONE);
19
20
self.tokenKindTab [@" \" " ] = @(DUPELITERALS_TOKEN_KIND_QUOTE);
20
21
21
22
self.tokenKindNameTab [DUPELITERALS_TOKEN_KIND_NONE_1] = @" NONE" ;
22
23
self.tokenKindNameTab [DUPELITERALS_TOKEN_KIND_NONE_2] = @" None" ;
24
+ self.tokenKindNameTab [DUPELITERALS_TOKEN_KIND_PIPE] = @" |" ;
23
25
self.tokenKindNameTab [DUPELITERALS_TOKEN_KIND_NONE] = @" none" ;
24
26
self.tokenKindNameTab [DUPELITERALS_TOKEN_KIND_QUOTE] = @" \" " ;
25
27
@@ -50,8 +52,16 @@ - (void)start {
50
52
- (void )start_ {
51
53
52
54
do {
53
- [self none_ ];
54
- } while ([self predicts: DUPELITERALS_TOKEN_KIND_NONE, DUPELITERALS_TOKEN_KIND_NONE_1, DUPELITERALS_TOKEN_KIND_NONE_2, 0 ]);
55
+ if ([self predicts: DUPELITERALS_TOKEN_KIND_NONE, DUPELITERALS_TOKEN_KIND_NONE_1, DUPELITERALS_TOKEN_KIND_NONE_2, 0 ]) {
56
+ [self none_ ];
57
+ } else if ([self predicts: DUPELITERALS_TOKEN_KIND_QUOTE, 0 ]) {
58
+ [self quote_ ];
59
+ } else if ([self predicts: DUPELITERALS_TOKEN_KIND_PIPE, 0 ]) {
60
+ [self block_ ];
61
+ } else {
62
+ [self raise :@" No viable alternative found in rule 'start'." ];
63
+ }
64
+ } while ([self speculate: ^{ if ([self predicts: DUPELITERALS_TOKEN_KIND_NONE, DUPELITERALS_TOKEN_KIND_NONE_1, DUPELITERALS_TOKEN_KIND_NONE_2, 0 ]) {[self none_ ]; } else if ([self predicts: DUPELITERALS_TOKEN_KIND_QUOTE, 0 ]) {[self quote_ ]; } else if ([self predicts: DUPELITERALS_TOKEN_KIND_PIPE, 0 ]) {[self block_ ]; } else {[self raise :@" No viable alternative found in rule 'start'." ];}}]);
55
65
56
66
[self fireDelegateSelector: @selector (parser:didMatchStart: )];
57
67
}
@@ -80,4 +90,13 @@ - (void)quote_ {
80
90
[self fireDelegateSelector: @selector (parser:didMatchQuote: )];
81
91
}
82
92
93
+ - (void )block_ {
94
+
95
+ [self match: DUPELITERALS_TOKEN_KIND_PIPE discard: NO ];
96
+ [self matchWord: NO ];
97
+ [self match: DUPELITERALS_TOKEN_KIND_PIPE discard: NO ];
98
+
99
+ [self fireDelegateSelector: @selector (parser:didMatchBlock: )];
100
+ }
101
+
83
102
@end
0 commit comments