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 HRMProgram(string code) { parser = new Parser(code); ctv = new CompileTimeVars(code); string token = parser.GetNextToken(); if (token == "var") { CreateVarTab(); } block = new StmtBlock(parser); token = parser.GetNextToken(); if (!string.IsNullOrWhiteSpace(token)) { throw new CompileException(ErrorHelper.UnexpectedEndOfProgram); } }