Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

Parser.java

00001 package edu.ksu.cis.bandera.specification.parser;
00002 
00003 /* This file was generated by SableCC (http://www.sablecc.org/). */
00004 
00005 import edu.ksu.cis.bandera.specification.lexer.*;
00006 import edu.ksu.cis.bandera.specification.node.*;
00007 import edu.ksu.cis.bandera.specification.analysis.*;
00008 import java.util.*;
00009 
00010 import java.io.DataInputStream;
00011 import java.io.BufferedInputStream;
00012 import java.io.IOException;
00013 
00014 public class Parser
00015 {
00016     public final Analysis ignoredTokens = new AnalysisAdapter();
00017 
00018     protected Node node;
00019 
00020     private final Lexer lexer;
00021     private final ListIterator stack = new LinkedList().listIterator();
00022     private int last_shift;
00023     private int last_pos;
00024     private int last_line;
00025     private Token last_token;
00026     private final TokenIndex converter = new TokenIndex();
00027     private final int[] action = new int[2];
00028 
00029     private final static int SHIFT = 0;
00030     private final static int REDUCE = 1;
00031     private final static int ACCEPT = 2;
00032     private final static int ERROR = 3;
00033 
00034     private static int[][][] actionTable;
00035 /*      {
00036             {{-1, REDUCE, 0}, {0, SHIFT, 1}, {19, SHIFT, 2}, {23, SHIFT, 3}, {30, SHIFT, 4}, },
00037             {{-1, ERROR, 1}, {30, SHIFT, 13}, },
00038             {{-1, ERROR, 2}, {9, SHIFT, 14}, {14, SHIFT, 15}, {18, SHIFT, 16}, {19, SHIFT, 17}, {29, SHIFT, 18}, {30, SHIFT, 19}, },
00039             {{-1, ERROR, 3}, {27, SHIFT, 22}, {28, SHIFT, 23}, {30, SHIFT, 24}, },
00040             {{-1, ERROR, 4}, {10, SHIFT, 28}, },
00041             {{-1, ERROR, 5}, {31, ACCEPT, -1}, },
00042             {{-1, REDUCE, 8}, },
00043             {{-1, REDUCE, 3}, },
00044             {{-1, REDUCE, 6}, },
00045             {{-1, REDUCE, 27}, },
00046             {{-1, REDUCE, 28}, },
00047             {{-1, REDUCE, 1}, {0, SHIFT, 1}, {23, SHIFT, 3}, {30, SHIFT, 4}, },
00048             {{-1, REDUCE, 4}, {0, SHIFT, 1}, {30, SHIFT, 4}, },
00049             {{-1, ERROR, 13}, {10, SHIFT, 32}, },
00050             {{-1, REDUCE, 17}, },
00051             {{-1, ERROR, 15}, {30, SHIFT, 33}, },
00052             {{-1, REDUCE, 15}, },
00053             {{-1, REDUCE, 9}, },
00054             {{-1, REDUCE, 16}, },
00055             {{-1, REDUCE, 14}, },
00056             {{-1, REDUCE, 12}, },
00057             {{-1, ERROR, 21}, {9, SHIFT, 14}, {14, SHIFT, 15}, {18, SHIFT, 16}, {19, SHIFT, 34}, {29, SHIFT, 18}, {30, SHIFT, 19}, },
00058             {{-1, ERROR, 22}, {30, SHIFT, 24}, },
00059             {{-1, ERROR, 23}, {30, SHIFT, 24}, },
00060             {{-1, REDUCE, 25}, },
00061             {{-1, ERROR, 25}, {11, SHIFT, 38}, {18, SHIFT, 39}, },
00062             {{-1, REDUCE, 21}, },
00063             {{-1, REDUCE, 24}, {9, SHIFT, 40}, },
00064             {{-1, ERROR, 28}, {9, SHIFT, 41}, {14, SHIFT, 42}, {18, SHIFT, 43}, {24, SHIFT, 44}, {26, SHIFT, 45}, {29, SHIFT, 46}, {30, SHIFT, 47}, },
00065             {{-1, REDUCE, 2}, },
00066             {{-1, REDUCE, 7}, {0, SHIFT, 1}, {30, SHIFT, 4}, },
00067             {{-1, REDUCE, 5}, },
00068             {{-1, ERROR, 32}, {9, SHIFT, 41}, {14, SHIFT, 42}, {18, SHIFT, 43}, {24, SHIFT, 52}, {26, SHIFT, 45}, {29, SHIFT, 46}, {30, SHIFT, 47}, },
00069             {{-1, ERROR, 33}, {15, SHIFT, 55}, },
00070             {{-1, REDUCE, 10}, },
00071             {{-1, REDUCE, 11}, },
00072             {{-1, ERROR, 36}, {11, SHIFT, 56}, {18, SHIFT, 39}, },
00073             {{-1, ERROR, 37}, {11, SHIFT, 57}, {18, SHIFT, 39}, },
00074             {{-1, REDUCE, 18}, },
00075             {{-1, ERROR, 39}, {30, SHIFT, 24}, },
00076             {{-1, ERROR, 40}, {20, SHIFT, 59}, {30, SHIFT, 60}, },
00077             {{-1, REDUCE, 56}, },
00078             {{-1, ERROR, 42}, {8, SHIFT, 61}, {16, SHIFT, 62}, {30, SHIFT, 24}, },
00079             {{-1, REDUCE, 54}, },
00080             {{-1, ERROR, 44}, {25, SHIFT, 70}, },
00081             {{-1, ERROR, 45}, {12, SHIFT, 71}, },
00082             {{-1, REDUCE, 55}, },
00083             {{-1, REDUCE, 53}, },
00084             {{-1, REDUCE, 39}, },
00085             {{-1, REDUCE, 35}, },
00086             {{-1, ERROR, 50}, {9, SHIFT, 41}, {11, SHIFT, 72}, {14, SHIFT, 42}, {18, SHIFT, 43}, {29, SHIFT, 46}, {30, SHIFT, 47}, },
00087             {{-1, ERROR, 51}, {9, SHIFT, 41}, {14, SHIFT, 42}, {18, SHIFT, 43}, {26, SHIFT, 45}, {29, SHIFT, 46}, {30, SHIFT, 47}, },
00088             {{-1, ERROR, 52}, {25, SHIFT, 76}, },
00089             {{-1, ERROR, 53}, {9, SHIFT, 41}, {11, SHIFT, 77}, {14, SHIFT, 42}, {18, SHIFT, 43}, {29, SHIFT, 46}, {30, SHIFT, 47}, },
00090             {{-1, ERROR, 54}, {9, SHIFT, 41}, {14, SHIFT, 42}, {18, SHIFT, 43}, {26, SHIFT, 45}, {29, SHIFT, 46}, {30, SHIFT, 47}, },
00091             {{-1, REDUCE, 13}, },
00092             {{-1, REDUCE, 20}, },
00093             {{-1, REDUCE, 19}, },
00094             {{-1, REDUCE, 22}, },
00095             {{-1, REDUCE, 23}, },
00096             {{-1, REDUCE, 26}, },
00097             {{-1, ERROR, 61}, {16, SHIFT, 62}, {30, SHIFT, 24}, },
00098             {{-1, ERROR, 62}, {8, SHIFT, 61}, {16, SHIFT, 62}, {30, SHIFT, 24}, },
00099             {{-1, ERROR, 63}, {9, SHIFT, 81}, {16, SHIFT, 82}, },
00100             {{-1, ERROR, 64}, {15, SHIFT, 83}, },
00101             {{-1, REDUCE, 57}, {5, SHIFT, 84}, },
00102             {{-1, REDUCE, 60}, {7, SHIFT, 85}, },
00103             {{-1, REDUCE, 62}, {6, SHIFT, 86}, },
00104             {{-1, REDUCE, 64}, },
00105             {{-1, REDUCE, 66}, },
00106             {{-1, ERROR, 70}, {14, SHIFT, 87}, },
00107             {{-1, ERROR, 71}, {30, SHIFT, 88}, },
00108             {{-1, REDUCE, 33}, },
00109             {{-1, REDUCE, 34}, },
00110             {{-1, REDUCE, 38}, },
00111             {{-1, ERROR, 75}, {9, SHIFT, 41}, {11, SHIFT, 90}, {14, SHIFT, 42}, {18, SHIFT, 43}, {29, SHIFT, 46}, {30, SHIFT, 47}, },
00112             {{-1, ERROR, 76}, {14, SHIFT, 91}, },
00113             {{-1, REDUCE, 36}, },
00114             {{-1, ERROR, 78}, {9, SHIFT, 41}, {11, SHIFT, 92}, {14, SHIFT, 42}, {18, SHIFT, 43}, {29, SHIFT, 46}, {30, SHIFT, 47}, },
00115             {{-1, REDUCE, 67}, },
00116             {{-1, ERROR, 80}, {17, SHIFT, 93}, },
00117             {{-1, ERROR, 81}, {30, SHIFT, 60}, },
00118             {{-1, ERROR, 82}, {17, SHIFT, 94}, {30, SHIFT, 95}, },
00119             {{-1, REDUCE, 52}, },
00120             {{-1, ERROR, 84}, {8, SHIFT, 61}, {16, SHIFT, 62}, {30, SHIFT, 24}, },
00121             {{-1, ERROR, 85}, {8, SHIFT, 61}, {16, SHIFT, 62}, {30, SHIFT, 24}, },
00122             {{-1, ERROR, 86}, {8, SHIFT, 61}, {16, SHIFT, 62}, {30, SHIFT, 24}, },
00123             {{-1, ERROR, 87}, {30, SHIFT, 24}, },
00124             {{-1, REDUCE, 50}, },
00125             {{-1, ERROR, 89}, {3, SHIFT, 102}, {10, SHIFT, 103}, {18, SHIFT, 104}, },
00126             {{-1, REDUCE, 37}, },
00127             {{-1, ERROR, 91}, {30, SHIFT, 24}, },
00128             {{-1, REDUCE, 40}, },
00129             {{-1, REDUCE, 70}, },
00130             {{-1, REDUCE, 68}, },
00131             {{-1, REDUCE, 58}, },
00132             {{-1, ERROR, 96}, {17, SHIFT, 107}, {18, SHIFT, 108}, },
00133             {{-1, REDUCE, 61}, {7, SHIFT, 85}, },
00134             {{-1, REDUCE, 63}, {6, SHIFT, 86}, },
00135             {{-1, REDUCE, 65}, },
00136             {{-1, REDUCE, 31}, {9, SHIFT, 81}, },
00137             {{-1, ERROR, 101}, {15, SHIFT, 109}, {18, SHIFT, 110}, },
00138             {{-1, REDUCE, 43}, },
00139             {{-1, REDUCE, 42}, },
00140             {{-1, ERROR, 104}, {30, SHIFT, 111}, },
00141             {{-1, ERROR, 105}, {16, SHIFT, 112}, {30, SHIFT, 24}, },
00142             {{-1, ERROR, 106}, {15, SHIFT, 116}, {18, SHIFT, 110}, },
00143             {{-1, REDUCE, 69}, },
00144             {{-1, ERROR, 108}, {30, SHIFT, 117}, },
00145             {{-1, ERROR, 109}, {11, SHIFT, 118}, },
00146             {{-1, ERROR, 110}, {30, SHIFT, 24}, },
00147             {{-1, REDUCE, 51}, },
00148             {{-1, ERROR, 112}, {16, SHIFT, 112}, {30, SHIFT, 24}, },
00149             {{-1, REDUCE, 46}, {9, SHIFT, 81}, },
00150             {{-1, ERROR, 114}, {13, SHIFT, 121}, },
00151             {{-1, REDUCE, 44}, {21, SHIFT, 122}, {22, SHIFT, 123}, },
00152             {{-1, ERROR, 116}, {11, SHIFT, 125}, },
00153             {{-1, REDUCE, 59}, },
00154             {{-1, REDUCE, 29}, },
00155             {{-1, REDUCE, 32}, {9, SHIFT, 81}, },
00156             {{-1, ERROR, 120}, {17, SHIFT, 126}, },
00157             {{-1, ERROR, 121}, {9, SHIFT, 127}, },
00158             {{-1, REDUCE, 49}, },
00159             {{-1, REDUCE, 48}, },
00160             {{-1, ERROR, 124}, {16, SHIFT, 112}, {30, SHIFT, 24}, },
00161             {{-1, REDUCE, 30}, },
00162             {{-1, REDUCE, 47}, },
00163             {{-1, REDUCE, 41}, },
00164             {{-1, REDUCE, 45}, },
00165         };*/
00166     private static int[][][] gotoTable;
00167 /*      {
00168             {{-1, 5}, },
00169             {{-1, 6}, },
00170             {{-1, 20}, {21, 35}, },
00171             {{-1, 7}, {11, 29}, },
00172             {{-1, 25}, {22, 36}, {23, 37}, },
00173             {{-1, 26}, {39, 58}, },
00174             {{-1, 63}, {3, 27}, {22, 27}, {23, 27}, {39, 27}, {87, 100}, {91, 100}, {105, 113}, {110, 119}, {112, 113}, {124, 113}, },
00175             {{-1, 8}, {12, 31}, {30, 31}, },
00176             {{-1, 9}, },
00177             {{-1, 101}, {91, 106}, },
00178             {{-1, 10}, },
00179             {{-1, 48}, {51, 74}, {54, 74}, },
00180             {{-1, 105}, },
00181             {{-1, 114}, {112, 120}, {124, 128}, },
00182             {{-1, 115}, },
00183             {{-1, 124}, },
00184             {{-1, 89}, },
00185             {{-1, 49}, {50, 73}, {53, 73}, {75, 73}, {78, 73}, },
00186             {{-1, 64}, {62, 80}, },
00187             {{-1, 96}, },
00188             {{-1, 65}, },
00189             {{-1, 66}, {84, 97}, },
00190             {{-1, 67}, {85, 98}, },
00191             {{-1, 68}, {86, 99}, },
00192             {{-1, 69}, {61, 79}, },
00193             {{-1, -1}, },
00194             {{-1, 11}, },
00195             {{-1, 12}, {11, 30}, },
00196             {{-1, 21}, },
00197             {{-1, 50}, {32, 53}, {51, 75}, {54, 78}, },
00198             {{-1, 51}, {32, 54}, },
00199         };*/
00200     private static String[] errorMessages;
00201 /*      {
00202             "expecting: documentation comment, '"', 'import', id, EOF",
00203             "expecting: id",
00204             "expecting: '.', '{', ',', '"', number, id",
00205             "expecting: 'predicate', 'assertion', id",
00206             "expecting: ':'",
00207             "expecting: EOF",
00208             "expecting: documentation comment, 'import', id, EOF",
00209             "expecting: documentation comment, id, EOF",
00210             "expecting: '.', ';', ']', '}', '(', ')', ',', '+', '-'",
00211             "expecting: ';', ','",
00212             "expecting: '.', ';', ','",
00213             "expecting: '.', '{', ',', 'enable', 'forall', number, id",
00214             "expecting: '}'",
00215             "expecting: '*', id",
00216             "expecting: '.', ';', '{', ',', number, id",
00217             "expecting: '!', '(', id",
00218             "expecting: 'assertions'",
00219             "expecting: '['",
00220             "expecting: '.', '{', ',', 'forall', number, id",
00221             "expecting: '(', id",
00222             "expecting: '.', '('",
00223             "expecting: '->', '}', ')'",
00224             "expecting: '->', '||', '}', ')'",
00225             "expecting: '->', '&&', '||', '}', ')'",
00226             "expecting: '{'",
00227             "expecting: ')'",
00228             "expecting: ')', id",
00229             "expecting: '<:', ':', ','",
00230             "expecting: ')', ','",
00231             "expecting: '.', '}', ','",
00232             "expecting: '}', ','",
00233             "expecting: ';'",
00234             "expecting: '.', ']', ')', '+', '-'",
00235             "expecting: ']'",
00236             "expecting: ']', ')', '+', '-'",
00237             "expecting: '.'",
00238             "expecting: ']', ')'",
00239         };*/
00240     private static int[] errors;
00241 /*      {
00242             0, 1, 2, 3, 4, 5, 5, 6, 7, 7, 7, 6, 7, 4, 2, 1, 2, 5, 2, 2, 2, 2, 1, 1, 8, 9, 9, 10, 11, 6, 7, 7, 11, 12, 5, 2, 9, 9, 6, 1, 13, 14, 15, 14, 16, 17, 14, 14, 18, 14, 14, 18, 16, 14, 18, 2, 6, 6, 9, 9, 8, 19, 15, 20, 12, 21, 22, 23, 23, 23, 24, 1, 7, 14, 18, 14, 24, 7, 14, 23, 25, 1, 26, 14, 15, 15, 15, 1, 27, 27, 7, 1, 7, 23, 23, 28, 28, 22, 23, 23, 29, 30, 19, 19, 1, 19, 30, 23, 1, 31, 1, 27, 19, 32, 33, 34, 31, 28, 7, 29, 25, 35, 19, 19, 19, 7, 34, 18, 36, 
00243         };*/
00244     public Parser(Lexer lexer)
00245     {
00246         this.lexer = lexer;
00247 
00248         if(actionTable == null)
00249         {
00250             try
00251             {
00252                 DataInputStream s = new DataInputStream(
00253                     new BufferedInputStream(
00254                     Parser.class.getResourceAsStream("parser.dat")));
00255 
00256                 // read actionTable
00257                 int length = s.readInt();
00258                 actionTable = new int[length][][];
00259                 for(int i = 0; i < actionTable.length; i++)
00260                 {
00261                     length = s.readInt();
00262                     actionTable[i] = new int[length][3];
00263                     for(int j = 0; j < actionTable[i].length; j++)
00264                     {
00265                         for(int k = 0; k < 3; k++)
00266                         {
00267                             actionTable[i][j][k] = s.readInt();
00268                         }
00269                     }
00270                 }
00271 
00272                 // read gotoTable
00273                 length = s.readInt();
00274                 gotoTable = new int[length][][];
00275                 for(int i = 0; i < gotoTable.length; i++)
00276                 {
00277                     length = s.readInt();
00278                     gotoTable[i] = new int[length][2];
00279                     for(int j = 0; j < gotoTable[i].length; j++)
00280                     {
00281                         for(int k = 0; k < 2; k++)
00282                         {
00283                             gotoTable[i][j][k] = s.readInt();
00284                         }
00285                     }
00286                 }
00287 
00288                 // read errorMessages
00289                 length = s.readInt();
00290                 errorMessages = new String[length];
00291                 for(int i = 0; i < errorMessages.length; i++)
00292                 {
00293                     length = s.readInt();
00294                     StringBuffer buffer = new StringBuffer();
00295 
00296                     for(int j = 0; j < length; j++)
00297                     {
00298                         buffer.append(s.readChar());
00299                     }
00300                     errorMessages[i] = buffer.toString();
00301                 }
00302 
00303                 // read errors
00304                 length = s.readInt();
00305                 errors = new int[length];
00306                 for(int i = 0; i < errors.length; i++)
00307                 {
00308                     errors[i] = s.readInt();
00309                 }
00310 
00311                 s.close();
00312             }
00313             catch(Exception e)
00314             {
00315                 throw new RuntimeException("The file \"parser.dat\" is either missing or corrupted.");
00316             }
00317         }
00318     }
00319     protected void filter() throws ParserException, LexerException, IOException
00320     {
00321     }
00322     private int goTo(int index)
00323     {
00324         int state = state();
00325         int low = 1;
00326         int high = gotoTable[index].length - 1;
00327         int value = gotoTable[index][0][1];
00328 
00329         while(low <= high)
00330         {
00331             int middle = (low + high) / 2;
00332 
00333             if(state < gotoTable[index][middle][0])
00334             {
00335                 high = middle - 1;
00336             }
00337             else if(state > gotoTable[index][middle][0])
00338             {
00339                 low = middle + 1;
00340             }
00341             else
00342             {
00343                 value = gotoTable[index][middle][1];
00344                 break;
00345             }
00346         }
00347 
00348         return value;
00349     }
00350     private int index(Switchable token)
00351     {
00352         converter.index = -1;
00353         token.apply(converter);
00354         return converter.index;
00355     }
00356     Node new0()
00357     {
00358         XPDef node2 = null;
00359         XPImport node1 = null;
00360         APropertiesUnit node = new APropertiesUnit(node1, node2);
00361         return node;
00362     }
00363     Node new1()
00364     {
00365         XPDef node2 = null;
00366         XPImport node1 = (XPImport) pop();
00367         APropertiesUnit node = new APropertiesUnit(node1, node2);
00368         return node;
00369     }
00370     Node new10()
00371     {
00372         TDoubleQuote node3 = (TDoubleQuote) pop();
00373         XPFormatWord node2 = (XPFormatWord) pop();
00374         TDoubleQuote node1 = (TDoubleQuote) pop();
00375         AFormat node = new AFormat(node1, node2, node3);
00376         return node;
00377     }
00378     Node new11()
00379     {
00380         PFormatWord node2 = (PFormatWord) pop();
00381         XPFormatWord node1 = (XPFormatWord) pop();
00382         X1PFormatWord node = new X1PFormatWord(node1, node2);
00383         return node;
00384     }
00385     Node new12()
00386     {
00387         PFormatWord node1 = (PFormatWord) pop();
00388         X2PFormatWord node = new X2PFormatWord(node1);
00389         return node;
00390     }
00391     Node new13()
00392     {
00393         TRBrace node3 = (TRBrace) pop();
00394         TId node2 = (TId) pop();
00395         TLBrace node1 = (TLBrace) pop();
00396         AHoleFormatWord node = new AHoleFormatWord(node1, node2, node3);
00397         return node;
00398     }
00399     Node new14()
00400     {
00401         TId node1 = (TId) pop();
00402         AIdFormatWord node = new AIdFormatWord(node1);
00403         return node;
00404     }
00405     Node new15()
00406     {
00407         TComma node1 = (TComma) pop();
00408         ACommaFormatWord node = new ACommaFormatWord(node1);
00409         return node;
00410     }
00411     Node new16()
00412     {
00413         TNumber node1 = (TNumber) pop();
00414         ANumberFormatWord node = new ANumberFormatWord(node1);
00415         return node;
00416     }
00417     Node new17()
00418     {
00419         TDot node1 = (TDot) pop();
00420         ADotFormatWord node = new ADotFormatWord(node1);
00421         return node;
00422     }
00423     Node new18()
00424     {
00425         TSemicolon node3 = (TSemicolon) pop();
00426         PImportNames node2 = (PImportNames) pop();
00427         TImport node1 = (TImport) pop();
00428         ATypeImport node = new ATypeImport(node1, node2, node3);
00429         return node;
00430     }
00431     Node new19()
00432     {
00433         TSemicolon node4 = (TSemicolon) pop();
00434         PImportNames node3 = (PImportNames) pop();
00435         TAssertion node2 = (TAssertion) pop();
00436         TImport node1 = (TImport) pop();
00437         AAssertionImport node = new AAssertionImport(node1, node2, node3, node4);
00438         return node;
00439     }
00440     Node new2()
00441     {
00442         PImport node2 = (PImport) pop();
00443         XPImport node1 = (XPImport) pop();
00444         X1PImport node = new X1PImport(node1, node2);
00445         return node;
00446     }
00447     Node new20()
00448     {
00449         TSemicolon node4 = (TSemicolon) pop();
00450         PImportNames node3 = (PImportNames) pop();
00451         TPredicate node2 = (TPredicate) pop();
00452         TImport node1 = (TImport) pop();
00453         APredicateImport node = new APredicateImport(node1, node2, node3, node4);
00454         return node;
00455     }
00456     Node new21()
00457     {
00458         PImportName node1 = (PImportName) pop();
00459         ANameImportNames node = new ANameImportNames(node1);
00460         return node;
00461     }
00462     Node new22()
00463     {
00464         PImportName node3 = (PImportName) pop();
00465         TComma node2 = (TComma) pop();
00466         PImportNames node1 = (PImportNames) pop();
00467         ANamesImportNames node = new ANamesImportNames(node1, node2, node3);
00468         return node;
00469     }
00470     Node new23()
00471     {
00472         TStar node3 = (TStar) pop();
00473         TDot node2 = (TDot) pop();
00474         PName node1 = (PName) pop();
00475         AOnDemandImportName node = new AOnDemandImportName(node1, node2, node3);
00476         return node;
00477     }
00478     Node new24()
00479     {
00480         PName node1 = (PName) pop();
00481         ASpecificImportName node = new ASpecificImportName(node1);
00482         return node;
00483     }
00484     Node new25()
00485     {
00486         TId node1 = (TId) pop();
00487         ASimpleName node = new ASimpleName(node1);
00488         return node;
00489     }
00490     Node new26()
00491     {
00492         TId node3 = (TId) pop();
00493         TDot node2 = (TDot) pop();
00494         PName node1 = (PName) pop();
00495         AQualifiedName node = new AQualifiedName(node1, node2, node3);
00496         return node;
00497     }
00498     Node new27()
00499     {
00500         PAssert node1 = (PAssert) pop();
00501         AAssertDef node = new AAssertDef(node1);
00502         return node;
00503     }
00504     Node new28()
00505     {
00506         PTl node1 = (PTl) pop();
00507         ATlDef node = new ATlDef(node1);
00508         return node;
00509     }
00510     Node new29()
00511     {
00512         TSemicolon node9 = (TSemicolon) pop();
00513         TRBrace node8 = (TRBrace) pop();
00514         PNames node7 = (PNames) pop();
00515         TLBrace node6 = (TLBrace) pop();
00516         TAssertions node5 = (TAssertions) pop();
00517         TEnable node4 = (TEnable) pop();
00518         TColon node3 = (TColon) pop();
00519         TId node2 = (TId) pop();
00520         TDocumentationComment node1 = null;
00521         AAssert node = new AAssert(node1, node2, node3, node4, node5, node6, node7, node8, node9);
00522         return node;
00523     }
00524     Node new3()
00525     {
00526         PImport node1 = (PImport) pop();
00527         X2PImport node = new X2PImport(node1);
00528         return node;
00529     }
00530     Node new30()
00531     {
00532         TSemicolon node9 = (TSemicolon) pop();
00533         TRBrace node8 = (TRBrace) pop();
00534         PNames node7 = (PNames) pop();
00535         TLBrace node6 = (TLBrace) pop();
00536         TAssertions node5 = (TAssertions) pop();
00537         TEnable node4 = (TEnable) pop();
00538         TColon node3 = (TColon) pop();
00539         TId node2 = (TId) pop();
00540         TDocumentationComment node1 = (TDocumentationComment) pop();
00541         AAssert node = new AAssert(node1, node2, node3, node4, node5, node6, node7, node8, node9);
00542         return node;
00543     }
00544     Node new31()
00545     {
00546         PName node1 = (PName) pop();
00547         ANameNames node = new ANameNames(node1);
00548         return node;
00549     }
00550     Node new32()
00551     {
00552         PName node3 = (PName) pop();
00553         TComma node2 = (TComma) pop();
00554         PNames node1 = (PNames) pop();
00555         ANamesNames node = new ANamesNames(node1, node2, node3);
00556         return node;
00557     }
00558     Node new33()
00559     {
00560         TSemicolon node6 = (TSemicolon) pop();
00561         XPWord node5 = (XPWord) pop();
00562         XPQtl node4 = null;
00563         TColon node3 = (TColon) pop();
00564         TId node2 = (TId) pop();
00565         TDocumentationComment node1 = null;
00566         ATl node = new ATl(node1, node2, node3, node4, node5, node6);
00567         return node;
00568     }
00569     Node new34()
00570     {
00571         PWord node2 = (PWord) pop();
00572         XPWord node1 = (XPWord) pop();
00573         X1PWord node = new X1PWord(node1, node2);
00574         return node;
00575     }
00576     Node new35()
00577     {
00578         PWord node1 = (PWord) pop();
00579         X2PWord node = new X2PWord(node1);
00580         return node;
00581     }
00582     Node new36()
00583     {
00584         TSemicolon node6 = (TSemicolon) pop();
00585         XPWord node5 = (XPWord) pop();
00586         XPQtl node4 = null;
00587         TColon node3 = (TColon) pop();
00588         TId node2 = (TId) pop();
00589         TDocumentationComment node1 = (TDocumentationComment) pop();
00590         ATl node = new ATl(node1, node2, node3, node4, node5, node6);
00591         return node;
00592     }
00593     Node new37()
00594     {
00595         TSemicolon node6 = (TSemicolon) pop();
00596         XPWord node5 = (XPWord) pop();
00597         XPQtl node4 = (XPQtl) pop();
00598         TColon node3 = (TColon) pop();
00599         TId node2 = (TId) pop();
00600         TDocumentationComment node1 = null;
00601         ATl node = new ATl(node1, node2, node3, node4, node5, node6);
00602         return node;
00603     }
00604     Node new38()
00605     {
00606         PQtl node2 = (PQtl) pop();
00607         XPQtl node1 = (XPQtl) pop();
00608         X1PQtl node = new X1PQtl(node1, node2);
00609         return node;
00610     }
00611     Node new39()
00612     {
00613         PQtl node1 = (PQtl) pop();
00614         X2PQtl node = new X2PQtl(node1);
00615         return node;
00616     }
00617     Node new4()
00618     {
00619         XPDef node2 = (XPDef) pop();
00620         XPImport node1 = null;
00621         APropertiesUnit node = new APropertiesUnit(node1, node2);
00622         return node;
00623     }
00624     Node new40()
00625     {
00626         TSemicolon node6 = (TSemicolon) pop();
00627         XPWord node5 = (XPWord) pop();
00628         XPQtl node4 = (XPQtl) pop();
00629         TColon node3 = (TColon) pop();
00630         TId node2 = (TId) pop();
00631         TDocumentationComment node1 = (TDocumentationComment) pop();
00632         ATl node = new ATl(node1, node2, node3, node4, node5, node6);
00633         return node;
00634     }
00635     Node new41()
00636     {
00637         TDot node7 = (TDot) pop();
00638         TRBracket node6 = (TRBracket) pop();
00639         PTypeExp node5 = (PTypeExp) pop();
00640         PQtlBinding node4 = (PQtlBinding) pop();
00641         PIds node3 = (PIds) pop();
00642         TLBracket node2 = (TLBracket) pop();
00643         TForall node1 = (TForall) pop();
00644         AQtl node = new AQtl(node1, node2, node3, node4, node5, node6, node7);
00645         return node;
00646     }
00647     Node new42()
00648     {
00649         TColon node1 = (TColon) pop();
00650         AExactQtlBinding node = new AExactQtlBinding(node1);
00651         return node;
00652     }
00653     Node new43()
00654     {
00655         TInstance node1 = (TInstance) pop();
00656         AInstanceQtlBinding node = new AInstanceQtlBinding(node1);
00657         return node;
00658     }
00659     Node new44()
00660     {
00661         PPrimaryTypeExp node1 = (PPrimaryTypeExp) pop();
00662         APrimaryTypeExp node = new APrimaryTypeExp(node1);
00663         return node;
00664     }
00665     Node new45()
00666     {
00667         PTypeExp node3 = (PTypeExp) pop();
00668         PTypeOp node2 = (PTypeOp) pop();
00669         PPrimaryTypeExp node1 = (PPrimaryTypeExp) pop();
00670         AOpTypeExp node = new AOpTypeExp(node1, node2, node3);
00671         return node;
00672     }
00673     Node new46()
00674     {
00675         PName node1 = (PName) pop();
00676         ANamePrimaryTypeExp node = new ANamePrimaryTypeExp(node1);
00677         return node;
00678     }
00679     Node new47()
00680     {
00681         TRParen node3 = (TRParen) pop();
00682         PTypeExp node2 = (PTypeExp) pop();
00683         TLParen node1 = (TLParen) pop();
00684         AParenPrimaryTypeExp node = new AParenPrimaryTypeExp(node1, node2, node3);
00685         return node;
00686     }
00687     Node new48()
00688     {
00689         TMinus node1 = (TMinus) pop();
00690         AFilterTypeOp node = new AFilterTypeOp(node1);
00691         return node;
00692     }
00693     Node new49()
00694     {
00695         TPlus node1 = (TPlus) pop();
00696         AUnionTypeOp node = new AUnionTypeOp(node1);
00697         return node;
00698     }
00699     Node new5()
00700     {
00701         PDef node2 = (PDef) pop();
00702         XPDef node1 = (XPDef) pop();
00703         X1PDef node = new X1PDef(node1, node2);
00704         return node;
00705     }
00706     Node new50()
00707     {
00708         TId node1 = (TId) pop();
00709         AIdIds node = new AIdIds(node1);
00710         return node;
00711     }
00712     Node new51()
00713     {
00714         TId node3 = (TId) pop();
00715         TComma node2 = (TComma) pop();
00716         PIds node1 = (PIds) pop();
00717         AIdsIds node = new AIdsIds(node1, node2, node3);
00718         return node;
00719     }
00720     Node new52()
00721     {
00722         TRBrace node3 = (TRBrace) pop();
00723         PExp node2 = (PExp) pop();
00724         TLBrace node1 = (TLBrace) pop();
00725         AExpWord node = new AExpWord(node1, node2, node3);
00726         return node;
00727     }
00728     Node new53()
00729     {
00730         TId node1 = (TId) pop();
00731         AIdWord node = new AIdWord(node1);
00732         return node;
00733     }
00734     Node new54()
00735     {
00736         TComma node1 = (TComma) pop();
00737         ACommaWord node = new ACommaWord(node1);
00738         return node;
00739     }
00740     Node new55()
00741     {
00742         TNumber node1 = (TNumber) pop();
00743         ANumberWord node = new ANumberWord(node1);
00744         return node;
00745     }
00746     Node new56()
00747     {
00748         TDot node1 = (TDot) pop();
00749         ADotWord node = new ADotWord(node1);
00750         return node;
00751     }
00752     Node new57()
00753     {
00754         PImplicationExp node1 = (PImplicationExp) pop();
00755         AImplicationExp node = new AImplicationExp(node1);
00756         return node;
00757     }
00758     Node new58()
00759     {
00760         TId node1 = (TId) pop();
00761         AIdArgs node = new AIdArgs(node1);
00762         return node;
00763     }
00764     Node new59()
00765     {
00766         TId node3 = (TId) pop();
00767         TComma node2 = (TComma) pop();
00768         PArgs node1 = (PArgs) pop();
00769         AArgsArgs node = new AArgsArgs(node1, node2, node3);
00770         return node;
00771     }
00772     Node new6()
00773     {
00774         PDef node1 = (PDef) pop();
00775         X2PDef node = new X2PDef(node1);
00776         return node;
00777     }
00778     Node new60()
00779     {
00780         POrExp node1 = (POrExp) pop();
00781         AOrImplicationExp node = new AOrImplicationExp(node1);
00782         return node;
00783     }
00784     Node new61()
00785     {
00786         POrExp node3 = (POrExp) pop();
00787         TImply node2 = (TImply) pop();
00788         PImplicationExp node1 = (PImplicationExp) pop();
00789         AImplyImplicationExp node = new AImplyImplicationExp(node1, node2, node3);
00790         return node;
00791     }
00792     Node new62()
00793     {
00794         PAndExp node1 = (PAndExp) pop();
00795         AAndOrExp node = new AAndOrExp(node1);
00796         return node;
00797     }
00798     Node new63()
00799     {
00800         PAndExp node3 = (PAndExp) pop();
00801         TOr node2 = (TOr) pop();
00802         POrExp node1 = (POrExp) pop();
00803         AOrOrExp node = new AOrOrExp(node1, node2, node3);
00804         return node;
00805     }
00806     Node new64()
00807     {
00808         PUnaryExp node1 = (PUnaryExp) pop();
00809         AUnaryAndExp node = new AUnaryAndExp(node1);
00810         return node;
00811     }
00812     Node new65()
00813     {
00814         PUnaryExp node3 = (PUnaryExp) pop();
00815         TAnd node2 = (TAnd) pop();
00816         PAndExp node1 = (PAndExp) pop();
00817         AAndAndExp node = new AAndAndExp(node1, node2, node3);
00818         return node;
00819     }
00820     Node new66()
00821     {
00822         PPrimaryExp node1 = (PPrimaryExp) pop();
00823         APrimaryUnaryExp node = new APrimaryUnaryExp(node1);
00824         return node;
00825     }
00826     Node new67()
00827     {
00828         PPrimaryExp node2 = (PPrimaryExp) pop();
00829         TNot node1 = (TNot) pop();
00830         AComplementUnaryExp node = new AComplementUnaryExp(node1, node2);
00831         return node;
00832     }
00833     Node new68()
00834     {
00835         TRParen node4 = (TRParen) pop();
00836         PArgs node3 = null;
00837         TLParen node2 = (TLParen) pop();
00838         PName node1 = (PName) pop();
00839         APredicatePrimaryExp node = new APredicatePrimaryExp(node1, node2, node3, node4);
00840         return node;
00841     }
00842     Node new69()
00843     {
00844         TRParen node4 = (TRParen) pop();
00845         PArgs node3 = (PArgs) pop();
00846         TLParen node2 = (TLParen) pop();
00847         PName node1 = (PName) pop();
00848         APredicatePrimaryExp node = new APredicatePrimaryExp(node1, node2, node3, node4);
00849         return node;
00850     }
00851     Node new7()
00852     {
00853         XPDef node2 = (XPDef) pop();
00854         XPImport node1 = (XPImport) pop();
00855         APropertiesUnit node = new APropertiesUnit(node1, node2);
00856         return node;
00857     }
00858     Node new70()
00859     {
00860         TRParen node3 = (TRParen) pop();
00861         PExp node2 = (PExp) pop();
00862         TLParen node1 = (TLParen) pop();
00863         AParenPrimaryExp node = new AParenPrimaryExp(node1, node2, node3);
00864         return node;
00865     }
00866     Node new71()
00867     {
00868         TAnd node1 = (TAnd) pop();
00869         AAndBinOp node = new AAndBinOp(node1);
00870         return node;
00871     }
00872     Node new72()
00873     {
00874         TOr node1 = (TOr) pop();
00875         AOrBinOp node = new AOrBinOp(node1);
00876         return node;
00877     }
00878     Node new73()
00879     {
00880         TImply node1 = (TImply) pop();
00881         AImplyBinOp node = new AImplyBinOp(node1);
00882         return node;
00883     }
00884     Node new8()
00885     {
00886         PFormat node1 = (PFormat) pop();
00887         AFormatUnit node = new AFormatUnit(node1);
00888         return node;
00889     }
00890     Node new9()
00891     {
00892         TDoubleQuote node3 = (TDoubleQuote) pop();
00893         XPFormatWord node2 = null;
00894         TDoubleQuote node1 = (TDoubleQuote) pop();
00895         AFormat node = new AFormat(node1, node2, node3);
00896         return node;
00897     }
00898     public Start parse() throws ParserException, LexerException, IOException
00899     {
00900         push(0, null, false);
00901 
00902         List ign = null;
00903         while(true)
00904         {
00905             while(index(lexer.peek()) == -1)
00906             {
00907                 if(ign == null)
00908                 {
00909                     ign = new TypedLinkedList(NodeCast.instance);
00910                 }
00911 
00912                 ign.add(lexer.next());
00913             }
00914 
00915             if(ign != null)
00916             {
00917                 ignoredTokens.setIn(lexer.peek(), ign);
00918                 ign = null;
00919             }
00920 
00921             last_pos = lexer.peek().getPos();
00922             last_line = lexer.peek().getLine();
00923             last_token = lexer.peek();
00924 
00925             int index = index(lexer.peek());
00926             action[0] = actionTable[state()][0][1];
00927             action[1] = actionTable[state()][0][2];
00928 
00929             int low = 1;
00930             int high = actionTable[state()].length - 1;
00931 
00932             while(low <= high)
00933             {
00934                 int middle = (low + high) / 2;
00935 
00936                 if(index < actionTable[state()][middle][0])
00937                 {
00938                     high = middle - 1;
00939                 }
00940                 else if(index > actionTable[state()][middle][0])
00941                 {
00942                     low = middle + 1;
00943                 }
00944                 else
00945                 {
00946                     action[0] = actionTable[state()][middle][1];
00947                     action[1] = actionTable[state()][middle][2];
00948                     break;
00949                 }
00950             }
00951 
00952             switch(action[0])
00953             {
00954                 case SHIFT:
00955                     push(action[1], lexer.next(), true);
00956                     last_shift = action[1];
00957                     break;
00958                 case REDUCE:
00959                     switch(action[1])
00960                     {
00961                     case 0: { Node node = new0(); push(goTo(0), node, true); } break;
00962                     case 1: { Node node = new1(); push(goTo(0), node, true); } break;
00963                     case 2: { Node node = new2(); push(goTo(26), node, false); } break;
00964                     case 3: { Node node = new3(); push(goTo(26), node, false); } break;
00965                     case 4: { Node node = new4(); push(goTo(0), node, true); } break;
00966                     case 5: { Node node = new5(); push(goTo(27), node, false); } break;
00967                     case 6: { Node node = new6(); push(goTo(27), node, false); } break;
00968                     case 7: { Node node = new7(); push(goTo(0), node, true); } break;
00969                     case 8: { Node node = new8(); push(goTo(0), node, true); } break;
00970                     case 9: { Node node = new9(); push(goTo(1), node, true); } break;
00971                     case 10: { Node node = new10(); push(goTo(1), node, true); } break;
00972                     case 11: { Node node = new11(); push(goTo(28), node, false); } break;
00973                     case 12: { Node node = new12(); push(goTo(28), node, false); } break;
00974                     case 13: { Node node = new13(); push(goTo(2), node, true); } break;
00975                     case 14: { Node node = new14(); push(goTo(2), node, true); } break;
00976                     case 15: { Node node = new15(); push(goTo(2), node, true); } break;
00977                     case 16: { Node node = new16(); push(goTo(2), node, true); } break;
00978                     case 17: { Node node = new17(); push(goTo(2), node, true); } break;
00979                     case 18: { Node node = new18(); push(goTo(3), node, true); } break;
00980                     case 19: { Node node = new19(); push(goTo(3), node, true); } break;
00981                     case 20: { Node node = new20(); push(goTo(3), node, true); } break;
00982                     case 21: { Node node = new21(); push(goTo(4), node, true); } break;
00983                     case 22: { Node node = new22(); push(goTo(4), node, true); } break;
00984                     case 23: { Node node = new23(); push(goTo(5), node, true); } break;
00985                     case 24: { Node node = new24(); push(goTo(5), node, true); } break;
00986                     case 25: { Node node = new25(); push(goTo(6), node, true); } break;
00987                     case 26: { Node node = new26(); push(goTo(6), node, true); } break;
00988                     case 27: { Node node = new27(); push(goTo(7), node, true); } break;
00989                     case 28: { Node node = new28(); push(goTo(7), node, true); } break;
00990                     case 29: { Node node = new29(); push(goTo(8), node, true); } break;
00991                     case 30: { Node node = new30(); push(goTo(8), node, true); } break;
00992                     case 31: { Node node = new31(); push(goTo(9), node, true); } break;
00993                     case 32: { Node node = new32(); push(goTo(9), node, true); } break;
00994                     case 33: { Node node = new33(); push(goTo(10), node, true); } break;
00995                     case 34: { Node node = new34(); push(goTo(29), node, false); } break;
00996                     case 35: { Node node = new35(); push(goTo(29), node, false); } break;
00997                     case 36: { Node node = new36(); push(goTo(10), node, true); } break;
00998                     case 37: { Node node = new37(); push(goTo(10), node, true); } break;
00999                     case 38: { Node node = new38(); push(goTo(30), node, false); } break;
01000                     case 39: { Node node = new39(); push(goTo(30), node, false); } break;
01001                     case 40: { Node node = new40(); push(goTo(10), node, true); } break;
01002                     case 41: { Node node = new41(); push(goTo(11), node, true); } break;
01003                     case 42: { Node node = new42(); push(goTo(12), node, true); } break;
01004                     case 43: { Node node = new43(); push(goTo(12), node, true); } break;
01005                     case 44: { Node node = new44(); push(goTo(13), node, true); } break;
01006                     case 45: { Node node = new45(); push(goTo(13), node, true); } break;
01007                     case 46: { Node node = new46(); push(goTo(14), node, true); } break;
01008                     case 47: { Node node = new47(); push(goTo(14), node, true); } break;
01009                     case 48: { Node node = new48(); push(goTo(15), node, true); } break;
01010                     case 49: { Node node = new49(); push(goTo(15), node, true); } break;
01011                     case 50: { Node node = new50(); push(goTo(16), node, true); } break;
01012                     case 51: { Node node = new51(); push(goTo(16), node, true); } break;
01013                     case 52: { Node node = new52(); push(goTo(17), node, true); } break;
01014                     case 53: { Node node = new53(); push(goTo(17), node, true); } break;
01015                     case 54: { Node node = new54(); push(goTo(17), node, true); } break;
01016                     case 55: { Node node = new55(); push(goTo(17), node, true); } break;
01017                     case 56: { Node node = new56(); push(goTo(17), node, true); } break;
01018                     case 57: { Node node = new57(); push(goTo(18), node, true); } break;
01019                     case 58: { Node node = new58(); push(goTo(19), node, true); } break;
01020                     case 59: { Node node = new59(); push(goTo(19), node, true); } break;
01021                     case 60: { Node node = new60(); push(goTo(20), node, true); } break;
01022                     case 61: { Node node = new61(); push(goTo(20), node, true); } break;
01023                     case 62: { Node node = new62(); push(goTo(21), node, true); } break;
01024                     case 63: { Node node = new63(); push(goTo(21), node, true); } break;
01025                     case 64: { Node node = new64(); push(goTo(22), node, true); } break;
01026                     case 65: { Node node = new65(); push(goTo(22), node, true); } break;
01027                     case 66: { Node node = new66(); push(goTo(23), node, true); } break;
01028                     case 67: { Node node = new67(); push(goTo(23), node, true); } break;
01029                     case 68: { Node node = new68(); push(goTo(24), node, true); } break;
01030                     case 69: { Node node = new69(); push(goTo(24), node, true); } break;
01031                     case 70: { Node node = new70(); push(goTo(24), node, true); } break;
01032                     case 71: { Node node = new71(); push(goTo(25), node, true); } break;
01033                     case 72: { Node node = new72(); push(goTo(25), node, true); } break;
01034                     case 73: { Node node = new73(); push(goTo(25), node, true); } break;
01035                     }
01036                     break;
01037                 case ACCEPT:
01038                     {
01039                         EOF node2 = (EOF) lexer.next();
01040                         PUnit node1 = (PUnit) pop();
01041                         Start node = new Start(node1, node2);
01042                         return node;
01043                     }
01044                 case ERROR:
01045                     throw new ParserException(last_token,
01046                         "[" + last_line + "," + last_pos + "] " +
01047                         errorMessages[errors[action[1]]]);
01048             }
01049         }
01050     }
01051     private Node pop()
01052     {
01053         return (Node) ((State) stack.previous()).node;
01054     }
01055     private void push(int state, Node node, boolean filter) throws ParserException, LexerException, IOException
01056     {
01057         this.node = node;
01058 
01059         if(filter)
01060         {
01061             filter();
01062         }
01063 
01064         if(!stack.hasNext())
01065         {
01066             stack.add(new State(state, this.node));
01067             return;
01068         }
01069 
01070         State s = (State) stack.next();
01071         s.state = state;
01072         s.node = this.node;
01073     }
01074     private int state()
01075     {
01076         State s = (State) stack.previous();
01077         stack.next();
01078         return s.state;
01079     }
01080 }

Generated at Thu Feb 7 06:51:32 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001