1 import ro.infoiasi.donald.compiler.parser.runtime.*; 2 3 4 public class CalcParser extends SkeletonLRParser { 5 public CalcParser() { 6 super(); 7 } 8 9 public CalcParser(parser.runtime.Lexer lex) { 10 super(lex); 11 } 12 13 public short[][] getProductionTable() { 14 return unpackFromStrings(new String [] { 15 "\000\016\000\002\002\004\000\002\002\003\000\002\007" + 16 "\002\000\002\003\005\000\002\004\005\000\002\004\005" + 17 "\000\002\004\003\000\002\005\005\000\002\005\005\000" + 18 "\002\005\003\000\002\006\005\000\002\006\003\000\002" + 19 "\006\003\000\002\010\004" }); 20 } 21 22 public short[][] getActionTable() { 23 return unpackFromStrings(new String [] { 24 "\000\027\000\012\002\002\002\002\002\002\011\002\012" + 25 "\013\000\012\015\002\002\002\002\002\011\002\012\013" + 26 "\000\012\000\002\002\002\002\002\000\002\000\000\000" + 27 "\012\002\uffff\002\002\002\002\002\002\002\002\000\012" + 28 "\002\ufffb\017\020\021\022\002\ufffb\002\002\000\012\002" + 29 "\ufff8\ufff8\ufff8\ufff8\ufff8\002\ufff8\002\002\000\012\002\002" + 30 "\002\002\002\002\011\002\012\013\000\012\002\ufff6\ufff6" + 31 "\ufff6\ufff6\ufff6\002\ufff6\002\002\000\012\002\ufff5\ufff5\ufff5" + 32 "\ufff5\ufff5\002\ufff5\002\002\000\012\001\002\002\002\002" + 33 "\002\001\002\001\001\000\012\ufff4\002\002\002\002\002" + 34 "\002\002\002\002\000\012\002\024\002\002\002\002\002" + 35 "\002\002\002\000\012\002\002\002\002\002\002\011\002" + 36 "\012\013\000\012\002\002\002\002\002\002\011\002\012" + 37 "\013\000\012\002\002\002\002\002\002\011\002\012\013" + 38 "\000\012\002\002\002\002\002\002\011\002\012\013\000" + 39 "\012\002\002\002\002\002\002\002\031\002\002\000\012" + 40 "\ufffe\002\002\002\002\002\ufffe\002\ufffe\ufffe\000\012\002" + 41 "\ufffd\002\002\002\002\002\ufffd\002\002\000\012\002\ufffc" + 42 "\002\002\002\002\002\ufffc\002\002\000\012\002\ufffa\ufffa" + 43 "\ufffa\ufffa\ufffa\002\ufffa\002\002\000\012\002\ufff9\ufff9\ufff9" + 44 "\ufff9\ufff9\002\ufff9\002\002\000\012\002\ufff7\ufff7\ufff7\ufff7" + 45 "\ufff7\002\ufff7\002\002" }); 46 } 47 48 public short[][] getGotoTable() { 49 return unpackFromStrings(new String [] { 50 "\000\027\000\007\003\004\005\006\007\001\001\000\007" + 51 "\001\013\005\006\007\001\001\000\007\001\001\001\001" + 52 "\001\001\001\000\007\001\001\001\001\001\015\001\000" + 53 "\007\001\001\001\001\001\001\001\000\007\001\001\001" + 54 "\001\001\001\001\000\007\001\001\022\006\007\001\001" + 55 "\000\007\001\001\001\001\001\001\001\000\007\001\001" + 56 "\001\001\001\001\001\000\007\001\001\001\001\001\001" + 57 "\001\000\007\001\001\001\001\001\001\001\000\007\001" + 58 "\001\001\001\001\001\001\000\007\001\001\024\006\007" + 59 "\001\001\000\007\001\001\025\006\007\001\001\000\007" + 60 "\001\001\001\001\026\001\001\000\007\001\001\001\001" + 61 "\027\001\001\000\007\001\001\001\001\001\001\001\000" + 62 "\007\001\001\001\001\001\001\001\000\007\001\001\001" + 63 "\001\001\001\001\000\007\001\001\001\001\001\001\001" + 64 "\000\007\001\001\001\001\001\001\001\000\007\001\001" + 65 "\001\001\001\001\001\000\007\001\001\001\001\001\001" + 66 "\001" }); 67 } 68 69 protected SJCC$CalcParser$Actions actionObject; 70 71 protected void initActions() { 72 actionObject = new SJCC$CalcParser$Actions(this); 73 } 74 75 public final parser.runtime.StackSymbol doAction ( 76 int action, parser.runtime.SkeletonLRParser parser, 77 java.util.Stack stack) throws java.lang.Exception { 78 return actionObject.SJCC$CalcParser$doAction(action, parser, stack); 79 } 80 81 public int getStartState() { 82 return 0; 83 } 84 85 public int getStartProduction() { 86 return 13; 87 } 88 89 public int getEOF() { 90 return 0; 91 } 92 public int getTokenOffset() { 93 return 7; 94 } 95 } 96 97 class SJCC$CalcParser$Actions { 98 private final CalcParser parser; 99 100 SJCC$CalcParser$Actions(CalcParser parser) { 101 this.parser = parser; 102 } 103 104 public final parser.runtime.StackSymbol SJCC$CalcParser$doAction( 105 int SJCC$CalcParser$action, 106 parser.runtime.SkeletonLRParser SJCC$CalcParser$parser, 107 java.util.Stack SJCC$CalcParser$stack) throws java.lang.Exception { 108 109 switch (SJCC$CalcParser$action) { 110 case 0: { 112 Object RESULT = null; 113 return new parser.runtime.StackSymbol(0 , RESULT); 114 } 115 case 1: { 117 Object RESULT = null; 118 return new parser.runtime.StackSymbol(0 , RESULT); 119 } 120 case 2: { 122 java.lang.Object RESULT = null; 123 Integer e = (Integer )((parser.runtime.StackSymbol)SJCC$CalcParser$stack.elementAt(SJCC$CalcParser$stack.size()-1)).value; 124 System.out.println(" = " + e); 125 return new parser.runtime.StackSymbol(5 , RESULT); 126 } 127 case 3: { 129 Object RESULT = null; 130 if (((parser.runtime.StackSymbol) SJCC$CalcParser$stack.elementAt(SJCC$CalcParser$stack.size()-1)).value != null) { 132 RESULT = ((parser.runtime.StackSymbol) SJCC$CalcParser$stack.elementAt(SJCC$CalcParser$stack.size()-1)).value; 133 } 134 return new parser.runtime.StackSymbol(1 , RESULT); 135 } 136 case 4: { 138 Integer RESULT = null; 139 Integer f = (Integer )((parser.runtime.StackSymbol)SJCC$CalcParser$stack.elementAt(SJCC$CalcParser$stack.size()-3)).value; 140 Integer e = (Integer )((parser.runtime.StackSymbol)SJCC$CalcParser$stack.elementAt(SJCC$CalcParser$stack.size()-1)).value; 141 RESULT = new Integer (f.intValue() + e.intValue()); 142 return new parser.runtime.StackSymbol(2 , RESULT); 143 } 144 case 5: { 146 Integer RESULT = null; 147 Integer f = (Integer )((parser.runtime.StackSymbol)SJCC$CalcParser$stack.elementAt(SJCC$CalcParser$stack.size()-3)).value; 148 Integer e = (Integer )((parser.runtime.StackSymbol)SJCC$CalcParser$stack.elementAt(SJCC$CalcParser$stack.size()-1)).value; 149 RESULT = new Integer (f.intValue() - e.intValue()); 150 return new parser.runtime.StackSymbol(2 , RESULT); 151 } 152 case 6: { 154 Integer RESULT = null; 155 Integer f = (Integer )((parser.runtime.StackSymbol)SJCC$CalcParser$stack.elementAt(SJCC$CalcParser$stack.size()-1)).value; 156 RESULT = new Integer (f.intValue()); 157 return new parser.runtime.StackSymbol(2 , RESULT); 158 } 159 case 7: { 161 Integer RESULT = null; 162 Integer f = (Integer )((parser.runtime.StackSymbol)SJCC$CalcParser$stack.elementAt(SJCC$CalcParser$stack.size()-3)).value; 163 Integer t = (Integer )((parser.runtime.StackSymbol)SJCC$CalcParser$stack.elementAt(SJCC$CalcParser$stack.size()-1)).value; 164 RESULT = new Integer (f.intValue() * t.intValue()); 165 return new parser.runtime.StackSymbol(3 , RESULT); 166 } 167 case 8: { 169 Integer RESULT = null; 170 Integer f = (Integer )((parser.runtime.StackSymbol)SJCC$CalcParser$stack.elementAt(SJCC$CalcParser$stack.size()-3)).value; 171 Integer t = (Integer )((parser.runtime.StackSymbol)SJCC$CalcParser$stack.elementAt(SJCC$CalcParser$stack.size()-1)).value; 172 RESULT = new Integer (f.intValue() / t.intValue()); 173 return new parser.runtime.StackSymbol(3 , RESULT); 174 } 175 case 9: { 177 Integer RESULT = null; 178 Integer t = (Integer )((parser.runtime.StackSymbol)SJCC$CalcParser$stack.elementAt(SJCC$CalcParser$stack.size()-1)).value; 179 RESULT = new Integer (t.intValue()); 180 return new parser.runtime.StackSymbol(3 , RESULT); 181 } 182 case 10: { 184 Integer RESULT = null; 185 Integer e = (Integer )((parser.runtime.StackSymbol)SJCC$CalcParser$stack.elementAt(SJCC$CalcParser$stack.size()-2)).value; 186 RESULT = e; 187 return new parser.runtime.StackSymbol(4 , RESULT); 188 } 189 case 11: { 191 Integer RESULT = null; 192 Integer n = (Integer )((parser.runtime.StackSymbol)SJCC$CalcParser$stack.elementAt(SJCC$CalcParser$stack.size()-1)).value; 193 RESULT = n; 194 return new parser.runtime.StackSymbol(4 , RESULT); 195 } 196 case 12: { 198 Integer RESULT = null; 199 Integer i = (Integer )((parser.runtime.StackSymbol)SJCC$CalcParser$stack.elementAt(SJCC$CalcParser$stack.size()-1)).value; 200 RESULT = i; 201 return new parser.runtime.StackSymbol(4 , RESULT); 202 } 203 case 13: { 205 java.lang.Object RESULT = null; 206 parser.doneParsing(); 207 return new parser.runtime.StackSymbol(6 , RESULT); 208 } 209 default: 210 throw new Exception ("Invalid action number"); 211 } 212 } 213 } 214 | Popular Tags |