1 8 9 package beaver.spec; 10 11 14 public class Terminal extends GrammarSymbol 15 { 16 static public final class Associativity 17 { 18 static public final Associativity LEFT = new Associativity("LEFT"); 19 static public final Associativity RIGHT = new Associativity("RIGHT"); 20 static public final Associativity NONE = new Associativity("NONE"); 21 22 private final String name; 23 24 private Associativity(String name) 25 { 26 this.name = name; 27 } 28 29 public String toString() 30 { 31 return name; 32 } 33 } 34 35 36 public int prec; 37 38 39 public Associativity assoc; 40 41 Terminal(String name) 42 { 43 super(name); 44 } 45 46 Terminal(String name, int prec, Associativity type) 47 { 48 super(name); 49 setPrecedence(prec, type); 50 } 51 52 public void setPrecedence(int value, Associativity type) 53 { 54 prec = value; 55 assoc = type; 56 } 57 } 58 | Popular Tags |