01: package ro.infoiasi.donald.compiler.cfg;
02:
03: /** A grammar terminal */
04: public class Terminal extends Symbol {
05: public static final int LEFT_ASSOCIATIVE = 0;
06: public static final int RIGHT_ASSOCIATIVE = 1;
07: public static final int NON_ASSOCIATIVE = 2;
08: public static final int NO_PRECEDENCE = -1;
09:
10: private int precedence;
11: private int associativity;
12:
13: Terminal(String name, int index, String type, int precedence,
14: int associativity) {
15: super (name, index, type);
16: this .precedence = precedence;
17: this .associativity = associativity;
18: }
19:
20: Terminal(String name, int index, String type) {
21: this (name, index, type, NO_PRECEDENCE, NO_PRECEDENCE);
22: }
23:
24: Terminal(String 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: }
|