1 package antlr; 3 4 import antlr.TokenBuffer; 5 import antlr.TokenStreamException; 6 import antlr.TokenStreamIOException; 7 import antlr.ANTLRException; 8 import antlr.LLkParser; 9 import antlr.Token; 10 import antlr.TokenStream; 11 import antlr.RecognitionException; 12 import antlr.NoViableAltException; 13 import antlr.MismatchedTokenException; 14 import antlr.SemanticException; 15 import antlr.ParserSharedInputState; 16 import antlr.collections.impl.BitSet; 17 import antlr.collections.AST; 18 import antlr.ASTPair; 19 import antlr.collections.impl.ASTArray; 20 21 24 public class ANTLRTokdefParser extends antlr.LLkParser 25 implements ANTLRTokdefParserTokenTypes { 26 27 protected ANTLRTokdefParser(TokenBuffer tokenBuf, int k) { 28 super(tokenBuf, k); 29 tokenNames = _tokenNames; 30 } 31 32 public ANTLRTokdefParser(TokenBuffer tokenBuf) { 33 this(tokenBuf, 3); 34 } 35 36 protected ANTLRTokdefParser(TokenStream lexer, int k) { 37 super(lexer, k); 38 tokenNames = _tokenNames; 39 } 40 41 public ANTLRTokdefParser(TokenStream lexer) { 42 this(lexer, 3); 43 } 44 45 public ANTLRTokdefParser(ParserSharedInputState state) { 46 super(state, 3); 47 tokenNames = _tokenNames; 48 } 49 50 public final void file( 51 ImportVocabTokenManager tm 52 ) throws RecognitionException, TokenStreamException { 53 54 Token name = null; 55 56 try { name = LT(1); 58 match(ID); 59 { 60 _loop3: 61 do { 62 if ((LA(1) == ID || LA(1) == STRING)) { 63 line(tm); 64 } 65 else { 66 break _loop3; 67 } 68 69 } while (true); 70 } 71 } 72 catch (RecognitionException ex) { 73 reportError(ex); 74 consume(); 75 consumeUntil(_tokenSet_0); 76 } 77 } 78 79 public final void line( 80 ImportVocabTokenManager tm 81 ) throws RecognitionException, TokenStreamException { 82 83 Token s1 = null; 84 Token lab = null; 85 Token s2 = null; 86 Token id = null; 87 Token para = null; 88 Token id2 = null; 89 Token i = null; 90 Token t = null; 91 Token s = null; 92 93 try { { 95 if ((LA(1) == STRING)) { 96 s1 = LT(1); 97 match(STRING); 98 s = s1; 99 } 100 else if ((LA(1) == ID) && (LA(2) == ASSIGN) && (LA(3) == STRING)) { 101 lab = LT(1); 102 match(ID); 103 t = lab; 104 match(ASSIGN); 105 s2 = LT(1); 106 match(STRING); 107 s = s2; 108 } 109 else if ((LA(1) == ID) && (LA(2) == LPAREN)) { 110 id = LT(1); 111 match(ID); 112 t = id; 113 match(LPAREN); 114 para = LT(1); 115 match(STRING); 116 match(RPAREN); 117 } 118 else if ((LA(1) == ID) && (LA(2) == ASSIGN) && (LA(3) == INT)) { 119 id2 = LT(1); 120 match(ID); 121 t = id2; 122 } 123 else { 124 throw new NoViableAltException(LT(1), getFilename()); 125 } 126 127 } 128 match(ASSIGN); 129 i = LT(1); 130 match(INT); 131 132 Integer value = Integer.valueOf(i.getText()); 133 if (s != null) { 135 tm.define(s.getText(), value.intValue()); 136 if (t != null) { 138 StringLiteralSymbol sl = 139 (StringLiteralSymbol)tm.getTokenSymbol(s.getText()); 140 sl.setLabel(t.getText()); 141 tm.mapToTokenSymbol(t.getText(), sl); 142 } 143 } 144 else if (t != null) { 146 tm.define(t.getText(), value.intValue()); 147 if (para != null) { 148 TokenSymbol ts = tm.getTokenSymbol(t.getText()); 149 ts.setParaphrase( 150 para.getText() 151 ); 152 } 153 } 154 155 } 156 catch (RecognitionException ex) { 157 reportError(ex); 158 consume(); 159 consumeUntil(_tokenSet_1); 160 } 161 } 162 163 164 public static final String [] _tokenNames = { 165 "<0>", 166 "EOF", 167 "<2>", 168 "NULL_TREE_LOOKAHEAD", 169 "ID", 170 "STRING", 171 "ASSIGN", 172 "LPAREN", 173 "RPAREN", 174 "INT", 175 "WS", 176 "SL_COMMENT", 177 "ML_COMMENT", 178 "ESC", 179 "DIGIT", 180 "XDIGIT", 181 "VOCAB" 182 }; 183 184 private static final long _tokenSet_0_data_[] = {2L, 0L}; 185 public static final BitSet _tokenSet_0 = new BitSet(_tokenSet_0_data_); 186 private static final long _tokenSet_1_data_[] = {50L, 0L}; 187 public static final BitSet _tokenSet_1 = new BitSet(_tokenSet_1_data_); 188 189 } 190
| Popular Tags
|