public bool Visit(BinaryExprNode node)
        {
            if (node.Type != null)
            {
                return(true);
            }

            node.Left.Accept(this);
            node.Right.Accept(this);

            _typeChecker.RequireBinaryAny(ref node.Left, ref node.Right, node.Operation);

            switch (node.Operation)
            {
            case OperatorToken op:
                switch (op.Value)
                {
                case Constants.Operators.Less:
                case Constants.Operators.LessOrEqual:
                case Constants.Operators.More:
                case Constants.Operators.MoreOreEqual:
                case Constants.Operators.Equal:
                case Constants.Operators.NotEqual:
                    node.Type = _stack.SymBool;
                    return(true);
//                    case Constants.Operators.Divide:
                }
                break;
            }
            // left and right nodes should be same type by this point
            node.Type = node.Left.Type;
            return(true);
        }
Example #2
0
        public PrinterNode Visit(BinaryExprNode node)
        {
            var pNode = new PrinterNode(node.Operation.StringValue);

            pNode.AddChild(node.Left.Accept(this));
            pNode.AddChild(node.Right.Accept(this));
            return(pNode);
        }