source: trunk/yao/share/antlr-2.7.7/antlr/TokenRefElement.java @ 1

Last change on this file since 1 was 1, checked in by lnalod, 15 years ago

Initial import of YAO sources

File size: 1.3 KB
Line 
1package antlr;
2
3/* ANTLR Translator Generator
4 * Project led by Terence Parr at http://www.cs.usfca.edu
5 * Software rights: http://www.antlr.org/license.html
6 *
7 * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/TokenRefElement.java#2 $
8 */
9
10class 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}
Note: See TracBrowser for help on using the repository browser.