00001 package edu.ksu.cis.bandera.abstraction.specification.parser;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 import edu.ksu.cis.bandera.abstraction.specification.lexer.*;
00039 import edu.ksu.cis.bandera.abstraction.specification.node.*;
00040 import edu.ksu.cis.bandera.abstraction.specification.analysis.*;
00041 import java.util.*;
00042
00043 import java.io.DataInputStream;
00044 import java.io.BufferedInputStream;
00045 import java.io.IOException;
00046
00047 public class Parser
00048 {
00049 public final Analysis ignoredTokens = new AnalysisAdapter();
00050
00051 protected Node node;
00052
00053 private final Lexer lexer;
00054 private final ListIterator stack = new LinkedList().listIterator();
00055 private int last_shift;
00056 private int last_pos;
00057 private int last_line;
00058 private final TokenIndex converter = new TokenIndex();
00059 private final int[] action = new int[2];
00060
00061 private final static int SHIFT = 0;
00062 private final static int REDUCE = 1;
00063 private final static int ACCEPT = 2;
00064 private final static int ERROR = 3;
00065
00066 private static int[][][] actionTable;
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262 private static int[][][] gotoTable;
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301 private static String[] errorMessages;
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344 private static int[] errors;
00345
00346
00347
00348 public Parser(Lexer lexer)
00349 {
00350 this.lexer = lexer;
00351
00352 if(actionTable == null)
00353 {
00354 try
00355 {
00356 DataInputStream s = new DataInputStream(
00357 new BufferedInputStream(
00358 Parser.class.getResourceAsStream("parser.dat")));
00359
00360
00361 int length = s.readInt();
00362 actionTable = new int[length][][];
00363 for(int i = 0; i < actionTable.length; i++)
00364 {
00365 length = s.readInt();
00366 actionTable[i] = new int[length][3];
00367 for(int j = 0; j < actionTable[i].length; j++)
00368 {
00369 for(int k = 0; k < 3; k++)
00370 {
00371 actionTable[i][j][k] = s.readInt();
00372 }
00373 }
00374 }
00375
00376
00377 length = s.readInt();
00378 gotoTable = new int[length][][];
00379 for(int i = 0; i < gotoTable.length; i++)
00380 {
00381 length = s.readInt();
00382 gotoTable[i] = new int[length][2];
00383 for(int j = 0; j < gotoTable[i].length; j++)
00384 {
00385 for(int k = 0; k < 2; k++)
00386 {
00387 gotoTable[i][j][k] = s.readInt();
00388 }
00389 }
00390 }
00391
00392
00393 length = s.readInt();
00394 errorMessages = new String[length];
00395 for(int i = 0; i < errorMessages.length; i++)
00396 {
00397 length = s.readInt();
00398 StringBuffer buffer = new StringBuffer();
00399
00400 for(int j = 0; j < length; j++)
00401 {
00402 buffer.append(s.readChar());
00403 }
00404 errorMessages[i] = buffer.toString();
00405 }
00406
00407
00408 length = s.readInt();
00409 errors = new int[length];
00410 for(int i = 0; i < errors.length; i++)
00411 {
00412 errors[i] = s.readInt();
00413 }
00414
00415 s.close();
00416 }
00417 catch(Exception e)
00418 {
00419 throw new RuntimeException("Unable to read parser.dat.");
00420 }
00421 }
00422 }
00423 protected void filter() throws ParserException, LexerException, IOException
00424 {
00425 }
00426 private int goTo(int index)
00427 {
00428 int state = state();
00429 int low = 1;
00430 int high = gotoTable[index].length - 1;
00431 int value = gotoTable[index][0][1];
00432
00433 while(low <= high)
00434 {
00435 int middle = (low + high) / 2;
00436
00437 if(state < gotoTable[index][middle][0])
00438 {
00439 high = middle - 1;
00440 }
00441 else if(state > gotoTable[index][middle][0])
00442 {
00443 low = middle + 1;
00444 }
00445 else
00446 {
00447 value = gotoTable[index][middle][1];
00448 break;
00449 }
00450 }
00451
00452 return value;
00453 }
00454 private int index(Switchable token)
00455 {
00456 converter.index = -1;
00457 token.apply(converter);
00458 return converter.index;
00459 }
00460 Node new0()
00461 {
00462 TEnd node11 = (TEnd) pop();
00463 XPOperatorTest node10 = null;
00464 PAbstractFunction node9 = (PAbstractFunction) pop();
00465 POne2oneSet node8 = null;
00466 PDefaultToken node7 = null;
00467 PTokenSet node6 = (PTokenSet) pop();
00468 TBegin node5 = (TBegin) pop();
00469 PType node4 = (PType) pop();
00470 TExtends node3 = (TExtends) pop();
00471 TId node2 = (TId) pop();
00472 TAbstraction node1 = (TAbstraction) pop();
00473 AUnit node = new AUnit(node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11);
00474 return node;
00475 }
00476 Node new1()
00477 {
00478 TEnd node11 = (TEnd) pop();
00479 XPOperatorTest node10 = null;
00480 PAbstractFunction node9 = (PAbstractFunction) pop();
00481 POne2oneSet node8 = null;
00482 PDefaultToken node7 = (PDefaultToken) pop();
00483 PTokenSet node6 = (PTokenSet) pop();
00484 TBegin node5 = (TBegin) pop();
00485 PType node4 = (PType) pop();
00486 TExtends node3 = (TExtends) pop();
00487 TId node2 = (TId) pop();
00488 TAbstraction node1 = (TAbstraction) pop();
00489 AUnit node = new AUnit(node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11);
00490 return node;
00491 }
00492 Node new10()
00493 {
00494 TReal node1 = (TReal) pop();
00495 ARealType node = new ARealType(node1);
00496 return node;
00497 }
00498 Node new11()
00499 {
00500 TIntegral node1 = (TIntegral) pop();
00501 AIntegralType node = new AIntegralType(node1);
00502 return node;
00503 }
00504 Node new12()
00505 {
00506 TSemicolon node4 = (TSemicolon) pop();
00507 PIdSet node3 = (PIdSet) pop();
00508 TEq node2 = (TEq) pop();
00509 TTokens node1 = (TTokens) pop();
00510 ATokenSet node = new ATokenSet(node1, node2, node3, node4);
00511 return node;
00512 }
00513 Node new13()
00514 {
00515 TSemicolon node4 = (TSemicolon) pop();
00516 TId node3 = (TId) pop();
00517 TEq node2 = (TEq) pop();
00518 TDefault node1 = (TDefault) pop();
00519 ADefaultToken node = new ADefaultToken(node1, node2, node3, node4);
00520 return node;
00521 }
00522 Node new14()
00523 {
00524 TRBrace node3 = (TRBrace) pop();
00525 PIdList node2 = (PIdList) pop();
00526 TLBrace node1 = (TLBrace) pop();
00527 AIdSet node = new AIdSet(node1, node2, node3);
00528 return node;
00529 }
00530 Node new15()
00531 {
00532 TId node1 = (TId) pop();
00533 AIdIdList node = new AIdIdList(node1);
00534 return node;
00535 }
00536 Node new16()
00537 {
00538 TId node3 = (TId) pop();
00539 TComma node2 = (TComma) pop();
00540 PIdList node1 = (PIdList) pop();
00541 AIdsIdList node = new AIdsIdList(node1, node2, node3);
00542 return node;
00543 }
00544 Node new17()
00545 {
00546 TSemicolon node6 = (TSemicolon) pop();
00547 TRBrace node5 = (TRBrace) pop();
00548 PIdList node4 = null;
00549 TLBrace node3 = (TLBrace) pop();
00550 TEq node2 = (TEq) pop();
00551 TOne2one node1 = (TOne2one) pop();
00552 AOne2oneSet node = new AOne2oneSet(node1, node2, node3, node4, node5, node6);
00553 return node;
00554 }
00555 Node new18()
00556 {
00557 TSemicolon node6 = (TSemicolon) pop();
00558 TRBrace node5 = (TRBrace) pop();
00559 PIdList node4 = (PIdList) pop();
00560 TLBrace node3 = (TLBrace) pop();
00561 TEq node2 = (TEq) pop();
00562 TOne2one node1 = (TOne2one) pop();
00563 AOne2oneSet node = new AOne2oneSet(node1, node2, node3, node4, node5, node6);
00564 return node;
00565 }
00566 Node new19()
00567 {
00568 TEnd node7 = (TEnd) pop();
00569 XPAbstractDef node6 = null;
00570 TBegin node5 = (TBegin) pop();
00571 TRParen node4 = (TRParen) pop();
00572 TId node3 = (TId) pop();
00573 TLParen node2 = (TLParen) pop();
00574 TAbstract node1 = (TAbstract) pop();
00575 AAbstractFunction node = new AAbstractFunction(node1, node2, node3, node4, node5, node6, node7);
00576 return node;
00577 }
00578 Node new2()
00579 {
00580 TEnd node11 = (TEnd) pop();
00581 XPOperatorTest node10 = null;
00582 PAbstractFunction node9 = (PAbstractFunction) pop();
00583 POne2oneSet node8 = (POne2oneSet) pop();
00584 PDefaultToken node7 = null;
00585 PTokenSet node6 = (PTokenSet) pop();
00586 TBegin node5 = (TBegin) pop();
00587 PType node4 = (PType) pop();
00588 TExtends node3 = (TExtends) pop();
00589 TId node2 = (TId) pop();
00590 TAbstraction node1 = (TAbstraction) pop();
00591 AUnit node = new AUnit(node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11);
00592 return node;
00593 }
00594 Node new20()
00595 {
00596 TEnd node7 = (TEnd) pop();
00597 XPAbstractDef node6 = (XPAbstractDef) pop();
00598 TBegin node5 = (TBegin) pop();
00599 TRParen node4 = (TRParen) pop();
00600 TId node3 = (TId) pop();
00601 TLParen node2 = (TLParen) pop();
00602 TAbstract node1 = (TAbstract) pop();
00603 AAbstractFunction node = new AAbstractFunction(node1, node2, node3, node4, node5, node6, node7);
00604 return node;
00605 }
00606 Node new21()
00607 {
00608 PAbstractDef node2 = (PAbstractDef) pop();
00609 XPAbstractDef node1 = (XPAbstractDef) pop();
00610 X1PAbstractDef node = new X1PAbstractDef(node1, node2);
00611 return node;
00612 }
00613 Node new22()
00614 {
00615 PAbstractDef node1 = (PAbstractDef) pop();
00616 X2PAbstractDef node = new X2PAbstractDef(node1);
00617 return node;
00618 }
00619 Node new23()
00620 {
00621 TSemicolon node4 = (TSemicolon) pop();
00622 TId node3 = (TId) pop();
00623 TRightarrow node2 = (TRightarrow) pop();
00624 TAny node1 = (TAny) pop();
00625 AAnyAbstractDef node = new AAnyAbstractDef(node1, node2, node3, node4);
00626 return node;
00627 }
00628 Node new24()
00629 {
00630 TSemicolon node4 = (TSemicolon) pop();
00631 TId node3 = (TId) pop();
00632 TRightarrow node2 = (TRightarrow) pop();
00633 PExp node1 = (PExp) pop();
00634 AExpAbstractDef node = new AExpAbstractDef(node1, node2, node3, node4);
00635 return node;
00636 }
00637 Node new25()
00638 {
00639 POperator node1 = (POperator) pop();
00640 AOperatorOperatorTest node = new AOperatorOperatorTest(node1);
00641 return node;
00642 }
00643 Node new26()
00644 {
00645 PTest node1 = (PTest) pop();
00646 ATestOperatorTest node = new ATestOperatorTest(node1);
00647 return node;
00648 }
00649 Node new27()
00650 {
00651 TEnd node6 = (TEnd) pop();
00652 XPPattern node5 = null;
00653 TBegin node4 = (TBegin) pop();
00654 TId node3 = (TId) pop();
00655 POp node2 = (POp) pop();
00656 TOperator node1 = (TOperator) pop();
00657 AOperator node = new AOperator(node1, node2, node3, node4, node5, node6);
00658 return node;
00659 }
00660 Node new28()
00661 {
00662 TEnd node6 = (TEnd) pop();
00663 XPPattern node5 = (XPPattern) pop();
00664 TBegin node4 = (TBegin) pop();
00665 TId node3 = (TId) pop();
00666 POp node2 = (POp) pop();
00667 TOperator node1 = (TOperator) pop();
00668 AOperator node = new AOperator(node1, node2, node3, node4, node5, node6);
00669 return node;
00670 }
00671 Node new29()
00672 {
00673 PPattern node2 = (PPattern) pop();
00674 XPPattern node1 = (XPPattern) pop();
00675 X1PPattern node = new X1PPattern(node1, node2);
00676 return node;
00677 }
00678 Node new3()
00679 {
00680 TEnd node11 = (TEnd) pop();
00681 XPOperatorTest node10 = null;
00682 PAbstractFunction node9 = (PAbstractFunction) pop();
00683 POne2oneSet node8 = (POne2oneSet) pop();
00684 PDefaultToken node7 = (PDefaultToken) pop();
00685 PTokenSet node6 = (PTokenSet) pop();
00686 TBegin node5 = (TBegin) pop();
00687 PType node4 = (PType) pop();
00688 TExtends node3 = (TExtends) pop();
00689 TId node2 = (TId) pop();
00690 TAbstraction node1 = (TAbstraction) pop();
00691 AUnit node = new AUnit(node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11);
00692 return node;
00693 }
00694 Node new30()
00695 {
00696 PPattern node1 = (PPattern) pop();
00697 X2PPattern node = new X2PPattern(node1);
00698 return node;
00699 }
00700 Node new31()
00701 {
00702 TPlus node1 = (TPlus) pop();
00703 APlusOp node = new APlusOp(node1);
00704 return node;
00705 }
00706 Node new32()
00707 {
00708 TMinus node1 = (TMinus) pop();
00709 AMinusOp node = new AMinusOp(node1);
00710 return node;
00711 }
00712 Node new33()
00713 {
00714 TTimes node1 = (TTimes) pop();
00715 ATimesOp node = new ATimesOp(node1);
00716 return node;
00717 }
00718 Node new34()
00719 {
00720 TDiv node1 = (TDiv) pop();
00721 ADivOp node = new ADivOp(node1);
00722 return node;
00723 }
00724 Node new35()
00725 {
00726 TMod node1 = (TMod) pop();
00727 AModOp node = new AModOp(node1);
00728 return node;
00729 }
00730 Node new36()
00731 {
00732 TSemicolon node4 = (TSemicolon) pop();
00733 PTokenTokenSet node3 = (PTokenTokenSet) pop();
00734 TRightarrow node2 = (TRightarrow) pop();
00735 TAny node1 = (TAny) pop();
00736 AAnyPattern node = new AAnyPattern(node1, node2, node3, node4);
00737 return node;
00738 }
00739 Node new37()
00740 {
00741 TSemicolon node8 = (TSemicolon) pop();
00742 PTokenTokenSet node7 = (PTokenTokenSet) pop();
00743 TRightarrow node6 = (TRightarrow) pop();
00744 TRParen node5 = (TRParen) pop();
00745 PAnyId node4 = (PAnyId) pop();
00746 TComma node3 = (TComma) pop();
00747 PAnyId node2 = (PAnyId) pop();
00748 TLParen node1 = (TLParen) pop();
00749 APatternPattern node = new APatternPattern(node1, node2, node3, node4, node5, node6, node7, node8);
00750 return node;
00751 }
00752 Node new38()
00753 {
00754 TId node1 = (TId) pop();
00755 AIdAnyId node = new AIdAnyId(node1);
00756 return node;
00757 }
00758 Node new39()
00759 {
00760 TAny node1 = (TAny) pop();
00761 AAnyAnyId node = new AAnyAnyId(node1);
00762 return node;
00763 }
00764 Node new4()
00765 {
00766 TEnd node11 = (TEnd) pop();
00767 XPOperatorTest node10 = (XPOperatorTest) pop();
00768 PAbstractFunction node9 = (PAbstractFunction) pop();
00769 POne2oneSet node8 = null;
00770 PDefaultToken node7 = null;
00771 PTokenSet node6 = (PTokenSet) pop();
00772 TBegin node5 = (TBegin) pop();
00773 PType node4 = (PType) pop();
00774 TExtends node3 = (TExtends) pop();
00775 TId node2 = (TId) pop();
00776 TAbstraction node1 = (TAbstraction) pop();
00777 AUnit node = new AUnit(node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11);
00778 return node;
00779 }
00780 Node new40()
00781 {
00782 TId node1 = (TId) pop();
00783 ATokenTokenTokenSet node = new ATokenTokenTokenSet(node1);
00784 return node;
00785 }
00786 Node new41()
00787 {
00788 PIdSet node1 = (PIdSet) pop();
00789 ATokenSetTokenTokenSet node = new ATokenSetTokenTokenSet(node1);
00790 return node;
00791 }
00792 Node new42()
00793 {
00794 TEnd node6 = (TEnd) pop();
00795 XPPattern node5 = null;
00796 TBegin node4 = (TBegin) pop();
00797 TId node3 = (TId) pop();
00798 PTOp node2 = (PTOp) pop();
00799 TTest node1 = (TTest) pop();
00800 ATest node = new ATest(node1, node2, node3, node4, node5, node6);
00801 return node;
00802 }
00803 Node new43()
00804 {
00805 TEnd node6 = (TEnd) pop();
00806 XPPattern node5 = (XPPattern) pop();
00807 TBegin node4 = (TBegin) pop();
00808 TId node3 = (TId) pop();
00809 PTOp node2 = (PTOp) pop();
00810 TTest node1 = (TTest) pop();
00811 ATest node = new ATest(node1, node2, node3, node4, node5, node6);
00812 return node;
00813 }
00814 Node new44()
00815 {
00816 TEqual node1 = (TEqual) pop();
00817 AEqualTOp node = new AEqualTOp(node1);
00818 return node;
00819 }
00820 Node new45()
00821 {
00822 TNotEqual node1 = (TNotEqual) pop();
00823 ANotEqualTOp node = new ANotEqualTOp(node1);
00824 return node;
00825 }
00826 Node new46()
00827 {
00828 TGreaterEqual node1 = (TGreaterEqual) pop();
00829 AGreaterEqualTOp node = new AGreaterEqualTOp(node1);
00830 return node;
00831 }
00832 Node new47()
00833 {
00834 TLessEqual node1 = (TLessEqual) pop();
00835 ALessEqualTOp node = new ALessEqualTOp(node1);
00836 return node;
00837 }
00838 Node new48()
00839 {
00840 TGreater node1 = (TGreater) pop();
00841 AGreaterTOp node = new AGreaterTOp(node1);
00842 return node;
00843 }
00844 Node new49()
00845 {
00846 TLess node1 = (TLess) pop();
00847 ALessTOp node = new ALessTOp(node1);
00848 return node;
00849 }
00850 Node new5()
00851 {
00852 POperatorTest node2 = (POperatorTest) pop();
00853 XPOperatorTest node1 = (XPOperatorTest) pop();
00854 X1POperatorTest node = new X1POperatorTest(node1, node2);
00855 return node;
00856 }
00857 Node new50()
00858 {
00859 PLiteral node1 = (PLiteral) pop();
00860 ALiteralPrimaryExp node = new ALiteralPrimaryExp(node1);
00861 return node;
00862 }
00863 Node new51()
00864 {
00865 TRParen node3 = (TRParen) pop();
00866 PExp node2 = (PExp) pop();
00867 TLParen node1 = (TLParen) pop();
00868 AParenPrimaryExp node = new AParenPrimaryExp(node1, node2, node3);
00869 return node;
00870 }
00871 Node new52()
00872 {
00873 TId node1 = (TId) pop();
00874 AIdPrimaryExp node = new AIdPrimaryExp(node1);
00875 return node;
00876 }
00877 Node new53()
00878 {
00879 PPrimaryExp node1 = (PPrimaryExp) pop();
00880 APrimaryUnaryNotPlusMinusExp node = new APrimaryUnaryNotPlusMinusExp(node1);
00881 return node;
00882 }
00883 Node new54()
00884 {
00885 PUnaryExp node2 = (PUnaryExp) pop();
00886 TNot node1 = (TNot) pop();
00887 AComplementUnaryNotPlusMinusExp node = new AComplementUnaryNotPlusMinusExp(node1, node2);
00888 return node;
00889 }
00890 Node new55()
00891 {
00892 PUnaryExp node2 = (PUnaryExp) pop();
00893 TBitComplement node1 = (TBitComplement) pop();
00894 ABitComplementUnaryNotPlusMinusExp node = new ABitComplementUnaryNotPlusMinusExp(node1, node2);
00895 return node;
00896 }
00897 Node new56()
00898 {
00899 PUnaryExp node2 = (PUnaryExp) pop();
00900 TPlus node1 = (TPlus) pop();
00901 APlusUnaryExp node = new APlusUnaryExp(node1, node2);
00902 return node;
00903 }
00904 Node new57()
00905 {
00906 PUnaryExp node2 = (PUnaryExp) pop();
00907 TMinus node1 = (TMinus) pop();
00908 AMinusUnaryExp node = new AMinusUnaryExp(node1, node2);
00909 return node;
00910 }
00911 Node new58()
00912 {
00913 PUnaryNotPlusMinusExp node1 = (PUnaryNotPlusMinusExp) pop();
00914 AUnaryNotPlusMinusUnaryExp node = new AUnaryNotPlusMinusUnaryExp(node1);
00915 return node;
00916 }
00917 Node new59()
00918 {
00919 PUnaryExp node1 = (PUnaryExp) pop();
00920 AUnaryExpMultExp node = new AUnaryExpMultExp(node1);
00921 return node;
00922 }
00923 Node new6()
00924 {
00925 POperatorTest node1 = (POperatorTest) pop();
00926 X2POperatorTest node = new X2POperatorTest(node1);
00927 return node;
00928 }
00929 Node new60()
00930 {
00931 PUnaryExp node3 = (PUnaryExp) pop();
00932 TTimes node2 = (TTimes) pop();
00933 PMultExp node1 = (PMultExp) pop();
00934 ATimesMultExp node = new ATimesMultExp(node1, node2, node3);
00935 return node;
00936 }
00937 Node new61()
00938 {
00939 PUnaryExp node3 = (PUnaryExp) pop();
00940 TDiv node2 = (TDiv) pop();
00941 PMultExp node1 = (PMultExp) pop();
00942 ADivMultExp node = new ADivMultExp(node1, node2, node3);
00943 return node;
00944 }
00945 Node new62()
00946 {
00947 PUnaryExp node3 = (PUnaryExp) pop();
00948 TMod node2 = (TMod) pop();
00949 PMultExp node1 = (PMultExp) pop();
00950 AModMultExp node = new AModMultExp(node1, node2, node3);
00951 return node;
00952 }
00953 Node new63()
00954 {
00955 PMultExp node1 = (PMultExp) pop();
00956 AMultAddExp node = new AMultAddExp(node1);
00957 return node;
00958 }
00959 Node new64()
00960 {
00961 PMultExp node3 = (PMultExp) pop();
00962 TPlus node2 = (TPlus) pop();
00963 PAddExp node1 = (PAddExp) pop();
00964 APlusAddExp node = new APlusAddExp(node1, node2, node3);
00965 return node;
00966 }
00967 Node new65()
00968 {
00969 PMultExp node3 = (PMultExp) pop();
00970 TMinus node2 = (TMinus) pop();
00971 PAddExp node1 = (PAddExp) pop();
00972 AMinusAddExp node = new AMinusAddExp(node1, node2, node3);
00973 return node;
00974 }
00975 Node new66()
00976 {
00977 PAddExp node1 = (PAddExp) pop();
00978 AAddExpShiftExp node = new AAddExpShiftExp(node1);
00979 return node;
00980 }
00981 Node new67()
00982 {
00983 PAddExp node3 = (PAddExp) pop();
00984 TShiftLeft node2 = (TShiftLeft) pop();
00985 PShiftExp node1 = (PShiftExp) pop();
00986 ALeftShiftExp node = new ALeftShiftExp(node1, node2, node3);
00987 return node;
00988 }
00989 Node new68()
00990 {
00991 PAddExp node3 = (PAddExp) pop();
00992 TSignedShiftRight node2 = (TSignedShiftRight) pop();
00993 PShiftExp node1 = (PShiftExp) pop();
00994 ASignedRightShiftExp node = new ASignedRightShiftExp(node1, node2, node3);
00995 return node;
00996 }
00997 Node new69()
00998 {
00999 PAddExp node3 = (PAddExp) pop();
01000 TUnsignedShiftRight node2 = (TUnsignedShiftRight) pop();
01001 PShiftExp node1 = (PShiftExp) pop();
01002 AUnsignedRightShiftExp node = new AUnsignedRightShiftExp(node1, node2, node3);
01003 return node;
01004 }
01005 Node new7()
01006 {
01007 TEnd node11 = (TEnd) pop();
01008 XPOperatorTest node10 = (XPOperatorTest) pop();
01009 PAbstractFunction node9 = (PAbstractFunction) pop();
01010 POne2oneSet node8 = null;
01011 PDefaultToken node7 = (PDefaultToken) pop();
01012 PTokenSet node6 = (PTokenSet) pop();
01013 TBegin node5 = (TBegin) pop();
01014 PType node4 = (PType) pop();
01015 TExtends node3 = (TExtends) pop();
01016 TId node2 = (TId) pop();
01017 TAbstraction node1 = (TAbstraction) pop();
01018 AUnit node = new AUnit(node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11);
01019 return node;
01020 }
01021 Node new70()
01022 {
01023 PShiftExp node1 = (PShiftExp) pop();
01024 AShiftRelExp node = new AShiftRelExp(node1);
01025 return node;
01026 }
01027 Node new71()
01028 {
01029 PShiftExp node3 = (PShiftExp) pop();
01030 TLess node2 = (TLess) pop();
01031 PRelExp node1 = (PRelExp) pop();
01032 ALessRelExp node = new ALessRelExp(node1, node2, node3);
01033 return node;
01034 }
01035 Node new72()
01036 {
01037 PShiftExp node3 = (PShiftExp) pop();
01038 TGreater node2 = (TGreater) pop();
01039 PRelExp node1 = (PRelExp) pop();
01040 AGreaterRelExp node = new AGreaterRelExp(node1, node2, node3);
01041 return node;
01042 }
01043 Node new73()
01044 {
01045 PShiftExp node3 = (PShiftExp) pop();
01046 TLessEqual node2 = (TLessEqual) pop();
01047 PRelExp node1 = (PRelExp) pop();
01048 ALessEqualRelExp node = new ALessEqualRelExp(node1, node2, node3);
01049 return node;
01050 }
01051 Node new74()
01052 {
01053 PShiftExp node3 = (PShiftExp) pop();
01054 TGreaterEqual node2 = (TGreaterEqual) pop();
01055 PRelExp node1 = (PRelExp) pop();
01056 AGreaterEqualRelExp node = new AGreaterEqualRelExp(node1, node2, node3);
01057 return node;
01058 }
01059 Node new75()
01060 {
01061 PRelExp node1 = (PRelExp) pop();
01062 ARelEqExp node = new ARelEqExp(node1);
01063 return node;
01064 }
01065 Node new76()
01066 {
01067 PRelExp node3 = (PRelExp) pop();
01068 TEqual node2 = (TEqual) pop();
01069 PEqExp node1 = (PEqExp) pop();
01070 AEqEqExp node = new AEqEqExp(node1, node2, node3);
01071 return node;
01072 }
01073 Node new77()
01074 {
01075 PRelExp node3 = (PRelExp) pop();
01076 TNotEqual node2 = (TNotEqual) pop();
01077 PEqExp node1 = (PEqExp) pop();
01078 ANeqEqExp node = new ANeqEqExp(node1, node2, node3);
01079 return node;
01080 }
01081 Node new78()
01082 {
01083 PEqExp node1 = (PEqExp) pop();
01084 AEqBitAndExp node = new AEqBitAndExp(node1);
01085 return node;
01086 }
01087 Node new79()
01088 {
01089 PEqExp node3 = (PEqExp) pop();
01090 TBitAnd node2 = (TBitAnd) pop();
01091 PBitAndExp node1 = (PBitAndExp) pop();
01092 AAndBitAndExp node = new AAndBitAndExp(node1, node2, node3);
01093 return node;
01094 }
01095 Node new8()
01096 {
01097 TEnd node11 = (TEnd) pop();
01098 XPOperatorTest node10 = (XPOperatorTest) pop();
01099 PAbstractFunction node9 = (PAbstractFunction) pop();
01100 POne2oneSet node8 = (POne2oneSet) pop();
01101 PDefaultToken node7 = null;
01102 PTokenSet node6 = (PTokenSet) pop();
01103 TBegin node5 = (TBegin) pop();
01104 PType node4 = (PType) pop();
01105 TExtends node3 = (TExtends) pop();
01106 TId node2 = (TId) pop();
01107 TAbstraction node1 = (TAbstraction) pop();
01108 AUnit node = new AUnit(node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11);
01109 return node;
01110 }
01111 Node new80()
01112 {
01113 PBitAndExp node1 = (PBitAndExp) pop();
01114 AAndExclusiveOrExp node = new AAndExclusiveOrExp(node1);
01115 return node;
01116 }
01117 Node new81()
01118 {
01119 PBitAndExp node3 = (PBitAndExp) pop();
01120 TBitXor node2 = (TBitXor) pop();
01121 PExclusiveOrExp node1 = (PExclusiveOrExp) pop();
01122 AXorExclusiveOrExp node = new AXorExclusiveOrExp(node1, node2, node3);
01123 return node;
01124 }
01125 Node new82()
01126 {
01127 PExclusiveOrExp node1 = (PExclusiveOrExp) pop();
01128 AXorInclusiveOrExp node = new AXorInclusiveOrExp(node1);
01129 return node;
01130 }
01131 Node new83()
01132 {
01133 PExclusiveOrExp node3 = (PExclusiveOrExp) pop();
01134 TBitOr node2 = (TBitOr) pop();
01135 PInclusiveOrExp node1 = (PInclusiveOrExp) pop();
01136 AOrInclusiveOrExp node = new AOrInclusiveOrExp(node1, node2, node3);
01137 return node;
01138 }
01139 Node new84()
01140 {
01141 PInclusiveOrExp node1 = (PInclusiveOrExp) pop();
01142 AInclusiveOrAndExp node = new AInclusiveOrAndExp(node1);
01143 return node;
01144 }
01145 Node new85()
01146 {
01147 PInclusiveOrExp node3 = (PInclusiveOrExp) pop();
01148 TAnd node2 = (TAnd) pop();
01149 PAndExp node1 = (PAndExp) pop();
01150 AAndAndExp node = new AAndAndExp(node1, node2, node3);
01151 return node;
01152 }
01153 Node new86()
01154 {
01155 PAndExp node1 = (PAndExp) pop();
01156 AAndOrExp node = new AAndOrExp(node1);
01157 return node;
01158 }
01159 Node new87()
01160 {
01161 PAndExp node3 = (PAndExp) pop();
01162 TOr node2 = (TOr) pop();
01163 POrExp node1 = (POrExp) pop();
01164 AOrOrExp node = new AOrOrExp(node1, node2, node3);
01165 return node;
01166 }
01167 Node new88()
01168 {
01169 POrExp node1 = (POrExp) pop();
01170 AOrConditionalExp node = new AOrConditionalExp(node1);
01171 return node;
01172 }
01173 Node new89()
01174 {
01175 PConditionalExp node5 = (PConditionalExp) pop();
01176 TColon node4 = (TColon) pop();
01177 PExp node3 = (PExp) pop();
01178 TQuestion node2 = (TQuestion) pop();
01179 POrExp node1 = (POrExp) pop();
01180 AQuestionConditionalExp node = new AQuestionConditionalExp(node1, node2, node3, node4, node5);
01181 return node;
01182 }
01183 Node new9()
01184 {
01185 TEnd node11 = (TEnd) pop();
01186 XPOperatorTest node10 = (XPOperatorTest) pop();
01187 PAbstractFunction node9 = (PAbstractFunction) pop();
01188 POne2oneSet node8 = (POne2oneSet) pop();
01189 PDefaultToken node7 = (PDefaultToken) pop();
01190 PTokenSet node6 = (PTokenSet) pop();
01191 TBegin node5 = (TBegin) pop();
01192 PType node4 = (PType) pop();
01193 TExtends node3 = (TExtends) pop();
01194 TId node2 = (TId) pop();
01195 TAbstraction node1 = (TAbstraction) pop();
01196 AUnit node = new AUnit(node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11);
01197 return node;
01198 }
01199 Node new90()
01200 {
01201 PConditionalExp node1 = (PConditionalExp) pop();
01202 AExp node = new AExp(node1);
01203 return node;
01204 }
01205 Node new91()
01206 {
01207 TDecIntLiteral node1 = (TDecIntLiteral) pop();
01208 ADecIntLiteral node = new ADecIntLiteral(node1);
01209 return node;
01210 }
01211 Node new92()
01212 {
01213 THexIntLiteral node1 = (THexIntLiteral) pop();
01214 AHexIntLiteral node = new AHexIntLiteral(node1);
01215 return node;
01216 }
01217 Node new93()
01218 {
01219 TOctIntLiteral node1 = (TOctIntLiteral) pop();
01220 AOctIntLiteral node = new AOctIntLiteral(node1);
01221 return node;
01222 }
01223 Node new94()
01224 {
01225 TDecLongLiteral node1 = (TDecLongLiteral) pop();
01226 ADecLongLiteral node = new ADecLongLiteral(node1);
01227 return node;
01228 }
01229 Node new95()
01230 {
01231 THexLongLiteral node1 = (THexLongLiteral) pop();
01232 AHexLongLiteral node = new AHexLongLiteral(node1);
01233 return node;
01234 }
01235 Node new96()
01236 {
01237 TOctLongLiteral node1 = (TOctLongLiteral) pop();
01238 AOctLongLiteral node = new AOctLongLiteral(node1);
01239 return node;
01240 }
01241 Node new97()
01242 {
01243 TFloatLiteral node1 = (TFloatLiteral) pop();
01244 AFloatLiteral node = new AFloatLiteral(node1);
01245 return node;
01246 }
01247 Node new98()
01248 {
01249 TDoubleLiteral node1 = (TDoubleLiteral) pop();
01250 ADoubleLiteral node = new ADoubleLiteral(node1);
01251 return node;
01252 }
01253 public Start parse() throws ParserException, LexerException, IOException
01254 {
01255 push(0, null, false);
01256
01257 List ign = null;
01258 while(true)
01259 {
01260 while(index(lexer.peek()) == -1)
01261 {
01262 if(ign == null)
01263 {
01264 ign = new TypedLinkedList(NodeCast.instance);
01265 }
01266
01267 ign.add(lexer.next());
01268 }
01269
01270 if(ign != null)
01271 {
01272 ignoredTokens.setIn(lexer.peek(), ign);
01273 ign = null;
01274 }
01275
01276 last_pos = lexer.peek().getPos();
01277 last_line = lexer.peek().getLine();
01278
01279 int index = index(lexer.peek());
01280 action[0] = actionTable[state()][0][1];
01281 action[1] = actionTable[state()][0][2];
01282
01283 int low = 1;
01284 int high = actionTable[state()].length - 1;
01285
01286 while(low <= high)
01287 {
01288 int middle = (low + high) / 2;
01289
01290 if(index < actionTable[state()][middle][0])
01291 {
01292 high = middle - 1;
01293 }
01294 else if(index > actionTable[state()][middle][0])
01295 {
01296 low = middle + 1;
01297 }
01298 else
01299 {
01300 action[0] = actionTable[state()][middle][1];
01301 action[1] = actionTable[state()][middle][2];
01302 break;
01303 }
01304 }
01305
01306 switch(action[0])
01307 {
01308 case SHIFT:
01309 push(action[1], lexer.next(), true);
01310 last_shift = action[1];
01311 break;
01312 case REDUCE:
01313 switch(action[1])
01314 {
01315 case 0: { Node node = new0(); push(goTo(0), node, true); } break;
01316 case 1: { Node node = new1(); push(goTo(0), node, true); } break;
01317 case 2: { Node node = new2(); push(goTo(0), node, true); } break;
01318 case 3: { Node node = new3(); push(goTo(0), node, true); } break;
01319 case 4: { Node node = new4(); push(goTo(0), node, true); } break;
01320 case 5: { Node node = new5(); push(goTo(33), node, false); } break;
01321 case 6: { Node node = new6(); push(goTo(33), node, false); } break;
01322 case 7: { Node node = new7(); push(goTo(0), node, true); } break;
01323 case 8: { Node node = new8(); push(goTo(0), node, true); } break;
01324 case 9: { Node node = new9(); push(goTo(0), node, true); } break;
01325 case 10: { Node node = new10(); push(goTo(1), node, true); } break;
01326 case 11: { Node node = new11(); push(goTo(1), node, true); } break;
01327 case 12: { Node node = new12(); push(goTo(2), node, true); } break;
01328 case 13: { Node node = new13(); push(goTo(3), node, true); } break;
01329 case 14: { Node node = new14(); push(goTo(4), node, true); } break;
01330 case 15: { Node node = new15(); push(goTo(5), node, true); } break;
01331 case 16: { Node node = new16(); push(goTo(5), node, true); } break;
01332 case 17: { Node node = new17(); push(goTo(6), node, true); } break;
01333 case 18: { Node node = new18(); push(goTo(6), node, true); } break;
01334 case 19: { Node node = new19(); push(goTo(7), node, true); } break;
01335 case 20: { Node node = new20(); push(goTo(7), node, true); } break;
01336 case 21: { Node node = new21(); push(goTo(34), node, false); } break;
01337 case 22: { Node node = new22(); push(goTo(34), node, false); } break;
01338 case 23: { Node node = new23(); push(goTo(8), node, true); } break;
01339 case 24: { Node node = new24(); push(goTo(8), node, true); } break;
01340 case 25: { Node node = new25(); push(goTo(9), node, true); } break;
01341 case 26: { Node node = new26(); push(goTo(9), node, true); } break;
01342 case 27: { Node node = new27(); push(goTo(10), node, true); } break;
01343 case 28: { Node node = new28(); push(goTo(10), node, true); } break;
01344 case 29: { Node node = new29(); push(goTo(35), node, false); } break;
01345 case 30: { Node node = new30(); push(goTo(35), node, false); } break;
01346 case 31: { Node node = new31(); push(goTo(11), node, true); } break;
01347 case 32: { Node node = new32(); push(goTo(11), node, true); } break;
01348 case 33: { Node node = new33(); push(goTo(11), node, true); } break;
01349 case 34: { Node node = new34(); push(goTo(11), node, true); } break;
01350 case 35: { Node node = new35(); push(goTo(11), node, true); } break;
01351 case 36: { Node node = new36(); push(goTo(12), node, true); } break;
01352 case 37: { Node node = new37(); push(goTo(12), node, true); } break;
01353 case 38: { Node node = new38(); push(goTo(13), node, true); } break;
01354 case 39: { Node node = new39(); push(goTo(13), node, true); } break;
01355 case 40: { Node node = new40(); push(goTo(14), node, true); } break;
01356 case 41: { Node node = new41(); push(goTo(14), node, true); } break;
01357 case 42: { Node node = new42(); push(goTo(15), node, true); } break;
01358 case 43: { Node node = new43(); push(goTo(15), node, true); } break;
01359 case 44: { Node node = new44(); push(goTo(16), node, true); } break;
01360 case 45: { Node node = new45(); push(goTo(16), node, true); } break;
01361 case 46: { Node node = new46(); push(goTo(16), node, true); } break;
01362 case 47: { Node node = new47(); push(goTo(16), node, true); } break;
01363 case 48: { Node node = new48(); push(goTo(16), node, true); } break;
01364 case 49: { Node node = new49(); push(goTo(16), node, true); } break;
01365 case 50: { Node node = new50(); push(goTo(17), node, true); } break;
01366 case 51: { Node node = new51(); push(goTo(17), node, true); } break;
01367 case 52: { Node node = new52(); push(goTo(17), node, true); } break;
01368 case 53: { Node node = new53(); push(goTo(18), node, true); } break;
01369 case 54: { Node node = new54(); push(goTo(18), node, true); } break;
01370 case 55: { Node node = new55(); push(goTo(18), node, true); } break;
01371 case 56: { Node node = new56(); push(goTo(19), node, true); } break;
01372 case 57: { Node node = new57(); push(goTo(19), node, true); } break;
01373 case 58: { Node node = new58(); push(goTo(19), node, true); } break;
01374 case 59: { Node node = new59(); push(goTo(20), node, true); } break;
01375 case 60: { Node node = new60(); push(goTo(20), node, true); } break;
01376 case 61: { Node node = new61(); push(goTo(20), node, true); } break;
01377 case 62: { Node node = new62(); push(goTo(20), node, true); } break;
01378 case 63: { Node node = new63(); push(goTo(21), node, true); } break;
01379 case 64: { Node node = new64(); push(goTo(21), node, true); } break;
01380 case 65: { Node node = new65(); push(goTo(21), node, true); } break;
01381 case 66: { Node node = new66(); push(goTo(22), node, true); } break;
01382 case 67: { Node node = new67(); push(goTo(22), node, true); } break;
01383 case 68: { Node node = new68(); push(goTo(22), node, true); } break;
01384 case 69: { Node node = new69(); push(goTo(22), node, true); } break;
01385 case 70: { Node node = new70(); push(goTo(23), node, true); } break;
01386 case 71: { Node node = new71(); push(goTo(23), node, true); } break;
01387 case 72: { Node node = new72(); push(goTo(23), node, true); } break;
01388 case 73: { Node node = new73(); push(goTo(23), node, true); } break;
01389 case 74: { Node node = new74(); push(goTo(23), node, true); } break;
01390 case 75: { Node node = new75(); push(goTo(24), node, true); } break;
01391 case 76: { Node node = new76(); push(goTo(24), node, true); } break;
01392 case 77: { Node node = new77(); push(goTo(24), node, true); } break;
01393 case 78: { Node node = new78(); push(goTo(25), node, true); } break;
01394 case 79: { Node node = new79(); push(goTo(25), node, true); } break;
01395 case 80: { Node node = new80(); push(goTo(26), node, true); } break;
01396 case 81: { Node node = new81(); push(goTo(26), node, true); } break;
01397 case 82: { Node node = new82(); push(goTo(27), node, true); } break;
01398 case 83: { Node node = new83(); push(goTo(27), node, true); } break;
01399 case 84: { Node node = new84(); push(goTo(28), node, true); } break;
01400 case 85: { Node node = new85(); push(goTo(28), node, true); } break;
01401 case 86: { Node node = new86(); push(goTo(29), node, true); } break;
01402 case 87: { Node node = new87(); push(goTo(29), node, true); } break;
01403 case 88: { Node node = new88(); push(goTo(30), node, true); } break;
01404 case 89: { Node node = new89(); push(goTo(30), node, true); } break;
01405 case 90: { Node node = new90(); push(goTo(31), node, true); } break;
01406 case 91: { Node node = new91(); push(goTo(32), node, true); } break;
01407 case 92: { Node node = new92(); push(goTo(32), node, true); } break;
01408 case 93: { Node node = new93(); push(goTo(32), node, true); } break;
01409 case 94: { Node node = new94(); push(goTo(32), node, true); } break;
01410 case 95: { Node node = new95(); push(goTo(32), node, true); } break;
01411 case 96: { Node node = new96(); push(goTo(32), node, true); } break;
01412 case 97: { Node node = new97(); push(goTo(32), node, true); } break;
01413 case 98: { Node node = new98(); push(goTo(32), node, true); } break;
01414 }
01415 break;
01416 case ACCEPT:
01417 {
01418 EOF node2 = (EOF) lexer.next();
01419 PUnit node1 = (PUnit) pop();
01420 Start node = new Start(node1, node2);
01421 return node;
01422 }
01423 case ERROR:
01424 throw new ParserException(
01425 "[" + last_line + "," + last_pos + "] " +
01426 errorMessages[errors[action[1]]]);
01427 }
01428 }
01429 }
01430 private Node pop()
01431 {
01432 return (Node) ((State) stack.previous()).node;
01433 }
01434 private void push(int state, Node node, boolean filter) throws ParserException, LexerException, IOException
01435 {
01436 this.node = node;
01437
01438 if(filter)
01439 {
01440 filter();
01441 }
01442
01443 if(!stack.hasNext())
01444 {
01445 stack.add(new State(state, this.node));
01446 return;
01447 }
01448
01449 State s = (State) stack.next();
01450 s.state = state;
01451 s.node = this.node;
01452 }
01453 private int state()
01454 {
01455 State s = (State) stack.previous();
01456 stack.next();
01457 return s.state;
01458 }
01459 }