00001
00002 package plp.functional1.parser;
00003
00004 import plp.functional1.*;
00005 import plp.functional1.declaration.DecVariavel;
00006 import plp.functional1.declaration.DeclaracaoFuncional;
00007 import plp.functional1.declaration.DecFuncao;
00008 import plp.functional1.expression.ExpDeclaracao;
00009 import plp.functional1.expression.IfThenElse;
00010 import plp.functional1.expression.Aplicacao;
00011 import java.util.*;
00012 import plp.expressions2.expression.ExpAnd;
00013 import plp.expressions2.expression.ExpConcat;
00014 import plp.expressions2.expression.ExpEquals;
00015 import plp.expressions2.expression.ExpLength;
00016 import plp.expressions2.expression.ExpMenos;
00017 import plp.expressions2.expression.ExpNot;
00018 import plp.expressions2.expression.ExpOr;
00019 import plp.expressions2.expression.ExpSoma;
00020 import plp.expressions2.expression.ExpSub;
00021 import plp.expressions2.expression.Expressao;
00022 import plp.expressions2.expression.Id;
00023 import plp.expressions2.expression.Valor;
00024 import plp.expressions2.expression.ValorBooleano;
00025 import plp.expressions2.expression.ValorInteiro;
00026 import plp.expressions2.expression.ValorString;
00027
00028
00029 public class Func1Parser implements Func1ParserConstants {
00030
00031 public static void main(String args[]) {
00032 Func1Parser parser;
00033 if (args.length == 0) {
00034 System.out.println("Funcional 1 PLP Parser Version 0.0.1: Reading from standard input . . .");
00035 parser = new Func1Parser(System.in);
00036 } else if (args.length == 1) {
00037 System.out.println("Funcional 1 PLP Parser Version 0.0.1: Reading from file " + args[0] + " . . .");
00038 try {
00039 parser = new Func1Parser(new java.io.FileInputStream(args[0]));
00040 } catch (java.io.FileNotFoundException e) {
00041 System.out.println("Funcional 1 PLP Parser Version 0.0.1: File " + args[0] + " not found.");
00042 return;
00043 }
00044 } else {
00045 System.out.println("Funcional 1 PLP Parser Version 0.0.1: Usage is one of:");
00046 System.out.println(" java Func1Parser < inputfile");
00047 System.out.println("OR");
00048 System.out.println(" java Func1Parser inputfile");
00049 return;
00050 }
00051 Programa programa = null;
00052 try {
00053 programa = parser.Input();
00054 System.out.println("Funcional 1 PLP Parser Version 0.0.1: Expressoes1 program parsed successfully.");
00055 } catch (ParseException e) {
00056 e.printStackTrace();
00057 System.out.println("Funcional 1 PLP Parser Version 0.0.1: Encountered errors during parse.");
00058 System.exit(0);
00059 }
00060 try {
00061 System.out.println("Funcional 1 PLP Parser Version 0.0.1: running...");
00062 Valor val = programa.executar();
00063 if (val instanceof ValorString) {
00064 ValorString valStr = (ValorString) val;
00065 System.out.println("Funcional 1 PLP Parser Version 0.0.1: resultado="+valStr.valor());
00066 } else if (val instanceof ValorInteiro) {
00067 ValorInteiro valInt = (ValorInteiro) val;
00068 System.out.println("Funcional 1 PLP Parser Version 0.0.1: resultado="+valInt.valor());
00069 } else if (val instanceof ValorBooleano) {
00070 ValorBooleano valBool = (ValorBooleano) val;
00071 System.out.println("Funcional 1 PLP Parser Version 0.0.1: resultado="+valBool.valor());
00072 }
00073 } catch (Exception e) {
00074 e.printStackTrace();
00075 System.out.println("Funcional 1 PLP Parser Version 0.0.1: Encountered errors during execution.");
00076 }
00077 }
00078
00079 static final public Programa Input() throws ParseException {
00080 Programa retorno;
00081 retorno = PPrograma();
00082 jj_consume_token(0);
00083 {if (true) return retorno;}
00084 throw new Error("Missing return statement in function");
00085 }
00086
00087 static final public Valor PValorInteiro() throws ParseException {
00088 Token token;
00089 token = jj_consume_token(INTEGER_LITERAL);
00090
00091 {if (true) return new ValorInteiro(Integer.parseInt(token.toString()));}
00092 throw new Error("Missing return statement in function");
00093 }
00094
00095 static final public Valor PValorBooleano() throws ParseException {
00096 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
00097 case FALSE:
00098 jj_consume_token(FALSE);
00099 {if (true) return new ValorBooleano(false);}
00100 break;
00101 case TRUE:
00102 jj_consume_token(TRUE);
00103 {if (true) return new ValorBooleano(true);}
00104 break;
00105 default:
00106 jj_la1[0] = jj_gen;
00107 jj_consume_token(-1);
00108 throw new ParseException();
00109 }
00110 throw new Error("Missing return statement in function");
00111 }
00112
00113 static final public Valor PValorString() throws ParseException {
00114 Token token;
00115 token = jj_consume_token(STRING_LITERAL);
00116
00117 String tokenStr = token.toString();
00118 tokenStr = tokenStr.substring(1,tokenStr.length()-1);
00119 {if (true) return new ValorString(tokenStr);}
00120 throw new Error("Missing return statement in function");
00121 }
00122
00123 static final public Valor PValor() throws ParseException {
00124 Valor retorno;
00125 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
00126 case INTEGER_LITERAL:
00127 retorno = PValorInteiro();
00128 break;
00129 case TRUE:
00130 case FALSE:
00131 retorno = PValorBooleano();
00132 break;
00133 case STRING_LITERAL:
00134 retorno = PValorString();
00135 break;
00136 default:
00137 jj_la1[1] = jj_gen;
00138 jj_consume_token(-1);
00139 throw new ParseException();
00140 }
00141 {if (true) return retorno;}
00142 throw new Error("Missing return statement in function");
00143 }
00144
00145 static final public Id PId() throws ParseException {
00146 Token token;
00147 token = jj_consume_token(IDENTIFIER);
00148
00149
00150 String tokenStr = token.toString();
00151
00152 {if (true) return new Id(tokenStr);}
00153 throw new Error("Missing return statement in function");
00154 }
00155
00156 static final public Expressao PExpMenos() throws ParseException {
00157 Expressao retorno;
00158 jj_consume_token(MINUS);
00159 retorno = PExpPrimaria();
00160 {if (true) return new ExpMenos(retorno);}
00161 throw new Error("Missing return statement in function");
00162 }
00163
00164 static final public Expressao PExpNot() throws ParseException {
00165 Expressao retorno;
00166 jj_consume_token(NOT);
00167 retorno = PExpPrimaria();
00168 {if (true) return new ExpNot(retorno);}
00169 throw new Error("Missing return statement in function");
00170 }
00171
00172 static final public Expressao PExpLength() throws ParseException {
00173 Expressao retorno;
00174 jj_consume_token(LENGTH);
00175 retorno = PExpPrimaria();
00176 if (retorno instanceof ValorString) {
00177 ValorString val = (ValorString) retorno;
00178
00179 }
00180
00181 {if (true) return new ExpLength(retorno);}
00182 throw new Error("Missing return statement in function");
00183 }
00184
00185 static final public Expressao PExpPrimaria() throws ParseException {
00186 Expressao retorno;
00187 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
00188 case TRUE:
00189 case FALSE:
00190 case INTEGER_LITERAL:
00191 case STRING_LITERAL:
00192 retorno = PValor();
00193 break;
00194 case IDENTIFIER:
00195 retorno = PId();
00196 break;
00197 case LPAREN:
00198 jj_consume_token(LPAREN);
00199 retorno = PExpressao();
00200 jj_consume_token(RPAREN);
00201 break;
00202 default:
00203 jj_la1[2] = jj_gen;
00204 jj_consume_token(-1);
00205 throw new ParseException();
00206 }
00207
00208 {if (true) return retorno;}
00209 throw new Error("Missing return statement in function");
00210 }
00211
00212 static final public List PListaId() throws ParseException {
00213 List<Id> retorno = null;
00214 Id id;
00215 label_1:
00216 while (true) {
00217 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
00218 case IDENTIFIER:
00219 ;
00220 break;
00221 default:
00222 jj_la1[3] = jj_gen;
00223 break label_1;
00224 }
00225 id = PId();
00226 if (retorno == null) {
00227 retorno = new ArrayList<Id>();
00228 retorno.add(id);
00229 } else {
00230 retorno.add(id);
00231 }
00232 }
00233 {if (true) return retorno;}
00234 throw new Error("Missing return statement in function");
00235 }
00236
00237 static final public DeclaracaoFuncional PDeclVar() throws ParseException {
00238 Id id;
00239 Expressao expressao;
00240 DeclaracaoFuncional retorno;
00241 jj_consume_token(VAR);
00242 id = PId();
00243 jj_consume_token(ASSIGN);
00244 expressao = PExpressao();
00245 {if (true) return new DecVariavel(id, expressao);}
00246 throw new Error("Missing return statement in function");
00247 }
00248
00249 static final public DeclaracaoFuncional PDeclFuncao() throws ParseException {
00250 Id id;
00251 Expressao expressao;
00252 DeclaracaoFuncional retorno;
00253 List<Id> lista;
00254 jj_consume_token(FUNC);
00255 id = PId();
00256 lista = PListaId();
00257 jj_consume_token(ASSIGN);
00258 expressao = PExpressao();
00259 {if (true) return new DecFuncao(id, lista, expressao);}
00260 throw new Error("Missing return statement in function");
00261 }
00262
00263 static final public List PDeclFuncional() throws ParseException {
00264 List retorno=null;
00265 DeclaracaoFuncional decl;
00266 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
00267 case VAR:
00268 decl = PDeclVar();
00269 break;
00270 case FUNC:
00271 decl = PDeclFuncao();
00272 break;
00273 default:
00274 jj_la1[4] = jj_gen;
00275 jj_consume_token(-1);
00276 throw new ParseException();
00277 }
00278 retorno = new ArrayList();
00279 retorno.add(decl);
00280 label_2:
00281 while (true) {
00282 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
00283 case COMMA:
00284 ;
00285 break;
00286 default:
00287 jj_la1[5] = jj_gen;
00288 break label_2;
00289 }
00290 if (jj_2_1(2147483647)) {
00291 jj_consume_token(COMMA);
00292 decl = PDeclVar();
00293 } else if (jj_2_2(2147483647)) {
00294 jj_consume_token(COMMA);
00295 decl = PDeclFuncao();
00296 } else {
00297 jj_consume_token(-1);
00298 throw new ParseException();
00299 }
00300 retorno.add(decl);
00301 }
00302 {if (true) return retorno;}
00303 throw new Error("Missing return statement in function");
00304 }
00305
00306 static final public Expressao PExpDeclaracao() throws ParseException {
00307 List declaracoes;
00308 Expressao expressao;
00309 jj_consume_token(LET);
00310 declaracoes = PDeclFuncional();
00311 jj_consume_token(IN);
00312 expressao = PExpressao();
00313 {if (true) return new ExpDeclaracao(declaracoes, expressao);}
00314 throw new Error("Missing return statement in function");
00315 }
00316
00317 static final public Expressao PExpCondicional() throws ParseException {
00318 Expressao expCond, expThen, expElse;
00319 jj_consume_token(IF);
00320 expCond = PExpressao();
00321 jj_consume_token(THEN);
00322 expThen = PExpressao();
00323 jj_consume_token(ELSE);
00324 expElse = PExpressao();
00325 {if (true) return new IfThenElse(expCond, expThen, expElse);}
00326 throw new Error("Missing return statement in function");
00327 }
00328
00329 static final public Expressao PAplicacao() throws ParseException {
00330 List expressoes = null;
00331 Expressao expressao;
00332 Id id;
00333 id = PId();
00334 jj_consume_token(LPAREN);
00335 expressao = PExpressao();
00336 expressoes = new ArrayList();
00337 expressoes.add(expressao);
00338 label_3:
00339 while (true) {
00340 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
00341 case COMMA:
00342 ;
00343 break;
00344 default:
00345 jj_la1[6] = jj_gen;
00346 break label_3;
00347 }
00348 jj_consume_token(COMMA);
00349 expressao = PExpressao();
00350 expressoes.add(expressao);
00351 }
00352 jj_consume_token(RPAREN);
00353 {if (true) return new Aplicacao(id, expressoes);}
00354 throw new Error("Missing return statement in function");
00355 }
00356
00357 static final public Expressao PExpUnaria() throws ParseException {
00358 Expressao retorno;
00359 if (jj_2_3(2147483647)) {
00360 retorno = PExpMenos();
00361 } else if (jj_2_4(2147483647)) {
00362 retorno = PExpNot();
00363 } else if (jj_2_5(2147483647)) {
00364 retorno = PExpLength();
00365 } else if (jj_2_6(2147483647)) {
00366 retorno = PExpDeclaracao();
00367 } else if (jj_2_7(2147483647)) {
00368 retorno = PExpCondicional();
00369 } else if (jj_2_8(2147483647)) {
00370 retorno = PAplicacao();
00371 } else if (jj_2_9(2147483647)) {
00372 retorno = PExpPrimaria();
00373 } else {
00374 jj_consume_token(-1);
00375 throw new ParseException();
00376 }
00377
00378 {if (true) return retorno;}
00379 throw new Error("Missing return statement in function");
00380 }
00381
00382 static final public Expressao PExpBinaria() throws ParseException {
00383 Expressao retorno, param2;
00384 retorno = PExpUnaria();
00385 label_4:
00386 while (true) {
00387 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
00388 case AND:
00389 case OR:
00390 case EQ:
00391 case CONCAT:
00392 case PLUS:
00393 case MINUS:
00394 ;
00395 break;
00396 default:
00397 jj_la1[7] = jj_gen;
00398 break label_4;
00399 }
00400 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
00401 case PLUS:
00402 jj_consume_token(PLUS);
00403 param2 = PExpUnaria();
00404 retorno = new ExpSoma(retorno, param2);
00405 break;
00406 case MINUS:
00407 jj_consume_token(MINUS);
00408 param2 = PExpUnaria();
00409 retorno = new ExpSub(retorno, param2);
00410 break;
00411 case AND:
00412 jj_consume_token(AND);
00413 param2 = PExpUnaria();
00414 retorno = new ExpAnd(retorno, param2);
00415 break;
00416 case OR:
00417 jj_consume_token(OR);
00418 param2 = PExpUnaria();
00419 retorno = new ExpOr(retorno, param2);
00420 break;
00421 case EQ:
00422 jj_consume_token(EQ);
00423 param2 = PExpUnaria();
00424 retorno = new ExpEquals(retorno, param2);
00425 break;
00426 case CONCAT:
00427 jj_consume_token(CONCAT);
00428 param2 = PExpUnaria();
00429 retorno = new ExpConcat(retorno, param2);
00430 break;
00431 default:
00432 jj_la1[8] = jj_gen;
00433 jj_consume_token(-1);
00434 throw new ParseException();
00435 }
00436 }
00437
00438 {if (true) return retorno;}
00439 throw new Error("Missing return statement in function");
00440 }
00441
00442 static final public Expressao PExpressao() throws ParseException {
00443 Expressao retorno;
00444 retorno = PExpBinaria();
00445 {if (true) return retorno;}
00446 throw new Error("Missing return statement in function");
00447 }
00448
00449 static final public Programa PPrograma() throws ParseException {
00450 Expressao retorno;
00451 retorno = PExpressao();
00452
00453 {if (true) return new Programa(retorno);}
00454 throw new Error("Missing return statement in function");
00455 }
00456
00457 static private boolean jj_2_1(int xla) {
00458 jj_la = xla; jj_lastpos = jj_scanpos = token;
00459 try { return !jj_3_1(); }
00460 catch(LookaheadSuccess ls) { return true; }
00461 finally { jj_save(0, xla); }
00462 }
00463
00464 static private boolean jj_2_2(int xla) {
00465 jj_la = xla; jj_lastpos = jj_scanpos = token;
00466 try { return !jj_3_2(); }
00467 catch(LookaheadSuccess ls) { return true; }
00468 finally { jj_save(1, xla); }
00469 }
00470
00471 static private boolean jj_2_3(int xla) {
00472 jj_la = xla; jj_lastpos = jj_scanpos = token;
00473 try { return !jj_3_3(); }
00474 catch(LookaheadSuccess ls) { return true; }
00475 finally { jj_save(2, xla); }
00476 }
00477
00478 static private boolean jj_2_4(int xla) {
00479 jj_la = xla; jj_lastpos = jj_scanpos = token;
00480 try { return !jj_3_4(); }
00481 catch(LookaheadSuccess ls) { return true; }
00482 finally { jj_save(3, xla); }
00483 }
00484
00485 static private boolean jj_2_5(int xla) {
00486 jj_la = xla; jj_lastpos = jj_scanpos = token;
00487 try { return !jj_3_5(); }
00488 catch(LookaheadSuccess ls) { return true; }
00489 finally { jj_save(4, xla); }
00490 }
00491
00492 static private boolean jj_2_6(int xla) {
00493 jj_la = xla; jj_lastpos = jj_scanpos = token;
00494 try { return !jj_3_6(); }
00495 catch(LookaheadSuccess ls) { return true; }
00496 finally { jj_save(5, xla); }
00497 }
00498
00499 static private boolean jj_2_7(int xla) {
00500 jj_la = xla; jj_lastpos = jj_scanpos = token;
00501 try { return !jj_3_7(); }
00502 catch(LookaheadSuccess ls) { return true; }
00503 finally { jj_save(6, xla); }
00504 }
00505
00506 static private boolean jj_2_8(int xla) {
00507 jj_la = xla; jj_lastpos = jj_scanpos = token;
00508 try { return !jj_3_8(); }
00509 catch(LookaheadSuccess ls) { return true; }
00510 finally { jj_save(7, xla); }
00511 }
00512
00513 static private boolean jj_2_9(int xla) {
00514 jj_la = xla; jj_lastpos = jj_scanpos = token;
00515 try { return !jj_3_9(); }
00516 catch(LookaheadSuccess ls) { return true; }
00517 finally { jj_save(8, xla); }
00518 }
00519
00520 static private boolean jj_3R_42() {
00521 if (jj_scan_token(OR)) return true;
00522 if (jj_3R_26()) return true;
00523 return false;
00524 }
00525
00526 static private boolean jj_3R_31() {
00527 Token xsp;
00528 while (true) {
00529 xsp = jj_scanpos;
00530 if (jj_3R_48()) { jj_scanpos = xsp; break; }
00531 }
00532 return false;
00533 }
00534
00535 static private boolean jj_3R_47() {
00536 if (jj_scan_token(STRING_LITERAL)) return true;
00537 return false;
00538 }
00539
00540 static private boolean jj_3R_41() {
00541 if (jj_scan_token(AND)) return true;
00542 if (jj_3R_26()) return true;
00543 return false;
00544 }
00545
00546 static private boolean jj_3R_8() {
00547 if (jj_scan_token(LET)) return true;
00548 if (jj_3R_12()) return true;
00549 if (jj_scan_token(IN)) return true;
00550 if (jj_3R_13()) return true;
00551 return false;
00552 }
00553
00554 static private boolean jj_3R_16() {
00555 if (jj_scan_token(LPAREN)) return true;
00556 if (jj_3R_13()) return true;
00557 if (jj_scan_token(RPAREN)) return true;
00558 return false;
00559 }
00560
00561 static private boolean jj_3R_51() {
00562 if (jj_scan_token(TRUE)) return true;
00563 return false;
00564 }
00565
00566 static private boolean jj_3R_50() {
00567 if (jj_scan_token(FALSE)) return true;
00568 return false;
00569 }
00570
00571 static private boolean jj_3R_46() {
00572 Token xsp;
00573 xsp = jj_scanpos;
00574 if (jj_3R_50()) {
00575 jj_scanpos = xsp;
00576 if (jj_3R_51()) return true;
00577 }
00578 return false;
00579 }
00580
00581 static private boolean jj_3R_40() {
00582 if (jj_scan_token(MINUS)) return true;
00583 if (jj_3R_26()) return true;
00584 return false;
00585 }
00586
00587 static private boolean jj_3R_15() {
00588 if (jj_3R_10()) return true;
00589 return false;
00590 }
00591
00592 static private boolean jj_3_2() {
00593 if (jj_scan_token(COMMA)) return true;
00594 if (jj_scan_token(FUNC)) return true;
00595 return false;
00596 }
00597
00598 static private boolean jj_3R_14() {
00599 if (jj_3R_21()) return true;
00600 return false;
00601 }
00602
00603 static private boolean jj_3_1() {
00604 if (jj_scan_token(COMMA)) return true;
00605 if (jj_scan_token(VAR)) return true;
00606 return false;
00607 }
00608
00609 static private boolean jj_3R_39() {
00610 if (jj_scan_token(PLUS)) return true;
00611 if (jj_3R_26()) return true;
00612 return false;
00613 }
00614
00615 static private boolean jj_3R_11() {
00616 Token xsp;
00617 xsp = jj_scanpos;
00618 if (jj_3R_14()) {
00619 jj_scanpos = xsp;
00620 if (jj_3R_15()) {
00621 jj_scanpos = xsp;
00622 if (jj_3R_16()) return true;
00623 }
00624 }
00625 return false;
00626 }
00627
00628 static private boolean jj_3R_27() {
00629 Token xsp;
00630 xsp = jj_scanpos;
00631 if (jj_3R_39()) {
00632 jj_scanpos = xsp;
00633 if (jj_3R_40()) {
00634 jj_scanpos = xsp;
00635 if (jj_3R_41()) {
00636 jj_scanpos = xsp;
00637 if (jj_3R_42()) {
00638 jj_scanpos = xsp;
00639 if (jj_3R_43()) {
00640 jj_scanpos = xsp;
00641 if (jj_3R_44()) return true;
00642 }
00643 }
00644 }
00645 }
00646 }
00647 return false;
00648 }
00649
00650 static private boolean jj_3R_20() {
00651 if (jj_3R_26()) return true;
00652 Token xsp;
00653 while (true) {
00654 xsp = jj_scanpos;
00655 if (jj_3R_27()) { jj_scanpos = xsp; break; }
00656 }
00657 return false;
00658 }
00659
00660 static private boolean jj_3R_25() {
00661 if (jj_scan_token(COMMA)) return true;
00662 if (jj_3R_23()) return true;
00663 return false;
00664 }
00665
00666 static private boolean jj_3_9() {
00667 if (jj_3R_11()) return true;
00668 return false;
00669 }
00670
00671 static private boolean jj_3R_45() {
00672 if (jj_scan_token(INTEGER_LITERAL)) return true;
00673 return false;
00674 }
00675
00676 static private boolean jj_3R_24() {
00677 if (jj_scan_token(COMMA)) return true;
00678 if (jj_3R_22()) return true;
00679 return false;
00680 }
00681
00682 static private boolean jj_3_8() {
00683 if (jj_3R_10()) return true;
00684 if (jj_scan_token(LPAREN)) return true;
00685 return false;
00686 }
00687
00688 static private boolean jj_3R_19() {
00689 Token xsp;
00690 xsp = jj_scanpos;
00691 if (jj_3R_24()) {
00692 jj_scanpos = xsp;
00693 if (jj_3R_25()) return true;
00694 }
00695 return false;
00696 }
00697
00698 static private boolean jj_3_7() {
00699 if (jj_3R_9()) return true;
00700 return false;
00701 }
00702
00703 static private boolean jj_3_6() {
00704 if (jj_3R_8()) return true;
00705 return false;
00706 }
00707
00708 static private boolean jj_3R_7() {
00709 if (jj_scan_token(LENGTH)) return true;
00710 if (jj_3R_11()) return true;
00711 return false;
00712 }
00713
00714 static private boolean jj_3R_38() {
00715 if (jj_3R_11()) return true;
00716 return false;
00717 }
00718
00719 static private boolean jj_3R_18() {
00720 if (jj_3R_23()) return true;
00721 return false;
00722 }
00723
00724 static private boolean jj_3_5() {
00725 if (jj_3R_7()) return true;
00726 return false;
00727 }
00728
00729 static private boolean jj_3R_17() {
00730 if (jj_3R_22()) return true;
00731 return false;
00732 }
00733
00734 static private boolean jj_3R_37() {
00735 if (jj_3R_49()) return true;
00736 return false;
00737 }
00738
00739 static private boolean jj_3_4() {
00740 if (jj_3R_6()) return true;
00741 return false;
00742 }
00743
00744 static private boolean jj_3R_12() {
00745 Token xsp;
00746 xsp = jj_scanpos;
00747 if (jj_3R_17()) {
00748 jj_scanpos = xsp;
00749 if (jj_3R_18()) return true;
00750 }
00751 while (true) {
00752 xsp = jj_scanpos;
00753 if (jj_3R_19()) { jj_scanpos = xsp; break; }
00754 }
00755 return false;
00756 }
00757
00758 static private boolean jj_3R_36() {
00759 if (jj_3R_9()) return true;
00760 return false;
00761 }
00762
00763 static private boolean jj_3_3() {
00764 if (jj_3R_5()) return true;
00765 return false;
00766 }
00767
00768 static private boolean jj_3R_35() {
00769 if (jj_3R_8()) return true;
00770 return false;
00771 }
00772
00773 static private boolean jj_3R_6() {
00774 if (jj_scan_token(NOT)) return true;
00775 if (jj_3R_11()) return true;
00776 return false;
00777 }
00778
00779 static private boolean jj_3R_34() {
00780 if (jj_3R_7()) return true;
00781 return false;
00782 }
00783
00784 static private boolean jj_3R_33() {
00785 if (jj_3R_6()) return true;
00786 return false;
00787 }
00788
00789 static private boolean jj_3R_32() {
00790 if (jj_3R_5()) return true;
00791 return false;
00792 }
00793
00794 static private boolean jj_3R_23() {
00795 if (jj_scan_token(FUNC)) return true;
00796 if (jj_3R_10()) return true;
00797 if (jj_3R_31()) return true;
00798 if (jj_scan_token(ASSIGN)) return true;
00799 if (jj_3R_13()) return true;
00800 return false;
00801 }
00802
00803 static private boolean jj_3R_5() {
00804 if (jj_scan_token(MINUS)) return true;
00805 if (jj_3R_11()) return true;
00806 return false;
00807 }
00808
00809 static private boolean jj_3R_26() {
00810 Token xsp;
00811 xsp = jj_scanpos;
00812 if (jj_3R_32()) {
00813 jj_scanpos = xsp;
00814 if (jj_3R_33()) {
00815 jj_scanpos = xsp;
00816 if (jj_3R_34()) {
00817 jj_scanpos = xsp;
00818 if (jj_3R_35()) {
00819 jj_scanpos = xsp;
00820 if (jj_3R_36()) {
00821 jj_scanpos = xsp;
00822 if (jj_3R_37()) {
00823 jj_scanpos = xsp;
00824 if (jj_3R_38()) return true;
00825 }
00826 }
00827 }
00828 }
00829 }
00830 }
00831 return false;
00832 }
00833
00834 static private boolean jj_3R_22() {
00835 if (jj_scan_token(VAR)) return true;
00836 if (jj_3R_10()) return true;
00837 if (jj_scan_token(ASSIGN)) return true;
00838 if (jj_3R_13()) return true;
00839 return false;
00840 }
00841
00842 static private boolean jj_3R_10() {
00843 if (jj_scan_token(IDENTIFIER)) return true;
00844 return false;
00845 }
00846
00847 static private boolean jj_3R_52() {
00848 if (jj_scan_token(COMMA)) return true;
00849 if (jj_3R_13()) return true;
00850 return false;
00851 }
00852
00853 static private boolean jj_3R_13() {
00854 if (jj_3R_20()) return true;
00855 return false;
00856 }
00857
00858 static private boolean jj_3R_49() {
00859 if (jj_3R_10()) return true;
00860 if (jj_scan_token(LPAREN)) return true;
00861 if (jj_3R_13()) return true;
00862 Token xsp;
00863 while (true) {
00864 xsp = jj_scanpos;
00865 if (jj_3R_52()) { jj_scanpos = xsp; break; }
00866 }
00867 if (jj_scan_token(RPAREN)) return true;
00868 return false;
00869 }
00870
00871 static private boolean jj_3R_30() {
00872 if (jj_3R_47()) return true;
00873 return false;
00874 }
00875
00876 static private boolean jj_3R_29() {
00877 if (jj_3R_46()) return true;
00878 return false;
00879 }
00880
00881 static private boolean jj_3R_28() {
00882 if (jj_3R_45()) return true;
00883 return false;
00884 }
00885
00886 static private boolean jj_3R_21() {
00887 Token xsp;
00888 xsp = jj_scanpos;
00889 if (jj_3R_28()) {
00890 jj_scanpos = xsp;
00891 if (jj_3R_29()) {
00892 jj_scanpos = xsp;
00893 if (jj_3R_30()) return true;
00894 }
00895 }
00896 return false;
00897 }
00898
00899 static private boolean jj_3R_44() {
00900 if (jj_scan_token(CONCAT)) return true;
00901 if (jj_3R_26()) return true;
00902 return false;
00903 }
00904
00905 static private boolean jj_3R_9() {
00906 if (jj_scan_token(IF)) return true;
00907 if (jj_3R_13()) return true;
00908 if (jj_scan_token(THEN)) return true;
00909 if (jj_3R_13()) return true;
00910 if (jj_scan_token(ELSE)) return true;
00911 if (jj_3R_13()) return true;
00912 return false;
00913 }
00914
00915 static private boolean jj_3R_43() {
00916 if (jj_scan_token(EQ)) return true;
00917 if (jj_3R_26()) return true;
00918 return false;
00919 }
00920
00921 static private boolean jj_3R_48() {
00922 if (jj_3R_10()) return true;
00923 return false;
00924 }
00925
00926 static private boolean jj_initialized_once = false;
00928 static public Func1ParserTokenManager token_source;
00929 static JavaCharStream jj_input_stream;
00931 static public Token token;
00933 static public Token jj_nt;
00934 static private int jj_ntk;
00935 static private Token jj_scanpos, jj_lastpos;
00936 static private int jj_la;
00937 static private int jj_gen;
00938 static final private int[] jj_la1 = new int[9];
00939 static private int[] jj_la1_0;
00940 static private int[] jj_la1_1;
00941 static {
00942 jj_la1_init_0();
00943 jj_la1_init_1();
00944 }
00945 private static void jj_la1_init_0() {
00946 jj_la1_0 = new int[] {0x6000,0x4406000,0x4c406000,0x8000000,0x210000,0x0,0x0,0x600,0x600,};
00947 }
00948 private static void jj_la1_init_1() {
00949 jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x20,0x20,0x704000,0x704000,};
00950 }
00951 static final private JJCalls[] jj_2_rtns = new JJCalls[9];
00952 static private boolean jj_rescan = false;
00953 static private int jj_gc = 0;
00954
00956 public Func1Parser(java.io.InputStream stream) {
00957 this(stream, null);
00958 }
00960 public Func1Parser(java.io.InputStream stream, String encoding) {
00961 if (jj_initialized_once) {
00962 System.out.println("ERROR: Second call to constructor of static parser. ");
00963 System.out.println(" You must either use ReInit() or set the JavaCC option STATIC to false");
00964 System.out.println(" during parser generation.");
00965 throw new Error();
00966 }
00967 jj_initialized_once = true;
00968 try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
00969 token_source = new Func1ParserTokenManager(jj_input_stream);
00970 token = new Token();
00971 jj_ntk = -1;
00972 jj_gen = 0;
00973 for (int i = 0; i < 9; i++) jj_la1[i] = -1;
00974 for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
00975 }
00976
00978 static public void ReInit(java.io.InputStream stream) {
00979 ReInit(stream, null);
00980 }
00982 static public void ReInit(java.io.InputStream stream, String encoding) {
00983 try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
00984 token_source.ReInit(jj_input_stream);
00985 token = new Token();
00986 jj_ntk = -1;
00987 jj_gen = 0;
00988 for (int i = 0; i < 9; i++) jj_la1[i] = -1;
00989 for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
00990 }
00991
00993 public Func1Parser(java.io.Reader stream) {
00994 if (jj_initialized_once) {
00995 System.out.println("ERROR: Second call to constructor of static parser. ");
00996 System.out.println(" You must either use ReInit() or set the JavaCC option STATIC to false");
00997 System.out.println(" during parser generation.");
00998 throw new Error();
00999 }
01000 jj_initialized_once = true;
01001 jj_input_stream = new JavaCharStream(stream, 1, 1);
01002 token_source = new Func1ParserTokenManager(jj_input_stream);
01003 token = new Token();
01004 jj_ntk = -1;
01005 jj_gen = 0;
01006 for (int i = 0; i < 9; i++) jj_la1[i] = -1;
01007 for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
01008 }
01009
01011 static public void ReInit(java.io.Reader stream) {
01012 jj_input_stream.ReInit(stream, 1, 1);
01013 token_source.ReInit(jj_input_stream);
01014 token = new Token();
01015 jj_ntk = -1;
01016 jj_gen = 0;
01017 for (int i = 0; i < 9; i++) jj_la1[i] = -1;
01018 for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
01019 }
01020
01022 public Func1Parser(Func1ParserTokenManager tm) {
01023 if (jj_initialized_once) {
01024 System.out.println("ERROR: Second call to constructor of static parser. ");
01025 System.out.println(" You must either use ReInit() or set the JavaCC option STATIC to false");
01026 System.out.println(" during parser generation.");
01027 throw new Error();
01028 }
01029 jj_initialized_once = true;
01030 token_source = tm;
01031 token = new Token();
01032 jj_ntk = -1;
01033 jj_gen = 0;
01034 for (int i = 0; i < 9; i++) jj_la1[i] = -1;
01035 for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
01036 }
01037
01039 public void ReInit(Func1ParserTokenManager tm) {
01040 token_source = tm;
01041 token = new Token();
01042 jj_ntk = -1;
01043 jj_gen = 0;
01044 for (int i = 0; i < 9; i++) jj_la1[i] = -1;
01045 for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
01046 }
01047
01048 static private Token jj_consume_token(int kind) throws ParseException {
01049 Token oldToken;
01050 if ((oldToken = token).next != null) token = token.next;
01051 else token = token.next = token_source.getNextToken();
01052 jj_ntk = -1;
01053 if (token.kind == kind) {
01054 jj_gen++;
01055 if (++jj_gc > 100) {
01056 jj_gc = 0;
01057 for (int i = 0; i < jj_2_rtns.length; i++) {
01058 JJCalls c = jj_2_rtns[i];
01059 while (c != null) {
01060 if (c.gen < jj_gen) c.first = null;
01061 c = c.next;
01062 }
01063 }
01064 }
01065 return token;
01066 }
01067 token = oldToken;
01068 jj_kind = kind;
01069 throw generateParseException();
01070 }
01071
01072 static private final class LookaheadSuccess extends java.lang.Error { }
01073 static final private LookaheadSuccess jj_ls = new LookaheadSuccess();
01074 static private boolean jj_scan_token(int kind) {
01075 if (jj_scanpos == jj_lastpos) {
01076 jj_la--;
01077 if (jj_scanpos.next == null) {
01078 jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
01079 } else {
01080 jj_lastpos = jj_scanpos = jj_scanpos.next;
01081 }
01082 } else {
01083 jj_scanpos = jj_scanpos.next;
01084 }
01085 if (jj_rescan) {
01086 int i = 0; Token tok = token;
01087 while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
01088 if (tok != null) jj_add_error_token(kind, i);
01089 }
01090 if (jj_scanpos.kind != kind) return true;
01091 if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
01092 return false;
01093 }
01094
01095
01097 static final public Token getNextToken() {
01098 if (token.next != null) token = token.next;
01099 else token = token.next = token_source.getNextToken();
01100 jj_ntk = -1;
01101 jj_gen++;
01102 return token;
01103 }
01104
01106 static final public Token getToken(int index) {
01107 Token t = token;
01108 for (int i = 0; i < index; i++) {
01109 if (t.next != null) t = t.next;
01110 else t = t.next = token_source.getNextToken();
01111 }
01112 return t;
01113 }
01114
01115 static private int jj_ntk() {
01116 if ((jj_nt=token.next) == null)
01117 return (jj_ntk = (token.next=token_source.getNextToken()).kind);
01118 else
01119 return (jj_ntk = jj_nt.kind);
01120 }
01121
01122 static private java.util.List jj_expentries = new java.util.ArrayList();
01123 static private int[] jj_expentry;
01124 static private int jj_kind = -1;
01125 static private int[] jj_lasttokens = new int[100];
01126 static private int jj_endpos;
01127
01128 static private void jj_add_error_token(int kind, int pos) {
01129 if (pos >= 100) return;
01130 if (pos == jj_endpos + 1) {
01131 jj_lasttokens[jj_endpos++] = kind;
01132 } else if (jj_endpos != 0) {
01133 jj_expentry = new int[jj_endpos];
01134 for (int i = 0; i < jj_endpos; i++) {
01135 jj_expentry[i] = jj_lasttokens[i];
01136 }
01137 jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) {
01138 int[] oldentry = (int[])(it.next());
01139 if (oldentry.length == jj_expentry.length) {
01140 for (int i = 0; i < jj_expentry.length; i++) {
01141 if (oldentry[i] != jj_expentry[i]) {
01142 continue jj_entries_loop;
01143 }
01144 }
01145 jj_expentries.add(jj_expentry);
01146 break jj_entries_loop;
01147 }
01148 }
01149 if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
01150 }
01151 }
01152
01154 static public ParseException generateParseException() {
01155 jj_expentries.clear();
01156 boolean[] la1tokens = new boolean[61];
01157 if (jj_kind >= 0) {
01158 la1tokens[jj_kind] = true;
01159 jj_kind = -1;
01160 }
01161 for (int i = 0; i < 9; i++) {
01162 if (jj_la1[i] == jj_gen) {
01163 for (int j = 0; j < 32; j++) {
01164 if ((jj_la1_0[i] & (1<<j)) != 0) {
01165 la1tokens[j] = true;
01166 }
01167 if ((jj_la1_1[i] & (1<<j)) != 0) {
01168 la1tokens[32+j] = true;
01169 }
01170 }
01171 }
01172 }
01173 for (int i = 0; i < 61; i++) {
01174 if (la1tokens[i]) {
01175 jj_expentry = new int[1];
01176 jj_expentry[0] = i;
01177 jj_expentries.add(jj_expentry);
01178 }
01179 }
01180 jj_endpos = 0;
01181 jj_rescan_token();
01182 jj_add_error_token(0, 0);
01183 int[][] exptokseq = new int[jj_expentries.size()][];
01184 for (int i = 0; i < jj_expentries.size(); i++) {
01185 exptokseq[i] = (int[])jj_expentries.get(i);
01186 }
01187 return new ParseException(token, exptokseq, tokenImage);
01188 }
01189
01191 static final public void enable_tracing() {
01192 }
01193
01195 static final public void disable_tracing() {
01196 }
01197
01198 static private void jj_rescan_token() {
01199 jj_rescan = true;
01200 for (int i = 0; i < 9; i++) {
01201 try {
01202 JJCalls p = jj_2_rtns[i];
01203 do {
01204 if (p.gen > jj_gen) {
01205 jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
01206 switch (i) {
01207 case 0: jj_3_1(); break;
01208 case 1: jj_3_2(); break;
01209 case 2: jj_3_3(); break;
01210 case 3: jj_3_4(); break;
01211 case 4: jj_3_5(); break;
01212 case 5: jj_3_6(); break;
01213 case 6: jj_3_7(); break;
01214 case 7: jj_3_8(); break;
01215 case 8: jj_3_9(); break;
01216 }
01217 }
01218 p = p.next;
01219 } while (p != null);
01220 } catch(LookaheadSuccess ls) { }
01221 }
01222 jj_rescan = false;
01223 }
01224
01225 static private void jj_save(int index, int xla) {
01226 JJCalls p = jj_2_rtns[index];
01227 while (p.gen > jj_gen) {
01228 if (p.next == null) { p = p.next = new JJCalls(); break; }
01229 p = p.next;
01230 }
01231 p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
01232 }
01233
01234 static final class JJCalls {
01235 int gen;
01236 Token first;
01237 int arg;
01238 JJCalls next;
01239 }
01240
01241 }