KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > persistence > antlr > TokenRefElement


1 package persistence.antlr;
2
3 /* ANTLR Translator Generator
4  * Project led by Terence Parr at http://www.jGuru.com
5  * Software rights: http://www.antlr.org/license.html
6  *
7  */

8
9 class TokenRefElement extends GrammarAtom {
10
11     public TokenRefElement(Grammar g,
12                            Token t,
13                            boolean inverted,
14                            int autoGenType) {
15         super(g, t, autoGenType);
16         not = inverted;
17         TokenSymbol ts = grammar.tokenManager.getTokenSymbol(atomText);
18         if (ts == null) {
19             g.antlrTool.error("Undefined token symbol: " +
20                          atomText, grammar.getFilename(), t.getLine(), t.getColumn());
21         }
22         else {
23             tokenType = ts.getTokenType();
24             // set the AST node type to whatever was set in tokens {...}
25
// section (if anything);
26
// Lafter, after this is created, the element option can set this.
27
setASTNodeType(ts.getASTNodeType());
28         }
29         line = t.getLine();
30     }
31
32     public void generate() {
33         grammar.generator.gen(this);
34     }
35
36     public Lookahead look(int k) {
37         return grammar.theLLkAnalyzer.look(k, this);
38     }
39 }
40
Popular Tags