KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ro > infoiasi > donald > compiler > cfg > Terminal


1 package ro.infoiasi.donald.compiler.cfg;
2
3 /** A grammar terminal */
4 public class Terminal extends Symbol {
5     public static final int LEFT_ASSOCIATIVE = 0;
6     public static final int RIGHT_ASSOCIATIVE = 1;
7     public static final int NON_ASSOCIATIVE = 2;
8     public static final int NO_PRECEDENCE = -1;
9
10     private int precedence;
11     private int associativity;
12
13     Terminal(String JavaDoc name, int index, String JavaDoc type,
14             int precedence, int associativity) {
15         super(name, index, type);
16         this.precedence = precedence;
17         this.associativity = associativity;
18     }
19
20     Terminal(String JavaDoc name, int index, String JavaDoc type) {
21         this(name, index, type, NO_PRECEDENCE, NO_PRECEDENCE);
22     }
23
24     Terminal(String JavaDoc name, int index) {
25         this(name, index, null);
26     }
27     
28     public int getPrecedence() {
29         return precedence;
30     }
31     
32     public int getAssociativity() {
33         return associativity;
34     }
35
36     public void setPrecedence(int precedence, int associativity) {
37         this.precedence = precedence;
38         this.associativity = associativity;
39     }
40
41     public boolean isTerminal() {
42         return true;
43     }
44 }
45
Popular Tags