| /* Generated By:JavaCC: Do not edit this line. LuaParser.java */ |
| package org.luaj.vm3.parser; |
| import org.luaj.vm3.*; |
| import org.luaj.vm3.ast.*; |
| import java.util.*; |
| |
| public class LuaParser implements LuaParserConstants { |
| static { |
| LuaValue.valueOf(true); |
| } |
| |
| public static void main(String args[]) throws ParseException { |
| LuaParser parser = new LuaParser(System.in); |
| parser.Chunk(); |
| } |
| |
| private static Exp.VarExp assertvarexp(Exp.PrimaryExp pe) throws ParseException { |
| if (!pe.isvarexp()) |
| throw new ParseException("expected variable"); |
| return (Exp.VarExp) pe; |
| } |
| |
| private static Exp.FuncCall assertfunccall(Exp.PrimaryExp pe) throws ParseException { |
| if (!pe.isfunccall()) |
| throw new ParseException("expected function call"); |
| return (Exp.FuncCall) pe; |
| } |
| |
| public SimpleCharStream getCharStream() { |
| return jj_input_stream; |
| } |
| |
| private long LineInfo() { |
| return ((long) jj_input_stream.getBeginLine() << 32) | jj_input_stream.getBeginColumn(); |
| } |
| |
| private void L(SyntaxElement e, long startinfo) { |
| e.beginLine = (int) (startinfo >> 32); |
| e.beginColumn = (short) startinfo; |
| e.endLine = token.endLine; |
| e.endColumn = (short) token.endColumn; |
| } |
| |
| private void L(SyntaxElement e, Token starttoken) { |
| e.beginLine = starttoken.beginLine; |
| e.beginColumn = (short) starttoken.beginColumn; |
| e.endLine = token.endLine; |
| e.endColumn = (short) token.endColumn; |
| } |
| |
| /** Root production. */ |
| final public Chunk Chunk() throws ParseException { |
| Block b; |
| Chunk c; |
| long i = LineInfo(); |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case 69: |
| jj_consume_token(69); |
| token_source.SwitchTo(IN_COMMENT); |
| break; |
| default: |
| jj_la1[0] = jj_gen; |
| ; |
| } |
| b = Block(); |
| jj_consume_token(0); |
| c=new Chunk(b); L(c,i); {if (true) return c;} |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public Block Block() throws ParseException { |
| Block b = new Block(); |
| Stat s; |
| long i = LineInfo(); |
| label_1: |
| while (true) { |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case BREAK: |
| case DO: |
| case FOR: |
| case FUNCTION: |
| case GOTO: |
| case IF: |
| case LOCAL: |
| case REPEAT: |
| case WHILE: |
| case NAME: |
| case DBCOLON: |
| case 70: |
| case 75: |
| ; |
| break; |
| default: |
| jj_la1[1] = jj_gen; |
| break label_1; |
| } |
| s = Stat(); |
| b.add(s); |
| } |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case RETURN: |
| s = ReturnStat(); |
| b.add(s); |
| break; |
| default: |
| jj_la1[2] = jj_gen; |
| ; |
| } |
| L(b,i); {if (true) return b;} |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public Stat Stat() throws ParseException { |
| Block b,b2; |
| Exp e,e2,e3=null; |
| Stat s; |
| FuncName fn; |
| FuncBody fb; |
| Token n; |
| List<Name> nl; |
| List<Exp> el=null; |
| long i = LineInfo(); |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case 70: |
| jj_consume_token(70); |
| {if (true) return null;} |
| break; |
| case DBCOLON: |
| s = Label(); |
| L(s,i); {if (true) return s;} |
| break; |
| case BREAK: |
| jj_consume_token(BREAK); |
| s=Stat.breakstat(); L(s,i); {if (true) return s;} |
| break; |
| case GOTO: |
| jj_consume_token(GOTO); |
| n = jj_consume_token(NAME); |
| s=Stat.gotostat(n.image); L(s,i); {if (true) return s;} |
| break; |
| case DO: |
| jj_consume_token(DO); |
| b = Block(); |
| jj_consume_token(END); |
| s=Stat.block(b); L(s,i); {if (true) return s;} |
| break; |
| case WHILE: |
| jj_consume_token(WHILE); |
| e = Exp(); |
| jj_consume_token(DO); |
| b = Block(); |
| jj_consume_token(END); |
| s=Stat.whiledo(e,b); L(s,i); {if (true) return s;} |
| break; |
| case REPEAT: |
| jj_consume_token(REPEAT); |
| b = Block(); |
| jj_consume_token(UNTIL); |
| e = Exp(); |
| s=Stat.repeatuntil(b,e); L(s,i); {if (true) return s;} |
| break; |
| case IF: |
| s = IfThenElse(); |
| L(s,i); {if (true) return s;} |
| break; |
| default: |
| jj_la1[5] = jj_gen; |
| if (jj_2_1(3)) { |
| jj_consume_token(FOR); |
| n = jj_consume_token(NAME); |
| jj_consume_token(71); |
| e = Exp(); |
| jj_consume_token(72); |
| e2 = Exp(); |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case 72: |
| jj_consume_token(72); |
| e3 = Exp(); |
| break; |
| default: |
| jj_la1[3] = jj_gen; |
| ; |
| } |
| jj_consume_token(DO); |
| b = Block(); |
| jj_consume_token(END); |
| s=Stat.fornumeric(n.image,e,e2,e3,b); L(s,i); {if (true) return s;} |
| } else { |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case FOR: |
| jj_consume_token(FOR); |
| nl = NameList(); |
| jj_consume_token(IN); |
| el = ExpList(); |
| jj_consume_token(DO); |
| b = Block(); |
| jj_consume_token(END); |
| s=Stat.forgeneric(nl,el,b); L(s,i); {if (true) return s;} |
| break; |
| case FUNCTION: |
| jj_consume_token(FUNCTION); |
| fn = FuncName(); |
| fb = FuncBody(); |
| s=Stat.functiondef(fn,fb); L(s,i); {if (true) return s;} |
| break; |
| default: |
| jj_la1[6] = jj_gen; |
| if (jj_2_2(2)) { |
| jj_consume_token(LOCAL); |
| jj_consume_token(FUNCTION); |
| n = jj_consume_token(NAME); |
| fb = FuncBody(); |
| s=Stat.localfunctiondef(n.image,fb); L(s,i); {if (true) return s;} |
| } else { |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case LOCAL: |
| jj_consume_token(LOCAL); |
| nl = NameList(); |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case 71: |
| jj_consume_token(71); |
| el = ExpList(); |
| break; |
| default: |
| jj_la1[4] = jj_gen; |
| ; |
| } |
| s=Stat.localassignment(nl,el); L(s,i); {if (true) return s;} |
| break; |
| case NAME: |
| case 75: |
| s = ExprStat(); |
| L(s,i); {if (true) return s;} |
| break; |
| default: |
| jj_la1[7] = jj_gen; |
| jj_consume_token(-1); |
| throw new ParseException(); |
| } |
| } |
| } |
| } |
| } |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public Stat IfThenElse() throws ParseException { |
| Block b,b2,b3=null; |
| Exp e,e2; |
| List<Exp> el=null; |
| List<Block> bl=null; |
| jj_consume_token(IF); |
| e = Exp(); |
| jj_consume_token(THEN); |
| b = Block(); |
| label_2: |
| while (true) { |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case ELSEIF: |
| ; |
| break; |
| default: |
| jj_la1[8] = jj_gen; |
| break label_2; |
| } |
| jj_consume_token(ELSEIF); |
| e2 = Exp(); |
| jj_consume_token(THEN); |
| b2 = Block(); |
| if (el==null) el=new ArrayList<Exp>(); |
| if (bl==null) bl=new ArrayList<Block>(); |
| el.add(e2); |
| bl.add(b2); |
| } |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case ELSE: |
| jj_consume_token(ELSE); |
| b3 = Block(); |
| break; |
| default: |
| jj_la1[9] = jj_gen; |
| ; |
| } |
| jj_consume_token(END); |
| {if (true) return Stat.ifthenelse(e,b,el,bl,b3);} |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public Stat ReturnStat() throws ParseException { |
| List<Exp> el=null; |
| Stat s; |
| long i = LineInfo(); |
| jj_consume_token(RETURN); |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case LONGSTRING0: |
| case LONGSTRING1: |
| case LONGSTRING2: |
| case LONGSTRING3: |
| case LONGSTRINGN: |
| case FALSE: |
| case FUNCTION: |
| case NIL: |
| case NOT: |
| case TRUE: |
| case NAME: |
| case NUMBER: |
| case STRING: |
| case CHARSTRING: |
| case 69: |
| case 75: |
| case 79: |
| case 80: |
| case 83: |
| el = ExpList(); |
| break; |
| default: |
| jj_la1[10] = jj_gen; |
| ; |
| } |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case 70: |
| jj_consume_token(70); |
| break; |
| default: |
| jj_la1[11] = jj_gen; |
| ; |
| } |
| s=Stat.returnstat(el); L(s,i); {if (true) return s;} |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public Stat Label() throws ParseException { |
| Token n; |
| jj_consume_token(DBCOLON); |
| n = jj_consume_token(NAME); |
| jj_consume_token(DBCOLON); |
| {if (true) return Stat.labelstat(n.image);} |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public Stat ExprStat() throws ParseException { |
| Exp.PrimaryExp p; |
| Stat s=null; |
| long i = LineInfo(); |
| p = PrimaryExp(); |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case 71: |
| case 72: |
| s = Assign(assertvarexp(p)); |
| break; |
| default: |
| jj_la1[12] = jj_gen; |
| ; |
| } |
| if (s==null) { s=Stat.functioncall(assertfunccall(p)); } L(s,i); {if (true) return s;} |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public Stat Assign(Exp.VarExp v0) throws ParseException { |
| List<Exp.VarExp> vl = new ArrayList<Exp.VarExp>(); |
| vl.add(v0); |
| Exp.VarExp ve; |
| List<Exp> el; |
| Stat s; |
| long i = LineInfo(); |
| label_3: |
| while (true) { |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case 72: |
| ; |
| break; |
| default: |
| jj_la1[13] = jj_gen; |
| break label_3; |
| } |
| jj_consume_token(72); |
| ve = VarExp(); |
| vl.add(ve); |
| } |
| jj_consume_token(71); |
| el = ExpList(); |
| s=Stat.assignment(vl,el); L(s,i); {if (true) return s;} |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public Exp.VarExp VarExp() throws ParseException { |
| Exp.PrimaryExp p; |
| p = PrimaryExp(); |
| {if (true) return assertvarexp(p);} |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public FuncName FuncName() throws ParseException { |
| Token n; |
| FuncName f; |
| n = jj_consume_token(NAME); |
| f=new FuncName(n.image); |
| label_4: |
| while (true) { |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case 73: |
| ; |
| break; |
| default: |
| jj_la1[14] = jj_gen; |
| break label_4; |
| } |
| jj_consume_token(73); |
| n = jj_consume_token(NAME); |
| f.adddot(n.image); |
| } |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case 74: |
| jj_consume_token(74); |
| n = jj_consume_token(NAME); |
| f.method=n.image; |
| break; |
| default: |
| jj_la1[15] = jj_gen; |
| ; |
| } |
| L(f,n); {if (true) return f;} |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public Exp.PrimaryExp PrefixExp() throws ParseException { |
| Token n; |
| Exp e; |
| Exp.PrimaryExp p; |
| long i = LineInfo(); |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case NAME: |
| n = jj_consume_token(NAME); |
| p=Exp.nameprefix(n.image); L(p,i); {if (true) return p;} |
| break; |
| case 75: |
| jj_consume_token(75); |
| e = Exp(); |
| jj_consume_token(76); |
| p=Exp.parensprefix(e); L(p,i); {if (true) return p;} |
| break; |
| default: |
| jj_la1[16] = jj_gen; |
| jj_consume_token(-1); |
| throw new ParseException(); |
| } |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public Exp.PrimaryExp PrimaryExp() throws ParseException { |
| Exp.PrimaryExp p; |
| long i = LineInfo(); |
| p = PrefixExp(); |
| label_5: |
| while (true) { |
| if (jj_2_3(2)) { |
| ; |
| } else { |
| break label_5; |
| } |
| p = PostfixOp(p); |
| } |
| L(p,i); {if (true) return p;} |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public Exp.PrimaryExp PostfixOp(Exp.PrimaryExp lhs) throws ParseException { |
| Token n; |
| Exp e; |
| FuncArgs a; |
| Exp.PrimaryExp p; |
| long i = LineInfo(); |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case 73: |
| jj_consume_token(73); |
| n = jj_consume_token(NAME); |
| p=Exp.fieldop(lhs, n.image); L(p,i); {if (true) return p;} |
| break; |
| case 77: |
| jj_consume_token(77); |
| e = Exp(); |
| jj_consume_token(78); |
| p=Exp.indexop(lhs, e); L(p,i); {if (true) return p;} |
| break; |
| case 74: |
| jj_consume_token(74); |
| n = jj_consume_token(NAME); |
| a = FuncArgs(); |
| p=Exp.methodop(lhs, n.image,a); L(p,i); {if (true) return p;} |
| break; |
| case LONGSTRING0: |
| case LONGSTRING1: |
| case LONGSTRING2: |
| case LONGSTRING3: |
| case LONGSTRINGN: |
| case STRING: |
| case CHARSTRING: |
| case 75: |
| case 80: |
| a = FuncArgs(); |
| p=Exp.functionop(lhs, a); L(p,i); {if (true) return p;} |
| break; |
| default: |
| jj_la1[17] = jj_gen; |
| jj_consume_token(-1); |
| throw new ParseException(); |
| } |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public FuncArgs FuncArgs() throws ParseException { |
| List<Exp> el=null; |
| TableConstructor tc; |
| LuaString s; |
| FuncArgs a; |
| long i = LineInfo(); |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case 75: |
| jj_consume_token(75); |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case LONGSTRING0: |
| case LONGSTRING1: |
| case LONGSTRING2: |
| case LONGSTRING3: |
| case LONGSTRINGN: |
| case FALSE: |
| case FUNCTION: |
| case NIL: |
| case NOT: |
| case TRUE: |
| case NAME: |
| case NUMBER: |
| case STRING: |
| case CHARSTRING: |
| case 69: |
| case 75: |
| case 79: |
| case 80: |
| case 83: |
| el = ExpList(); |
| break; |
| default: |
| jj_la1[18] = jj_gen; |
| ; |
| } |
| jj_consume_token(76); |
| a=FuncArgs.explist(el); L(a,i); {if (true) return a;} |
| break; |
| case 80: |
| tc = TableConstructor(); |
| a=FuncArgs.tableconstructor(tc); L(a,i); {if (true) return a;} |
| break; |
| case LONGSTRING0: |
| case LONGSTRING1: |
| case LONGSTRING2: |
| case LONGSTRING3: |
| case LONGSTRINGN: |
| case STRING: |
| case CHARSTRING: |
| s = Str(); |
| a=FuncArgs.string(s); L(a,i); {if (true) return a;} |
| break; |
| default: |
| jj_la1[19] = jj_gen; |
| jj_consume_token(-1); |
| throw new ParseException(); |
| } |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public List<Name> NameList() throws ParseException { |
| List<Name> l = new ArrayList<Name>(); |
| Token name; |
| name = jj_consume_token(NAME); |
| l.add(new Name(name.image)); |
| label_6: |
| while (true) { |
| if (jj_2_4(2)) { |
| ; |
| } else { |
| break label_6; |
| } |
| jj_consume_token(72); |
| name = jj_consume_token(NAME); |
| l.add(new Name(name.image)); |
| } |
| {if (true) return l;} |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public List<Exp> ExpList() throws ParseException { |
| List<Exp> l = new ArrayList<Exp>(); |
| Exp e; |
| e = Exp(); |
| l.add(e); |
| label_7: |
| while (true) { |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case 72: |
| ; |
| break; |
| default: |
| jj_la1[20] = jj_gen; |
| break label_7; |
| } |
| jj_consume_token(72); |
| e = Exp(); |
| l.add(e); |
| } |
| {if (true) return l;} |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public Exp SimpleExp() throws ParseException { |
| Token n; |
| LuaString s; |
| Exp e; |
| TableConstructor c; |
| FuncBody b; |
| long i = LineInfo(); |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case NIL: |
| jj_consume_token(NIL); |
| e=Exp.constant(LuaValue.NIL); L(e,i); {if (true) return e;} |
| break; |
| case TRUE: |
| jj_consume_token(TRUE); |
| e=Exp.constant(LuaValue.TRUE); L(e,i); {if (true) return e;} |
| break; |
| case FALSE: |
| jj_consume_token(FALSE); |
| e=Exp.constant(LuaValue.FALSE); L(e,i); {if (true) return e;} |
| break; |
| case NUMBER: |
| n = jj_consume_token(NUMBER); |
| e=Exp.numberconstant(n.image); L(e,i); {if (true) return e;} |
| break; |
| case LONGSTRING0: |
| case LONGSTRING1: |
| case LONGSTRING2: |
| case LONGSTRING3: |
| case LONGSTRINGN: |
| case STRING: |
| case CHARSTRING: |
| s = Str(); |
| e=Exp.constant(s); L(e,i); {if (true) return e;} |
| break; |
| case 79: |
| jj_consume_token(79); |
| e=Exp.varargs(); L(e,i); {if (true) return e;} |
| break; |
| case 80: |
| c = TableConstructor(); |
| e=Exp.tableconstructor(c); L(e,i); {if (true) return e;} |
| break; |
| case FUNCTION: |
| b = FunctionCall(); |
| e=Exp.anonymousfunction(b); L(e,i); {if (true) return e;} |
| break; |
| case NAME: |
| case 75: |
| e = PrimaryExp(); |
| {if (true) return e;} |
| break; |
| default: |
| jj_la1[21] = jj_gen; |
| jj_consume_token(-1); |
| throw new ParseException(); |
| } |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public LuaString Str() throws ParseException { |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case STRING: |
| jj_consume_token(STRING); |
| {if (true) return Str.quoteString(token.image);} |
| break; |
| case CHARSTRING: |
| jj_consume_token(CHARSTRING); |
| {if (true) return Str.charString(token.image);} |
| break; |
| case LONGSTRING0: |
| jj_consume_token(LONGSTRING0); |
| {if (true) return Str.longString(token.image);} |
| break; |
| case LONGSTRING1: |
| jj_consume_token(LONGSTRING1); |
| {if (true) return Str.longString(token.image);} |
| break; |
| case LONGSTRING2: |
| jj_consume_token(LONGSTRING2); |
| {if (true) return Str.longString(token.image);} |
| break; |
| case LONGSTRING3: |
| jj_consume_token(LONGSTRING3); |
| {if (true) return Str.longString(token.image);} |
| break; |
| case LONGSTRINGN: |
| jj_consume_token(LONGSTRINGN); |
| {if (true) return Str.longString(token.image);} |
| break; |
| default: |
| jj_la1[22] = jj_gen; |
| jj_consume_token(-1); |
| throw new ParseException(); |
| } |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public Exp Exp() throws ParseException { |
| Exp e,s; |
| int op; |
| long i = LineInfo(); |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case LONGSTRING0: |
| case LONGSTRING1: |
| case LONGSTRING2: |
| case LONGSTRING3: |
| case LONGSTRINGN: |
| case FALSE: |
| case FUNCTION: |
| case NIL: |
| case TRUE: |
| case NAME: |
| case NUMBER: |
| case STRING: |
| case CHARSTRING: |
| case 75: |
| case 79: |
| case 80: |
| e = SimpleExp(); |
| break; |
| case NOT: |
| case 69: |
| case 83: |
| op = Unop(); |
| s = Exp(); |
| e=Exp.unaryexp(op,s); |
| break; |
| default: |
| jj_la1[23] = jj_gen; |
| jj_consume_token(-1); |
| throw new ParseException(); |
| } |
| label_8: |
| while (true) { |
| if (jj_2_5(2)) { |
| ; |
| } else { |
| break label_8; |
| } |
| op = Binop(); |
| s = Exp(); |
| e=Exp.binaryexp(e,op,s); |
| } |
| L(e,i); {if (true) return e;} |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public FuncBody FunctionCall() throws ParseException { |
| FuncBody b; |
| long i = LineInfo(); |
| jj_consume_token(FUNCTION); |
| b = FuncBody(); |
| L(b,i); {if (true) return b;} |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public FuncBody FuncBody() throws ParseException { |
| ParList pl=null; |
| Block b; |
| FuncBody f; |
| long i = LineInfo(); |
| jj_consume_token(75); |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case NAME: |
| case 79: |
| pl = ParList(); |
| break; |
| default: |
| jj_la1[24] = jj_gen; |
| ; |
| } |
| jj_consume_token(76); |
| b = Block(); |
| jj_consume_token(END); |
| f=new FuncBody(pl,b); L(f,i); {if (true) return f;} |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public ParList ParList() throws ParseException { |
| List<Name> l=null; |
| boolean v=false; |
| ParList p; |
| long i = LineInfo(); |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case NAME: |
| l = NameList(); |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case 72: |
| jj_consume_token(72); |
| jj_consume_token(79); |
| v=true; |
| break; |
| default: |
| jj_la1[25] = jj_gen; |
| ; |
| } |
| p=new ParList(l,v); L(p,i); {if (true) return p;} |
| break; |
| case 79: |
| jj_consume_token(79); |
| p=new ParList(null,true); L(p,i); {if (true) return p;} |
| break; |
| default: |
| jj_la1[26] = jj_gen; |
| jj_consume_token(-1); |
| throw new ParseException(); |
| } |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public TableConstructor TableConstructor() throws ParseException { |
| TableConstructor c = new TableConstructor(); |
| List<TableField> l = null; |
| long i = LineInfo(); |
| jj_consume_token(80); |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case LONGSTRING0: |
| case LONGSTRING1: |
| case LONGSTRING2: |
| case LONGSTRING3: |
| case LONGSTRINGN: |
| case FALSE: |
| case FUNCTION: |
| case NIL: |
| case NOT: |
| case TRUE: |
| case NAME: |
| case NUMBER: |
| case STRING: |
| case CHARSTRING: |
| case 69: |
| case 75: |
| case 77: |
| case 79: |
| case 80: |
| case 83: |
| l = FieldList(); |
| c.fields=l; |
| break; |
| default: |
| jj_la1[27] = jj_gen; |
| ; |
| } |
| jj_consume_token(81); |
| L(c,i); {if (true) return c;} |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public List<TableField> FieldList() throws ParseException { |
| List<TableField> l = new ArrayList<TableField>(); |
| TableField f; |
| f = Field(); |
| l.add(f); |
| label_9: |
| while (true) { |
| if (jj_2_6(2)) { |
| ; |
| } else { |
| break label_9; |
| } |
| FieldSep(); |
| f = Field(); |
| l.add(f); |
| } |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case 70: |
| case 72: |
| FieldSep(); |
| break; |
| default: |
| jj_la1[28] = jj_gen; |
| ; |
| } |
| {if (true) return l;} |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public TableField Field() throws ParseException { |
| Token name; |
| Exp exp,rhs; |
| TableField f; |
| long i = LineInfo(); |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case 77: |
| jj_consume_token(77); |
| exp = Exp(); |
| jj_consume_token(78); |
| jj_consume_token(71); |
| rhs = Exp(); |
| f=TableField.keyedField(exp,rhs); L(f,i); {if (true) return f;} |
| break; |
| default: |
| jj_la1[29] = jj_gen; |
| if (jj_2_7(2)) { |
| name = jj_consume_token(NAME); |
| jj_consume_token(71); |
| rhs = Exp(); |
| f=TableField.namedField(name.image,rhs); L(f,i); {if (true) return f;} |
| } else { |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case LONGSTRING0: |
| case LONGSTRING1: |
| case LONGSTRING2: |
| case LONGSTRING3: |
| case LONGSTRINGN: |
| case FALSE: |
| case FUNCTION: |
| case NIL: |
| case NOT: |
| case TRUE: |
| case NAME: |
| case NUMBER: |
| case STRING: |
| case CHARSTRING: |
| case 69: |
| case 75: |
| case 79: |
| case 80: |
| case 83: |
| rhs = Exp(); |
| f=TableField.listField(rhs); L(f,i); {if (true) return f;} |
| break; |
| default: |
| jj_la1[30] = jj_gen; |
| jj_consume_token(-1); |
| throw new ParseException(); |
| } |
| } |
| } |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public void FieldSep() throws ParseException { |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case 72: |
| jj_consume_token(72); |
| break; |
| case 70: |
| jj_consume_token(70); |
| break; |
| default: |
| jj_la1[31] = jj_gen; |
| jj_consume_token(-1); |
| throw new ParseException(); |
| } |
| } |
| |
| final public int Binop() throws ParseException { |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case 82: |
| jj_consume_token(82); |
| {if (true) return Lua.OP_ADD;} |
| break; |
| case 83: |
| jj_consume_token(83); |
| {if (true) return Lua.OP_SUB;} |
| break; |
| case 84: |
| jj_consume_token(84); |
| {if (true) return Lua.OP_MUL;} |
| break; |
| case 85: |
| jj_consume_token(85); |
| {if (true) return Lua.OP_DIV;} |
| break; |
| case 86: |
| jj_consume_token(86); |
| {if (true) return Lua.OP_POW;} |
| break; |
| case 87: |
| jj_consume_token(87); |
| {if (true) return Lua.OP_MOD;} |
| break; |
| case 88: |
| jj_consume_token(88); |
| {if (true) return Lua.OP_CONCAT;} |
| break; |
| case 89: |
| jj_consume_token(89); |
| {if (true) return Lua.OP_LT;} |
| break; |
| case 90: |
| jj_consume_token(90); |
| {if (true) return Lua.OP_LE;} |
| break; |
| case 91: |
| jj_consume_token(91); |
| {if (true) return Lua.OP_GT;} |
| break; |
| case 92: |
| jj_consume_token(92); |
| {if (true) return Lua.OP_GE;} |
| break; |
| case 93: |
| jj_consume_token(93); |
| {if (true) return Lua.OP_EQ;} |
| break; |
| case 94: |
| jj_consume_token(94); |
| {if (true) return Lua.OP_NEQ;} |
| break; |
| case AND: |
| jj_consume_token(AND); |
| {if (true) return Lua.OP_AND;} |
| break; |
| case OR: |
| jj_consume_token(OR); |
| {if (true) return Lua.OP_OR;} |
| break; |
| default: |
| jj_la1[32] = jj_gen; |
| jj_consume_token(-1); |
| throw new ParseException(); |
| } |
| throw new Error("Missing return statement in function"); |
| } |
| |
| final public int Unop() throws ParseException { |
| switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { |
| case 83: |
| jj_consume_token(83); |
| {if (true) return Lua.OP_UNM;} |
| break; |
| case NOT: |
| jj_consume_token(NOT); |
| {if (true) return Lua.OP_NOT;} |
| break; |
| case 69: |
| jj_consume_token(69); |
| {if (true) return Lua.OP_LEN;} |
| break; |
| default: |
| jj_la1[33] = jj_gen; |
| jj_consume_token(-1); |
| throw new ParseException(); |
| } |
| throw new Error("Missing return statement in function"); |
| } |
| |
| 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_2_6(int xla) { |
| jj_la = xla; jj_lastpos = jj_scanpos = token; |
| try { return !jj_3_6(); } |
| catch(LookaheadSuccess ls) { return true; } |
| finally { jj_save(5, xla); } |
| } |
| |
| private boolean jj_2_7(int xla) { |
| jj_la = xla; jj_lastpos = jj_scanpos = token; |
| try { return !jj_3_7(); } |
| catch(LookaheadSuccess ls) { return true; } |
| finally { jj_save(6, xla); } |
| } |
| |
| private boolean jj_3R_43() { |
| if (jj_3R_58()) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_42() { |
| if (jj_3R_57()) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_41() { |
| if (jj_scan_token(75)) return true; |
| Token xsp; |
| xsp = jj_scanpos; |
| if (jj_3R_56()) jj_scanpos = xsp; |
| if (jj_scan_token(76)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_38() { |
| Token xsp; |
| xsp = jj_scanpos; |
| if (jj_3R_41()) { |
| jj_scanpos = xsp; |
| if (jj_3R_42()) { |
| jj_scanpos = xsp; |
| if (jj_3R_43()) return true; |
| } |
| } |
| return false; |
| } |
| |
| private boolean jj_3_3() { |
| if (jj_3R_10()) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_18() { |
| if (jj_3R_38()) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_17() { |
| if (jj_scan_token(74)) return true; |
| if (jj_scan_token(NAME)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_16() { |
| if (jj_scan_token(77)) return true; |
| if (jj_3R_12()) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_35() { |
| if (jj_3R_40()) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_15() { |
| if (jj_scan_token(73)) return true; |
| if (jj_scan_token(NAME)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_10() { |
| Token xsp; |
| xsp = jj_scanpos; |
| if (jj_3R_15()) { |
| jj_scanpos = xsp; |
| if (jj_3R_16()) { |
| jj_scanpos = xsp; |
| if (jj_3R_17()) { |
| jj_scanpos = xsp; |
| if (jj_3R_18()) return true; |
| } |
| } |
| } |
| return false; |
| } |
| |
| private boolean jj_3R_59() { |
| if (jj_scan_token(FUNCTION)) return true; |
| return false; |
| } |
| |
| private boolean jj_3_5() { |
| if (jj_3R_11()) return true; |
| if (jj_3R_12()) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_60() { |
| if (jj_3R_70()) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_55() { |
| if (jj_scan_token(69)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_54() { |
| if (jj_scan_token(NOT)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_53() { |
| if (jj_scan_token(83)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_40() { |
| Token xsp; |
| xsp = jj_scanpos; |
| if (jj_3R_53()) { |
| jj_scanpos = xsp; |
| if (jj_3R_54()) { |
| jj_scanpos = xsp; |
| if (jj_3R_55()) return true; |
| } |
| } |
| return false; |
| } |
| |
| private boolean jj_3R_34() { |
| if (jj_3R_39()) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_12() { |
| Token xsp; |
| xsp = jj_scanpos; |
| if (jj_3R_34()) { |
| jj_scanpos = xsp; |
| if (jj_3R_35()) return true; |
| } |
| return false; |
| } |
| |
| private boolean jj_3R_73() { |
| if (jj_scan_token(75)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_33() { |
| if (jj_scan_token(OR)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_72() { |
| if (jj_scan_token(NAME)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_70() { |
| Token xsp; |
| xsp = jj_scanpos; |
| if (jj_3R_72()) { |
| jj_scanpos = xsp; |
| if (jj_3R_73()) return true; |
| } |
| return false; |
| } |
| |
| private boolean jj_3_2() { |
| if (jj_scan_token(LOCAL)) return true; |
| if (jj_scan_token(FUNCTION)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_32() { |
| if (jj_scan_token(AND)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_31() { |
| if (jj_scan_token(94)) return true; |
| return false; |
| } |
| |
| private boolean jj_3_4() { |
| if (jj_scan_token(72)) return true; |
| if (jj_scan_token(NAME)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_30() { |
| if (jj_scan_token(93)) return true; |
| return false; |
| } |
| |
| private boolean jj_3_1() { |
| if (jj_scan_token(FOR)) return true; |
| if (jj_scan_token(NAME)) return true; |
| if (jj_scan_token(71)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_29() { |
| if (jj_scan_token(92)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_28() { |
| if (jj_scan_token(91)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_69() { |
| if (jj_scan_token(LONGSTRINGN)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_27() { |
| if (jj_scan_token(90)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_68() { |
| if (jj_scan_token(LONGSTRING3)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_26() { |
| if (jj_scan_token(89)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_67() { |
| if (jj_scan_token(LONGSTRING2)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_25() { |
| if (jj_scan_token(88)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_66() { |
| if (jj_scan_token(LONGSTRING1)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_24() { |
| if (jj_scan_token(87)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_65() { |
| if (jj_scan_token(LONGSTRING0)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_23() { |
| if (jj_scan_token(86)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_64() { |
| if (jj_scan_token(CHARSTRING)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_22() { |
| if (jj_scan_token(85)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_63() { |
| if (jj_scan_token(STRING)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_58() { |
| Token xsp; |
| xsp = jj_scanpos; |
| if (jj_3R_63()) { |
| jj_scanpos = xsp; |
| if (jj_3R_64()) { |
| jj_scanpos = xsp; |
| if (jj_3R_65()) { |
| jj_scanpos = xsp; |
| if (jj_3R_66()) { |
| jj_scanpos = xsp; |
| if (jj_3R_67()) { |
| jj_scanpos = xsp; |
| if (jj_3R_68()) { |
| jj_scanpos = xsp; |
| if (jj_3R_69()) return true; |
| } |
| } |
| } |
| } |
| } |
| } |
| return false; |
| } |
| |
| private boolean jj_3R_21() { |
| if (jj_scan_token(84)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_20() { |
| if (jj_scan_token(83)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_19() { |
| if (jj_scan_token(82)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_11() { |
| Token xsp; |
| xsp = jj_scanpos; |
| if (jj_3R_19()) { |
| jj_scanpos = xsp; |
| if (jj_3R_20()) { |
| jj_scanpos = xsp; |
| if (jj_3R_21()) { |
| jj_scanpos = xsp; |
| if (jj_3R_22()) { |
| jj_scanpos = xsp; |
| if (jj_3R_23()) { |
| jj_scanpos = xsp; |
| if (jj_3R_24()) { |
| jj_scanpos = xsp; |
| if (jj_3R_25()) { |
| jj_scanpos = xsp; |
| 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()) { |
| jj_scanpos = xsp; |
| if (jj_3R_32()) { |
| jj_scanpos = xsp; |
| if (jj_3R_33()) return true; |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| return false; |
| } |
| |
| private boolean jj_3_6() { |
| if (jj_3R_13()) return true; |
| if (jj_3R_14()) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_52() { |
| if (jj_3R_60()) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_51() { |
| if (jj_3R_59()) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_50() { |
| if (jj_3R_57()) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_13() { |
| Token xsp; |
| xsp = jj_scanpos; |
| if (jj_scan_token(72)) { |
| jj_scanpos = xsp; |
| if (jj_scan_token(70)) return true; |
| } |
| return false; |
| } |
| |
| private boolean jj_3R_49() { |
| if (jj_scan_token(79)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_48() { |
| if (jj_3R_58()) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_47() { |
| if (jj_scan_token(NUMBER)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_46() { |
| if (jj_scan_token(FALSE)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_45() { |
| if (jj_scan_token(TRUE)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_44() { |
| if (jj_scan_token(NIL)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_39() { |
| Token xsp; |
| xsp = jj_scanpos; |
| if (jj_3R_44()) { |
| jj_scanpos = xsp; |
| if (jj_3R_45()) { |
| jj_scanpos = xsp; |
| if (jj_3R_46()) { |
| jj_scanpos = xsp; |
| if (jj_3R_47()) { |
| jj_scanpos = xsp; |
| if (jj_3R_48()) { |
| jj_scanpos = xsp; |
| if (jj_3R_49()) { |
| jj_scanpos = xsp; |
| if (jj_3R_50()) { |
| jj_scanpos = xsp; |
| if (jj_3R_51()) { |
| jj_scanpos = xsp; |
| if (jj_3R_52()) return true; |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| return false; |
| } |
| |
| private boolean jj_3R_37() { |
| if (jj_3R_12()) return true; |
| return false; |
| } |
| |
| private boolean jj_3_7() { |
| if (jj_scan_token(NAME)) return true; |
| if (jj_scan_token(71)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_14() { |
| Token xsp; |
| xsp = jj_scanpos; |
| if (jj_3R_36()) { |
| jj_scanpos = xsp; |
| if (jj_3_7()) { |
| jj_scanpos = xsp; |
| if (jj_3R_37()) return true; |
| } |
| } |
| return false; |
| } |
| |
| private boolean jj_3R_36() { |
| if (jj_scan_token(77)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_71() { |
| if (jj_3R_14()) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_61() { |
| if (jj_3R_12()) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_62() { |
| if (jj_3R_71()) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_57() { |
| if (jj_scan_token(80)) return true; |
| Token xsp; |
| xsp = jj_scanpos; |
| if (jj_3R_62()) jj_scanpos = xsp; |
| if (jj_scan_token(81)) return true; |
| return false; |
| } |
| |
| private boolean jj_3R_56() { |
| if (jj_3R_61()) return true; |
| return false; |
| } |
| |
| /** Generated Token Manager. */ |
| public LuaParserTokenManager token_source; |
| SimpleCharStream 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; |
| private int jj_gen; |
| final private int[] jj_la1 = new int[34]; |
| static private int[] jj_la1_0; |
| static private int[] jj_la1_1; |
| static private int[] jj_la1_2; |
| static { |
| jj_la1_init_0(); |
| jj_la1_init_1(); |
| jj_la1_init_2(); |
| } |
| private static void jj_la1_init_0() { |
| jj_la1_0 = new int[] {0x0,0xc0000000,0x0,0x0,0x0,0xc0000000,0x0,0x0,0x0,0x0,0xf800000,0x0,0x0,0x0,0x0,0x0,0x0,0xf800000,0xf800000,0xf800000,0x0,0xf800000,0xf800000,0xf800000,0x0,0x0,0x0,0xf800000,0x0,0x0,0xf800000,0x0,0x20000000,0x0,}; |
| } |
| private static void jj_la1_init_1() { |
| jj_la1_1 = new int[] {0x0,0xc42f0,0x2000,0x0,0x0,0x440c0,0x30,0x80200,0x2,0x1,0x60190c28,0x0,0x0,0x0,0x0,0x0,0x80000,0x60000000,0x60190c28,0x60000000,0x0,0x60190428,0x60000000,0x60190c28,0x80000,0x0,0x80000,0x60190c28,0x0,0x0,0x60190c28,0x0,0x1000,0x800,}; |
| } |
| private static void jj_la1_init_2() { |
| jj_la1_2 = new int[] {0x20,0x842,0x0,0x100,0x80,0x42,0x0,0x800,0x0,0x0,0x98820,0x40,0x180,0x100,0x200,0x400,0x800,0x12e00,0x98820,0x10800,0x100,0x18800,0x0,0x98820,0x8000,0x100,0x8000,0x9a820,0x140,0x2000,0x98820,0x140,0x7ffc0000,0x80020,}; |
| } |
| final private JJCalls[] jj_2_rtns = new JJCalls[7]; |
| private boolean jj_rescan = false; |
| private int jj_gc = 0; |
| |
| /** Constructor with InputStream. */ |
| public LuaParser(java.io.InputStream stream) { |
| this(stream, null); |
| } |
| /** Constructor with InputStream and supplied encoding */ |
| public LuaParser(java.io.InputStream stream, String encoding) { |
| try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e.getMessage()); } |
| token_source = new LuaParserTokenManager(jj_input_stream); |
| token = new Token(); |
| jj_ntk = -1; |
| jj_gen = 0; |
| for (int i = 0; i < 34; 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.getMessage()); } |
| token_source.ReInit(jj_input_stream); |
| token = new Token(); |
| jj_ntk = -1; |
| jj_gen = 0; |
| for (int i = 0; i < 34; i++) jj_la1[i] = -1; |
| for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); |
| } |
| |
| /** Constructor. */ |
| public LuaParser(java.io.Reader stream) { |
| jj_input_stream = new SimpleCharStream(stream, 1, 1); |
| token_source = new LuaParserTokenManager(jj_input_stream); |
| token = new Token(); |
| jj_ntk = -1; |
| jj_gen = 0; |
| for (int i = 0; i < 34; 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; |
| jj_gen = 0; |
| for (int i = 0; i < 34; 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 LuaParser(LuaParserTokenManager tm) { |
| token_source = tm; |
| token = new Token(); |
| jj_ntk = -1; |
| jj_gen = 0; |
| for (int i = 0; i < 34; 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(LuaParserTokenManager tm) { |
| token_source = tm; |
| token = new Token(); |
| jj_ntk = -1; |
| jj_gen = 0; |
| for (int i = 0; i < 34; 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 = 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[95]; |
| if (jj_kind >= 0) { |
| la1tokens[jj_kind] = true; |
| jj_kind = -1; |
| } |
| for (int i = 0; i < 34; 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; |
| } |
| if ((jj_la1_2[i] & (1<<j)) != 0) { |
| la1tokens[64+j] = true; |
| } |
| } |
| } |
| } |
| for (int i = 0; i < 95; 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 < 7; 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; |
| case 5: jj_3_6(); break; |
| case 6: jj_3_7(); 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; |
| } |
| |
| } |