1// $ANTLR 3.2 Aug 13, 2010 14:19:31 SimpleC.g 2010-08-13 14:29:19
2
3import org.antlr.runtime.*;
4import java.util.Stack;
5import java.util.List;
6import java.util.ArrayList;
7
8public class SimpleCLexer extends Lexer {
9    public static final int LT=18;
10    public static final int T__26=26;
11    public static final int T__25=25;
12    public static final int T__24=24;
13    public static final int T__23=23;
14    public static final int T__22=22;
15    public static final int T__21=21;
16    public static final int CHAR=15;
17    public static final int FOR=13;
18    public static final int FUNC_HDR=6;
19    public static final int INT=12;
20    public static final int FUNC_DEF=8;
21    public static final int INT_TYPE=14;
22    public static final int ID=10;
23    public static final int EOF=-1;
24    public static final int FUNC_DECL=7;
25    public static final int ARG_DEF=5;
26    public static final int WS=20;
27    public static final int BLOCK=9;
28    public static final int PLUS=19;
29    public static final int VOID=16;
30    public static final int EQ=11;
31    public static final int VAR_DEF=4;
32    public static final int EQEQ=17;
33
34    // delegates
35    // delegators
36
37    public SimpleCLexer() {;}
38    public SimpleCLexer(CharStream input) {
39        this(input, new RecognizerSharedState());
40    }
41    public SimpleCLexer(CharStream input, RecognizerSharedState state) {
42        super(input,state);
43
44    }
45    public String getGrammarFileName() { return "SimpleC.g"; }
46
47    // $ANTLR start "T__21"
48    public final void mT__21() throws RecognitionException {
49        try {
50            int _type = T__21;
51            int _channel = DEFAULT_TOKEN_CHANNEL;
52            // SimpleC.g:7:7: ( ';' )
53            // SimpleC.g:7:9: ';'
54            {
55            match(';');
56
57            }
58
59            state.type = _type;
60            state.channel = _channel;
61        }
62        finally {
63        }
64    }
65    // $ANTLR end "T__21"
66
67    // $ANTLR start "T__22"
68    public final void mT__22() throws RecognitionException {
69        try {
70            int _type = T__22;
71            int _channel = DEFAULT_TOKEN_CHANNEL;
72            // SimpleC.g:8:7: ( '(' )
73            // SimpleC.g:8:9: '('
74            {
75            match('(');
76
77            }
78
79            state.type = _type;
80            state.channel = _channel;
81        }
82        finally {
83        }
84    }
85    // $ANTLR end "T__22"
86
87    // $ANTLR start "T__23"
88    public final void mT__23() throws RecognitionException {
89        try {
90            int _type = T__23;
91            int _channel = DEFAULT_TOKEN_CHANNEL;
92            // SimpleC.g:9:7: ( ',' )
93            // SimpleC.g:9:9: ','
94            {
95            match(',');
96
97            }
98
99            state.type = _type;
100            state.channel = _channel;
101        }
102        finally {
103        }
104    }
105    // $ANTLR end "T__23"
106
107    // $ANTLR start "T__24"
108    public final void mT__24() throws RecognitionException {
109        try {
110            int _type = T__24;
111            int _channel = DEFAULT_TOKEN_CHANNEL;
112            // SimpleC.g:10:7: ( ')' )
113            // SimpleC.g:10:9: ')'
114            {
115            match(')');
116
117            }
118
119            state.type = _type;
120            state.channel = _channel;
121        }
122        finally {
123        }
124    }
125    // $ANTLR end "T__24"
126
127    // $ANTLR start "T__25"
128    public final void mT__25() throws RecognitionException {
129        try {
130            int _type = T__25;
131            int _channel = DEFAULT_TOKEN_CHANNEL;
132            // SimpleC.g:11:7: ( '{' )
133            // SimpleC.g:11:9: '{'
134            {
135            match('{');
136
137            }
138
139            state.type = _type;
140            state.channel = _channel;
141        }
142        finally {
143        }
144    }
145    // $ANTLR end "T__25"
146
147    // $ANTLR start "T__26"
148    public final void mT__26() throws RecognitionException {
149        try {
150            int _type = T__26;
151            int _channel = DEFAULT_TOKEN_CHANNEL;
152            // SimpleC.g:12:7: ( '}' )
153            // SimpleC.g:12:9: '}'
154            {
155            match('}');
156
157            }
158
159            state.type = _type;
160            state.channel = _channel;
161        }
162        finally {
163        }
164    }
165    // $ANTLR end "T__26"
166
167    // $ANTLR start "FOR"
168    public final void mFOR() throws RecognitionException {
169        try {
170            int _type = FOR;
171            int _channel = DEFAULT_TOKEN_CHANNEL;
172            // SimpleC.g:91:5: ( 'for' )
173            // SimpleC.g:91:7: 'for'
174            {
175            match("for");
176
177
178            }
179
180            state.type = _type;
181            state.channel = _channel;
182        }
183        finally {
184        }
185    }
186    // $ANTLR end "FOR"
187
188    // $ANTLR start "INT_TYPE"
189    public final void mINT_TYPE() throws RecognitionException {
190        try {
191            int _type = INT_TYPE;
192            int _channel = DEFAULT_TOKEN_CHANNEL;
193            // SimpleC.g:92:10: ( 'int' )
194            // SimpleC.g:92:12: 'int'
195            {
196            match("int");
197
198
199            }
200
201            state.type = _type;
202            state.channel = _channel;
203        }
204        finally {
205        }
206    }
207    // $ANTLR end "INT_TYPE"
208
209    // $ANTLR start "CHAR"
210    public final void mCHAR() throws RecognitionException {
211        try {
212            int _type = CHAR;
213            int _channel = DEFAULT_TOKEN_CHANNEL;
214            // SimpleC.g:93:5: ( 'char' )
215            // SimpleC.g:93:7: 'char'
216            {
217            match("char");
218
219
220            }
221
222            state.type = _type;
223            state.channel = _channel;
224        }
225        finally {
226        }
227    }
228    // $ANTLR end "CHAR"
229
230    // $ANTLR start "VOID"
231    public final void mVOID() throws RecognitionException {
232        try {
233            int _type = VOID;
234            int _channel = DEFAULT_TOKEN_CHANNEL;
235            // SimpleC.g:94:5: ( 'void' )
236            // SimpleC.g:94:7: 'void'
237            {
238            match("void");
239
240
241            }
242
243            state.type = _type;
244            state.channel = _channel;
245        }
246        finally {
247        }
248    }
249    // $ANTLR end "VOID"
250
251    // $ANTLR start "ID"
252    public final void mID() throws RecognitionException {
253        try {
254            int _type = ID;
255            int _channel = DEFAULT_TOKEN_CHANNEL;
256            // SimpleC.g:96:5: ( ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' )* )
257            // SimpleC.g:96:9: ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' )*
258            {
259            if ( (input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) {
260                input.consume();
261
262            }
263            else {
264                MismatchedSetException mse = new MismatchedSetException(null,input);
265                recover(mse);
266                throw mse;}
267
268            // SimpleC.g:96:33: ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' )*
269            loop1:
270            do {
271                int alt1=2;
272                int LA1_0 = input.LA(1);
273
274                if ( ((LA1_0>='0' && LA1_0<='9')||(LA1_0>='A' && LA1_0<='Z')||LA1_0=='_'||(LA1_0>='a' && LA1_0<='z')) ) {
275                    alt1=1;
276                }
277
278
279                switch (alt1) {
280            	case 1 :
281            	    // SimpleC.g:
282            	    {
283            	    if ( (input.LA(1)>='0' && input.LA(1)<='9')||(input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) {
284            	        input.consume();
285
286            	    }
287            	    else {
288            	        MismatchedSetException mse = new MismatchedSetException(null,input);
289            	        recover(mse);
290            	        throw mse;}
291
292
293            	    }
294            	    break;
295
296            	default :
297            	    break loop1;
298                }
299            } while (true);
300
301
302            }
303
304            state.type = _type;
305            state.channel = _channel;
306        }
307        finally {
308        }
309    }
310    // $ANTLR end "ID"
311
312    // $ANTLR start "INT"
313    public final void mINT() throws RecognitionException {
314        try {
315            int _type = INT;
316            int _channel = DEFAULT_TOKEN_CHANNEL;
317            CommonToken int=null;
318            List list_int=null;
319            // SimpleC.g:99:5: ( (int+= ( '0' .. '9' ) )+ )
320            // SimpleC.g:99:7: (int+= ( '0' .. '9' ) )+
321            {
322            // SimpleC.g:99:10: (int+= ( '0' .. '9' ) )+
323            int cnt2=0;
324            loop2:
325            do {
326                int alt2=2;
327                int LA2_0 = input.LA(1);
328
329                if ( ((LA2_0>='0' && LA2_0<='9')) ) {
330                    alt2=1;
331                }
332
333
334                switch (alt2) {
335            	case 1 :
336            	    // SimpleC.g:99:10: int+= ( '0' .. '9' )
337            	    {
338            	    // SimpleC.g:99:12: ( '0' .. '9' )
339            	    // SimpleC.g:99:13: '0' .. '9'
340            	    {
341            	    matchRange('0','9');
342
343            	    }
344
345
346            	    }
347            	    break;
348
349            	default :
350            	    if ( cnt2 >= 1 ) break loop2;
351                        EarlyExitException eee =
352                            new EarlyExitException(2, input);
353                        throw eee;
354                }
355                cnt2++;
356            } while (true);
357
358            NSLog(@"%@", list_int);
359
360            }
361
362            state.type = _type;
363            state.channel = _channel;
364        }
365        finally {
366        }
367    }
368    // $ANTLR end "INT"
369
370    // $ANTLR start "EQ"
371    public final void mEQ() throws RecognitionException {
372        try {
373            int _type = EQ;
374            int _channel = DEFAULT_TOKEN_CHANNEL;
375            // SimpleC.g:102:6: ( '=' )
376            // SimpleC.g:102:8: '='
377            {
378            match('=');
379
380            }
381
382            state.type = _type;
383            state.channel = _channel;
384        }
385        finally {
386        }
387    }
388    // $ANTLR end "EQ"
389
390    // $ANTLR start "EQEQ"
391    public final void mEQEQ() throws RecognitionException {
392        try {
393            int _type = EQEQ;
394            int _channel = DEFAULT_TOKEN_CHANNEL;
395            // SimpleC.g:103:6: ( '==' )
396            // SimpleC.g:103:8: '=='
397            {
398            match("==");
399
400
401            }
402
403            state.type = _type;
404            state.channel = _channel;
405        }
406        finally {
407        }
408    }
409    // $ANTLR end "EQEQ"
410
411    // $ANTLR start "LT"
412    public final void mLT() throws RecognitionException {
413        try {
414            int _type = LT;
415            int _channel = DEFAULT_TOKEN_CHANNEL;
416            // SimpleC.g:104:6: ( '<' )
417            // SimpleC.g:104:8: '<'
418            {
419            match('<');
420
421            }
422
423            state.type = _type;
424            state.channel = _channel;
425        }
426        finally {
427        }
428    }
429    // $ANTLR end "LT"
430
431    // $ANTLR start "PLUS"
432    public final void mPLUS() throws RecognitionException {
433        try {
434            int _type = PLUS;
435            int _channel = DEFAULT_TOKEN_CHANNEL;
436            // SimpleC.g:105:6: ( '+' )
437            // SimpleC.g:105:8: '+'
438            {
439            match('+');
440
441            }
442
443            state.type = _type;
444            state.channel = _channel;
445        }
446        finally {
447        }
448    }
449    // $ANTLR end "PLUS"
450
451    // $ANTLR start "WS"
452    public final void mWS() throws RecognitionException {
453        try {
454            int _type = WS;
455            int _channel = DEFAULT_TOKEN_CHANNEL;
456            // SimpleC.g:107:5: ( ( ' ' | '\\t' | '\\r' | '\\n' )+ )
457            // SimpleC.g:107:9: ( ' ' | '\\t' | '\\r' | '\\n' )+
458            {
459            // SimpleC.g:107:9: ( ' ' | '\\t' | '\\r' | '\\n' )+
460            int cnt3=0;
461            loop3:
462            do {
463                int alt3=2;
464                int LA3_0 = input.LA(1);
465
466                if ( ((LA3_0>='\t' && LA3_0<='\n')||LA3_0=='\r'||LA3_0==' ') ) {
467                    alt3=1;
468                }
469
470
471                switch (alt3) {
472            	case 1 :
473            	    // SimpleC.g:
474            	    {
475            	    if ( (input.LA(1)>='\t' && input.LA(1)<='\n')||input.LA(1)=='\r'||input.LA(1)==' ' ) {
476            	        input.consume();
477
478            	    }
479            	    else {
480            	        MismatchedSetException mse = new MismatchedSetException(null,input);
481            	        recover(mse);
482            	        throw mse;}
483
484
485            	    }
486            	    break;
487
488            	default :
489            	    if ( cnt3 >= 1 ) break loop3;
490                        EarlyExitException eee =
491                            new EarlyExitException(3, input);
492                        throw eee;
493                }
494                cnt3++;
495            } while (true);
496
497             _channel=99;
498
499            }
500
501            state.type = _type;
502            state.channel = _channel;
503        }
504        finally {
505        }
506    }
507    // $ANTLR end "WS"
508
509    public void mTokens() throws RecognitionException {
510        // SimpleC.g:1:8: ( T__21 | T__22 | T__23 | T__24 | T__25 | T__26 | FOR | INT_TYPE | CHAR | VOID | ID | INT | EQ | EQEQ | LT | PLUS | WS )
511        int alt4=17;
512        alt4 = dfa4.predict(input);
513        switch (alt4) {
514            case 1 :
515                // SimpleC.g:1:10: T__21
516                {
517                mT__21();
518
519                }
520                break;
521            case 2 :
522                // SimpleC.g:1:16: T__22
523                {
524                mT__22();
525
526                }
527                break;
528            case 3 :
529                // SimpleC.g:1:22: T__23
530                {
531                mT__23();
532
533                }
534                break;
535            case 4 :
536                // SimpleC.g:1:28: T__24
537                {
538                mT__24();
539
540                }
541                break;
542            case 5 :
543                // SimpleC.g:1:34: T__25
544                {
545                mT__25();
546
547                }
548                break;
549            case 6 :
550                // SimpleC.g:1:40: T__26
551                {
552                mT__26();
553
554                }
555                break;
556            case 7 :
557                // SimpleC.g:1:46: FOR
558                {
559                mFOR();
560
561                }
562                break;
563            case 8 :
564                // SimpleC.g:1:50: INT_TYPE
565                {
566                mINT_TYPE();
567
568                }
569                break;
570            case 9 :
571                // SimpleC.g:1:59: CHAR
572                {
573                mCHAR();
574
575                }
576                break;
577            case 10 :
578                // SimpleC.g:1:64: VOID
579                {
580                mVOID();
581
582                }
583                break;
584            case 11 :
585                // SimpleC.g:1:69: ID
586                {
587                mID();
588
589                }
590                break;
591            case 12 :
592                // SimpleC.g:1:72: INT
593                {
594                mINT();
595
596                }
597                break;
598            case 13 :
599                // SimpleC.g:1:76: EQ
600                {
601                mEQ();
602
603                }
604                break;
605            case 14 :
606                // SimpleC.g:1:79: EQEQ
607                {
608                mEQEQ();
609
610                }
611                break;
612            case 15 :
613                // SimpleC.g:1:84: LT
614                {
615                mLT();
616
617                }
618                break;
619            case 16 :
620                // SimpleC.g:1:87: PLUS
621                {
622                mPLUS();
623
624                }
625                break;
626            case 17 :
627                // SimpleC.g:1:92: WS
628                {
629                mWS();
630
631                }
632                break;
633
634        }
635
636    }
637
638
639    protected DFA4 dfa4 = new DFA4(this);
640    static final String DFA4_eotS =
641        "\7\uffff\4\13\2\uffff\1\26\3\uffff\4\13\2\uffff\1\33\1\34\2\13\2"+
642        "\uffff\1\37\1\40\2\uffff";
643    static final String DFA4_eofS =
644        "\41\uffff";
645    static final String DFA4_minS =
646        "\1\11\6\uffff\1\157\1\156\1\150\1\157\2\uffff\1\75\3\uffff\1\162"+
647        "\1\164\1\141\1\151\2\uffff\2\60\1\162\1\144\2\uffff\2\60\2\uffff";
648    static final String DFA4_maxS =
649        "\1\175\6\uffff\1\157\1\156\1\150\1\157\2\uffff\1\75\3\uffff\1\162"+
650        "\1\164\1\141\1\151\2\uffff\2\172\1\162\1\144\2\uffff\2\172\2\uffff";
651    static final String DFA4_acceptS =
652        "\1\uffff\1\1\1\2\1\3\1\4\1\5\1\6\4\uffff\1\13\1\14\1\uffff\1\17"+
653        "\1\20\1\21\4\uffff\1\16\1\15\4\uffff\1\7\1\10\2\uffff\1\11\1\12";
654    static final String DFA4_specialS =
655        "\41\uffff}>";
656    static final String[] DFA4_transitionS = {
657            "\2\20\2\uffff\1\20\22\uffff\1\20\7\uffff\1\2\1\4\1\uffff\1\17"+
658            "\1\3\3\uffff\12\14\1\uffff\1\1\1\16\1\15\3\uffff\32\13\4\uffff"+
659            "\1\13\1\uffff\2\13\1\11\2\13\1\7\2\13\1\10\14\13\1\12\4\13\1"+
660            "\5\1\uffff\1\6",
661            "",
662            "",
663            "",
664            "",
665            "",
666            "",
667            "\1\21",
668            "\1\22",
669            "\1\23",
670            "\1\24",
671            "",
672            "",
673            "\1\25",
674            "",
675            "",
676            "",
677            "\1\27",
678            "\1\30",
679            "\1\31",
680            "\1\32",
681            "",
682            "",
683            "\12\13\7\uffff\32\13\4\uffff\1\13\1\uffff\32\13",
684            "\12\13\7\uffff\32\13\4\uffff\1\13\1\uffff\32\13",
685            "\1\35",
686            "\1\36",
687            "",
688            "",
689            "\12\13\7\uffff\32\13\4\uffff\1\13\1\uffff\32\13",
690            "\12\13\7\uffff\32\13\4\uffff\1\13\1\uffff\32\13",
691            "",
692            ""
693    };
694
695    static final short[] DFA4_eot = DFA.unpackEncodedString(DFA4_eotS);
696    static final short[] DFA4_eof = DFA.unpackEncodedString(DFA4_eofS);
697    static final char[] DFA4_min = DFA.unpackEncodedStringToUnsignedChars(DFA4_minS);
698    static final char[] DFA4_max = DFA.unpackEncodedStringToUnsignedChars(DFA4_maxS);
699    static final short[] DFA4_accept = DFA.unpackEncodedString(DFA4_acceptS);
700    static final short[] DFA4_special = DFA.unpackEncodedString(DFA4_specialS);
701    static final short[][] DFA4_transition;
702
703    static {
704        int numStates = DFA4_transitionS.length;
705        DFA4_transition = new short[numStates][];
706        for (int i=0; i<numStates; i++) {
707            DFA4_transition[i] = DFA.unpackEncodedString(DFA4_transitionS[i]);
708        }
709    }
710
711    class DFA4 extends DFA {
712
713        public DFA4(BaseRecognizer recognizer) {
714            this.recognizer = recognizer;
715            this.decisionNumber = 4;
716            this.eot = DFA4_eot;
717            this.eof = DFA4_eof;
718            this.min = DFA4_min;
719            this.max = DFA4_max;
720            this.accept = DFA4_accept;
721            this.special = DFA4_special;
722            this.transition = DFA4_transition;
723        }
724        public String getDescription() {
725            return "1:1: Tokens : ( T__21 | T__22 | T__23 | T__24 | T__25 | T__26 | FOR | INT_TYPE | CHAR | VOID | ID | INT | EQ | EQEQ | LT | PLUS | WS );";
726        }
727    }
728
729
730}