home *** CD-ROM | disk | FTP | other *** search
- import java.io.PrintStream;
-
- public class JScriptParser extends JSbxBase implements JScriptTokenInterface {
- private JScriptTokenInterface aTokenInterface;
- private JScriptCompiler aCompiler;
- private JScriptExprParser aExprParser;
- private JScriptErrorLog aErrorLog;
- JSbxStack aStructLevelStack;
- private JScriptCodeGenParam aCodeGenParam;
- boolean bGenCode;
- private JScriptModule aModule;
- private JSbxVector aGlobalVarVector;
- private JScriptCodeBlock aCodeBlock;
- private boolean bEndOfStmtExpected;
- private boolean bInFunction;
- private JScriptMethod pFunctionObject;
- private boolean bInEval;
- private boolean bDebugCode;
- private boolean bSourceAsPCode;
- private boolean bDumpParsing;
- private PrintStream aDebugOutStream;
- private JScriptTokenPosition aActualTokenPos;
- private JScriptTokenPosition aDebugStepPos;
- private JScriptTokenPosition aStatementPos;
- private String aSourceCodeStr;
- private static final JSP_ClrExpStack aJSP_ClrExpStack = new JSP_ClrExpStack();
- private static final JSP_EvalClrExpStack aJSP_EvalClrExpStack = new JSP_EvalClrExpStack();
-
- public void SetTokenInterface(JScriptTokenInterface var1) {
- this.aTokenInterface = var1;
- }
-
- public void SetErrorLog(JScriptErrorLog var1) {
- this.aErrorLog = var1;
- }
-
- JSbxStack GetStructLevelStack() {
- return this.aStructLevelStack;
- }
-
- private JScriptCodeGenParam GetCodeGenParam() {
- return this.aCodeGenParam;
- }
-
- public void SetGenCodeFlag(boolean var1) {
- this.bGenCode = var1;
- if (this.aCodeGenParam != null) {
- this.aCodeGenParam.SetGenCodeFlag(var1);
- }
-
- }
-
- private JScriptCodeBlock GetCodeBlock() {
- return this.aCodeBlock;
- }
-
- private void SetCodeBlock(JScriptCodeBlock var1) {
- this.aCodeBlock = var1;
- if (this.aCodeGenParam != null) {
- this.aCodeGenParam.SetCodeBlock(var1);
- }
-
- }
-
- public void SetDebug(boolean var1, boolean var2, PrintStream var3) {
- this.bSourceAsPCode = var1;
- this.bDebugCode = var2;
- this.aDebugOutStream = var3;
- }
-
- private void ClrSourceStr() {
- this.aSourceCodeStr = "";
- this.aStatementPos = null;
- }
-
- private void AddSourceCode() {
- if (this.bSourceAsPCode && this.bGenCode) {
- this.ParserAddCode(new JSP_DebugSourceItem(this.aSourceCodeStr));
- this.ClrSourceStr();
- }
-
- }
-
- private void SetSourceCode(int var1) throws JSbxExceptionBase {
- if (this.bSourceAsPCode && this.bGenCode && var1 >= 0) {
- this.ParserSetCode(var1, new JSP_DebugSourceItem(this.aSourceCodeStr));
- this.ClrSourceStr();
- }
-
- }
-
- private int GetSourceCodePC() throws JSbxExceptionBase {
- return this.bSourceAsPCode && this.bGenCode ? this.ParserAddCode((JScriptPCode)null) : -1;
- }
-
- private void AddDebugStepCode() {
- this.AddDebugStepCode(this.aDebugStepPos);
- this.ClrDebugStepPos();
- }
-
- private void AddDebugStepCode(JScriptTokenPosition var1) {
- if (this.bDebugCode && this.bGenCode) {
- this.ParserAddCode(new JSP_DebugStep(var1));
- }
-
- }
-
- private void SetDebugStepCode(int var1) throws JSbxExceptionBase {
- this.SetDebugStepCode(var1, this.aDebugStepPos);
- this.ClrDebugStepPos();
- }
-
- private void SetDebugStepCode(int var1, JScriptTokenPosition var2) throws JSbxExceptionBase {
- if (this.bDebugCode && this.bGenCode) {
- this.ParserSetCode(var1, new JSP_DebugStep(var2));
- }
-
- }
-
- private int GetDebugStepPC() throws JSbxExceptionBase {
- return this.bDebugCode && this.bGenCode ? this.ParserAddCode((JScriptPCode)null) : -1;
- }
-
- private void ClrDebugStepPos() {
- this.aDebugStepPos = null;
- }
-
- private void GenClrExpStack() {
- if (this.bInEval) {
- this.ParserAddCode(aJSP_EvalClrExpStack);
- } else {
- this.ParserAddCode(aJSP_ClrExpStack);
- }
- }
-
- public JScriptParser(JScriptCompiler var1) {
- this.Init();
- this.aCompiler = var1;
- this.aTokenInterface = this.aCompiler.GetTokenInterface();
- this.aErrorLog = this.aCompiler.GetErrorLog();
- this.bDumpParsing = false;
- }
-
- private void Init() {
- this.aCodeGenParam = new JScriptCodeGenParam();
- this.aStructLevelStack = new JSbxStack(10);
- this.aActualTokenPos = new JScriptTokenPosition();
- this.aExprParser = new JScriptExprParser(this, this.aErrorLog);
- this.bSourceAsPCode = false;
- this.bDebugCode = false;
- this.bDumpParsing = false;
- }
-
- private void InitParsing() {
- this.bEndOfStmtExpected = false;
- this.pFunctionObject = null;
- this.bInEval = false;
- this.aDebugStepPos = null;
- this.aStatementPos = null;
- this.ClrSourceStr();
- this.aModule = null;
- this.aGlobalVarVector = null;
- }
-
- void ParserError(JSbxExceptionBase var1) throws JScriptParserException {
- String var2 = " --> Position:";
- JScriptTokenPosition var3 = this.aActualTokenPos;
- if (var1 instanceof JScriptTokenizerException) {
- JScriptTokenizerException var4 = (JScriptTokenizerException)var1;
- var3 = var4.GetErrorPosition();
- }
-
- if (var3 != null) {
- var2 = var2 + " line= " + var3.GetLine();
- var2 = var2 + " col.= " + var3.GetCol();
- } else {
- var2 = var2 + " ???";
- }
-
- this.aDebugOutStream.println(((Throwable)var1).getMessage() + var2);
- if (!(var1 instanceof JScriptParserException)) {
- throw new JScriptParserException(0, ((Throwable)var1).getMessage(), var3);
- } else {
- if (var1 instanceof JScriptTokenizerException) {
- JScriptTokenizerException var7 = (JScriptTokenizerException)var1;
- if (var7.GetErrorPosition() == null) {
- var7.SetErrorPosition(this.aActualTokenPos);
- }
- }
-
- throw (JScriptParserException)var1;
- }
- }
-
- public int ParserAddCode(JScriptPCode var1) {
- return this.bGenCode ? this.GetCodeBlock().AddCode(var1) : 0;
- }
-
- public void ParserSetCode(int var1, JScriptPCode var2) throws JSbxExceptionBase {
- if (this.bGenCode) {
- this.GetCodeBlock().SetPCode(var1, var2);
- }
-
- }
-
- public void ParseModule(JScriptModule var1, boolean var2) throws JScriptParserException {
- this.InitParsing();
- this.aModule = var1;
- this.aGlobalVarVector = new JSbxVector();
- this.SetCodeBlock(this.aModule.GetCodeBlock());
- this.SetGenCodeFlag(var2);
- this.ParseAll();
- int var3 = this.aGlobalVarVector.GetSize();
- if (var3 > 0) {
- String[] var4 = new String[var3];
-
- for(int var5 = 0; var5 < var3; ++var5) {
- String var6 = (String)this.aGlobalVarVector.Get(var5);
- var4[var5] = var6;
- }
-
- this.aModule.SetGlobalVarList(var4);
- }
-
- this.aGlobalVarVector = null;
- }
-
- public void RuntimeParse(JScriptModule var1, JScriptCodeBlock var2, JScriptMethod var3, boolean var4) throws JScriptParserException {
- this.InitParsing();
- this.aModule = var1;
- JScriptMethod var5 = this.pFunctionObject;
- boolean var6 = this.bInEval;
- this.pFunctionObject = var3;
- this.bInEval = var4;
- this.SetCodeBlock(var2);
- this.SetGenCodeFlag(true);
- this.ParseAll();
- if (this.pFunctionObject != null) {
- this.pFunctionObject.LocalVarDefFinished();
- }
-
- this.pFunctionObject = var5;
- this.bInEval = var6;
- }
-
- public void ParseAll() throws JScriptParserException {
- try {
- while(this.ParseStatement()) {
- }
-
- } catch (JSbxExceptionBase var2) {
- this.ParserError(var2);
- }
- }
-
- public boolean ParseStatement() throws JScriptParserException, JSbxExceptionBase {
- boolean var1 = true;
- this.ClrDebugStepPos();
- JScriptToken var2 = this.PeekToken();
- if (var2 == null) {
- this.ParserAddCode(new JSP_Stop());
- return false;
- } else if (this.bEndOfStmtExpected) {
- throw new JScriptParserException(2000, this.aActualTokenPos);
- } else {
- if (var2.GetType() != 2 || !var2.GetString().equalsIgnoreCase("print") && !var2.GetString().equalsIgnoreCase("nop")) {
- if (var2.GetType() == 1 && var2.GetID() != 42 && var2.GetID() != 31) {
- var1 = this.ParseKeywordStatement();
- this.TestForEOS(false);
- } else if (var2.GetType() == 5) {
- if (var2.GetID() == 132) {
- try {
- this.NextToken();
- } catch (JScriptTokenizerException var4) {
- }
- } else {
- if (var2.GetID() != 128) {
- throw new JScriptParserException(2019, this.aActualTokenPos);
- }
-
- var1 = this.ParseBlock(false);
- this.TestForEOS(false);
- }
- } else {
- this.bEndOfStmtExpected = true;
- Object var8 = null;
- JScriptParserExpression var9 = this.ParseExpression();
- if (var9 == null) {
- throw new JScriptParserException(2001, this.aActualTokenPos);
- }
-
- this.TestForEOS(false);
- this.AddSourceCode();
- this.AddDebugStepCode();
- this.GetCodeGenParam().SetFlag_OptimizeIncDec(true);
- var9.GenerateCode(this.GetCodeGenParam());
- this.GetCodeGenParam().SetFlag_OptimizeIncDec(false);
- this.GenClrExpStack();
- }
- } else {
- if (var2.GetString().equalsIgnoreCase("print")) {
- try {
- this.NextToken();
- } catch (JScriptTokenizerException var6) {
- }
-
- Object var3 = null;
- JScriptParserExpression var7 = this.ParseExpression(true);
- this.TestForEOS(false);
- this.AddSourceCode();
- this.AddDebugStepCode();
- if (var7 != null) {
- var7.GenerateCode(this.GetCodeGenParam());
- } else {
- this.ParserAddCode(new JSP_StringConst(""));
- }
-
- this.ParserAddCode(new JSP_Print(this.aDebugOutStream));
- }
-
- if (var2.GetString().equalsIgnoreCase("nop")) {
- try {
- this.NextToken();
- } catch (JScriptTokenizerException var5) {
- }
-
- this.ParserAddCode(new JSP_Nop());
- }
- }
-
- return var1;
- }
- }
-
- private boolean ParseKeywordStatement() throws JSbxExceptionBase {
- boolean var1 = true;
- JScriptToken var2 = this.NextToken();
- switch (var2.GetID()) {
- case 3:
- var1 = this.ParseBreak();
- break;
- case 10:
- var1 = this.ParseContinue();
- break;
- case 14:
- var1 = this.ParseElse();
- break;
- case 19:
- var1 = this.ParseFor();
- break;
- case 20:
- var1 = this.ParseFunction();
- break;
- case 22:
- var1 = this.ParseIf();
- break;
- case 36:
- var1 = this.ParseReturn();
- break;
- case 48:
- var1 = this.ParseVar();
- this.GenClrExpStack();
- break;
- case 50:
- var1 = this.ParseWhile();
- break;
- case 51:
- var1 = this.ParseWith();
- break;
- case 52:
- var1 = this.ParseDelete();
- break;
- default:
- throw new JScriptParserException(2004, this.aActualTokenPos);
- }
-
- return var1;
- }
-
- private boolean ParseBreak() throws JSbxExceptionBase {
- this.AddSourceCode();
- this.AddDebugStepCode();
- if (this.bDumpParsing) {
- this.aDebugOutStream.println("ParseBreak()");
- }
-
- JScriptParserStructItem var1 = (JScriptParserStructItem)this.GetStructLevelStack().Peek();
- if (var1 == null) {
- throw new JScriptParserException(2005, this.aActualTokenPos);
- } else {
- int var2 = this.ParserAddCode((JScriptPCode)null);
- var1.AddBreak(var2);
- return true;
- }
- }
-
- private boolean ParseContinue() throws JSbxExceptionBase {
- this.AddSourceCode();
- this.AddDebugStepCode();
- if (this.bDumpParsing) {
- this.aDebugOutStream.println("ParseContinue()");
- }
-
- JScriptParserStructItem var1 = (JScriptParserStructItem)this.GetStructLevelStack().Peek();
- if (var1 == null) {
- throw new JScriptParserException(2003, this.aActualTokenPos);
- } else {
- int var2 = this.ParserAddCode((JScriptPCode)null);
- var1.AddContinue(var2);
- return true;
- }
- }
-
- private boolean ParseDelete() throws JSbxExceptionBase {
- int var1 = this.GetSourceCodePC();
- int var2 = this.GetDebugStepPC();
- JScriptParserExpression var3 = null;
- this.bEndOfStmtExpected = true;
- this.TestForEOS(false);
- if (this.bEndOfStmtExpected) {
- var3 = this.ParseExpression();
- }
-
- if (var3 != null) {
- var3.GenerateCode(this.GetCodeGenParam());
- this.ParserAddCode(new JSP_Delete());
- this.SetSourceCode(var1);
- this.SetDebugStepCode(var2);
- return true;
- } else {
- throw new JScriptParserException(2019, this.aActualTokenPos);
- }
- }
-
- private boolean ParseElse() throws JSbxExceptionBase {
- throw new JScriptParserException(2002, this.aActualTokenPos);
- }
-
- private boolean ParseFor() throws JSbxExceptionBase {
- if (this.bDumpParsing) {
- this.aDebugOutStream.println("ParseFor()");
- }
-
- this.TestForLParam(true);
- Object var1 = null;
- JScriptParserExpression var2 = null;
- Object var3 = null;
- int var7 = this.GetSourceCodePC();
- JScriptToken var8 = this.PeekToken();
- Object var9 = null;
- boolean var10 = false;
- if (var8 != null && var8.GetID() == 48) {
- this.NextToken();
- this.ParseVar();
- var10 = true;
- } else {
- JScriptParserExpression var18 = this.ParseExpression();
- if (var18 != null) {
- this.AddDebugStepCode();
- this.GetCodeGenParam().SetFlag_ExpressionInForInStatement(true);
- var18.GenerateCode(this.GetCodeGenParam());
- this.GetCodeGenParam().SetFlag_ExpressionInForInStatement(false);
- var10 = true;
- }
- }
-
- var8 = this.NextToken();
- if (var8 == null) {
- throw new JScriptParserException(2006, this.aActualTokenPos);
- } else {
- this.ClrDebugStepPos();
- JScriptTokenPosition var11 = null;
- boolean var12 = false;
- JScriptParserStructItem var4;
- int var5;
- if (var8.GetID() == 25) {
- var12 = true;
- if (!var10) {
- throw new JScriptParserException(2007, this.aActualTokenPos);
- }
-
- JScriptParserExpression var16 = this.ParseExpression();
- if (var16 == null) {
- throw new JScriptParserException(2007, this.aActualTokenPos);
- }
-
- var16.GenerateCode(this.GetCodeGenParam());
- this.ParserAddCode(new JSP_InitForIn());
- var5 = this.GetCodeBlock().GetNextCodePos();
- var4 = new JScriptParserStructItem((short)25);
- this.AddDebugStepCode();
- this.ParserAddCode(new JSP_NextForIn());
- } else {
- if (var8.GetID() != 132) {
- throw new JScriptParserException(2008, this.aActualTokenPos);
- }
-
- if (var10) {
- this.GenClrExpStack();
- }
-
- var5 = this.GetCodeBlock().GetNextCodePos();
- var4 = new JScriptParserStructItem((short)19);
- JScriptParserExpression var15 = this.ParseExpression();
- this.TestForEOS(true);
- this.AddDebugStepCode();
- if (var15 != null) {
- var15.GenerateCode(this.GetCodeGenParam(), true);
- } else {
- this.ParserAddCode(new JSP_BoolConst(true));
- }
-
- var2 = this.ParseExpression();
- if (this.aDebugStepPos != null) {
- var11 = (JScriptTokenPosition)this.aDebugStepPos.clone();
- }
- }
-
- this.TestForRParam(true);
- this.SetSourceCode(var7);
- this.GetStructLevelStack().Push(var4);
- int var13 = this.ParserAddCode((JScriptPCode)null);
- this.ParseStatement();
- int var6;
- if (var2 != null) {
- if (var11 != null) {
- this.AddDebugStepCode(var11);
- }
-
- var6 = this.GetCodeBlock().GetNextCodePos();
- this.GetCodeGenParam().SetFlag_OptimizeIncDec(true);
- var2.GenerateCode(this.GetCodeGenParam());
- this.GetCodeGenParam().SetFlag_OptimizeIncDec(false);
- this.GenClrExpStack();
- } else {
- var6 = var5;
- }
-
- this.ParserAddCode(new JSP_Jmp(var5));
- int var14 = this.GetCodeBlock().GetNextCodePos();
- var4.GenBreakJumps(this.GetCodeBlock(), var14);
- var4.GenContinueJumps(this.GetCodeBlock(), var6);
- this.GetCodeBlock().SetPCode(var13, new JSP_JmpIfFalse(var14));
- if (var12) {
- this.ParserAddCode(new JSP_ClrForIn());
- }
-
- this.GetStructLevelStack().Pop();
- return true;
- }
- }
-
- private boolean ParseFunction() throws JSbxExceptionBase {
- if (this.pFunctionObject != null) {
- throw new JScriptParserException(2009, this.aActualTokenPos);
- } else {
- JScriptTokenPosition var1 = (JScriptTokenPosition)this.aActualTokenPos.clone();
- JScriptParserIdentifier var2 = this.ParseIdentifier();
- if (var2 == null) {
- throw new JScriptParserException(2010, this.aActualTokenPos);
- } else {
- String var3 = var2.aIdentifierName;
- JScriptMethod var4 = new JScriptMethod(this.aModule, var3);
- this.pFunctionObject = var4;
- JScriptCodeBlock var5 = this.GetCodeBlock();
- this.SetCodeBlock(var4.GetCodeBlock());
- this.TestForLParam(true);
- JSbxVector var6 = new JSbxVector();
- boolean var7 = true;
-
- while(var7 && (var2 = this.ParseIdentifier()) != null) {
- var6.Add(var2);
- JScriptToken var8 = this.PeekToken();
- var7 = false;
- if (var8 != null && var8.GetID() == 94) {
- this.NextToken();
- var7 = true;
- }
- }
-
- int var14 = var6.GetSize();
- if (var14 > 0) {
- String[] var9 = new String[var14];
-
- for(int var10 = 0; var10 < var14; ++var10) {
- JScriptParserIdentifier var11 = (JScriptParserIdentifier)var6.Get(var10);
- var9[var10] = var11.aIdentifierName;
- }
-
- var4.SetParameterList(var9);
- }
-
- this.TestForRParam(true);
- this.AddSourceCode();
- this.AddDebugStepCode();
- this.ParseBlock(true);
- this.ParserAddCode(new JSP_Stop());
- var1.SetEndPos(this.aActualTokenPos.GetEndPos());
- var4.SetSourceCodePos(var1);
- var4.LocalVarDefFinished();
- this.pFunctionObject = null;
-
- try {
- this.aModule.AddFunction(var4);
- } catch (JSbxException var12) {
- }
-
- this.SetCodeBlock(var5);
- return true;
- }
- }
- }
-
- private boolean ParseIf() throws JSbxExceptionBase {
- if (this.bDumpParsing) {
- this.aDebugOutStream.println("ParseIf()");
- }
-
- int var1 = this.GetSourceCodePC();
- int var2 = this.GetDebugStepPC();
- this.TestForLParam(true);
- JScriptParserExpression var3 = this.ParseExpression();
- if (var3 == null) {
- throw new JScriptParserException(2007, this.aActualTokenPos);
- } else {
- this.TestForRParam(true);
- this.SetSourceCode(var1);
- this.SetDebugStepCode(var2);
- var3.GenerateCode(this.GetCodeGenParam(), true);
- int var4 = this.ParserAddCode((JScriptPCode)null);
- boolean var5 = this.ParseStatement();
- int var6 = this.GetCodeBlock().GetNextCodePos();
- JScriptToken var7 = this.PeekToken();
- if (var7 != null && var7.GetID() == 14) {
- int var8 = this.ParserAddCode((JScriptPCode)null);
- this.NextToken();
- this.AddSourceCode();
- var6 = this.GetCodeBlock().GetNextCodePos();
- var5 = this.ParseStatement();
- int var9 = this.GetCodeBlock().GetNextCodePos();
- this.GetCodeBlock().SetPCode(var8, new JSP_Jmp(var9));
- }
-
- this.GetCodeBlock().SetPCode(var4, new JSP_JmpIfFalse(var6));
- return true;
- }
- }
-
- private boolean ParseReturn() throws JSbxExceptionBase {
- int var1 = this.GetSourceCodePC();
- int var2 = this.GetDebugStepPC();
- JScriptParserExpression var3 = null;
- this.bEndOfStmtExpected = true;
- this.TestForEOS(false);
- if (this.bEndOfStmtExpected) {
- var3 = this.ParseExpression();
- }
-
- if (var3 != null) {
- var3.GenerateCode(this.GetCodeGenParam());
- this.ParserAddCode(new JSP_Return());
- } else {
- this.ParserAddCode(new JSP_Stop());
- }
-
- this.SetSourceCode(var1);
- this.SetDebugStepCode(var2);
- return true;
- }
-
- private boolean ParseVar() throws JSbxExceptionBase {
- int var1 = this.GetSourceCodePC();
-
- boolean var3;
- do {
- JScriptParserIdentifier var4 = this.ParseIdentifier();
- if (var4 == null) {
- throw new JScriptParserException(2012, this.aActualTokenPos);
- }
-
- String var5 = var4.aIdentifierName;
- JScriptToken var6 = this.PeekToken();
- JScriptParserExpression var2 = null;
- if (var6 != null && var6.GetID() == 105) {
- this.NextToken();
- var2 = this.ParseExpression(true);
- if (var2 == null) {
- throw new JScriptParserException(2007, this.aActualTokenPos);
- }
-
- var6 = this.PeekToken();
- }
-
- this.AddDebugStepCode();
- var3 = false;
- if (var6 != null && var6.GetID() == 94) {
- this.NextToken();
- var3 = true;
- }
-
- if (this.pFunctionObject != null) {
- this.pFunctionObject.GetLocalVarVector().Add(var5);
- this.ParserAddCode(new JSP_CreateLocal(var5, -1));
- } else {
- this.ParserAddCode(new JSP_CreateGlobal(var5, -1));
- if (this.aGlobalVarVector != null) {
- this.aGlobalVarVector.Add(var5);
- }
- }
-
- if (var2 != null) {
- var2.GenerateCode(this.GetCodeGenParam());
- this.ParserAddCode(new JSP_StoreIn(var5));
- } else {
- this.ParserAddCode(new JSP_Find(var5));
- }
-
- if (var3) {
- this.GenClrExpStack();
- }
- } while(var3);
-
- this.SetSourceCode(var1);
- return true;
- }
-
- private boolean ParseWhile() throws JSbxExceptionBase {
- if (this.bDumpParsing) {
- this.aDebugOutStream.println("ParseWhile()");
- }
-
- int var1 = this.GetSourceCodePC();
- this.TestForLParam(true);
- JScriptParserExpression var2 = this.ParseExpression();
- if (var2 == null) {
- throw new JScriptParserException(2007, this.aActualTokenPos);
- } else {
- this.TestForRParam(true);
- this.SetSourceCode(var1);
- int var3 = this.GetCodeBlock().GetNextCodePos();
- this.AddDebugStepCode();
- JScriptParserStructItem var5 = new JScriptParserStructItem((short)50);
- this.GetStructLevelStack().Push(var5);
- var2.GenerateCode(this.GetCodeGenParam(), true);
- int var6 = this.ParserAddCode((JScriptPCode)null);
- this.ParseStatement();
- this.ParserAddCode(new JSP_Jmp(var3));
- int var7 = this.GetCodeBlock().GetNextCodePos();
- var5.GenBreakJumps(this.GetCodeBlock(), var7);
- var5.GenContinueJumps(this.GetCodeBlock(), var3);
- this.GetCodeBlock().SetPCode(var6, new JSP_JmpIfFalse(var7));
- this.GetStructLevelStack().Pop();
- return true;
- }
- }
-
- private boolean ParseWith() throws JSbxExceptionBase {
- if (this.bDumpParsing) {
- this.aDebugOutStream.println("ParseWith()");
- }
-
- int var1 = this.GetSourceCodePC();
- this.TestForLParam(true);
- JScriptParserExpression var2 = this.ParseExpression();
- if (var2 == null) {
- throw new JScriptParserException(2007, this.aActualTokenPos);
- } else {
- this.TestForRParam(true);
- this.SetSourceCode(var1);
- this.AddDebugStepCode();
- var2.GenerateCode(this.GetCodeGenParam());
- this.ParserAddCode(new JSP_PushWith());
- this.ParseStatement();
- this.ParserAddCode(new JSP_PopWith());
- return true;
- }
- }
-
- private boolean ParseBlock(boolean var1) throws JSbxExceptionBase {
- if (this.bDumpParsing) {
- this.aDebugOutStream.println("ParseBlock()");
- }
-
- this.bEndOfStmtExpected = false;
- JScriptToken var2 = this.PeekToken();
- if (var2 == null) {
- return false;
- } else {
- boolean var3 = false;
- if (var2.GetID() == 128) {
- var3 = true;
- this.NextToken();
- this.AddSourceCode();
- boolean var4 = false;
-
- do {
- var2 = this.PeekToken();
- if (var2 == null) {
- throw new JScriptParserException(2006, this.aActualTokenPos);
- }
-
- short var5 = var2.GetID();
- if (var5 == 129) {
- var4 = true;
- this.NextToken();
- this.AddSourceCode();
- } else {
- this.ParseStatement();
- }
- } while(!var4);
-
- this.bEndOfStmtExpected = false;
- return true;
- } else if (var1) {
- throw new JScriptParserException(2006, this.aActualTokenPos);
- } else {
- return this.ParseStatement();
- }
- }
- }
-
- public JScriptParserTerm ParseTerm() throws JSbxExceptionBase {
- return this.ParseTerm(false);
- }
-
- public JScriptParserTerm ParseTerm(boolean var1) throws JSbxExceptionBase {
- if (this.bDumpParsing) {
- this.aDebugOutStream.println("ParseTerm()");
- }
-
- Object var2 = null;
- JScriptParserTerm var11 = new JScriptParserTerm();
- boolean var4 = false;
- JScriptToken var5 = this.PeekToken();
- if (var5 != null && var5.GetID() == 31) {
- this.NextToken();
- var4 = true;
- var11.bUsedForNew = true;
- }
-
- boolean var6 = true;
-
- JScriptParserSubTerm var3;
- while((var3 = this.ParseSubTerm(var6, var1)) != null) {
- var6 = false;
- var11.AddSubTerm(var3);
- var5 = this.PeekToken();
- if (var5 == null || var5.GetID() != 133) {
- break;
- }
-
- this.NextToken();
- }
-
- if (var11.GetSubTermCount() == 0) {
- var11 = null;
- } else if (var4) {
- boolean var7 = false;
- JScriptParserSubTerm var8 = var11.GetSubTerm(var11.GetSubTermCount() - 1);
- int var9 = var8.GetNumberOfCallOrIndex();
- if (var9 == 0) {
- var7 = true;
- } else {
- JSbxBase var10 = var8.GetCallOrIndex(var9 - 1);
- if (!(var10 instanceof JScriptParserParamList)) {
- var7 = true;
- }
- }
-
- if (var7) {
- var8.AddCall(new JScriptParserParamList());
- }
- }
-
- if (this.bDumpParsing) {
- if (var11 == null) {
- this.aDebugOutStream.println("returns null");
- } else {
- this.aDebugOutStream.println("returns SubTerm");
- }
- }
-
- return var11;
- }
-
- private JScriptParserSubTerm ParseSubTerm(boolean var1, boolean var2) throws JSbxExceptionBase {
- if (this.bDumpParsing) {
- this.aDebugOutStream.println("ParseSubTerm()");
- }
-
- JScriptParserSubTerm var3 = null;
- if (var1) {
- if (var2) {
- var3 = new JScriptParserSubTerm();
- var3.bStartsAsExpression = true;
- } else {
- JScriptToken var4 = this.PeekToken();
- if (var4 != null) {
- if (var4.GetID() == 42) {
- this.NextToken();
- var3 = new JScriptParserSubTerm();
- var3.bThis = true;
- } else if (var4.GetType() == 3) {
- JSbxValue var5 = var4.GetValue();
- if (var5.GetType() == 4) {
- this.NextToken();
- var3 = new JScriptParserSubTerm();
- var3.aStaticStr = var5.GetString();
- }
- }
- }
- }
- }
-
- if (var3 == null) {
- JScriptParserIdentifier var8 = this.ParseIdentifier();
- if (var8 != null) {
- var3 = new JScriptParserSubTerm();
- var3.aIdentifier = var8;
- }
- }
-
- if (var3 != null) {
- JScriptTokenPosition var9 = new JScriptTokenPosition();
-
- boolean var10;
- do {
- var10 = false;
- JScriptToken var6 = this.PeekToken();
- if (var6 != null) {
- if (var6.GetID() == 130) {
- if (this.bDumpParsing) {
- this.aDebugOutStream.println("Index gefunden");
- }
-
- this.NextToken(var9);
- var10 = true;
- JScriptParserExpression var7 = this.ParseExpression();
- if (var7 == null) {
- throw new JScriptParserException(2015, this.aActualTokenPos);
- }
-
- var6 = this.NextToken(var9);
- if (var6.GetID() != 131) {
- throw new JScriptParserException(2016, this.aActualTokenPos);
- }
-
- var3.AddIndex(var7);
- } else if (var6.GetID() == 87) {
- if (this.bDumpParsing) {
- this.aDebugOutStream.println("Call gefunden");
- }
-
- this.NextToken();
- var10 = true;
- JScriptParserParamList var13 = this.ParseCall();
- var6 = this.NextToken(var9);
- if (var6.GetID() != 88) {
- throw new JScriptParserException(2017, this.aActualTokenPos);
- }
-
- var3.AddCall(var13);
- }
- }
- } while(var10);
- }
-
- if (this.bDumpParsing) {
- if (var3 == null) {
- this.aDebugOutStream.println("returns null");
- } else {
- this.aDebugOutStream.println("returns SubTerm");
- }
- }
-
- return var3;
- }
-
- private JScriptParserIdentifier ParseIdentifier() throws JSbxExceptionBase {
- if (this.bDumpParsing) {
- this.aDebugOutStream.println("ParseIdentifier()");
- }
-
- JScriptParserIdentifier var1 = null;
- JScriptToken var2 = this.PeekToken();
- if (var2 != null && var2.GetType() == 2) {
- this.NextToken();
- var1 = new JScriptParserIdentifier(var2.GetString());
- }
-
- if (this.bDumpParsing) {
- if (var1 == null) {
- this.aDebugOutStream.println("returns null");
- } else {
- this.aDebugOutStream.println("returns " + var1.aIdentifierName);
- }
- }
-
- return var1;
- }
-
- private JScriptParserParamList ParseCall() throws JSbxExceptionBase {
- JScriptParserParamList var1 = new JScriptParserParamList();
- boolean var3 = true;
-
- JScriptParserExpression var2;
- while(var3 && (var2 = this.ParseExpression(true)) != null) {
- var1.AddExpression(var2);
- JScriptToken var4 = this.PeekToken();
- var3 = false;
- if (var4 != null && var4.GetID() == 94) {
- this.NextToken();
- var3 = true;
- }
- }
-
- return var1;
- }
-
- public JScriptParserExpression ParseExpression() throws JSbxExceptionBase {
- return this.ParseExpression(false);
- }
-
- private JScriptParserExpression ParseExpression(boolean var1) throws JSbxExceptionBase {
- return this.aExprParser != null ? this.aExprParser.ParseIt(var1) : null;
- }
-
- private boolean TestForLParam(boolean var1) throws JSbxExceptionBase {
- JScriptToken var2 = this.NextToken();
- if (var2 != null && var2.GetID() == 87) {
- return true;
- } else if (var1) {
- throw new JScriptParserException(2018, this.aActualTokenPos);
- } else {
- return false;
- }
- }
-
- private boolean TestForRParam(boolean var1) throws JSbxExceptionBase {
- JScriptToken var2 = this.NextToken();
- if (var2 != null && var2.GetID() == 88) {
- return true;
- } else if (var1) {
- throw new JScriptParserException(2017, this.aActualTokenPos);
- } else {
- return false;
- }
- }
-
- private boolean TestForEOS(boolean var1) throws JSbxExceptionBase {
- JScriptToken var2 = this.PeekToken();
- if (var2 != null && var2.GetID() == 132) {
- this.NextToken();
- this.bEndOfStmtExpected = false;
- } else if (var1) {
- throw new JScriptParserException(2008, this.aActualTokenPos);
- }
-
- return true;
- }
-
- public JScriptToken NextToken(JScriptTokenPosition var1) throws JScriptTokenizerException {
- JScriptToken var2 = this.ImpGetNextTokenButEOL((JScriptTokenPosition)null);
- this.aTokenInterface.NextToken(this.aActualTokenPos);
- if (var1 != null) {
- var1.Set(this.aActualTokenPos);
- }
-
- if (this.aDebugStepPos == null) {
- this.aDebugStepPos = (JScriptTokenPosition)this.aActualTokenPos.clone();
- } else {
- this.aDebugStepPos.SetEndPos(this.aActualTokenPos.GetEndPos());
- }
-
- if (this.aStatementPos == null) {
- this.aStatementPos = (JScriptTokenPosition)this.aActualTokenPos.clone();
- } else {
- this.aStatementPos.SetEndPos(this.aActualTokenPos.GetEndPos());
- }
-
- if (this.bSourceAsPCode) {
- if (var2.GetType() == 3 && var2.GetValue().GetType() == 4) {
- String var3 = this.aSourceCodeStr;
- this.aSourceCodeStr = var3 + "\"" + var2.GetString() + "\" ";
- } else {
- String var10001 = this.aSourceCodeStr;
- this.aSourceCodeStr = var10001 + var2.GetString() + " ";
- }
- }
-
- return var2;
- }
-
- public JScriptToken NextToken() throws JScriptTokenizerException {
- return this.NextToken((JScriptTokenPosition)null);
- }
-
- public JScriptToken PeekToken(JScriptTokenPosition var1) throws JScriptTokenizerException {
- return this.ImpGetNextTokenButEOL(var1);
- }
-
- public JScriptToken PeekToken() throws JScriptTokenizerException {
- return this.ImpGetNextTokenButEOL((JScriptTokenPosition)null);
- }
-
- private JScriptToken ImpGetNextTokenButEOL(JScriptTokenPosition var1) throws JScriptTokenizerException {
- JScriptToken var2;
- for(var2 = this.aTokenInterface.PeekToken(var1); var2 != null && var2.GetID() == 134; var2 = this.aTokenInterface.PeekToken(var1)) {
- this.aTokenInterface.NextToken((JScriptTokenPosition)null);
- this.bEndOfStmtExpected = false;
- }
-
- return var2;
- }
-
- public JScriptToken LastToken() {
- return this.aTokenInterface.LastToken();
- }
-
- public JScriptToken GetLastTokenForExpParser() {
- return this.aTokenInterface.LastToken();
- }
- }
-