01: package antlr;
02:
03: /* ANTLR Translator Generator
04: * Project led by Terence Parr at http://www.cs.usfca.edu
05: * Software rights: http://www.antlr.org/license.html
06: */
07:
08: class TokenRefElement extends GrammarAtom {
09:
10: public TokenRefElement(Grammar g, Token t, boolean inverted,
11: int autoGenType) {
12: super (g, t, autoGenType);
13: not = inverted;
14: TokenSymbol ts = grammar.tokenManager.getTokenSymbol(atomText);
15: if (ts == null) {
16: g.antlrTool.error("Undefined token symbol: " + atomText,
17: grammar.getFilename(), t.getLine(), t.getColumn());
18: } else {
19: tokenType = ts.getTokenType();
20: // set the AST node type to whatever was set in tokens {...}
21: // section (if anything);
22: // Lafter, after this is created, the element option can set this.
23: setASTNodeType(ts.getASTNodeType());
24: }
25: line = t.getLine();
26: }
27:
28: public void generate(Context context) {
29: grammar.generator.gen(this , context);
30: }
31:
32: public Lookahead look(int k) {
33: return grammar.theLLkAnalyzer.look(k, this);
34: }
35: }
|