1 /** \file 2 * This OBJC source file was generated by $ANTLR version 3.2 Aug 07, 2010 22:08:38 3 * 4 * - From the grammar source file : /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/lexertest-simple/TestLexer.g 5 * - On : 2010-08-11 13:41:44 6 * - for the lexer : TestLexerLexer * 7 * Editing it, at least manually, is not wise. 8 * 9 * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. 10 * 11 * 12 */ 13 // [The "BSD licence"] 14 // Copyright (c) 2010 Alan Condit 15 // 16 // All rights reserved. 17 // 18 // Redistribution and use in source and binary forms, with or without 19 // modification, are permitted provided that the following conditions 20 // are met: 21 // 1. Redistributions of source code must retain the above copyright 22 // notice, this list of conditions and the following disclaimer. 23 // 2. Redistributions in binary form must reproduce the above copyright 24 // notice, this list of conditions and the following disclaimer in the 25 // documentation and/or other materials provided with the distribution. 26 // 3. The name of the author may not be used to endorse or promote products 27 // derived from this software without specific prior written permission. 28 // 29 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 30 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 31 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 32 // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 33 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 34 // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 38 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 40 // $ANTLR 3.2 Aug 07, 2010 22:08:38 /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/lexertest-simple/TestLexer.g 2010-08-11 13:41:44 41 42 /* ----------------------------------------- 43 * Include the ANTLR3 generated header file. 44 */ 45 #import "TestLexer.h" 46 /* ----------------------------------------- */ 47 48 49 /* ============================================================================= */ 50 51 /* ============================================================================= 52 * Start of recognizer 53 */ 54 55 56 /** As per Terence: No returns for lexer rules! 57 #pragma mark Rule return scopes start 58 #pragma mark Rule return scopes end 59 */ 60 @implementation TestLexer 61 62 63 + (void) initialize 64 { 65 [ANTLRBaseRecognizer setGrammarFileName:@"/usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/lexertest-simple/TestLexer.g"]; 66 } 67 68 - (id) initWithCharStream:(id<ANTLRCharStream>)anInput 69 { 70 if ((self = [super initWithCharStream:anInput State:[ANTLRRecognizerSharedState newANTLRRecognizerSharedStateWithRuleLen:4+1]]) != nil) { 71 } 72 return self; 73 } 74 75 - (void) dealloc 76 { 77 [super dealloc]; 78 } 79 80 + (NSString *) tokenNameForType:(NSInteger)aTokenType 81 { 82 return [[self getTokenNames] objectAtIndex:aTokenType]; 83 } 84 85 // $ANTLR start "ID" 86 - (void) mID 87 { 88 // 89 // This is not in the Java.stg 90 91 @try { 92 NSInteger _type = ID; 93 NSInteger _channel = ANTLRTokenChannelDefault; 94 // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/lexertest-simple/TestLexer.g:8:4: ( LETTER ( LETTER | DIGIT )* ) // ruleBlockSingleAlt 95 // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/lexertest-simple/TestLexer.g:8:6: LETTER ( LETTER | DIGIT )* // alt 96 { 97 [self mLETTER]; 98 99 /* element() */ 100 do { 101 NSInteger alt1=2; 102 { 103 NSInteger LA1_0 = [input LA:1]; 104 if ( (LA1_0>='0' && LA1_0<='9')||(LA1_0>='A' && LA1_0<='Z')||(LA1_0>='a' && LA1_0<='z') ) { 105 alt1=1; 106 } 107 108 } 109 switch (alt1) { 110 case 1 : 111 // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/lexertest-simple/TestLexer.g: // alt 112 { 113 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')) { 114 [input consume]; 115 116 } else { 117 ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException exceptionWithSet:nil stream:input]; 118 [self recover:mse]; 119 @throw mse;} 120 /* element() */ 121 /* elements */ 122 } 123 break; 124 125 default : 126 goto loop1; 127 } 128 } while (YES); 129 loop1: ; 130 /* element() */ 131 /* elements */ 132 } 133 134 // token+rule list labels 135 136 [state setType:_type]; 137 138 state.channel = _channel; 139 } 140 @finally { 141 // 142 } 143 return; 144 } 145 // $ANTLR end ID 146 147 // $ANTLR start "DIGIT" 148 - (void) mDIGIT 149 { 150 // 151 // This is not in the Java.stg 152 153 @try { 154 // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/lexertest-simple/TestLexer.g:11:16: ( '0' .. '9' ) // ruleBlockSingleAlt 155 // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/lexertest-simple/TestLexer.g:11:18: '0' .. '9' // alt 156 { 157 [self matchRangeFromChar:'0' to:'9']; /* element() */ 158 /* elements */ 159 } 160 161 } 162 @finally { 163 // 164 } 165 return; 166 } 167 // $ANTLR end DIGIT 168 169 // $ANTLR start "LETTER" 170 - (void) mLETTER 171 { 172 // 173 // This is not in the Java.stg 174 175 @try { 176 // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/lexertest-simple/TestLexer.g:15:2: ( 'a' .. 'z' | 'A' .. 'Z' ) // ruleBlockSingleAlt 177 // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/lexertest-simple/TestLexer.g: // alt 178 { 179 if (([input LA:1]>='A' && [input LA:1]<='Z')||([input LA:1]>='a' && [input LA:1]<='z')) { 180 [input consume]; 181 182 } else { 183 ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException exceptionWithSet:nil stream:input]; 184 [self recover:mse]; 185 @throw mse;} 186 /* element() */ 187 /* elements */ 188 } 189 190 } 191 @finally { 192 // 193 } 194 return; 195 } 196 // $ANTLR end LETTER 197 198 - (void) mTokens 199 { 200 // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/lexertest-simple/TestLexer.g:1:8: ( ID ) // ruleBlockSingleAlt 201 // /usr/local/ANTLR3-ObjC2.0-Runtime/Framework/examples/lexertest-simple/TestLexer.g:1:10: ID // alt 202 { 203 [self mID]; 204 205 /* element() */ 206 /* elements */ 207 } 208 209 210 } 211 212 @end // end of TestLexer implementation 213 214 /* End of code 215 * ============================================================================= 216 */ 217