private Ast.Stmt ParseExecuteStmt(TokenQueue q) { var stmt = new Ast.ExecuteStmt { SourceToken = q.SourceToken }; q.Take("exec", "execute"); if (q.Peek(1) == "=") { stmt.ReturnVariableName = ParseVariableName(q); q.Take("="); } if (q.PeekToken().Type == TokenType.String || q.PeekToken().Type == TokenType.Id) { stmt.ScriptName = q.Take().GetUnescapedText(); } else { throw new SyntaxException(new[] { "string", "identifier" }, q); } if (IsVariableName(q.PeekToken()?.GetUnescapedText() ?? "") && q.Peek(1) == "=") { while (true) { var arg = new Ast.ArgumentPair(); arg.Name = ParseVariableName(q); q.Take("="); if (q.Peek() == "default") { q.Take(); } else { arg.Value = ParseExpr(q); } stmt.Arguments.Add(arg); if (!q.TakeMaybe(",")) { break; } } } ConsumeSemicolon(q); return(stmt); }
private Ast.Stmt ParseForStmt(TokenQueue q) { var stmt = new Ast.ForStmt { SourceToken = q.SourceToken }; q.Take("for"); stmt.VariableName = ParseVariableName(q); q.Take("="); stmt.FirstNumberExpr = ParseExpr(q); q.Take("to"); stmt.LastNumberExpr = ParseExpr(q); if (q.TakeMaybe("step")) { stmt.StepExpr = ParseExpr(q); } stmt.Block = ParseBlock(q); ConsumeSemicolon(q); return(stmt); }