public override ASTNode VisitAddminus([NotNull] SuperCOOLParser.AddminusContext context)
        {
            if (context.ADD() != null)
            {
                var resultadd = new ASTAddNode()
                {
                };
                ASTExpressionNode leftadd = (ASTExpressionNode)context.expression()[0].Accept(this);
                AssignSymbolTable(leftadd);
                ASTExpressionNode rightadd = (ASTExpressionNode)context.expression()[1].Accept(this);
                AssignSymbolTable(rightadd);
                resultadd.Left     = leftadd;
                resultadd.Right    = rightadd;
                resultadd.AddToken = context.ADD().Symbol;
                return(resultadd);
            }
            var result = new ASTMinusNode()
            {
            };
            ASTExpressionNode left = (ASTExpressionNode)context.expression()[0].Accept(this);

            AssignSymbolTable(left);
            ASTExpressionNode right = (ASTExpressionNode)context.expression()[1].Accept(this);

            AssignSymbolTable(right);

            result.Left       = left;
            result.Right      = right;
            result.MinusToken = context.MINUS().Symbol;
            return(result);
        }
        public override ASTNode VisitBlock([NotNull] SuperCOOLParser.BlockContext context)
        {
            var result = new ASTBlockNode();
            var exps   = context.expression();

            ASTExpressionNode[] exp = new ASTExpressionNode[exps.Length];
            for (int i = 0; i < exps.Length; i++)
            {
                exp[i] = (ASTExpressionNode)exps[i].Accept(this);
                AssignSymbolTable(exp[i]);
            }
            result.Expresions = exp;
            return(result);
        }
        public override ASTNode VisitAssignment([NotNull] SuperCOOLParser.AssignmentContext context)
        {
            var result            = new ASTAssingmentNode();
            ASTExpressionNode exp = (ASTExpressionNode)context.expression().Accept(this);

            AssignSymbolTable(exp);
            ASTIdNode id = new ASTIdNode()
            {
                Token = context.OBJECTID().Symbol
            };

            AssignSymbolTable(id);
            result.Id             = id;
            result.Expresion      = exp;
            result.AssigmentToken = context.ASSIGNMENT().Symbol;
            return(result);
        }
Ejemplo n.º 4
0
 public ASTCILNode VisitExpression(ASTExpressionNode Expression)
 {
     throw new NotImplementedException();
 }
 public virtual T VisitExpression(ASTExpressionNode Expression)
 {
     throw new NotImplementedException();//ASTExpressionNode is Abstract
 }