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