public StmtIfElse(Parser parser) { string token = parser.GetNextToken(); if (token != "(") { throw new CompileException(ErrorHelper.Unexpected("(", token)); } cond = new StmtExpression(parser); token = parser.GetNextToken(); if (token != ")") { throw new CompileException(ErrorHelper.Unexpected(")", token)); } ifBlock = new StmtBlock(parser); token = parser.PeekNextToken(); if (token == "else") { token = parser.GetNextToken(); elseBlock = new StmtBlock(parser); } if (cond.RequireSwitchLogic) { var tmp = ifBlock; ifBlock = elseBlock; elseBlock = tmp; } }
public StmtDoWhile(Parser parser) { loop = new StmtBlock(parser); string token = parser.GetNextToken(); if (token != "while") { throw new CompileException(ErrorHelper.Unexpected("while", token)); } token = parser.GetNextToken(); if (token != "(") { throw new CompileException(ErrorHelper.Unexpected("(", token)); } cond = new StmtExpression(parser); token = parser.GetNextToken(); if (token != ")") { throw new CompileException(ErrorHelper.Unexpected(")", token)); } token = parser.GetNextToken(); if (token != ";") { throw new CompileException(ErrorHelper.Unexpected(";", token)); } }
public StmtAssignment(Parser parser, string d) { dest = d; exp = new StmtExpression(parser); string token = parser.GetNextToken(); if (token != ";") { throw new CompileException(ErrorHelper.Unexpected(";", token)); } }