KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > persistence > antlr > TreeElement


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 /** A TreeElement is a block with one alternative and a root node */
10 class TreeElement extends AlternativeBlock {
11     GrammarAtom root;
12
13     public TreeElement(Grammar g, Token start) {
14         super(g, start, false);
15     }
16
17     public void generate() {
18         grammar.generator.gen(this);
19     }
20
21     public Lookahead look(int k) {
22         return grammar.theLLkAnalyzer.look(k, this);
23     }
24
25     public String JavaDoc toString() {
26         String JavaDoc s = " #(" + root;
27         Alternative a = (Alternative)alternatives.elementAt(0);
28         AlternativeElement p = a.head;
29         while (p != null) {
30             s += p;
31             p = p.next;
32         }
33         return s + " )";
34     }
35 }
36
Popular Tags