Пример #1
0
 public ForNode(AssignNode initial, DirectionType direction, ExprNode final, StatementNode body)
 {
     Initial   = initial;
     Direction = direction;
     Final     = final;
     Body      = body;
 }
Пример #2
0
        public PrinterNode Visit(AssignNode node)
        {
            var pNode = new PrinterNode(node.Operation.StringValue);

            pNode.AddChild(node.Left.Accept(this));
            pNode.AddChild(node.Right.Accept(this));
            return(pNode);
        }
Пример #3
0
        public bool Visit(AssignNode node)
        {
            node.Left.Accept(this);
            node.Right.Accept(this);

            if (!node.Left.IsLvalue)
            {
                throw BuildException <NotLvalueException>(ExprNode.GetClosestToken(node.Left));
            }

            _typeChecker.RequireAssignment(ref node.Left, ref node.Right, node.Operation);
            return(true);
        }
Пример #4
0
        /// <summary>
        /// Checks the static semantic constraints of an AssignNode.
        /// </summary>
        /// <returns>An void.</returns>
        /// <param name="node">Node.</param>
        public void VisitAssignNode(AssignNode node)
        {
            node.IDNode.Accept(this);
            node.AssignValueExpression.Accept(this);
            bool errored = false;

            TokenType varEval  = node.IDNode.EvaluationType;
            TokenType exprEval = node.AssignValueExpression.EvaluationType;

            bool     assignable  = node.IDNode.EvaluationType != TokenType.ERROR;
            Property varProperty = node.Scope.GetProperty(node.IDNode.IDNode.ID);

            if (varProperty.DeclarationRow > node.Token.Row)
            {
                analyzer.notifyError(new UndeclaredVariableError(node.IDNode));
                assignable = false;
                errored    = true;
            }

            if (!LegitOperationChecker.isAssignCompatible(varEval, exprEval) && !errored)
            {
                analyzer.notifyError(new IllegalAssignmentError(node));
                assignable = false;
                errored    = true;
            }

            if (!LegitOperationChecker.CanBeAssignedTo(varEval, exprEval) && !errored)
            {
                analyzer.notifyError(new IllegalAssignmentError(node));
                assignable = false;
                errored    = true;
            }

            if (assignable)
            {
                varProperty.Assigned = true;
            }
        }
Пример #5
0
 public void VisitAssignNode(AssignNode node)
 {
 }