1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 /* This file was generated by SableCC (http://www.sablecc.org/). */
14 package org.simantics.spreadsheet.common.expression.parser;
16 import org.simantics.spreadsheet.common.expression.lexer.*;
17 import org.simantics.spreadsheet.common.expression.node.*;
18 import org.simantics.spreadsheet.common.expression.analysis.*;
21 import java.io.DataInputStream;
22 import java.io.BufferedInputStream;
23 import java.io.IOException;
25 @SuppressWarnings("nls")
28 public final Analysis ignoredTokens = new AnalysisAdapter();
30 protected ArrayList nodeList;
32 private final Lexer lexer;
33 private final ListIterator stack = new LinkedList().listIterator();
35 private int last_line;
36 private Token last_token;
37 private final TokenIndex converter = new TokenIndex();
38 private final int[] action = new int[2];
40 private final static int SHIFT = 0;
41 private final static int REDUCE = 1;
42 private final static int ACCEPT = 2;
43 private final static int ERROR = 3;
45 public Parser(@SuppressWarnings("hiding") Lexer lexer)
50 protected void filter() throws ParserException, LexerException, IOException
55 private void push(int numstate, ArrayList listNode, boolean hidden) throws ParserException, LexerException, IOException
57 this.nodeList = listNode;
64 if(!this.stack.hasNext())
66 this.stack.add(new State(numstate, this.nodeList));
70 State s = (State) this.stack.next();
72 s.nodes = this.nodeList;
75 private int goTo(int index)
79 int high = gotoTable[index].length - 1;
80 int value = gotoTable[index][0][1];
84 int middle = (low + high) / 2;
86 if(state < gotoTable[index][middle][0])
90 else if(state > gotoTable[index][middle][0])
96 value = gotoTable[index][middle][1];
106 State s = (State) this.stack.previous();
111 private ArrayList pop()
113 return ((State) this.stack.previous()).nodes;
116 private int index(Switchable token)
118 this.converter.index = -1;
119 token.apply(this.converter);
120 return this.converter.index;
123 @SuppressWarnings("unchecked")
124 public Start parse() throws ParserException, LexerException, IOException
127 List<Node> ign = null;
130 while(index(this.lexer.peek()) == -1)
134 ign = new LinkedList<Node>();
137 ign.add(this.lexer.next());
142 this.ignoredTokens.setIn(this.lexer.peek(), ign);
146 this.last_pos = this.lexer.peek().getPos();
147 this.last_line = this.lexer.peek().getLine();
148 this.last_token = this.lexer.peek();
150 int index = index(this.lexer.peek());
151 this.action[0] = Parser.actionTable[state()][0][1];
152 this.action[1] = Parser.actionTable[state()][0][2];
155 int high = Parser.actionTable[state()].length - 1;
159 int middle = (low + high) / 2;
161 if(index < Parser.actionTable[state()][middle][0])
165 else if(index > Parser.actionTable[state()][middle][0])
171 this.action[0] = Parser.actionTable[state()][middle][1];
172 this.action[1] = Parser.actionTable[state()][middle][2];
177 switch(this.action[0])
181 ArrayList list = new ArrayList();
182 list.add(this.lexer.next());
183 push(this.action[1], list, false);
187 switch(this.action[1])
189 case 0: /* reduce AMultExpression */
191 ArrayList list = new0();
192 push(goTo(0), list, false);
195 case 1: /* reduce APlusExpression */
197 ArrayList list = new1();
198 push(goTo(0), list, false);
201 case 2: /* reduce AMinusExpression */
203 ArrayList list = new2();
204 push(goTo(0), list, false);
207 case 3: /* reduce AUnaryMultiplicative */
209 ArrayList list = new3();
210 push(goTo(1), list, false);
213 case 4: /* reduce AMultMultiplicative */
215 ArrayList list = new4();
216 push(goTo(1), list, false);
219 case 5: /* reduce ADivMultiplicative */
221 ArrayList list = new5();
222 push(goTo(1), list, false);
225 case 6: /* reduce APrimaryUnary */
227 ArrayList list = new6();
228 push(goTo(2), list, false);
231 case 7: /* reduce AUnaryplusUnary */
233 ArrayList list = new7();
234 push(goTo(2), list, false);
237 case 8: /* reduce AUnaryminusUnary */
239 ArrayList list = new8();
240 push(goTo(2), list, false);
243 case 9: /* reduce ASingleArgList */
245 ArrayList list = new9();
246 push(goTo(3), list, false);
249 case 10: /* reduce ASequenceArgList */
251 ArrayList list = new10();
252 push(goTo(3), list, false);
255 case 11: /* reduce AValuePrimary */
257 ArrayList list = new11();
258 push(goTo(4), list, false);
261 case 12: /* reduce AAfunctionprimary1Primary */
263 ArrayList list = new12();
264 push(goTo(4), list, false);
267 case 13: /* reduce AAfunctionprimary2Primary */
269 ArrayList list = new13();
270 push(goTo(4), list, false);
273 case 14: /* reduce ASingleRange */
275 ArrayList list = new14();
276 push(goTo(5), list, false);
279 case 15: /* reduce AMultiRange */
281 ArrayList list = new15();
282 push(goTo(5), list, false);
285 case 16: /* reduce AStringValue */
287 ArrayList list = new16();
288 push(goTo(6), list, false);
291 case 17: /* reduce AConstantValue */
293 ArrayList list = new17();
294 push(goTo(6), list, false);
297 case 18: /* reduce ARangeValue */
299 ArrayList list = new18();
300 push(goTo(6), list, false);
303 case 19: /* reduce AAddressValue */
305 ArrayList list = new19();
306 push(goTo(6), list, false);
309 case 20: /* reduce AExprValue */
311 ArrayList list = new20();
312 push(goTo(6), list, false);
319 EOF node2 = (EOF) this.lexer.next();
320 PExpression node1 = (PExpression) pop().get(0);
321 Start node = new Start(node1, node2);
325 throw new ParserException(this.last_token,
326 "[" + this.last_line + "," + this.last_pos + "] " +
327 Parser.errorMessages[Parser.errors[this.action[1]]]);
334 @SuppressWarnings("unchecked")
335 ArrayList new0() /* reduce AMultExpression */
337 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
339 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
340 PExpression pexpressionNode1;
343 PMultiplicative pmultiplicativeNode2;
344 pmultiplicativeNode2 = (PMultiplicative)nodeArrayList1.get(0);
346 pexpressionNode1 = new AMultExpression(pmultiplicativeNode2);
348 nodeList.add(pexpressionNode1);
354 @SuppressWarnings("unchecked")
355 ArrayList new1() /* reduce APlusExpression */
357 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
359 @SuppressWarnings("unused") ArrayList nodeArrayList3 = pop();
360 @SuppressWarnings("unused") ArrayList nodeArrayList2 = pop();
361 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
362 PExpression pexpressionNode1;
365 PExpression pexpressionNode2;
367 PMultiplicative pmultiplicativeNode4;
368 pexpressionNode2 = (PExpression)nodeArrayList1.get(0);
369 tplusNode3 = (TPlus)nodeArrayList2.get(0);
370 pmultiplicativeNode4 = (PMultiplicative)nodeArrayList3.get(0);
372 pexpressionNode1 = new APlusExpression(pexpressionNode2, tplusNode3, pmultiplicativeNode4);
374 nodeList.add(pexpressionNode1);
380 @SuppressWarnings("unchecked")
381 ArrayList new2() /* reduce AMinusExpression */
383 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
385 @SuppressWarnings("unused") ArrayList nodeArrayList3 = pop();
386 @SuppressWarnings("unused") ArrayList nodeArrayList2 = pop();
387 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
388 PExpression pexpressionNode1;
391 PExpression pexpressionNode2;
393 PMultiplicative pmultiplicativeNode4;
394 pexpressionNode2 = (PExpression)nodeArrayList1.get(0);
395 tminusNode3 = (TMinus)nodeArrayList2.get(0);
396 pmultiplicativeNode4 = (PMultiplicative)nodeArrayList3.get(0);
398 pexpressionNode1 = new AMinusExpression(pexpressionNode2, tminusNode3, pmultiplicativeNode4);
400 nodeList.add(pexpressionNode1);
406 @SuppressWarnings("unchecked")
407 ArrayList new3() /* reduce AUnaryMultiplicative */
409 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
411 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
412 PMultiplicative pmultiplicativeNode1;
416 punaryNode2 = (PUnary)nodeArrayList1.get(0);
418 pmultiplicativeNode1 = new AUnaryMultiplicative(punaryNode2);
420 nodeList.add(pmultiplicativeNode1);
426 @SuppressWarnings("unchecked")
427 ArrayList new4() /* reduce AMultMultiplicative */
429 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
431 @SuppressWarnings("unused") ArrayList nodeArrayList3 = pop();
432 @SuppressWarnings("unused") ArrayList nodeArrayList2 = pop();
433 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
434 PMultiplicative pmultiplicativeNode1;
437 PMultiplicative pmultiplicativeNode2;
440 pmultiplicativeNode2 = (PMultiplicative)nodeArrayList1.get(0);
441 tmultNode3 = (TMult)nodeArrayList2.get(0);
442 punaryNode4 = (PUnary)nodeArrayList3.get(0);
444 pmultiplicativeNode1 = new AMultMultiplicative(pmultiplicativeNode2, tmultNode3, punaryNode4);
446 nodeList.add(pmultiplicativeNode1);
452 @SuppressWarnings("unchecked")
453 ArrayList new5() /* reduce ADivMultiplicative */
455 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
457 @SuppressWarnings("unused") ArrayList nodeArrayList3 = pop();
458 @SuppressWarnings("unused") ArrayList nodeArrayList2 = pop();
459 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
460 PMultiplicative pmultiplicativeNode1;
463 PMultiplicative pmultiplicativeNode2;
466 pmultiplicativeNode2 = (PMultiplicative)nodeArrayList1.get(0);
467 tdivNode3 = (TDiv)nodeArrayList2.get(0);
468 punaryNode4 = (PUnary)nodeArrayList3.get(0);
470 pmultiplicativeNode1 = new ADivMultiplicative(pmultiplicativeNode2, tdivNode3, punaryNode4);
472 nodeList.add(pmultiplicativeNode1);
478 @SuppressWarnings("unchecked")
479 ArrayList new6() /* reduce APrimaryUnary */
481 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
483 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
487 PPrimary pprimaryNode2;
488 pprimaryNode2 = (PPrimary)nodeArrayList1.get(0);
490 punaryNode1 = new APrimaryUnary(pprimaryNode2);
492 nodeList.add(punaryNode1);
498 @SuppressWarnings("unchecked")
499 ArrayList new7() /* reduce AUnaryplusUnary */
501 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
503 @SuppressWarnings("unused") ArrayList nodeArrayList2 = pop();
504 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
510 tplusNode2 = (TPlus)nodeArrayList1.get(0);
511 punaryNode3 = (PUnary)nodeArrayList2.get(0);
513 punaryNode1 = new AUnaryplusUnary(tplusNode2, punaryNode3);
515 nodeList.add(punaryNode1);
521 @SuppressWarnings("unchecked")
522 ArrayList new8() /* reduce AUnaryminusUnary */
524 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
526 @SuppressWarnings("unused") ArrayList nodeArrayList2 = pop();
527 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
533 tminusNode2 = (TMinus)nodeArrayList1.get(0);
534 punaryNode3 = (PUnary)nodeArrayList2.get(0);
536 punaryNode1 = new AUnaryminusUnary(tminusNode2, punaryNode3);
538 nodeList.add(punaryNode1);
544 @SuppressWarnings("unchecked")
545 ArrayList new9() /* reduce ASingleArgList */
547 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
549 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
550 PArgList parglistNode1;
553 PExpression pexpressionNode2;
554 pexpressionNode2 = (PExpression)nodeArrayList1.get(0);
556 parglistNode1 = new ASingleArgList(pexpressionNode2);
558 nodeList.add(parglistNode1);
564 @SuppressWarnings("unchecked")
565 ArrayList new10() /* reduce ASequenceArgList */
567 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
569 @SuppressWarnings("unused") ArrayList nodeArrayList3 = pop();
570 @SuppressWarnings("unused") ArrayList nodeArrayList2 = pop();
571 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
572 PArgList parglistNode1;
575 PArgList parglistNode2;
577 PExpression pexpressionNode4;
578 parglistNode2 = (PArgList)nodeArrayList1.get(0);
579 tcommaNode3 = (TComma)nodeArrayList2.get(0);
580 pexpressionNode4 = (PExpression)nodeArrayList3.get(0);
582 parglistNode1 = new ASequenceArgList(parglistNode2, tcommaNode3, pexpressionNode4);
584 nodeList.add(parglistNode1);
590 @SuppressWarnings("unchecked")
591 ArrayList new11() /* reduce AValuePrimary */
593 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
595 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
596 PPrimary pprimaryNode1;
600 pvalueNode2 = (PValue)nodeArrayList1.get(0);
602 pprimaryNode1 = new AValuePrimary(pvalueNode2);
604 nodeList.add(pprimaryNode1);
610 @SuppressWarnings("unchecked")
611 ArrayList new12() /* reduce AAfunctionprimary1Primary */
613 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
615 @SuppressWarnings("unused") ArrayList nodeArrayList2 = pop();
616 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
617 PPrimary pprimaryNode1;
621 @SuppressWarnings("unused") Object nullNode3 = null;
623 tfuncNode2 = (TFunc)nodeArrayList1.get(0);
624 trparNode4 = (TRPar)nodeArrayList2.get(0);
626 pprimaryNode1 = new AFunctionPrimary(tfuncNode2, null, trparNode4);
628 nodeList.add(pprimaryNode1);
634 @SuppressWarnings("unchecked")
635 ArrayList new13() /* reduce AAfunctionprimary2Primary */
637 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
639 @SuppressWarnings("unused") ArrayList nodeArrayList3 = pop();
640 @SuppressWarnings("unused") ArrayList nodeArrayList2 = pop();
641 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
642 PPrimary pprimaryNode1;
646 PArgList parglistNode3;
648 tfuncNode2 = (TFunc)nodeArrayList1.get(0);
649 parglistNode3 = (PArgList)nodeArrayList2.get(0);
650 trparNode4 = (TRPar)nodeArrayList3.get(0);
652 pprimaryNode1 = new AFunctionPrimary(tfuncNode2, parglistNode3, trparNode4);
654 nodeList.add(pprimaryNode1);
660 @SuppressWarnings("unchecked")
661 ArrayList new14() /* reduce ASingleRange */
663 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
665 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
670 tcellNode2 = (TCell)nodeArrayList1.get(0);
672 prangeNode1 = new ASingleRange(tcellNode2);
674 nodeList.add(prangeNode1);
680 @SuppressWarnings("unchecked")
681 ArrayList new15() /* reduce AMultiRange */
683 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
685 @SuppressWarnings("unused") ArrayList nodeArrayList3 = pop();
686 @SuppressWarnings("unused") ArrayList nodeArrayList2 = pop();
687 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
694 tcellNode2 = (TCell)nodeArrayList1.get(0);
695 tcolonNode3 = (TColon)nodeArrayList2.get(0);
696 tcellNode4 = (TCell)nodeArrayList3.get(0);
698 prangeNode1 = new AMultiRange(tcellNode2, tcolonNode3, tcellNode4);
700 nodeList.add(prangeNode1);
706 @SuppressWarnings("unchecked")
707 ArrayList new16() /* reduce AStringValue */
709 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
711 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
715 TString tstringNode2;
716 tstringNode2 = (TString)nodeArrayList1.get(0);
718 pvalueNode1 = new AStringValue(tstringNode2);
720 nodeList.add(pvalueNode1);
726 @SuppressWarnings("unchecked")
727 ArrayList new17() /* reduce AConstantValue */
729 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
731 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
735 TNumber tnumberNode2;
736 tnumberNode2 = (TNumber)nodeArrayList1.get(0);
738 pvalueNode1 = new AConstantValue(tnumberNode2);
740 nodeList.add(pvalueNode1);
746 @SuppressWarnings("unchecked")
747 ArrayList new18() /* reduce ARangeValue */
749 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
751 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
756 prangeNode2 = (PRange)nodeArrayList1.get(0);
758 pvalueNode1 = new ARangeValue(prangeNode2);
760 nodeList.add(pvalueNode1);
766 @SuppressWarnings("unchecked")
767 ArrayList new19() /* reduce AAddressValue */
769 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
771 @SuppressWarnings("unused") ArrayList nodeArrayList2 = pop();
772 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
776 TAmpersand tampersandNode2;
778 tampersandNode2 = (TAmpersand)nodeArrayList1.get(0);
779 prangeNode3 = (PRange)nodeArrayList2.get(0);
781 pvalueNode1 = new AAddressValue(tampersandNode2, prangeNode3);
783 nodeList.add(pvalueNode1);
789 @SuppressWarnings("unchecked")
790 ArrayList new20() /* reduce AExprValue */
792 @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList();
794 @SuppressWarnings("unused") ArrayList nodeArrayList3 = pop();
795 @SuppressWarnings("unused") ArrayList nodeArrayList2 = pop();
796 @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop();
801 PExpression pexpressionNode3;
803 tlparNode2 = (TLPar)nodeArrayList1.get(0);
804 pexpressionNode3 = (PExpression)nodeArrayList2.get(0);
805 trparNode4 = (TRPar)nodeArrayList3.get(0);
807 pvalueNode1 = new AExprValue(tlparNode2, pexpressionNode3, trparNode4);
809 nodeList.add(pvalueNode1);
815 private static int[][][] actionTable;
817 {{-1, ERROR, 0}, {3, SHIFT, 1}, {4, SHIFT, 2}, {7, SHIFT, 3}, {10, SHIFT, 4}, {12, SHIFT, 5}, {13, SHIFT, 6}, {14, SHIFT, 7}, {15, SHIFT, 8}, },
818 {{-1, ERROR, 1}, {3, SHIFT, 1}, {4, SHIFT, 2}, {7, SHIFT, 3}, {10, SHIFT, 4}, {12, SHIFT, 5}, {13, SHIFT, 6}, {14, SHIFT, 7}, {15, SHIFT, 8}, },
819 {{-1, ERROR, 2}, {3, SHIFT, 1}, {4, SHIFT, 2}, {7, SHIFT, 3}, {10, SHIFT, 4}, {12, SHIFT, 5}, {13, SHIFT, 6}, {14, SHIFT, 7}, {15, SHIFT, 8}, },
820 {{-1, ERROR, 3}, {13, SHIFT, 6}, },
821 {{-1, ERROR, 4}, {3, SHIFT, 1}, {4, SHIFT, 2}, {7, SHIFT, 3}, {10, SHIFT, 4}, {12, SHIFT, 5}, {13, SHIFT, 6}, {14, SHIFT, 7}, {15, SHIFT, 8}, },
822 {{-1, ERROR, 5}, {3, SHIFT, 1}, {4, SHIFT, 2}, {7, SHIFT, 3}, {10, SHIFT, 4}, {11, SHIFT, 19}, {12, SHIFT, 5}, {13, SHIFT, 6}, {14, SHIFT, 7}, {15, SHIFT, 8}, },
823 {{-1, REDUCE, 14}, {9, SHIFT, 22}, },
824 {{-1, REDUCE, 17}, },
825 {{-1, REDUCE, 16}, },
826 {{-1, ERROR, 9}, {3, SHIFT, 23}, {4, SHIFT, 24}, {17, ACCEPT, -1}, },
827 {{-1, REDUCE, 0}, {5, SHIFT, 25}, {6, SHIFT, 26}, },
830 {{-1, REDUCE, 18}, },
831 {{-1, REDUCE, 11}, },
834 {{-1, REDUCE, 19}, },
835 {{-1, ERROR, 18}, {3, SHIFT, 23}, {4, SHIFT, 24}, {11, SHIFT, 27}, },
836 {{-1, REDUCE, 12}, },
837 {{-1, REDUCE, 9}, {3, SHIFT, 23}, {4, SHIFT, 24}, },
838 {{-1, ERROR, 21}, {8, SHIFT, 28}, {11, SHIFT, 29}, },
839 {{-1, ERROR, 22}, {13, SHIFT, 30}, },
840 {{-1, ERROR, 23}, {3, SHIFT, 1}, {4, SHIFT, 2}, {7, SHIFT, 3}, {10, SHIFT, 4}, {12, SHIFT, 5}, {13, SHIFT, 6}, {14, SHIFT, 7}, {15, SHIFT, 8}, },
841 {{-1, ERROR, 24}, {3, SHIFT, 1}, {4, SHIFT, 2}, {7, SHIFT, 3}, {10, SHIFT, 4}, {12, SHIFT, 5}, {13, SHIFT, 6}, {14, SHIFT, 7}, {15, SHIFT, 8}, },
842 {{-1, ERROR, 25}, {3, SHIFT, 1}, {4, SHIFT, 2}, {7, SHIFT, 3}, {10, SHIFT, 4}, {12, SHIFT, 5}, {13, SHIFT, 6}, {14, SHIFT, 7}, {15, SHIFT, 8}, },
843 {{-1, ERROR, 26}, {3, SHIFT, 1}, {4, SHIFT, 2}, {7, SHIFT, 3}, {10, SHIFT, 4}, {12, SHIFT, 5}, {13, SHIFT, 6}, {14, SHIFT, 7}, {15, SHIFT, 8}, },
844 {{-1, REDUCE, 20}, },
845 {{-1, ERROR, 28}, {3, SHIFT, 1}, {4, SHIFT, 2}, {7, SHIFT, 3}, {10, SHIFT, 4}, {12, SHIFT, 5}, {13, SHIFT, 6}, {14, SHIFT, 7}, {15, SHIFT, 8}, },
846 {{-1, REDUCE, 13}, },
847 {{-1, REDUCE, 15}, },
848 {{-1, REDUCE, 1}, {5, SHIFT, 25}, {6, SHIFT, 26}, },
849 {{-1, REDUCE, 2}, {5, SHIFT, 25}, {6, SHIFT, 26}, },
852 {{-1, REDUCE, 10}, {3, SHIFT, 23}, {4, SHIFT, 24}, },
854 private static int[][][] gotoTable;
856 {{-1, 9}, {4, 18}, {5, 20}, {28, 35}, },
857 {{-1, 10}, {23, 31}, {24, 32}, },
858 {{-1, 11}, {1, 15}, {2, 16}, {25, 33}, {26, 34}, },
861 {{-1, 13}, {3, 17}, },
864 private static String[] errorMessages;
866 "expecting: '+', '-', '&', '(', func, cell, number, string",
868 "expecting: '+', '-', '&', '(', ')', func, cell, number, string",
869 "expecting: '+', '-', '*', '/', ',', ':', ')', EOF",
870 "expecting: '+', '-', '*', '/', ',', ')', EOF",
871 "expecting: '+', '-', EOF",
872 "expecting: '+', '-', ')'",
873 "expecting: '+', '-', ',', ')'",
874 "expecting: ',', ')'",
876 private static int[] errors;
878 0, 0, 0, 1, 0, 2, 3, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 6, 4, 7, 8, 1, 0, 0, 0, 0, 4, 0, 4, 4, 4, 4, 4, 4, 7,
885 DataInputStream s = new DataInputStream(
886 new BufferedInputStream(
887 Parser.class.getResourceAsStream("parser.dat")));
890 int length = s.readInt();
891 Parser.actionTable = new int[length][][];
892 for(int i = 0; i < Parser.actionTable.length; i++)
894 length = s.readInt();
895 Parser.actionTable[i] = new int[length][3];
896 for(int j = 0; j < Parser.actionTable[i].length; j++)
898 for(int k = 0; k < 3; k++)
900 Parser.actionTable[i][j][k] = s.readInt();
906 length = s.readInt();
907 gotoTable = new int[length][][];
908 for(int i = 0; i < gotoTable.length; i++)
910 length = s.readInt();
911 gotoTable[i] = new int[length][2];
912 for(int j = 0; j < gotoTable[i].length; j++)
914 for(int k = 0; k < 2; k++)
916 gotoTable[i][j][k] = s.readInt();
921 // read errorMessages
922 length = s.readInt();
923 errorMessages = new String[length];
924 for(int i = 0; i < errorMessages.length; i++)
926 length = s.readInt();
927 StringBuffer buffer = new StringBuffer();
929 for(int j = 0; j < length; j++)
931 buffer.append(s.readChar());
933 errorMessages[i] = buffer.toString();
937 length = s.readInt();
938 errors = new int[length];
939 for(int i = 0; i < errors.length; i++)
941 errors[i] = s.readInt();
948 throw new RuntimeException("The file \"parser.dat\" is either missing or corrupted.");