1 2 7 package java_cup.simple_calc; 8 9 import java_cup.runtime.*; 10 11 14 public class parser extends java_cup.runtime.lr_parser { 15 16 17 public parser() {super();} 18 19 20 public parser(java_cup.runtime.Scanner s) {super(s);} 21 22 23 protected static final short _production_table[][] = 24 unpackFromStrings(new String [] { 25 "\000\015\000\002\003\004\000\002\002\004\000\002\003" + 26 "\003\000\002\006\002\000\002\004\005\000\002\005\005" + 27 "\000\002\005\005\000\002\005\005\000\002\005\005\000" + 28 "\002\005\005\000\002\005\003\000\002\005\004\000\002" + 29 "\005\005" }); 30 31 32 public short[][] production_table() {return _production_table;} 33 34 35 protected static final short[][] _action_table = 36 unpackFromStrings(new String [] { 37 "\000\030\000\010\006\004\013\011\015\005\001\002\000" + 38 "\010\006\004\013\011\015\005\001\002\000\020\004\ufff7" + 39 "\005\ufff7\006\ufff7\007\ufff7\010\ufff7\011\ufff7\014\ufff7\001" + 40 "\002\000\012\002\uffff\006\uffff\013\uffff\015\uffff\001\002" + 41 "\000\016\004\ufffe\005\016\006\014\007\020\010\017\011" + 42 "\013\001\002\000\012\002\027\006\004\013\011\015\005" + 43 "\001\002\000\010\006\004\013\011\015\005\001\002\000" + 44 "\016\005\016\006\014\007\020\010\017\011\013\014\015" + 45 "\001\002\000\010\006\004\013\011\015\005\001\002\000" + 46 "\010\006\004\013\011\015\005\001\002\000\020\004\ufff5" + 47 "\005\ufff5\006\ufff5\007\ufff5\010\ufff5\011\ufff5\014\ufff5\001" + 48 "\002\000\010\006\004\013\011\015\005\001\002\000\010" + 49 "\006\004\013\011\015\005\001\002\000\010\006\004\013" + 50 "\011\015\005\001\002\000\020\004\ufffa\005\ufffa\006\ufffa" + 51 "\007\ufffa\010\ufffa\011\ufffa\014\ufffa\001\002\000\020\004" + 52 "\ufff9\005\ufff9\006\ufff9\007\ufff9\010\ufff9\011\ufff9\014\ufff9" + 53 "\001\002\000\020\004\ufffc\005\ufffc\006\ufffc\007\020\010" + 54 "\017\011\013\014\ufffc\001\002\000\020\004\ufffb\005\ufffb" + 55 "\006\ufffb\007\020\010\017\011\013\014\ufffb\001\002\000" + 56 "\020\004\ufff8\005\ufff8\006\ufff8\007\ufff8\010\ufff8\011\ufff8" + 57 "\014\ufff8\001\002\000\012\002\001\006\001\013\001\015" + 58 "\001\001\002\000\004\002\000\001\002\000\004\004\031" + 59 "\001\002\000\012\002\ufffd\006\ufffd\013\ufffd\015\ufffd\001" + 60 "\002\000\020\004\ufff6\005\ufff6\006\ufff6\007\ufff6\010\ufff6" + 61 "\011\ufff6\014\ufff6\001\002" }); 62 63 64 public short[][] action_table() {return _action_table;} 65 66 67 protected static final short[][] _reduce_table = 68 unpackFromStrings(new String [] { 69 "\000\030\000\010\003\007\004\005\005\006\001\001\000" + 70 "\004\005\031\001\001\000\002\001\001\000\002\001\001" + 71 "\000\004\006\027\001\001\000\006\004\025\005\006\001" + 72 "\001\000\004\005\011\001\001\000\002\001\001\000\004" + 73 "\005\024\001\001\000\004\005\023\001\001\000\002\001" + 74 "\001\000\004\005\022\001\001\000\004\005\021\001\001" + 75 "\000\004\005\020\001\001\000\002\001\001\000\002\001" + 76 "\001\000\002\001\001\000\002\001\001\000\002\001\001" + 77 "\000\002\001\001\000\002\001\001\000\002\001\001\000" + 78 "\002\001\001\000\002\001\001" }); 79 80 81 public short[][] reduce_table() {return _reduce_table;} 82 83 84 protected CUP$parser$actions action_obj; 85 86 87 protected void init_actions() 88 { 89 action_obj = new CUP$parser$actions(this); 90 } 91 92 93 public java_cup.runtime.Symbol do_action( 94 int act_num, 95 java_cup.runtime.lr_parser parser, 96 java.util.Stack stack, 97 int top) 98 throws java.lang.Exception 99 { 100 101 return action_obj.CUP$parser$do_action(act_num, parser, stack, top); 102 } 103 104 105 public int start_state() {return 0;} 106 107 public int start_production() {return 1;} 108 109 110 public int EOF_sym() {return 0;} 111 112 113 public int error_sym() {return 1;} 114 115 } 116 117 118 class CUP$parser$actions { 119 private final parser parser; 120 121 122 CUP$parser$actions(parser parser) { 123 this.parser = parser; 124 } 125 126 127 public final java_cup.runtime.Symbol CUP$parser$do_action( 128 int CUP$parser$act_num, 129 java_cup.runtime.lr_parser CUP$parser$parser, 130 java.util.Stack CUP$parser$stack, 131 int CUP$parser$top) 132 throws java.lang.Exception 133 { 134 135 java_cup.runtime.Symbol CUP$parser$result; 136 137 138 switch (CUP$parser$act_num) 139 { 140 141 case 12: { 143 Integer RESULT = null; 144 int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; 145 int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; 146 Integer e = (Integer )((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; 147 RESULT = e; 148 CUP$parser$result = new java_cup.runtime.Symbol(3, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); 149 } 150 return CUP$parser$result; 151 152 153 case 11: { 155 Integer RESULT = null; 156 int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left; 157 int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right; 158 Integer e = (Integer )((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; 159 RESULT = new Integer (0 - e.intValue()); 160 CUP$parser$result = new java_cup.runtime.Symbol(3, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); 161 } 162 return CUP$parser$result; 163 164 165 case 10: { 167 Integer RESULT = null; 168 int nleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left; 169 int nright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right; 170 Integer n = (Integer )((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; 171 RESULT = n; 172 CUP$parser$result = new java_cup.runtime.Symbol(3, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); 173 } 174 return CUP$parser$result; 175 176 177 case 9: { 179 Integer RESULT = null; 180 int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; 181 int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; 182 Integer e1 = (Integer )((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; 183 int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left; 184 int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right; 185 Integer e2 = (Integer )((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; 186 RESULT = new Integer (e1.intValue() % e2.intValue()); 187 CUP$parser$result = new java_cup.runtime.Symbol(3, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); 188 } 189 return CUP$parser$result; 190 191 192 case 8: { 194 Integer RESULT = null; 195 int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; 196 int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; 197 Integer e1 = (Integer )((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; 198 int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left; 199 int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right; 200 Integer e2 = (Integer )((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; 201 RESULT = new Integer (e1.intValue() / e2.intValue()); 202 CUP$parser$result = new java_cup.runtime.Symbol(3, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); 203 } 204 return CUP$parser$result; 205 206 207 case 7: { 209 Integer RESULT = null; 210 int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; 211 int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; 212 Integer e1 = (Integer )((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; 213 int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left; 214 int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right; 215 Integer e2 = (Integer )((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; 216 RESULT = new Integer (e1.intValue() * e2.intValue()); 217 CUP$parser$result = new java_cup.runtime.Symbol(3, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); 218 } 219 return CUP$parser$result; 220 221 222 case 6: { 224 Integer RESULT = null; 225 int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; 226 int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; 227 Integer e1 = (Integer )((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; 228 int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left; 229 int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right; 230 Integer e2 = (Integer )((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; 231 RESULT = new Integer (e1.intValue() - e2.intValue()); 232 CUP$parser$result = new java_cup.runtime.Symbol(3, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); 233 } 234 return CUP$parser$result; 235 236 237 case 5: { 239 Integer RESULT = null; 240 int e1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; 241 int e1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; 242 Integer e1 = (Integer )((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; 243 int e2left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left; 244 int e2right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right; 245 Integer e2 = (Integer )((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; 246 RESULT = new Integer (e1.intValue() + e2.intValue()); 247 CUP$parser$result = new java_cup.runtime.Symbol(3, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); 248 } 249 return CUP$parser$result; 250 251 252 case 4: { 254 Object RESULT = null; 255 if ( ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value != null ) 257 RESULT = (Object ) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; 258 int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; 259 int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; 260 Integer e = (Integer )((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; 261 262 CUP$parser$result = new java_cup.runtime.Symbol(2, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); 263 } 264 return CUP$parser$result; 265 266 267 case 3: { 269 Object RESULT = null; 270 int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left; 271 int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right; 272 Integer e = (Integer )((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; 273 System.out.println("= " + e); 274 CUP$parser$result = new java_cup.runtime.Symbol(4, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); 275 } 276 return CUP$parser$result; 277 278 279 case 2: { 281 Object RESULT = null; 282 283 CUP$parser$result = new java_cup.runtime.Symbol(1, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); 284 } 285 return CUP$parser$result; 286 287 288 case 1: { 290 Object RESULT = null; 291 int start_valleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; 292 int start_valright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; 293 Object start_val = (Object )((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; 294 RESULT = start_val; 295 CUP$parser$result = new java_cup.runtime.Symbol(0, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); 296 } 297 298 CUP$parser$parser.done_parsing(); 299 return CUP$parser$result; 300 301 302 case 0: { 304 Object RESULT = null; 305 306 CUP$parser$result = new java_cup.runtime.Symbol(1, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); 307 } 308 return CUP$parser$result; 309 310 311 default: 312 throw new Exception ( 313 "Invalid action number found in internal parse table"); 314 315 } 316 } 317 } 318 319
| Popular Tags
|