protected override Boolean handleWhile(WhileStatementNode whileStatement, HashSet <StatementNode> visited) { switch (expressionChecker.handleExpression(whileStatement.Condition, visited, true)) { case Assigned: return(Boolean.FALSE); case AssignedAfterTrue: return(Boolean.TRUE); case AssignedAfterFalse: visitOrigin(whileStatement.Statement); return(Boolean.FALSE); default: var cinfo = whileStatement.Condition.getUserData(typeof(ExpressionInfo)); if (cinfo.IsConstant) { if ((Boolean)cinfo.Value) { return(visitOrigin(whileStatement.Statement)); } else { return(Boolean.TRUE); } } visitOrigin(whileStatement.Statement); return(Boolean.TRUE); } }
public virtual void VisitWhileStatementNode(WhileStatementNode node) { Visit(node.WhileKeywordNode); Visit(node.ConditionNode); Visit(node.DoKeywordNode); Visit(node.StatementNode); }
public void WholeProgramWithoutBindingTest() { const string Code = @" Output(""Hello world""); ... 0 Var name = Input(); ... 1 Output(""Hey"" + name); ... 2 While True ... 3 { Output(""Hey""); } "; Lexer lexer = new(Code); LexemeCollection lexemes = lexer.LexAll(); ProgramParser parser = new(lexemes, Code); Compilation tree = new(parser.ParseWholeProgram() !, Code); Assert.NotNull(tree); Assert.IsInstanceOf <ProgramNode>(tree.Program); ProgramNode programNode = tree.Program; Assert.AreEqual(4, programNode.TopLevelStatementNodes.Count); Assert.IsInstanceOf <FunctionCallStatementNode>(programNode.TopLevelStatementNodes[0]); Assert.IsInstanceOf <VariableDeclarationStatementNode>(programNode.TopLevelStatementNodes[1]); Assert.IsInstanceOf <FunctionCallStatementNode>(programNode.TopLevelStatementNodes[2]); Assert.IsInstanceOf <WhileStatementNode>(programNode.TopLevelStatementNodes[3]); WhileStatementNode @while = (WhileStatementNode)programNode.TopLevelStatementNodes[3]; Assert.AreEqual(1, @while.StatementNodes.Count); }
private bool BindInWhileStatement(WhileStatementNode whileStatement, VariableIdentifierMap variableIdentifierMap) { TypeSymbolNode?conditionType = BindInExpression(whileStatement.ConditionNode, variableIdentifierMap); if (conditionType == null) { return(false); } TypeSymbolNode?boolType = typeManager[FrameworkType.Bool]; if (!TypeIsCompatibleWith(conditionType, boolType, possiblyOffendingNode: whileStatement.ConditionNode, out ImplicitConversionSymbolNode? conversion)) { return(false); } if (conversion != null) { whileStatement.ConditionNode.SpecifyImplicitConversion(conversion); } bool success = BindInStatementBlock(whileStatement.StatementNodes, variableIdentifierMap); return(success); }
public override void Visit(WhileStatementNode node) { Console.WriteLine(this.indentation + "While ---- Statement ----"); indentation = indentation + " "; node.expression.Accept(this); node.statement.Accept(this); indentation = indentation.Substring(0, indentation.Length - 3); }
private static void Walk([NotNull] Agent agent, [NotNull] WhileStatementNode whileStatement, bool isStrict) { if (IsLabelledFunction(whileStatement.Body)) { throw agent.CreateSyntaxError(); } Walk(agent, whileStatement.Test, isStrict); Walk(agent, whileStatement.Body, isStrict); }
public override void Visit(WhileStatementNode node) { string WhileLabel = WhileLabelGenerator.GetNewLabel(); string WhileLabelLoop = WhileLabel + "Loop"; string WhileLabelTest = WhileLabel + "Test"; Gen("jmp", WhileLabelTest); GenText(WhileLabelLoop + ":"); node.statement.Accept(this); GenText(WhileLabelTest + ":"); node.expression.Accept(this); Gen("cmp", "eax", "0"); Gen("jg", WhileLabelLoop); }
private static PythonNode Wrap(WhileStatement stmt, PythonNode parent) { var result = new WhileStatementNode(stmt) { Parent = parent }; result.AddChild(Wrap(stmt.Test, result)); result.AddChild(Wrap(stmt.Body, result)); if (stmt.ElseStatement != null) { result.AddChild(Wrap(stmt.ElseStatement, result)); } return(result); }
public virtual Value evaluate(Context cx, WhileStatementNode node) { output("<WhileStatementNode position=\"" + node.pos() + "\">"); indent_Renamed_Field++; if (node.expr != null) { node.expr.evaluate(cx, this); } if (node.statement != null) { node.statement.evaluate(cx, this); } indent_Renamed_Field--; output("</WhileStatementNode>"); return(null); }
private WhileStatementNode Visit(WhileStatementNode node) { var condBB = func.AppendBasicBlock($"cond_{++count}"); var bodyBB = func.AppendBasicBlock($"body_{++count}"); var contBB = func.AppendBasicBlock($"next_{++count}"); builder.BuildBr(condBB); builder.PositionAtEnd(condBB); Visit(node.BoolRelationExpression); builder.BuildCondBr(GetProperty(node.BoolRelationExpression).addr, bodyBB, contBB); builder.PositionAtEnd(bodyBB); Visit(node.StatementNode); builder.BuildBr(condBB); builder.PositionAtEnd(contBB); return(node); }
private void EmitWhileStatement(WhileStatementNode whileStatement) { if (whileStatement.IsLeftOrContinued()) { // There exists a Leave or Continue statement targeting this loop. // We need to add a label so that we can emit a correct break or // continue statement. output.Append("$loop_").Append(globalLoopCount).Append(':'); associatedLoopIds[whileStatement] = globalLoopCount; globalLoopCount++; } output.Append("while("); EmitExpression(whileStatement.ConditionNode); output.Append(')'); EmitStatementBlock(whileStatement.StatementNodes); }
private void Write(WhileStatementNode stmt) { Fill(); _code.Append("while "); Write(stmt.Children[0]); Enter(); Write(stmt.Children[1]); Leave(); if (stmt.Children.Count == 3) { Fill(); _code.Append("else"); Enter(); Write(stmt.Children[2]); Leave(); } }
public override void Visit(WhileStatementNode node) { try { node.expression.Accept(this); if (!AreTypeCompatible(node.expression.ExpressionType.GetType(), typeof(BooleanType))) { throw new Exception("While condition expression is not of type Boolean!"); } } catch (Exception e) { Analysis.LogSemanticError(e.Message, node.lineNumber); } node.statement.Accept(this); }
private WhileStatementNode BuildWhileStatementNode( LexSpan lWhile, SyntaxNodeOrToken condition, SyntaxNodeOrToken body, LexSpan end, LexSpan rWhile) { var exp = new WhileStatementNode(); exp.AddNode(new WhileToken(lWhile)); exp.AddNode(condition); exp.AddNode(body); exp.AddNode(new EndToken(end)); exp.AddNode(new WhileToken(rWhile)); return(exp); }
private WhileStatementNode Visit(WhileStatementNode node) { var begin = MakeLabel(); var body = MakeLabel(); var next = MakeLabel(); dynamic BoolProp = new ExpandoObject(); properties.Add(node.BoolRelationExpression, BoolProp); BoolProp.trueLabel = body; BoolProp.falseLabel = next; generatedCode.Add(begin); node.BoolRelationExpression.Visit(this); generatedCode.Add(body); node.StatementNode.Visit(this); generatedCode.Add(MakeLabeledGoto(begin)); generatedCode.Add(next); return(node); }
private WhileStatementNode Visit(WhileStatementNode node) { dynamic props = new ExpandoObject(); properties.Add(node, props); var code = new List <CodeEntry>(); props.code = code; var begin = MakeLabel(); var trueLabel = properties[node.BoolRelationExpression].trueLabel; var falseLabel = properties[node.BoolRelationExpression].falseLabel; code.Add(begin); code.AddRange(properties[node.BoolRelationExpression].code); code.Add(trueLabel); code.AddRange(properties[node.StatementNode].code); code.Add(MakeLabeledGoto(begin)); code.Add(falseLabel); return(node); }
protected override Void handleWhile(WhileStatementNode whileStatement, Void source) { var condition = whileStatement.Condition; this.ExpressionValidator.handleExpression(condition, context.TypeSystem.BooleanType, true); ValidationHelper.setBoxing(context, context.TypeSystem.BooleanType, condition); var info = condition.getUserData(typeof(ExpressionInfo)); if (info == null || ValidationHelper.getType(context, condition) != context.TypeSystem.BooleanType) { throw context.error(CompileErrorId.NoImplicitConversion, condition, BytecodeHelper.getDisplayName(info == null ? null : ValidationHelper.getType(context, condition)), BytecodeHelper.getDisplayName(context.TypeSystem.BooleanType)); } try { context.MemberResolver.enterScope(); handleStatement(whileStatement.Statement, source); } finally { context.MemberResolver.leaveScope(); } return(null); }
protected override List <AssemblyElement> VisitWhileStatement(WhileStatementNode node) { _labelManager.StartNextWhileStatement(); string startLabel = _labelManager.GenerateWhileLabel(WhileLabelType.Start); string endLabel = _labelManager.GenerateWhileLabel(WhileLabelType.End); List <AssemblyElement> instructions = new List <AssemblyElement>(); instructions.Add(new AssemblyLabel(startLabel)); instructions.AddRange(Visit(node.ConditionNode)); instructions.Add(new JumpIfToLabel(endLabel)); foreach (StatementNode bodyNode in node.BodyNodes) { List <AssemblyElement> bodyInstructions = Visit(bodyNode); foreach (AssemblyElement instruction in bodyInstructions) { if (instruction is JumpToLoopStart) { instructions.Add(new JumpToLabel(startLabel)); } else if (instruction is JumpToLoopEnd) { instructions.Add(new JumpToLabel(endLabel)); } else { instructions.Add(instruction); } } } instructions.Add(new JumpToLabel(startLabel)); instructions.Add(new AssemblyLabel(endLabel)); return(instructions); }
public virtual void Visit(WhileStatementNode node) { node.expression.Accept(this); node.statement.Accept(this); }
protected override void DoAction(int action) { switch (action) { case 2: // Program -> MainClassDecl, ClassDeclList_Opt { CurrentSemanticValue = new ProgramNode((MainClassDeclNode)ValueStack[ValueStack.Depth - 2], (ClassDeclListNode)ValueStack[ValueStack.Depth - 1], LineNumber); Analysis.AST = (ProgramNode)CurrentSemanticValue; } break; case 3: // MainClassDecl -> ClassKeyword, Identifier, CurlyBracketOpen, PublicKeyword, // StaticKeyword, VoidKeyword, MainKeyword, RoundBracketOpen, // StringKeyword, SquareBracketOpen, SquareBracketClose, // Identifier, RoundBracketClose, CurlyBracketOpen, Statement, // CurlyBracketClose, CurlyBracketClose { CurrentSemanticValue = new MainClassDeclNode((IdentifierNode)ValueStack[ValueStack.Depth - 16], (IdentifierNode)ValueStack[ValueStack.Depth - 6], (StatementNode)ValueStack[ValueStack.Depth - 3], LineNumber); } break; case 4: // ClassDeclList_Opt -> ClassDeclList_Opt, ClassDecl { ((ClassDeclListNode)ValueStack[ValueStack.Depth - 2]).AddClassDecl((ClassDeclNode)ValueStack[ValueStack.Depth - 1]); CurrentSemanticValue = ValueStack[ValueStack.Depth - 2]; } break; case 5: // ClassDeclList_Opt -> /* empty */ { CurrentSemanticValue = new ClassDeclListNode(LineNumber); } break; case 6: // ClassDecl -> ClassKeyword, Identifier, Extends_Opt, CurlyBracketOpen, // VariableDeclList_Opt, MethodDeclList_Opt, CurlyBracketClose { CurrentSemanticValue = new ClassDeclNode((IdentifierNode)ValueStack[ValueStack.Depth - 6], (ExtendsNode)ValueStack[ValueStack.Depth - 5], (VariableDeclListNode)ValueStack[ValueStack.Depth - 3], (MethodDeclListNode)ValueStack[ValueStack.Depth - 2], LineNumber); } break; case 7: // Extends_Opt -> ExtendsKeyword, Identifier { CurrentSemanticValue = new ExtendsNode((IdentifierNode)ValueStack[ValueStack.Depth - 1], LineNumber); } break; case 9: // MethodDeclList_Opt -> MethodDeclList_Opt, MethodDecl { ((MethodDeclListNode)ValueStack[ValueStack.Depth - 2]).AddMethodDecl((MethodDeclNode)ValueStack[ValueStack.Depth - 1]); CurrentSemanticValue = ValueStack[ValueStack.Depth - 2]; } break; case 10: // MethodDeclList_Opt -> /* empty */ { CurrentSemanticValue = new MethodDeclListNode(LineNumber); } break; case 11: // MethodDecl -> PublicKeyword, Type, Identifier, RoundBracketOpen, // ParamDeclList_Opt, RoundBracketClose, CurlyBracketOpen, // VariableDeclList_Opt, StatementListEndingInReturn, // CurlyBracketClose { ((StatementListNode)ValueStack[ValueStack.Depth - 2]).statementList.Reverse(); CurrentSemanticValue = new MethodDeclNode((TypeNode)ValueStack[ValueStack.Depth - 9], (IdentifierNode)ValueStack[ValueStack.Depth - 8], (ParamDeclListNode)ValueStack[ValueStack.Depth - 6], (VariableDeclListNode)ValueStack[ValueStack.Depth - 3], (StatementListNode)ValueStack[ValueStack.Depth - 2], LineNumber); } break; case 12: // VariableDeclList_Opt -> VariableDeclList_Opt, VariableDecl { ((VariableDeclListNode)ValueStack[ValueStack.Depth - 2]).AddVariableDecl((VariableDeclNode)ValueStack[ValueStack.Depth - 1]); CurrentSemanticValue = ValueStack[ValueStack.Depth - 2]; } break; case 13: // VariableDeclList_Opt -> /* empty */ { CurrentSemanticValue = new VariableDeclListNode(LineNumber); } break; case 14: // VariableDecl -> Type, Identifier, SemiColon { CurrentSemanticValue = new VariableDeclNode((TypeNode)ValueStack[ValueStack.Depth - 3], (IdentifierNode)ValueStack[ValueStack.Depth - 2], LineNumber); } break; case 15: // StatementListEndingInReturn -> Statement, StatementListEndingInReturn { ((StatementListNode)ValueStack[ValueStack.Depth - 1]).AddStatement((StatementNode)ValueStack[ValueStack.Depth - 2]); CurrentSemanticValue = ValueStack[ValueStack.Depth - 1]; } break; case 16: // StatementListEndingInReturn -> ReturnKeyword, Expr, SemiColon { CurrentSemanticValue = new StatementListNode(LineNumber); ((StatementListNode)CurrentSemanticValue).AddStatement(new ReturnStatementNode((ExpressionNode)ValueStack[ValueStack.Depth - 2], LineNumber)); } break; case 17: // ParamDeclList_Opt -> Type, Identifier, ParamDeclListRest_Opt { ((ParamDeclListNode)ValueStack[ValueStack.Depth - 1]).paramDeclList.Reverse(); ((ParamDeclListNode)ValueStack[ValueStack.Depth - 1]).AddParamDecl(new ParamDeclNode((TypeNode)ValueStack[ValueStack.Depth - 3], (IdentifierNode)ValueStack[ValueStack.Depth - 2], LineNumber)); ((ParamDeclListNode)ValueStack[ValueStack.Depth - 1]).paramDeclList.Reverse(); CurrentSemanticValue = ValueStack[ValueStack.Depth - 1]; } break; case 19: // ParamDeclListRest_Opt -> ParamDeclListRest_Opt, Comma, Type, Identifier { ((ParamDeclListNode)ValueStack[ValueStack.Depth - 4]).AddParamDecl(new ParamDeclNode((TypeNode)ValueStack[ValueStack.Depth - 2], (IdentifierNode)ValueStack[ValueStack.Depth - 1], LineNumber)); CurrentSemanticValue = ValueStack[ValueStack.Depth - 4]; } break; case 20: // ParamDeclListRest_Opt -> /* empty */ { CurrentSemanticValue = new ParamDeclListNode(LineNumber); } break; case 21: // Type -> IntKeyword, SquareBracketOpen, SquareBracketClose { CurrentSemanticValue = new IntegerArrayTypeNode(LineNumber); } break; case 22: // Type -> IntKeyword { CurrentSemanticValue = new IntegerTypeNode(LineNumber); } break; case 23: // Type -> BooleanKeyword { CurrentSemanticValue = new BooleanTypeNode(LineNumber); } break; case 24: // Type -> Identifier { CurrentSemanticValue = new IdentifierTypeNode(((IdentifierNode)ValueStack[ValueStack.Depth - 1]).name, LineNumber); } break; case 25: // Statement -> CurlyBracketOpen, StatementList_Opt, CurlyBracketClose { CurrentSemanticValue = new StatementBlockNode((StatementListNode)ValueStack[ValueStack.Depth - 2], LineNumber); } break; case 26: // Statement -> IfKeyword, RoundBracketOpen, Expr, RoundBracketClose, Statement, // ElseKeyword, Statement { CurrentSemanticValue = new IfStatementNode((ExpressionNode)ValueStack[ValueStack.Depth - 5], (StatementNode)ValueStack[ValueStack.Depth - 3], (StatementNode)ValueStack[ValueStack.Depth - 1], LineNumber); } break; case 27: // Statement -> WhileKeyword, RoundBracketOpen, Expr, RoundBracketClose, Statement { CurrentSemanticValue = new WhileStatementNode((ExpressionNode)ValueStack[ValueStack.Depth - 3], (StatementNode)ValueStack[ValueStack.Depth - 1], LineNumber); } break; case 28: // Statement -> SystemOutPrintLnKeyword, RoundBracketOpen, Expr, RoundBracketClose, // SemiColon { CurrentSemanticValue = new SystemOutPrintLnStatementNode((ExpressionNode)ValueStack[ValueStack.Depth - 3], LineNumber); } break; case 29: // Statement -> Identifier, EqualsOperator, Expr, SemiColon { CurrentSemanticValue = new AssignmentStatementNode((IdentifierNode)ValueStack[ValueStack.Depth - 4], (ExpressionNode)ValueStack[ValueStack.Depth - 2], LineNumber); } break; case 30: // Statement -> Identifier, Dot, Identifier, EqualsOperator, Expr, SemiColon { CurrentSemanticValue = new FieldAssignmentStatementNode((IdentifierNode)ValueStack[ValueStack.Depth - 6], (IdentifierNode)ValueStack[ValueStack.Depth - 4], (ExpressionNode)ValueStack[ValueStack.Depth - 2], LineNumber); } break; case 31: // Statement -> Identifier, SquareBracketOpen, Expr, SquareBracketClose, // EqualsOperator, Expr, SemiColon { CurrentSemanticValue = new ArrayAssignmentStatementNode((IdentifierNode)ValueStack[ValueStack.Depth - 7], (ExpressionNode)ValueStack[ValueStack.Depth - 5], (ExpressionNode)ValueStack[ValueStack.Depth - 2], LineNumber); } break; case 32: // Statement -> error, SemiColon { CurrentSemanticValue = new StatementBlockNode(new StatementListNode(LineNumber), LineNumber); yyclearin(); Analysis.LogSyntaxError("Syntax error", LineNumber); } break; case 33: // Statement -> error, CurlyBracketClose { CurrentSemanticValue = new StatementBlockNode(new StatementListNode(LineNumber), LineNumber); yyclearin(); Analysis.LogSyntaxError("Syntax error", LineNumber); } break; case 34: // StatementList_Opt -> StatementList_Opt, Statement { ((StatementListNode)ValueStack[ValueStack.Depth - 2]).AddStatement((StatementNode)ValueStack[ValueStack.Depth - 1]); CurrentSemanticValue = ValueStack[ValueStack.Depth - 2]; } break; case 35: // StatementList_Opt -> /* empty */ { CurrentSemanticValue = new StatementListNode(LineNumber); } break; case 36: // Expr -> RoundBracketOpen, Expr, RoundBracketClose { CurrentSemanticValue = ValueStack[ValueStack.Depth - 2]; } break; case 37: // Expr -> NotOperator, Expr { CurrentSemanticValue = new NotExpressionNode((ExpressionNode)ValueStack[ValueStack.Depth - 1], LineNumber); } break; case 38: // Expr -> NewKeyword, IntKeyword, SquareBracketOpen, Expr, SquareBracketClose { CurrentSemanticValue = new NewIntegerArrayExpressionNode((ExpressionNode)ValueStack[ValueStack.Depth - 2], LineNumber); } break; case 39: // Expr -> NewKeyword, Identifier, RoundBracketOpen, RoundBracketClose { CurrentSemanticValue = new NewObjectExpressionNode((IdentifierNode)ValueStack[ValueStack.Depth - 3], LineNumber); } break; case 40: // Expr -> Expr, AndAndOperator, Expr { CurrentSemanticValue = new AndExpressionNode((ExpressionNode)ValueStack[ValueStack.Depth - 3], (ExpressionNode)ValueStack[ValueStack.Depth - 1], LineNumber); } break; case 41: // Expr -> Expr, LessThanOperator, Expr { CurrentSemanticValue = new LessThanExpressionNode((ExpressionNode)ValueStack[ValueStack.Depth - 3], (ExpressionNode)ValueStack[ValueStack.Depth - 1], LineNumber); } break; case 42: // Expr -> Expr, AddOperator, Expr { CurrentSemanticValue = new AddExpressionNode((ExpressionNode)ValueStack[ValueStack.Depth - 3], (ExpressionNode)ValueStack[ValueStack.Depth - 1], LineNumber); } break; case 43: // Expr -> Expr, SubtractOperator, Expr { CurrentSemanticValue = new SubtractExpressionNode((ExpressionNode)ValueStack[ValueStack.Depth - 3], (ExpressionNode)ValueStack[ValueStack.Depth - 1], LineNumber); } break; case 44: // Expr -> Expr, MultiplyOperator, Expr { CurrentSemanticValue = new MultiplyExpressionNode((ExpressionNode)ValueStack[ValueStack.Depth - 3], (ExpressionNode)ValueStack[ValueStack.Depth - 1], LineNumber); } break; case 45: // Expr -> Expr, SquareBracketOpen, Expr, SquareBracketClose { CurrentSemanticValue = new ArrayLookupExpressionNode((ExpressionNode)ValueStack[ValueStack.Depth - 4], (ExpressionNode)ValueStack[ValueStack.Depth - 2], LineNumber); } break; case 46: // Expr -> Expr, Dot, LengthKeyword { CurrentSemanticValue = new LengthExpressionNode((ExpressionNode)ValueStack[ValueStack.Depth - 3], LineNumber); } break; case 47: // Expr -> Expr, Dot, Identifier { CurrentSemanticValue = new FieldAccessExpressionNode((ExpressionNode)ValueStack[ValueStack.Depth - 3], (IdentifierNode)ValueStack[ValueStack.Depth - 1], LineNumber); } break; case 48: // Expr -> Expr, Dot, Identifier, RoundBracketOpen, ExprList_Opt, // RoundBracketClose { CurrentSemanticValue = new MethodCallExpressionNode((ExpressionNode)ValueStack[ValueStack.Depth - 6], (IdentifierNode)ValueStack[ValueStack.Depth - 4], (ExpressionListNode)ValueStack[ValueStack.Depth - 2], LineNumber); } break; case 49: // Expr -> ThisKeyword { CurrentSemanticValue = new ThisExpressionNode(LineNumber); } break; case 50: // Expr -> Identifier { CurrentSemanticValue = new IdentifierExpressionNode((IdentifierNode)ValueStack[ValueStack.Depth - 1], LineNumber); } break; case 51: // Expr -> IntegerConstant { CurrentSemanticValue = ValueStack[ValueStack.Depth - 1]; } break; case 52: // Expr -> TrueKeyword { CurrentSemanticValue = ValueStack[ValueStack.Depth - 1]; } break; case 53: // Expr -> FalseKeyword { CurrentSemanticValue = ValueStack[ValueStack.Depth - 1]; } break; case 54: // Expr -> error, IntegerConstant { CurrentSemanticValue = new InvalidExpressionNode(LineNumber); yyclearin(); Analysis.LogSyntaxError("Syntax error", LineNumber); } break; case 55: // Expr -> error, TrueKeyword { CurrentSemanticValue = new InvalidExpressionNode(LineNumber); yyclearin(); Analysis.LogSyntaxError("Syntax error", LineNumber); } break; case 56: // Expr -> error, FalseKeyword { CurrentSemanticValue = new InvalidExpressionNode(LineNumber); yyclearin(); Analysis.LogSyntaxError("Syntax error", LineNumber); } break; case 57: // Expr -> error, Identifier { CurrentSemanticValue = new InvalidExpressionNode(LineNumber); yyclearin(); Analysis.LogSyntaxError("Syntax error", LineNumber); } break; case 58: // Expr -> error, ThisKeyword { CurrentSemanticValue = new InvalidExpressionNode(LineNumber); yyclearin(); Analysis.LogSyntaxError("Syntax error", LineNumber); } break; case 59: // Expr -> error, SquareBracketClose { CurrentSemanticValue = new InvalidExpressionNode(LineNumber); yyclearin(); Analysis.LogSyntaxError("Syntax error", LineNumber); } break; case 60: // Expr -> error, RoundBracketClose { CurrentSemanticValue = new InvalidExpressionNode(LineNumber); yyclearin(); Analysis.LogSyntaxError("Syntax error", LineNumber); } break; case 61: // Expr -> error, LengthKeyword { CurrentSemanticValue = new InvalidExpressionNode(LineNumber); yyclearin(); Analysis.LogSyntaxError("Syntax error", LineNumber); } break; case 62: // ExprList_Opt -> Expr, ExprListRest_Opt { ((ExpressionListNode)ValueStack[ValueStack.Depth - 1]).expressionList.Reverse(); ((ExpressionListNode)ValueStack[ValueStack.Depth - 1]).AddExpression((ExpressionNode)ValueStack[ValueStack.Depth - 2]); ((ExpressionListNode)ValueStack[ValueStack.Depth - 1]).expressionList.Reverse(); CurrentSemanticValue = ValueStack[ValueStack.Depth - 1]; } break; case 63: // ExprList_Opt -> /* empty */ { new ExpressionListNode(LineNumber); } break; case 64: // ExprListRest_Opt -> ExprListRest_Opt, Comma, Expr { ((ExpressionListNode)ValueStack[ValueStack.Depth - 3]).AddExpression((ExpressionNode)ValueStack[ValueStack.Depth - 1]); CurrentSemanticValue = ValueStack[ValueStack.Depth - 3]; } break; case 65: // ExprListRest_Opt -> /* empty */ { CurrentSemanticValue = new ExpressionListNode(LineNumber); } break; } }
protected override Void handleWhile(WhileStatementNode whileStatement, Set <TypeInfo> dependencies) { expressionHandler.handleExpression(whileStatement.Condition, dependencies, true); handleStatement(whileStatement.Statement, dependencies); return(null); }
public virtual Value evaluate(Context cx, WhileStatementNode node) { output("<WhileStatementNode position=\"" + node.pos() + "\">"); indent_Renamed_Field++; if (node.expr != null) { node.expr.evaluate(cx, this); } if (node.statement != null) { node.statement.evaluate(cx, this); } indent_Renamed_Field--; output("</WhileStatementNode>"); return null; }