// IS
        public override ASTNode VisitInfixIs(CLUBSParser.InfixIsContext context)
        {
            IsNode node = new IsNode(new SourcePosition(context.start));

            node.Left  = Visit(context.left) as ExpressionNode;
            node.Right = Visit(context.right) as ExpressionNode;

            return(node);
        }
 // IS
 public override string Visit(IsNode node, object obj)
 {
     // Different behavior in Query, as this compares the underlying CardValues in a Card
     if (obj is QueryNode)
     {
         return($"x.CardValues.Any(y => y.Parent == \"{Visit(node.Left)}\" && y.Name == \"{Visit(node.Right)}\")\n");
     }
     else // If not a query, append regular equality comparison operator
     {
         return($"{Visit(node.Left)} == {Visit(node.Right)}");
     }
 }
Esempio n. 3
0
        // IS
        public override TypeNode Visit(IsNode node, object obj)
        {
            TypeNode leftType  = Visit(node.Left);
            TypeNode rightType = Visit(node.Right);

            // If left and right types are not the same, log error
            if (leftType != rightType)
            {
                ErrorLogger.LogError(new IncompatibleTypesError(leftType, rightType, node.Left.SourcePosition));
                return(new ErrorTypeNode(node.SourcePosition));
            }

            return(new BoolTypeNode(node.SourcePosition));
        }
Esempio n. 4
0
 public abstract T Visit(IsNode node, object obj);