Home | History | Annotate | Download | only in lexertest-simple
      1 /** \file
      2  *  This OBJC source file was generated by $ANTLR version ${project.version} ${buildNumber}
      3  *
      4  *     -  From the grammar source file : TestLexer.g
      5  *     -                            On : 2011-05-06 19:16:22
      6  *     -                 for the lexer : TestLexerLexer
      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 ${project.version} ${buildNumber} TestLexer.g 2011-05-06 19:16:22
     15 
     16 
     17 /* -----------------------------------------
     18  * Include the ANTLR3 generated header file.
     19  */
     20 #import "TestLexer.h"
     21 /* ----------------------------------------- */
     22 
     23 
     24 /* ============================================================================= */
     25 /* =============================================================================
     26  * Start of recognizer
     27  */
     28 
     29 /** As per Terence: No returns for lexer rules! */
     30 @implementation TestLexer // line 330
     31 
     32 + (void) initialize
     33 {
     34     [ANTLRBaseRecognizer setGrammarFileName:@"TestLexer.g"];
     35 }
     36 
     37 + (NSString *) tokenNameForType:(NSInteger)aTokenType
     38 {
     39     return [[self getTokenNames] objectAtIndex:aTokenType];
     40 }
     41 
     42 + (TestLexer *)newTestLexerWithCharStream:(id<ANTLRCharStream>)anInput
     43 {
     44     return [[TestLexer alloc] initWithCharStream:anInput];
     45 }
     46 
     47 - (id) initWithCharStream:(id<ANTLRCharStream>)anInput
     48 {
     49     self = [super initWithCharStream:anInput State:[[ANTLRRecognizerSharedState newANTLRRecognizerSharedStateWithRuleLen:4+1] retain]];
     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 "ID"
     67 - (void) mID
     68 {
     69     //
     70     /* my ruleScopeSetUp */
     71     /* Terence's stuff */
     72 
     73     @try {
     74         NSInteger _type = ID;
     75         NSInteger _channel = ANTLRTokenChannelDefault;
     76         // TestLexer.g:8:4: ( LETTER ( LETTER | DIGIT )* ) // ruleBlockSingleAlt
     77         // TestLexer.g:8:6: LETTER ( LETTER | DIGIT )* // alt
     78         {
     79         [self mLETTER];
     80 
     81 
     82 
     83         do {
     84             NSInteger alt1=2;
     85             NSInteger LA1_0 = [input LA:1];
     86             if ( ((LA1_0 >= '0' && LA1_0 <= '9')||(LA1_0 >= 'A' && LA1_0 <= 'Z')||(LA1_0 >= 'a' && LA1_0 <= 'z')) ) {
     87                 alt1=1;
     88             }
     89 
     90 
     91             switch (alt1) {
     92                 case 1 : ;
     93                     // TestLexer.g: // alt
     94                     {
     95                     if ((([input LA:1] >= '0') && ([input LA:1] <= '9'))||(([input LA:1] >= 'A') && ([input LA:1] <= 'Z'))||(([input LA:1] >= 'a') && ([input LA:1] <= 'z'))) {
     96                         [input consume];
     97                     } else {
     98                         ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException newException:nil stream:input];
     99                         [self recover:mse];
    100                         @throw mse;
    101                     }
    102 
    103 
    104                     }
    105                     break;
    106 
    107                 default :
    108                     goto loop1;
    109             }
    110         } while (YES);
    111         loop1: ;
    112 
    113 
    114         }
    115 
    116         // token+rule list labels
    117 
    118         state.type = _type;
    119         state.channel = _channel;
    120     }
    121     @finally {
    122         //
    123         /* Terence's stuff */
    124 
    125     }
    126     return;
    127 }
    128 /* $ANTLR end "ID" */
    129 
    130 // $ANTLR start "DIGIT"
    131 - (void) mDIGIT
    132 {
    133     //
    134     /* my ruleScopeSetUp */
    135     /* Terence's stuff */
    136 
    137     @try {
    138         // TestLexer.g:11:16: ( '0' .. '9' ) // ruleBlockSingleAlt
    139         // TestLexer.g: // alt
    140         {
    141         if ((([input LA:1] >= '0') && ([input LA:1] <= '9'))) {
    142             [input consume];
    143         } else {
    144             ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException newException:nil stream:input];
    145             [self recover:mse];
    146             @throw mse;
    147         }
    148 
    149 
    150         }
    151 
    152 
    153     }
    154     @finally {
    155         //
    156         /* Terence's stuff */
    157 
    158     }
    159     return;
    160 }
    161 /* $ANTLR end "DIGIT" */
    162 
    163 // $ANTLR start "LETTER"
    164 - (void) mLETTER
    165 {
    166     //
    167     /* my ruleScopeSetUp */
    168     /* Terence's stuff */
    169 
    170     @try {
    171         // TestLexer.g:15:2: ( 'a' .. 'z' | 'A' .. 'Z' ) // ruleBlockSingleAlt
    172         // TestLexer.g: // alt
    173         {
    174         if ((([input LA:1] >= 'A') && ([input LA:1] <= 'Z'))||(([input LA:1] >= 'a') && ([input LA:1] <= 'z'))) {
    175             [input consume];
    176         } else {
    177             ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException newException:nil stream:input];
    178             [self recover:mse];
    179             @throw mse;
    180         }
    181 
    182 
    183         }
    184 
    185 
    186     }
    187     @finally {
    188         //
    189         /* Terence's stuff */
    190 
    191     }
    192     return;
    193 }
    194 /* $ANTLR end "LETTER" */
    195 
    196 - (void) mTokens
    197 {
    198     // TestLexer.g:1:8: ( ID ) // ruleBlockSingleAlt
    199     // TestLexer.g:1:10: ID // alt
    200     {
    201     [self mID];
    202 
    203 
    204 
    205     }
    206 
    207 
    208 }
    209 
    210 @end /* end of TestLexer implementation line 397 */