KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > antlr > TreeElement


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/TreeElement.java#5 $
8  */

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