3 public class Operation {
4 public static final int LOGIC_OR=1;
5 public static final int LOGIC_AND=2;
6 public static final int BIT_OR=3;
7 public static final int BIT_XOR=4;
8 public static final int BIT_AND=5;
9 public static final int EQUAL=6;
10 public static final int NOTEQUAL=7;
11 public static final int LT=8;
12 public static final int GT=9;
13 public static final int LTE=10;
14 public static final int GTE=11;
15 public static final int LEFTSHIFT=12;
16 public static final int RIGHTSHIFT=13;
17 public static final int SUB=14;
18 public static final int ADD=15;
19 public static final int MULT=16;
20 public static final int DIV=17;
21 public static final int MOD=18;
22 public static final int UNARYPLUS=19;
23 public static final int UNARYMINUS=20;
24 public static final int POSTINC=21;
25 public static final int POSTDEC=22;
26 public static final int PREINC=23;
27 public static final int PREDEC=24;
28 public static final int LOGIC_NOT=25;
30 public static final int ASSIGN=100;
32 private int operation;
33 public Operation(int op) {
37 public Operation(String op) {
38 this.operation=parseOp(op);
45 public static int parseOp(String st) {
46 if (st.equals("logical_or"))
48 else if (st.equals("logical_and"))
50 else if (st.equals("bitwise_or"))
52 else if (st.equals("bitwise_xor"))
54 else if (st.equals("bitwise_and"))
56 else if (st.equals("equal"))
58 else if (st.equals("not_equal"))
60 else if (st.equals("comp_lt"))
62 else if (st.equals("comp_gt"))
64 else if (st.equals("comp_lte"))
66 else if (st.equals("comp_gte"))
68 else if (st.equals("leftshift"))
70 else if (st.equals("rightshift"))
72 else if (st.equals("sub"))
74 else if (st.equals("add"))
76 else if (st.equals("mult"))
78 else if (st.equals("div"))
80 else if (st.equals("mod"))
82 else if (st.equals("unaryplus"))
84 else if (st.equals("unaryminus"))
86 else if (st.equals("postinc"))
88 else if (st.equals("postdec"))
90 else if (st.equals("preinc"))
92 else if (st.equals("predec"))
94 else if (st.equals("not"))
100 public String toString() {
101 if (operation==LOGIC_OR)
103 else if (operation==LOGIC_AND)
105 else if (operation==LOGIC_NOT)
107 else if (operation==BIT_OR)
109 else if (operation==BIT_XOR)
111 else if (operation==BIT_AND)
113 else if (operation==EQUAL)
115 else if (operation==NOTEQUAL)
117 else if (operation==LT)
119 else if (operation==GT)
121 else if (operation==LTE)
123 else if (operation==GTE)
125 else if (operation==LEFTSHIFT)
127 else if (operation==RIGHTSHIFT)
129 else if (operation==SUB)
131 else if (operation==ADD)
133 else if (operation==MULT)
135 else if (operation==DIV)
137 else if (operation==MOD)
139 else if (operation==UNARYPLUS)
141 else if (operation==UNARYMINUS)
143 else if (operation==POSTINC)
145 else if (operation==POSTDEC)
147 else if (operation==PREINC)
149 else if (operation==PREDEC)
151 else if (operation==ASSIGN)
153 else throw new Error();