// Dot notation
        public override ASTNode VisitIdDot(CLUBSParser.IdDotContext context)
        {
            SourcePosition sourcePosition = new SourcePosition(context.start);

            DotReferenceNode node = new DotReferenceNode(sourcePosition);

            node.Parent = Visit(context.parent) as ReferenceNode;
            node.Member = Visit(context.member) as ReferenceNode;

            return(node);
        }
Beispiel #2
0
        // Dot notation reference
        public override TypeNode Visit(DotReferenceNode node, object obj)
        {
            node.Parent.Type = Visit(node.Parent);
            node.Member.Type = Visit(node.Member);

            node.Type = node.Member.Type; // Assign the type of the member to the DotReferenceNode

            // If DotReferenceNode is CountNode, parent must be of type Int
            if (node.Member is CountNode)
            {
                if (node.Parent.Type != StandardTypes.Set) // Log error
                {
                    ErrorLogger.LogError(new ExpectedTypeError(node.Member, StandardTypes.Set, node.Parent.SourcePosition));
                    return(new ErrorTypeNode(node.Parent.SourcePosition));
                }
            }

            return(node.Type);
        }
Beispiel #3
0
 public abstract T Visit(DotReferenceNode node, object obj);
 // Dot notation reference
 public override string Visit(DotReferenceNode node, object obj)
 {
     return($"{Visit(node.Parent)}.{Visit(node.Member)}");
 }