1/** \file
2 *  This OBJC source file was generated by $ANTLR version 3.4
3 *
4 *     -  From the grammar source file : /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g
5 *     -                            On : 2012-02-16 18:10:11
6 *     -                 for the lexer : PolyLexerLexer
7 *
8 * Editing it, at least manually, is not wise.
9 *
10 * ObjC language generator and runtime by Alan Condit, acondit|hereisanat|ipns|dotgoeshere|com.
11 *
12 *
13*/
14// $ANTLR 3.4 /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g 2012-02-16 18:10:11
15
16
17/* -----------------------------------------
18 * Include the ANTLR3 generated header file.
19 */
20#import "PolyLexer.h"
21/* ----------------------------------------- */
22
23
24/* ============================================================================= */
25/* =============================================================================
26 * Start of recognizer
27 */
28
29/** As per Terence: No returns for lexer rules! */
30@implementation PolyLexer // line 330
31
32+ (void) initialize
33{
34    [BaseRecognizer setGrammarFileName:@"/Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g"];
35}
36
37+ (NSString *) tokenNameForType:(NSInteger)aTokenType
38{
39    return [[self getTokenNames] objectAtIndex:aTokenType];
40}
41
42+ (PolyLexer *)newPolyLexerWithCharStream:(id<CharStream>)anInput
43{
44    return [[PolyLexer alloc] initWithCharStream:anInput];
45}
46
47- (id) initWithCharStream:(id<CharStream>)anInput
48{
49    self = [super initWithCharStream:anInput State:[RecognizerSharedState newRecognizerSharedStateWithRuleLen:6+1]];
50    if ( self != nil ) {
51    }
52    return self;
53}
54
55- (void) dealloc
56{
57    [super dealloc];
58}
59
60/* ObjC Start of actions.lexer.methods */
61/* ObjC end of actions.lexer.methods */
62/* ObjC start methods() */
63/* ObjC end methods() */
64
65/* Start of Rules */
66// $ANTLR start "T__8"
67- (void) mT__8
68{
69    //
70    /* ruleScopeSetUp */
71
72    /* ruleDeclarations */
73
74    @try {
75        NSInteger _type = T__8;
76        NSInteger _channel = TokenChannelDefault;
77        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g:7:6: ( '+' ) // ruleBlockSingleAlt
78        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g:7:8: '+' // alt
79        {
80
81
82        [self matchChar:'+'];
83
84
85        }
86
87        /* token+rule list labels */
88
89        state.type = _type;
90        state.channel = _channel;
91    }
92    @finally {
93        //
94        /* ruleScopeCleanUp */
95
96    }
97    return;
98}
99/* $ANTLR end "T__8" */
100// $ANTLR start "T__9"
101- (void) mT__9
102{
103    //
104    /* ruleScopeSetUp */
105
106    /* ruleDeclarations */
107
108    @try {
109        NSInteger _type = T__9;
110        NSInteger _channel = TokenChannelDefault;
111        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g:8:6: ( '^' ) // ruleBlockSingleAlt
112        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g:8:8: '^' // alt
113        {
114
115
116        [self matchChar:'^'];
117
118
119        }
120
121        /* token+rule list labels */
122
123        state.type = _type;
124        state.channel = _channel;
125    }
126    @finally {
127        //
128        /* ruleScopeCleanUp */
129
130    }
131    return;
132}
133/* $ANTLR end "T__9" */
134// $ANTLR start "ID"
135- (void) mID
136{
137    //
138    /* ruleScopeSetUp */
139
140    /* ruleDeclarations */
141    NSString * value = nil ;
142
143
144    @try {
145        NSInteger _type = ID;
146        NSInteger _channel = TokenChannelDefault;
147        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g:22:5: ( ( 'a' .. 'z' )+ ) // ruleBlockSingleAlt
148        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g:22:7: ( 'a' .. 'z' )+ // alt
149        {
150
151        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g:22:7: ( 'a' .. 'z' )+ // positiveClosureBlock
152        NSInteger cnt1 = 0;
153        do {
154            NSInteger alt1 = 2;
155            NSInteger LA1_0 = [input LA:1];
156            if ( ((LA1_0 >= 'a' && LA1_0 <= 'z')) ) {
157                alt1=1;
158            }
159
160
161            switch (alt1) {
162                case 1 : ;
163                    // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g: // alt
164                    {
165
166                    if ((([input LA:1] >= 'a') && ([input LA:1] <= 'z'))) {
167                        [input consume];
168                    } else {
169                        MismatchedSetException *mse = [MismatchedSetException newException:nil stream:input];
170                        [self recover:mse];
171                        @throw mse;
172                    }
173
174
175                    }
176                    break;
177
178                default :
179                    if ( cnt1 >= 1 )
180                        goto loop1;
181                    EarlyExitException *eee =
182                        [EarlyExitException newException:input decisionNumber:1];
183                    @throw eee;
184            }
185            cnt1++;
186        } while (YES);
187        loop1: ;
188
189
190        }
191
192        /* token+rule list labels */
193
194        state.type = _type;
195        state.channel = _channel;
196    }
197    @finally {
198        //
199        /* ruleScopeCleanUp */
200
201    }
202    return;
203}
204/* $ANTLR end "ID" */
205// $ANTLR start "INT"
206- (void) mINT
207{
208    //
209    /* ruleScopeSetUp */
210
211    /* ruleDeclarations */
212    NSString * value = nil ;
213
214
215    @try {
216        NSInteger _type = INT;
217        NSInteger _channel = TokenChannelDefault;
218        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g:25:5: ( ( '0' .. '9' )+ ) // ruleBlockSingleAlt
219        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g:25:7: ( '0' .. '9' )+ // alt
220        {
221
222        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g:25:7: ( '0' .. '9' )+ // positiveClosureBlock
223        NSInteger cnt2 = 0;
224        do {
225            NSInteger alt2 = 2;
226            NSInteger LA2_0 = [input LA:1];
227            if ( ((LA2_0 >= '0' && LA2_0 <= '9')) ) {
228                alt2=1;
229            }
230
231
232            switch (alt2) {
233                case 1 : ;
234                    // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g: // alt
235                    {
236
237                    if ((([input LA:1] >= '0') && ([input LA:1] <= '9'))) {
238                        [input consume];
239                    } else {
240                        MismatchedSetException *mse = [MismatchedSetException newException:nil stream:input];
241                        [self recover:mse];
242                        @throw mse;
243                    }
244
245
246                    }
247                    break;
248
249                default :
250                    if ( cnt2 >= 1 )
251                        goto loop2;
252                    EarlyExitException *eee =
253                        [EarlyExitException newException:input decisionNumber:2];
254                    @throw eee;
255            }
256            cnt2++;
257        } while (YES);
258        loop2: ;
259
260
261        }
262
263        /* token+rule list labels */
264
265        state.type = _type;
266        state.channel = _channel;
267    }
268    @finally {
269        //
270        /* ruleScopeCleanUp */
271
272    }
273    return;
274}
275/* $ANTLR end "INT" */
276// $ANTLR start "WS"
277- (void) mWS
278{
279    //
280    /* ruleScopeSetUp */
281
282    /* ruleDeclarations */
283
284    @try {
285        NSInteger _type = WS;
286        NSInteger _channel = TokenChannelDefault;
287        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g:27:4: ( ( ' ' | '\\t' | '\\r' | '\\n' )+ ) // ruleBlockSingleAlt
288        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g:27:6: ( ' ' | '\\t' | '\\r' | '\\n' )+ // alt
289        {
290
291        // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g:27:6: ( ' ' | '\\t' | '\\r' | '\\n' )+ // positiveClosureBlock
292        NSInteger cnt3 = 0;
293        do {
294            NSInteger alt3 = 2;
295            NSInteger LA3_0 = [input LA:1];
296            if ( ((LA3_0 >= '\t' && LA3_0 <= '\n')||LA3_0=='\r'||LA3_0==' ') ) {
297                alt3=1;
298            }
299
300
301            switch (alt3) {
302                case 1 : ;
303                    // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g: // alt
304                    {
305
306                    if ((([input LA:1] >= '\t') && ([input LA:1] <= '\n'))||[input LA:1] == '\r'||[input LA:1] == ' ') {
307                        [input consume];
308                    } else {
309                        MismatchedSetException *mse = [MismatchedSetException newException:nil stream:input];
310                        [self recover:mse];
311                        @throw mse;
312                    }
313
314
315                    }
316                    break;
317
318                default :
319                    if ( cnt3 >= 1 )
320                        goto loop3;
321                    EarlyExitException *eee =
322                        [EarlyExitException newException:input decisionNumber:3];
323                    @throw eee;
324            }
325            cnt3++;
326        } while (YES);
327        loop3: ;
328
329
330
331         _channel=HIDDEN;
332
333
334        }
335
336        /* token+rule list labels */
337
338        state.type = _type;
339        state.channel = _channel;
340    }
341    @finally {
342        //
343        /* ruleScopeCleanUp */
344
345    }
346    return;
347}
348/* $ANTLR end "WS" */
349- (void) mTokens
350{
351    // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g:1:8: ( T__8 | T__9 | ID | INT | WS ) //ruleblock
352    NSInteger alt4=5;
353    unichar charLA4 = [input LA:1];
354    switch (charLA4) {
355        case '+': ;
356            {
357            alt4=1;
358            }
359            break;
360        case '^': ;
361            {
362            alt4=2;
363            }
364            break;
365        case 'a': ;
366        case 'b': ;
367        case 'c': ;
368        case 'd': ;
369        case 'e': ;
370        case 'f': ;
371        case 'g': ;
372        case 'h': ;
373        case 'i': ;
374        case 'j': ;
375        case 'k': ;
376        case 'l': ;
377        case 'm': ;
378        case 'n': ;
379        case 'o': ;
380        case 'p': ;
381        case 'q': ;
382        case 'r': ;
383        case 's': ;
384        case 't': ;
385        case 'u': ;
386        case 'v': ;
387        case 'w': ;
388        case 'x': ;
389        case 'y': ;
390        case 'z': ;
391            {
392            alt4=3;
393            }
394            break;
395        case '0': ;
396        case '1': ;
397        case '2': ;
398        case '3': ;
399        case '4': ;
400        case '5': ;
401        case '6': ;
402        case '7': ;
403        case '8': ;
404        case '9': ;
405            {
406            alt4=4;
407            }
408            break;
409        case '\t': ;
410        case '\n': ;
411        case '\r': ;
412        case ' ': ;
413            {
414            alt4=5;
415            }
416            break;
417
418    default: ;
419        NoViableAltException *nvae = [NoViableAltException newException:4 state:0 stream:input];
420        nvae.c = charLA4;
421        @throw nvae;
422
423    }
424
425    switch (alt4) {
426        case 1 : ;
427            // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g:1:10: T__8 // alt
428            {
429
430
431            [self mT__8];
432
433
434
435            }
436            break;
437        case 2 : ;
438            // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g:1:15: T__9 // alt
439            {
440
441
442            [self mT__9];
443
444
445
446            }
447            break;
448        case 3 : ;
449            // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g:1:20: ID // alt
450            {
451
452
453            [self mID];
454
455
456
457            }
458            break;
459        case 4 : ;
460            // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g:1:23: INT // alt
461            {
462
463
464            [self mINT];
465
466
467
468            }
469            break;
470        case 5 : ;
471            // /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/polydiff/Poly.g:1:27: WS // alt
472            {
473
474
475            [self mWS];
476
477
478
479            }
480            break;
481
482    }
483
484}
485
486@end /* end of PolyLexer implementation line 397 */