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