public void CheckControlCondition(ast.Statement statement, ast.Expression expr) { if (expr == null) { return; } if ((expr.RootNode as ast.ExprNodeAssignment) != null) { currentScope.Compiler.RecordWarning(expr.Bookmark, "assignment as condition of flow control statement (use parens to disable this warning)"); } }
// Parse a single variable declaration void ParseVarDecl(ParseContext ctx, ast.StatementVariableDeclaration decl) { var bmk = t.GetBookmark(); // Variable name t.Require(Token.identifier); var name = t.identifier; t.Next(); // Optional initial value ast.Expression InitialValue = null; if (t.SkipOptional(Token.assign)) { InitialValue = ParseSingleExpression(ctx); } // Store it decl.AddDeclaration(bmk, name, InitialValue); }
// Create a new case clause public Case AddCase(Expression Value) { var c=new Case(Value); Cases.Add(c); return c; }
// Constructor public StatementSwitch(Bookmark bookmark, Expression testExpression) : base(bookmark) { TestExpression = testExpression; }
// Constructor public Case(Expression value) { Value = value; }
// Constructor public StatementExpression(Bookmark bookmark, Expression expression) : base(bookmark) { Expression = expression; }
// Constructor public StatementIfElse(Bookmark bookmark, Expression condition) : base(bookmark) { Condition = condition; }
// Constructor public StatementReturnThrow(Bookmark bookmark, Token op, Expression value) : base(bookmark) { Op = op; Value = value; }