コード例 #1
0
ファイル: AstNodes.cs プロジェクト: ZeroICQ/pascal-compiler
 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)
 {
 }