// Card value expression
        public override ASTNode VisitCardValueExpr(CLUBSParser.CardValueExprContext context)
        {
            CardValueExpressionNode node = new CardValueExpressionNode(new SourcePosition(context.start));

            node.Parent = Visit(context.parent) as ReferenceNode;
            node.Child  = Visit(context.child) as ReferenceNode;

            return(node);
        }
        // Card value expression
        public override string Visit(CardValueExpressionNode node, object obj)
        {
            StringBuilder builder = new StringBuilder();

            IdentifierNode cardId = obj as IdentifierNode;

            builder.Append($"{cardId};\n");
            builder.Append($"{cardId}.CardValues.Add({Visit(node.Child)});\n");

            return(builder.ToString());
        }
Beispiel #3
0
        // Card value expression
        public override TypeNode Visit(CardValueExpressionNode node, object obj)
        {
            TypeNode parentType = Visit(node.Parent);
            TypeNode childType  = Visit(node.Child);

            TypeNode CardValueSetType = StandardTypes.GetSetType(StandardTypes.CardValue);

            // If parent type is not Set OF CardValue, log error
            if (parentType != CardValueSetType)
            {
                ErrorLogger.LogError(new ExpectedTypeError(CardValueSetType, node.Parent.SourcePosition));
                return(new ErrorTypeNode(node.SourcePosition));
            }

            // If parent type is not CardValue, log error
            if (childType != StandardTypes.CardValue)
            {
                ErrorLogger.LogError(new ExpectedTypeError(StandardTypes.CardValue, node.Child.SourcePosition));
                return(new ErrorTypeNode(node.SourcePosition));
            }

            return(new CardTypeNode(node.SourcePosition));
        }
Beispiel #4
0
 public abstract T Visit(CardValueExpressionNode node, object obj);