KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > antlr > TokenRefElement


1 package antlr;
2
3 /* ANTLR Translator Generator
4  * Project led by Terence Parr at http://www.jGuru.com
5  * Software rights: http://www.antlr.org/RIGHTS.html
6  *
7  * $Id: //depot/code/org.antlr/main/main/antlr/TokenRefElement.java#6 $
8  */

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