Exemple #1
0
        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)");
            }
        }
Exemple #2
0
        // 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);
        }
Exemple #3
0
 // Create a new case clause
 public Case AddCase(Expression Value)
 {
     var c=new Case(Value);
     Cases.Add(c);
     return c;
 }
Exemple #4
0
 // Constructor
 public StatementSwitch(Bookmark bookmark, Expression testExpression)
     : base(bookmark)
 {
     TestExpression = testExpression;
 }
Exemple #5
0
 // Constructor
 public Case(Expression value)
 {
     Value = value;
 }
Exemple #6
0
 // Constructor
 public StatementExpression(Bookmark bookmark, Expression expression)
     : base(bookmark)
 {
     Expression = expression;
 }
Exemple #7
0
 // Constructor
 public StatementIfElse(Bookmark bookmark, Expression condition)
     : base(bookmark)
 {
     Condition = condition;
 }
Exemple #8
0
 // Constructor
 public StatementReturnThrow(Bookmark bookmark, Token op, Expression value)
     : base(bookmark)
 {
     Op = op;
     Value = value;
 }