/* Generated By:JJTree&JavaCC: Do not edit this line. Parser.java */
package com.meidusa.amoeba.sqljep;
import java.math.BigDecimal;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import com.meidusa.amoeba.sqljep.function.*;
import com.meidusa.amoeba.sqljep.variable.*;
public abstract class Parser/*@bgen(jjtree)*/implements ParserTreeConstants, ParserConstants {/*@bgen(jjtree)*/
protected JJTParserState jjtree = new JJTParserState();
private final static String metachars = "tnrbf\\\"";
private final static String chars = "\t\n\r\b\f\\\"";
public Node[] parseStream(java.io.Reader stream)
throws ParseException {
ReInit(stream);
// Parse the expression, and return the
Node start = Start();
Node[] nodes = new Node[start.jjtGetNumChildren()];
for(int i=0;i<start.jjtGetNumChildren();i++)
{
nodes[i] = start.jjtGetChild(i);
}
return nodes;
}
public abstract PostfixCommandI getFunction(String name);
public abstract boolean containsKey(String key);
private List<String> errorList = new ArrayList<String>();
private Map<String,Integer> columnMapping;
private Map<String,Variable> variableMapping;
private List<String> declareList = new ArrayList<String>();
public List<String> getErrorList(){
return errorList;
}
public Variable getVariable(String iden){
if(variableMapping == null){
return null;
}else{
return variableMapping.get(iden);
}
}
public void setVariableMapping(Map<String,Variable> variableMapping){
this.variableMapping = variableMapping;
}
public void setColumnMapping(Map<String,Integer> columnMapping){
this.columnMapping = columnMapping;
}
public void addDeclareVar(String declare)
{
this.declareList.add(declare);
}
public boolean containsDeclareVar(String declare)
{
return declareList.contains(declare);
}
public int findColumn(String name){
if (columnMapping != null) {
Integer v = columnMapping.get(name);
if (v != null) {
return v;
}
}
return -1;
}
private void addToErrorList(String errorStr) {
errorList.add(errorStr);
}
/**
* Translate all escape sequences to characters. Inspired by Rob Millar's
* unescape() method in rcm.util.Str fron the Web Sphinx project.
*
* @param inputStr String containing escape characters.
* @return String with all escape sequences replaced.
*/
private static String replaceEscape(String inputStr) {
int len = inputStr.length();
int p = 0;
int i;
StringBuilder output = new StringBuilder();
while ((i = inputStr.indexOf('\\', p)) != -1) {
output.append(inputStr.substring(p, i));
if (i+1 == len) break;
// find metacharacter
char metac = inputStr.charAt(i+1);
// find the index of the metac
int k = metachars.indexOf(metac);
if (k == -1) {
// didn't find the metachar, leave sequence as found.
// This code should be unreachable if the parser
// is functioning properly because strings containing
// unknown escape characters should not be accepted.
output.append('\\');
output.append(metac);
} else {
// its corresponding true char
output.append(chars.charAt(k));
}
// skip over both escape character & metacharacter
p = i + 2;
}
// add the end of the input string to the output
if (p < len)
output.append(inputStr.substring(p));
return output.toString();
}
/***************************************************************
GRAMMAR START
***************************************************************/
final public ASTStart Start() throws ParseException {
/*@bgen(jjtree) Start */
ASTStart jjtn000 = new ASTStart(JJTSTART);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
if (jj_2_1(1)) {
VarExpression();
Expression();
jj_consume_token(0);
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
{if (true) return jjtn000;}
} else {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 0:
jj_consume_token(0);
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
{if (true) throw new ParseException("No expression entered");}
addToErrorList("No expression entered");
{if (true) return null;}
break;
default:
jj_la1[0] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
throw new Error("Missing return statement in function");
}
/****
Expression with boolean result
*/
final public void Expression() throws ParseException {
OrExpression();
}
final public void VarExpression() throws ParseException {
String identString = "";
label_1:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case VAR:
;
break;
default:
jj_la1[1] = jj_gen;
break label_1;
}
ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
boolean jjtc001 = true;
jjtree.openNodeScope(jjtn001);
try {
jj_consume_token(VAR);
identString = Identifier();
jj_consume_token(EQ);
OrExpression();
jj_consume_token(COMM);
jjtree.closeNodeScope(jjtn001, true);
jjtc001 = false;
jjtn001.setFunction(tokenImage[VAR], new Var(identString));
addDeclareVar(identString);
} catch (Throwable jjte001) {
if (jjtc001) {
jjtree.clearNodeScope(jjtn001);
jjtc001 = false;
} else {
jjtree.popNode();
}
if (jjte001 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte001;}
}
if (jjte001 instanceof ParseException) {
{if (true) throw (ParseException)jjte001;}
}
{if (true) throw (Error)jjte001;}
} finally {
if (jjtc001) {
jjtree.closeNodeScope(jjtn001, true);
}
}
}
}
final public void OrExpression() throws ParseException {
AndExpression();
label_2:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case OR:
;
break;
default:
jj_la1[2] = jj_gen;
break label_2;
}
ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
boolean jjtc001 = true;
jjtree.openNodeScope(jjtn001);
try {
jj_consume_token(OR);
AndExpression();
jjtree.closeNodeScope(jjtn001, 2);
jjtc001 = false;
jjtn001.setFunction(tokenImage[OR], new LogicalOR());
} catch (Throwable jjte001) {
if (jjtc001) {
jjtree.clearNodeScope(jjtn001);
jjtc001 = false;
} else {
jjtree.popNode();
}
if (jjte001 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte001;}
}
if (jjte001 instanceof ParseException) {
{if (true) throw (ParseException)jjte001;}
}
{if (true) throw (Error)jjte001;}
} finally {
if (jjtc001) {
jjtree.closeNodeScope(jjtn001, 2);
}
}
}
}
final public void AndExpression() throws ParseException {
EqualExpression();
label_3:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case AND:
;
break;
default:
jj_la1[3] = jj_gen;
break label_3;
}
ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
boolean jjtc001 = true;
jjtree.openNodeScope(jjtn001);
try {
jj_consume_token(AND);
EqualExpression();
jjtree.closeNodeScope(jjtn001, 2);
jjtc001 = false;
jjtn001.setFunction(tokenImage[AND], new LogicalAND());
} catch (Throwable jjte001) {
if (jjtc001) {
jjtree.clearNodeScope(jjtn001);
jjtc001 = false;
} else {
jjtree.popNode();
}
if (jjte001 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte001;}
}
if (jjte001 instanceof ParseException) {
{if (true) throw (ParseException)jjte001;}
}
{if (true) throw (Error)jjte001;}
} finally {
if (jjtc001) {
jjtree.closeNodeScope(jjtn001, 2);
}
}
}
}
final public void EqualExpression() throws ParseException {
RelationalExpression();
label_4:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case EQ:
case NE:
;
break;
default:
jj_la1[4] = jj_gen;
break label_4;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case NE:
ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
boolean jjtc001 = true;
jjtree.openNodeScope(jjtn001);
try {
jj_consume_token(NE);
RelationalExpression();
jjtree.closeNodeScope(jjtn001, 2);
jjtc001 = false;
jjtn001.setFunction(tokenImage[NE], new ComparativeNE());
} catch (Throwable jjte001) {
if (jjtc001) {
jjtree.clearNodeScope(jjtn001);
jjtc001 = false;
} else {
jjtree.popNode();
}
if (jjte001 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte001;}
}
if (jjte001 instanceof ParseException) {
{if (true) throw (ParseException)jjte001;}
}
{if (true) throw (Error)jjte001;}
} finally {
if (jjtc001) {
jjtree.closeNodeScope(jjtn001, 2);
}
}
break;
case EQ:
ASTFunNode jjtn002 = new ASTFunNode(JJTFUNNODE);
boolean jjtc002 = true;
jjtree.openNodeScope(jjtn002);
try {
jj_consume_token(EQ);
RelationalExpression();
jjtree.closeNodeScope(jjtn002, 2);
jjtc002 = false;
jjtn002.setFunction(tokenImage[EQ], new ComparativeEQ());
} catch (Throwable jjte002) {
if (jjtc002) {
jjtree.clearNodeScope(jjtn002);
jjtc002 = false;
} else {
jjtree.popNode();
}
if (jjte002 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte002;}
}
if (jjte002 instanceof ParseException) {
{if (true) throw (ParseException)jjte002;}
}
{if (true) throw (Error)jjte002;}
} finally {
if (jjtc002) {
jjtree.closeNodeScope(jjtn002, 2);
}
}
break;
default:
jj_la1[5] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
}
final public void RelationalExpression() throws ParseException {
PostfixExpression();
label_5:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case GT:
case LT:
case LE:
case GE:
;
break;
default:
jj_la1[6] = jj_gen;
break label_5;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case LT:
ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
boolean jjtc001 = true;
jjtree.openNodeScope(jjtn001);
try {
jj_consume_token(LT);
PostfixExpression();
jjtree.closeNodeScope(jjtn001, 2);
jjtc001 = false;
jjtn001.setFunction(tokenImage[LT], new ComparativeLT());
} catch (Throwable jjte001) {
if (jjtc001) {
jjtree.clearNodeScope(jjtn001);
jjtc001 = false;
} else {
jjtree.popNode();
}
if (jjte001 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte001;}
}
if (jjte001 instanceof ParseException) {
{if (true) throw (ParseException)jjte001;}
}
{if (true) throw (Error)jjte001;}
} finally {
if (jjtc001) {
jjtree.closeNodeScope(jjtn001, 2);
}
}
break;
case GT:
ASTFunNode jjtn002 = new ASTFunNode(JJTFUNNODE);
boolean jjtc002 = true;
jjtree.openNodeScope(jjtn002);
try {
jj_consume_token(GT);
PostfixExpression();
jjtree.closeNodeScope(jjtn002, 2);
jjtc002 = false;
jjtn002.setFunction(tokenImage[GT], new ComparativeGT());
} catch (Throwable jjte002) {
if (jjtc002) {
jjtree.clearNodeScope(jjtn002);
jjtc002 = false;
} else {
jjtree.popNode();
}
if (jjte002 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte002;}
}
if (jjte002 instanceof ParseException) {
{if (true) throw (ParseException)jjte002;}
}
{if (true) throw (Error)jjte002;}
} finally {
if (jjtc002) {
jjtree.closeNodeScope(jjtn002, 2);
}
}
break;
case LE:
ASTFunNode jjtn003 = new ASTFunNode(JJTFUNNODE);
boolean jjtc003 = true;
jjtree.openNodeScope(jjtn003);
try {
jj_consume_token(LE);
PostfixExpression();
jjtree.closeNodeScope(jjtn003, 2);
jjtc003 = false;
jjtn003.setFunction(tokenImage[LE], new ComparativeLE());
} catch (Throwable jjte003) {
if (jjtc003) {
jjtree.clearNodeScope(jjtn003);
jjtc003 = false;
} else {
jjtree.popNode();
}
if (jjte003 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte003;}
}
if (jjte003 instanceof ParseException) {
{if (true) throw (ParseException)jjte003;}
}
{if (true) throw (Error)jjte003;}
} finally {
if (jjtc003) {
jjtree.closeNodeScope(jjtn003, 2);
}
}
break;
case GE:
ASTFunNode jjtn004 = new ASTFunNode(JJTFUNNODE);
boolean jjtc004 = true;
jjtree.openNodeScope(jjtn004);
try {
jj_consume_token(GE);
PostfixExpression();
jjtree.closeNodeScope(jjtn004, 2);
jjtc004 = false;
jjtn004.setFunction(tokenImage[GE], new ComparativeGE());
} catch (Throwable jjte004) {
if (jjtc004) {
jjtree.clearNodeScope(jjtn004);
jjtc004 = false;
} else {
jjtree.popNode();
}
if (jjte004 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte004;}
}
if (jjte004 instanceof ParseException) {
{if (true) throw (ParseException)jjte004;}
}
{if (true) throw (Error)jjte004;}
} finally {
if (jjtc004) {
jjtree.closeNodeScope(jjtn004, 2);
}
}
break;
default:
jj_la1[7] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
}
final public void PostfixExpression() throws ParseException {
AdditiveExpression();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case IS_NULL:
case IS_NOT_NULL:
case IN:
case BETWEEN:
case LIKE:
case NOT_LIKE:
case IF:
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case IS_NOT_NULL:
ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
boolean jjtc001 = true;
jjtree.openNodeScope(jjtn001);
try {
jj_consume_token(IS_NOT_NULL);
jjtree.closeNodeScope(jjtn001, 1);
jjtc001 = false;
jjtn001.setFunction(tokenImage[IS_NOT_NULL], new ComparativeIsNotNull());
} finally {
if (jjtc001) {
jjtree.closeNodeScope(jjtn001, 1);
}
}
break;
case IS_NULL:
ASTFunNode jjtn002 = new ASTFunNode(JJTFUNNODE);
boolean jjtc002 = true;
jjtree.openNodeScope(jjtn002);
try {
jj_consume_token(IS_NULL);
jjtree.closeNodeScope(jjtn002, 1);
jjtc002 = false;
jjtn002.setFunction(tokenImage[IS_NULL], new ComparativeIsNull());
} finally {
if (jjtc002) {
jjtree.closeNodeScope(jjtn002, 1);
}
}
break;
case IN:
ASTFunNode jjtn003 = new ASTFunNode(JJTFUNNODE);
boolean jjtc003 = true;
jjtree.openNodeScope(jjtn003);
try {
jj_consume_token(IN);
Array();
jjtree.closeNodeScope(jjtn003, 2);
jjtc003 = false;
jjtn003.setFunction(tokenImage[IN], new In());
} catch (Throwable jjte003) {
if (jjtc003) {
jjtree.clearNodeScope(jjtn003);
jjtc003 = false;
} else {
jjtree.popNode();
}
if (jjte003 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte003;}
}
if (jjte003 instanceof ParseException) {
{if (true) throw (ParseException)jjte003;}
}
{if (true) throw (Error)jjte003;}
} finally {
if (jjtc003) {
jjtree.closeNodeScope(jjtn003, 2);
}
}
break;
case BETWEEN:
ASTFunNode jjtn004 = new ASTFunNode(JJTFUNNODE);
boolean jjtc004 = true;
jjtree.openNodeScope(jjtn004);
try {
jj_consume_token(BETWEEN);
AdditiveExpression();
jj_consume_token(AND);
AdditiveExpression();
jjtree.closeNodeScope(jjtn004, 3);
jjtc004 = false;
jjtn004.setFunction(tokenImage[BETWEEN], new Between());
} catch (Throwable jjte004) {
if (jjtc004) {
jjtree.clearNodeScope(jjtn004);
jjtc004 = false;
} else {
jjtree.popNode();
}
if (jjte004 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte004;}
}
if (jjte004 instanceof ParseException) {
{if (true) throw (ParseException)jjte004;}
}
{if (true) throw (Error)jjte004;}
} finally {
if (jjtc004) {
jjtree.closeNodeScope(jjtn004, 3);
}
}
break;
case LIKE:
ASTFunNode jjtn005 = new ASTFunNode(JJTFUNNODE);
boolean jjtc005 = true;
jjtree.openNodeScope(jjtn005);
try {
jj_consume_token(LIKE);
AdditiveExpression();
jjtree.closeNodeScope(jjtn005, 2);
jjtc005 = false;
jjtn005.setFunction(tokenImage[LIKE], new Like());
} catch (Throwable jjte005) {
if (jjtc005) {
jjtree.clearNodeScope(jjtn005);
jjtc005 = false;
} else {
jjtree.popNode();
}
if (jjte005 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte005;}
}
if (jjte005 instanceof ParseException) {
{if (true) throw (ParseException)jjte005;}
}
{if (true) throw (Error)jjte005;}
} finally {
if (jjtc005) {
jjtree.closeNodeScope(jjtn005, 2);
}
}
break;
case NOT_LIKE:
ASTFunNode jjtn006 = new ASTFunNode(JJTFUNNODE);
boolean jjtc006 = true;
jjtree.openNodeScope(jjtn006);
try {
jj_consume_token(NOT_LIKE);
AdditiveExpression();
jjtree.closeNodeScope(jjtn006, 2);
jjtc006 = false;
jjtn006.setFunction(tokenImage[NOT_LIKE], new NotLike());
} catch (Throwable jjte006) {
if (jjtc006) {
jjtree.clearNodeScope(jjtn006);
jjtc006 = false;
} else {
jjtree.popNode();
}
if (jjte006 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte006;}
}
if (jjte006 instanceof ParseException) {
{if (true) throw (ParseException)jjte006;}
}
{if (true) throw (Error)jjte006;}
} finally {
if (jjtc006) {
jjtree.closeNodeScope(jjtn006, 2);
}
}
break;
case IF:
ASTFunNode jjtn007 = new ASTFunNode(JJTFUNNODE);
boolean jjtc007 = true;
jjtree.openNodeScope(jjtn007);
try {
jj_consume_token(IF);
AdditiveExpression();
jj_consume_token(ELSE);
AdditiveExpression();
jjtree.closeNodeScope(jjtn007, 3);
jjtc007 = false;
jjtn007.setFunction(tokenImage[IF], new IfElse());
} catch (Throwable jjte007) {
if (jjtc007) {
jjtree.clearNodeScope(jjtn007);
jjtc007 = false;
} else {
jjtree.popNode();
}
if (jjte007 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte007;}
}
if (jjte007 instanceof ParseException) {
{if (true) throw (ParseException)jjte007;}
}
{if (true) throw (Error)jjte007;}
} finally {
if (jjtc007) {
jjtree.closeNodeScope(jjtn007, 3);
}
}
break;
default:
jj_la1[8] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
default:
jj_la1[9] = jj_gen;
;
}
}
final public void AdditiveExpression() throws ParseException {
MultiplicativeExpression();
label_6:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case CONCAT:
case PLUS:
case MINUS:
;
break;
default:
jj_la1[10] = jj_gen;
break label_6;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case CONCAT:
ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
boolean jjtc001 = true;
jjtree.openNodeScope(jjtn001);
try {
jj_consume_token(CONCAT);
MultiplicativeExpression();
jjtree.closeNodeScope(jjtn001, 2);
jjtc001 = false;
jjtn001.setFunction(tokenImage[CONCAT], new Concat());
} catch (Throwable jjte001) {
if (jjtc001) {
jjtree.clearNodeScope(jjtn001);
jjtc001 = false;
} else {
jjtree.popNode();
}
if (jjte001 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte001;}
}
if (jjte001 instanceof ParseException) {
{if (true) throw (ParseException)jjte001;}
}
{if (true) throw (Error)jjte001;}
} finally {
if (jjtc001) {
jjtree.closeNodeScope(jjtn001, 2);
}
}
break;
case PLUS:
ASTFunNode jjtn002 = new ASTFunNode(JJTFUNNODE);
boolean jjtc002 = true;
jjtree.openNodeScope(jjtn002);
try {
jj_consume_token(PLUS);
MultiplicativeExpression();
jjtree.closeNodeScope(jjtn002, 2);
jjtc002 = false;
jjtn002.setFunction(tokenImage[PLUS], new Add());
} catch (Throwable jjte002) {
if (jjtc002) {
jjtree.clearNodeScope(jjtn002);
jjtc002 = false;
} else {
jjtree.popNode();
}
if (jjte002 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte002;}
}
if (jjte002 instanceof ParseException) {
{if (true) throw (ParseException)jjte002;}
}
{if (true) throw (Error)jjte002;}
} finally {
if (jjtc002) {
jjtree.closeNodeScope(jjtn002, 2);
}
}
break;
case MINUS:
ASTFunNode jjtn003 = new ASTFunNode(JJTFUNNODE);
boolean jjtc003 = true;
jjtree.openNodeScope(jjtn003);
try {
jj_consume_token(MINUS);
MultiplicativeExpression();
jjtree.closeNodeScope(jjtn003, 2);
jjtc003 = false;
jjtn003.setFunction(tokenImage[MINUS], new Subtract());
} catch (Throwable jjte003) {
if (jjtc003) {
jjtree.clearNodeScope(jjtn003);
jjtc003 = false;
} else {
jjtree.popNode();
}
if (jjte003 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte003;}
}
if (jjte003 instanceof ParseException) {
{if (true) throw (ParseException)jjte003;}
}
{if (true) throw (Error)jjte003;}
} finally {
if (jjtc003) {
jjtree.closeNodeScope(jjtn003, 2);
}
}
break;
default:
jj_la1[11] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
}
final public void MultiplicativeExpression() throws ParseException {
UnaryExpression();
label_7:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case MUL:
case DIV:
case DIV2:
case MOD:
;
break;
default:
jj_la1[12] = jj_gen;
break label_7;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case MUL:
ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
boolean jjtc001 = true;
jjtree.openNodeScope(jjtn001);
try {
jj_consume_token(MUL);
UnaryExpression();
jjtree.closeNodeScope(jjtn001, 2);
jjtc001 = false;
jjtn001.setFunction(tokenImage[MUL], new Multiply());
} catch (Throwable jjte001) {
if (jjtc001) {
jjtree.clearNodeScope(jjtn001);
jjtc001 = false;
} else {
jjtree.popNode();
}
if (jjte001 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte001;}
}
if (jjte001 instanceof ParseException) {
{if (true) throw (ParseException)jjte001;}
}
{if (true) throw (Error)jjte001;}
} finally {
if (jjtc001) {
jjtree.closeNodeScope(jjtn001, 2);
}
}
break;
case DIV:
ASTFunNode jjtn002 = new ASTFunNode(JJTFUNNODE);
boolean jjtc002 = true;
jjtree.openNodeScope(jjtn002);
try {
jj_consume_token(DIV);
UnaryExpression();
jjtree.closeNodeScope(jjtn002, 2);
jjtc002 = false;
jjtn002.setFunction(tokenImage[DIV], new Divide());
} catch (Throwable jjte002) {
if (jjtc002) {
jjtree.clearNodeScope(jjtn002);
jjtc002 = false;
} else {
jjtree.popNode();
}
if (jjte002 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte002;}
}
if (jjte002 instanceof ParseException) {
{if (true) throw (ParseException)jjte002;}
}
{if (true) throw (Error)jjte002;}
} finally {
if (jjtc002) {
jjtree.closeNodeScope(jjtn002, 2);
}
}
break;
case DIV2:
ASTFunNode jjtn003 = new ASTFunNode(JJTFUNNODE);
boolean jjtc003 = true;
jjtree.openNodeScope(jjtn003);
try {
jj_consume_token(DIV2);
UnaryExpression();
jjtree.closeNodeScope(jjtn003, 2);
jjtc003 = false;
jjtn003.setFunction(tokenImage[DIV2], new Divide());
} catch (Throwable jjte003) {
if (jjtc003) {
jjtree.clearNodeScope(jjtn003);
jjtc003 = false;
} else {
jjtree.popNode();
}
if (jjte003 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte003;}
}
if (jjte003 instanceof ParseException) {
{if (true) throw (ParseException)jjte003;}
}
{if (true) throw (Error)jjte003;}
} finally {
if (jjtc003) {
jjtree.closeNodeScope(jjtn003, 2);
}
}
break;
case MOD:
ASTFunNode jjtn004 = new ASTFunNode(JJTFUNNODE);
boolean jjtc004 = true;
jjtree.openNodeScope(jjtn004);
try {
jj_consume_token(MOD);
UnaryExpression();
jjtree.closeNodeScope(jjtn004, 2);
jjtc004 = false;
jjtn004.setFunction(tokenImage[MOD], new Modulus());
} catch (Throwable jjte004) {
if (jjtc004) {
jjtree.clearNodeScope(jjtn004);
jjtc004 = false;
} else {
jjtree.popNode();
}
if (jjte004 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte004;}
}
if (jjte004 instanceof ParseException) {
{if (true) throw (ParseException)jjte004;}
}
{if (true) throw (Error)jjte004;}
} finally {
if (jjtc004) {
jjtree.closeNodeScope(jjtn004, 2);
}
}
break;
default:
jj_la1[13] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
}
final public void UnaryExpression() throws ParseException {
boolean caseHead = false;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case PLUS:
jj_consume_token(PLUS);
UnaryExpression();
break;
case MINUS:
ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
boolean jjtc001 = true;
jjtree.openNodeScope(jjtn001);
try {
jj_consume_token(MINUS);
UnaryExpression();
jjtree.closeNodeScope(jjtn001, 1);
jjtc001 = false;
jjtn001.setFunction(tokenImage[MINUS], new UMinus());
} catch (Throwable jjte001) {
if (jjtc001) {
jjtree.clearNodeScope(jjtn001);
jjtc001 = false;
} else {
jjtree.popNode();
}
if (jjte001 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte001;}
}
if (jjte001 instanceof ParseException) {
{if (true) throw (ParseException)jjte001;}
}
{if (true) throw (Error)jjte001;}
} finally {
if (jjtc001) {
jjtree.closeNodeScope(jjtn001, 1);
}
}
break;
case NOT:
ASTFunNode jjtn002 = new ASTFunNode(JJTFUNNODE);
boolean jjtc002 = true;
jjtree.openNodeScope(jjtn002);
try {
jj_consume_token(NOT);
UnaryExpression();
jjtree.closeNodeScope(jjtn002, 1);
jjtc002 = false;
jjtn002.setFunction(tokenImage[NOT], new LogicalNOT());
} catch (Throwable jjte002) {
if (jjtc002) {
jjtree.clearNodeScope(jjtn002);
jjtc002 = false;
} else {
jjtree.popNode();
}
if (jjte002 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte002;}
}
if (jjte002 instanceof ParseException) {
{if (true) throw (ParseException)jjte002;}
}
{if (true) throw (Error)jjte002;}
} finally {
if (jjtc002) {
jjtree.closeNodeScope(jjtn002, 1);
}
}
break;
case CASE:
ASTFunNode jjtn003 = new ASTFunNode(JJTFUNNODE);
boolean jjtc003 = true;
jjtree.openNodeScope(jjtn003);
try {
jj_consume_token(CASE);
if (jj_2_2(1)) {
Expression();
caseHead = true;
} else {
;
}
label_8:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case WHEN:
;
break;
default:
jj_la1[14] = jj_gen;
break label_8;
}
jj_consume_token(WHEN);
Expression();
jj_consume_token(THEN);
Expression();
jj_consume_token(COMM);
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ELSE:
jj_consume_token(ELSE);
Expression();
break;
default:
jj_la1[15] = jj_gen;
;
}
jj_consume_token(ENDCASE);
jj_consume_token(COMM);
jjtree.closeNodeScope(jjtn003, true);
jjtc003 = false;
jjtn003.setFunction(tokenImage[CASE], new Case(caseHead));
} catch (Throwable jjte003) {
if (jjtc003) {
jjtree.clearNodeScope(jjtn003);
jjtc003 = false;
} else {
jjtree.popNode();
}
if (jjte003 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte003;}
}
if (jjte003 instanceof ParseException) {
{if (true) throw (ParseException)jjte003;}
}
{if (true) throw (Error)jjte003;}
} finally {
if (jjtc003) {
jjtree.closeNodeScope(jjtn003, true);
}
}
break;
default:
jj_la1[16] = jj_gen;
if (jj_2_3(1)) {
UnaryExpressionNotPlusMinus();
} else {
jj_consume_token(-1);
throw new ParseException();
}
}
}
final public void UnaryExpressionNotPlusMinus() throws ParseException {
String identString = "";
int type;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case NULL_LITERAL:
case TRUE_LITERAL:
case FALSE_LITERAL:
case INTEGER_LITERAL:
case FLOATING_POINT_LITERAL:
case STRING_LITERAL:
AnyConstant();
break;
default:
jj_la1[18] = jj_gen;
if (jj_2_4(1)) {
if (getToken(1).kind == IDENTIFIER &&
containsKey(getToken(1).image)) {
Function();
} else {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case IDENTIFIER:
Variable();
break;
default:
jj_la1[17] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
} else {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 48:
jj_consume_token(48);
Expression();
jj_consume_token(49);
break;
default:
jj_la1[19] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
}
}
final public void Variable() throws ParseException {
String identString = "";
ASTVarNode jjtn001 = new ASTVarNode(JJTVARNODE);
boolean jjtc001 = true;
jjtree.openNodeScope(jjtn001);
try {
identString = Identifier();
jjtree.closeNodeScope(jjtn001, true);
jjtc001 = false;
Variable c = getVariable(identString);
if (c != null) {
jjtn001.index = -1;
jjtn001.variable = c;
jjtn001.ident = identString;
}
else {
int i = findColumn(identString);
if (i >= 0) {
jjtn001.index = i;
jjtn001.variable = null;
}
else if(this.containsDeclareVar(identString)){
jjtn001.index = -1;
jjtn001.variable = c;
jjtn001.ident = identString;
}else
{
addToErrorList("Unrecognized symbol \"" + identString +"\"");
}
}
} catch (Throwable jjte001) {
if (jjtc001) {
jjtree.clearNodeScope(jjtn001);
jjtc001 = false;
} else {
jjtree.popNode();
}
if (jjte001 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte001;}
}
if (jjte001 instanceof ParseException) {
{if (true) throw (ParseException)jjte001;}
}
{if (true) throw (Error)jjte001;}
} finally {
if (jjtc001) {
jjtree.closeNodeScope(jjtn001, true);
}
}
}
final public void Function() throws ParseException {
int reqArguments = 0;
String identString = "";
ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
boolean jjtc001 = true;
jjtree.openNodeScope(jjtn001);
try {
identString = Identifier();
PostfixCommandI func = getFunction(identString);
if (func != null) {
//Set number of required arguments
reqArguments = func.getNumberOfParameters();
jjtn001.setFunction(identString, func);
} else {
addToErrorList("!!! Unrecognized function \"" + identString +"\"");
}
jj_consume_token(48);
ArgumentList(reqArguments, identString);
jj_consume_token(49);
} catch (Throwable jjte001) {
if (jjtc001) {
jjtree.clearNodeScope(jjtn001);
jjtc001 = false;
} else {
jjtree.popNode();
}
if (jjte001 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte001;}
}
if (jjte001 instanceof ParseException) {
{if (true) throw (ParseException)jjte001;}
}
{if (true) throw (Error)jjte001;}
} finally {
if (jjtc001) {
jjtree.closeNodeScope(jjtn001, true);
}
}
}
final public void ArgumentList(int reqArguments, String functionName) throws ParseException {
int count = 0;
String errorStr = "";
if (jj_2_5(1)) {
Expression();
count++;
label_9:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 50:
;
break;
default:
jj_la1[20] = jj_gen;
break label_9;
}
jj_consume_token(50);
Expression();
count++;
}
} else {
;
}
if (reqArguments != count && reqArguments != -1) {
errorStr = "Function \"" + functionName +"\" requires "
+ reqArguments + " parameter";
if (reqArguments!=1) errorStr += "s";
addToErrorList(errorStr);
}
}
final public String Identifier() throws ParseException {
Token t;
t = jj_consume_token(IDENTIFIER);
if(t.image.startsWith("`")){
{if (true) return t.image.substring(1,t.image.length()-1);}
}else
{
{if (true) return t.image;}
}
throw new Error("Missing return statement in function");
}
final public void Array() throws ParseException {
/*@bgen(jjtree) Array */
ASTArray jjtn000 = new ASTArray(JJTARRAY);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
jj_consume_token(48);
AdditiveExpression();
label_10:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 50:
;
break;
default:
jj_la1[21] = jj_gen;
break label_10;
}
jj_consume_token(50);
AdditiveExpression();
}
jj_consume_token(49);
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
final public void AnyConstant() throws ParseException {
/*@bgen(jjtree) Constant */
ASTConstant jjtn000 = new ASTConstant(JJTCONSTANT);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);Token t;
try {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case NULL_LITERAL:
t = jj_consume_token(NULL_LITERAL);
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
jjtn000.value = null;
break;
case TRUE_LITERAL:
t = jj_consume_token(TRUE_LITERAL);
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
jjtn000.value = Boolean.TRUE;
break;
case FALSE_LITERAL:
t = jj_consume_token(FALSE_LITERAL);
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
jjtn000.value = Boolean.FALSE;
break;
case STRING_LITERAL:
t = jj_consume_token(STRING_LITERAL);
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
// strip away double quotes at end of string
String temp = (t.image).substring(1,t.image.length()-1);
// replace escape characters
temp = replaceEscape(temp);
jjtn000.value = temp;
break;
case INTEGER_LITERAL:
t = jj_consume_token(INTEGER_LITERAL);
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
try {
jjtn000.value = Long.valueOf(t.image);
}
catch (Exception e) {
jjtn000.value = null;
addToErrorList("Can't parse \"" + t.image + "\"");
}
break;
case FLOATING_POINT_LITERAL:
t = jj_consume_token(FLOATING_POINT_LITERAL);
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
try {
jjtn000.value = new BigDecimal(t.image);
}
catch (Exception e) {
jjtn000.value = null;
addToErrorList("Can't parse \"" + t.image + "\"");
}
break;
default:
jj_la1[22] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
private boolean jj_2_1(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_1(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(0, xla); }
}
private boolean jj_2_2(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_2(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(1, xla); }
}
private boolean jj_2_3(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_3(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(2, xla); }
}
private boolean jj_2_4(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_4(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(3, xla); }
}
private boolean jj_2_5(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_5(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(4, xla); }
}
private boolean jj_3R_28() {
if (jj_scan_token(FALSE_LITERAL)) return true;
return false;
}
private boolean jj_3R_33() {
if (jj_3R_34()) return true;
return false;
}
private boolean jj_3R_34() {
if (jj_3R_35()) return true;
return false;
}
private boolean jj_3R_27() {
if (jj_scan_token(TRUE_LITERAL)) return true;
return false;
}
private boolean jj_3_2() {
if (jj_3R_12()) return true;
return false;
}
private boolean jj_3R_26() {
if (jj_scan_token(NULL_LITERAL)) return true;
return false;
}
private boolean jj_3R_23() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_26()) {
jj_scanpos = xsp;
if (jj_3R_27()) {
jj_scanpos = xsp;
if (jj_3R_28()) {
jj_scanpos = xsp;
if (jj_3R_29()) {
jj_scanpos = xsp;
if (jj_3R_30()) {
jj_scanpos = xsp;
if (jj_3R_31()) return true;
}
}
}
}
}
return false;
}
private boolean jj_3_3() {
if (jj_3R_13()) return true;
return false;
}
private boolean jj_3R_25() {
if (jj_3R_32()) return true;
return false;
}
private boolean jj_3R_16() {
if (jj_scan_token(VAR)) return true;
return false;
}
private boolean jj_3_5() {
if (jj_3R_12()) return true;
return false;
}
private boolean jj_3R_40() {
if (jj_scan_token(CASE)) return true;
return false;
}
private boolean jj_3R_11() {
Token xsp;
while (true) {
xsp = jj_scanpos;
if (jj_3R_16()) { jj_scanpos = xsp; break; }
}
return false;
}
private boolean jj_3R_12() {
if (jj_3R_17()) return true;
return false;
}
private boolean jj_3R_35() {
if (jj_3R_36()) return true;
return false;
}
private boolean jj_3R_21() {
if (jj_3R_24()) return true;
return false;
}
private boolean jj_3R_22() {
if (jj_3R_25()) return true;
return false;
}
private boolean jj_3R_31() {
if (jj_scan_token(FLOATING_POINT_LITERAL)) return true;
return false;
}
private boolean jj_3R_15() {
if (jj_3R_21()) return true;
return false;
}
private boolean jj_3R_39() {
if (jj_scan_token(NOT)) return true;
return false;
}
private boolean jj_3_1() {
if (jj_3R_11()) return true;
if (jj_3R_12()) return true;
return false;
}
private boolean jj_3R_19() {
if (jj_scan_token(48)) return true;
return false;
}
private boolean jj_3R_38() {
if (jj_scan_token(MINUS)) return true;
return false;
}
private boolean jj_3R_30() {
if (jj_scan_token(INTEGER_LITERAL)) return true;
return false;
}
private boolean jj_3R_37() {
if (jj_scan_token(PLUS)) return true;
return false;
}
private boolean jj_3R_36() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_37()) {
jj_scanpos = xsp;
if (jj_3R_38()) {
jj_scanpos = xsp;
if (jj_3R_39()) {
jj_scanpos = xsp;
if (jj_3R_40()) {
jj_scanpos = xsp;
if (jj_3_3()) return true;
}
}
}
}
return false;
}
private boolean jj_3R_20() {
if (jj_3R_24()) return true;
return false;
}
private boolean jj_3R_14() {
if (jj_3R_20()) return true;
return false;
}
private boolean jj_3R_24() {
if (jj_scan_token(IDENTIFIER)) return true;
return false;
}
private boolean jj_3R_17() {
if (jj_3R_22()) return true;
return false;
}
private boolean jj_3_4() {
Token xsp;
xsp = jj_scanpos;
jj_lookingAhead = true;
jj_semLA = getToken(1).kind == IDENTIFIER &&
containsKey(getToken(1).image);
jj_lookingAhead = false;
if (!jj_semLA || jj_3R_14()) {
jj_scanpos = xsp;
if (jj_3R_15()) return true;
}
return false;
}
private boolean jj_3R_32() {
if (jj_3R_33()) return true;
return false;
}
private boolean jj_3R_13() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_18()) {
jj_scanpos = xsp;
if (jj_3_4()) {
jj_scanpos = xsp;
if (jj_3R_19()) return true;
}
}
return false;
}
private boolean jj_3R_18() {
if (jj_3R_23()) return true;
return false;
}
private boolean jj_3R_29() {
if (jj_scan_token(STRING_LITERAL)) return true;
return false;
}
/** Generated Token Manager. */
public ParserTokenManager token_source;
JavaCharStream jj_input_stream;
/** Current token. */
public Token token;
/** Next token. */
public Token jj_nt;
private int jj_ntk;
private Token jj_scanpos, jj_lastpos;
private int jj_la;
/** Whether we are looking ahead. */
private boolean jj_lookingAhead = false;
private boolean jj_semLA;
private int jj_gen;
final private int[] jj_la1 = new int[23];
static private int[] jj_la1_0;
static private int[] jj_la1_1;
static {
jj_la1_init_0();
jj_la1_init_1();
}
private static void jj_la1_init_0() {
jj_la1_0 = new int[] {0x1,0x10000000,0x100000,0x80000,0x48000,0x48000,0x36000,0x36000,0xfc00000,0xfc00000,0x1c0,0x1c0,0x1e00,0x1e00,0x40000000,0x0,0x20200180,0x0,0x0,0x0,0x0,0x0,0x0,};
}
private static void jj_la1_init_1() {
jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x2,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x1000,0xaf0,0x10000,0x40000,0x40000,0xaf0,};
}
final private JJCalls[] jj_2_rtns = new JJCalls[5];
private boolean jj_rescan = false;
private int jj_gc = 0;
/** Constructor with InputStream. */
public Parser(java.io.InputStream stream) {
this(stream, null);
}
/** Constructor with InputStream and supplied encoding */
public Parser(java.io.InputStream stream, String encoding) {
try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
token_source = new ParserTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 23; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
/** Reinitialise. */
public void ReInit(java.io.InputStream stream) {
ReInit(stream, null);
}
/** Reinitialise. */
public void ReInit(java.io.InputStream stream, String encoding) {
try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
token_source.ReInit(jj_input_stream);
token = new Token();
jj_ntk = -1;
jjtree.reset();
jj_gen = 0;
for (int i = 0; i < 23; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
/** Constructor. */
public Parser(java.io.Reader stream) {
jj_input_stream = new JavaCharStream(stream, 1, 1);
token_source = new ParserTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 23; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
/** Reinitialise. */
public void ReInit(java.io.Reader stream) {
jj_input_stream.ReInit(stream, 1, 1);
token_source.ReInit(jj_input_stream);
token = new Token();
jj_ntk = -1;
jjtree.reset();
jj_gen = 0;
for (int i = 0; i < 23; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
/** Constructor with generated Token Manager. */
public Parser(ParserTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 23; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
/** Reinitialise. */
public void ReInit(ParserTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jjtree.reset();
jj_gen = 0;
for (int i = 0; i < 23; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
private Token jj_consume_token(int kind) throws ParseException {
Token oldToken;
if ((oldToken = token).next != null) token = token.next;
else token = token.next = token_source.getNextToken();
jj_ntk = -1;
if (token.kind == kind) {
jj_gen++;
if (++jj_gc > 100) {
jj_gc = 0;
for (int i = 0; i < jj_2_rtns.length; i++) {
JJCalls c = jj_2_rtns[i];
while (c != null) {
if (c.gen < jj_gen) c.first = null;
c = c.next;
}
}
}
return token;
}
token = oldToken;
jj_kind = kind;
throw generateParseException();
}
static private final class LookaheadSuccess extends java.lang.Error { }
final private LookaheadSuccess jj_ls = new LookaheadSuccess();
private boolean jj_scan_token(int kind) {
if (jj_scanpos == jj_lastpos) {
jj_la--;
if (jj_scanpos.next == null) {
jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
} else {
jj_lastpos = jj_scanpos = jj_scanpos.next;
}
} else {
jj_scanpos = jj_scanpos.next;
}
if (jj_rescan) {
int i = 0; Token tok = token;
while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
if (tok != null) jj_add_error_token(kind, i);
}
if (jj_scanpos.kind != kind) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
return false;
}
/** Get the next Token. */
final public Token getNextToken() {
if (token.next != null) token = token.next;
else token = token.next = token_source.getNextToken();
jj_ntk = -1;
jj_gen++;
return token;
}
/** Get the specific Token. */
final public Token getToken(int index) {
Token t = jj_lookingAhead ? jj_scanpos : token;
for (int i = 0; i < index; i++) {
if (t.next != null) t = t.next;
else t = t.next = token_source.getNextToken();
}
return t;
}
private int jj_ntk() {
if ((jj_nt=token.next) == null)
return (jj_ntk = (token.next=token_source.getNextToken()).kind);
else
return (jj_ntk = jj_nt.kind);
}
private java.util.List jj_expentries = new java.util.ArrayList();
private int[] jj_expentry;
private int jj_kind = -1;
private int[] jj_lasttokens = new int[100];
private int jj_endpos;
private void jj_add_error_token(int kind, int pos) {
if (pos >= 100) return;
if (pos == jj_endpos + 1) {
jj_lasttokens[jj_endpos++] = kind;
} else if (jj_endpos != 0) {
jj_expentry = new int[jj_endpos];
for (int i = 0; i < jj_endpos; i++) {
jj_expentry[i] = jj_lasttokens[i];
}
jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) {
int[] oldentry = (int[])(it.next());
if (oldentry.length == jj_expentry.length) {
for (int i = 0; i < jj_expentry.length; i++) {
if (oldentry[i] != jj_expentry[i]) {
continue jj_entries_loop;
}
}
jj_expentries.add(jj_expentry);
break jj_entries_loop;
}
}
if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
}
}
/** Generate ParseException. */
public ParseException generateParseException() {
jj_expentries.clear();
boolean[] la1tokens = new boolean[51];
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
for (int i = 0; i < 23; i++) {
if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) {
if ((jj_la1_0[i] & (1<<j)) != 0) {
la1tokens[j] = true;
}
if ((jj_la1_1[i] & (1<<j)) != 0) {
la1tokens[32+j] = true;
}
}
}
}
for (int i = 0; i < 51; i++) {
if (la1tokens[i]) {
jj_expentry = new int[1];
jj_expentry[0] = i;
jj_expentries.add(jj_expentry);
}
}
jj_endpos = 0;
jj_rescan_token();
jj_add_error_token(0, 0);
int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) {
exptokseq[i] = (int[])jj_expentries.get(i);
}
return new ParseException(token, exptokseq, tokenImage);
}
/** Enable tracing. */
final public void enable_tracing() {
}
/** Disable tracing. */
final public void disable_tracing() {
}
private void jj_rescan_token() {
jj_rescan = true;
for (int i = 0; i < 5; i++) {
try {
JJCalls p = jj_2_rtns[i];
do {
if (p.gen > jj_gen) {
jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
switch (i) {
case 0: jj_3_1(); break;
case 1: jj_3_2(); break;
case 2: jj_3_3(); break;
case 3: jj_3_4(); break;
case 4: jj_3_5(); break;
}
}
p = p.next;
} while (p != null);
} catch(LookaheadSuccess ls) { }
}
jj_rescan = false;
}
private void jj_save(int index, int xla) {
JJCalls p = jj_2_rtns[index];
while (p.gen > jj_gen) {
if (p.next == null) { p = p.next = new JJCalls(); break; }
p = p.next;
}
p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
}
static final class JJCalls {
int gen;
Token first;
int arg;
JJCalls next;
}
}