Exemplo n.º 1
0
        public override ASTNode VisitDispatchExplicit([NotNull] CoolParser.DispatchExplicitContext context)
        {
            DispatchExplicitNode node = new DispatchExplicitNode(context)
            {
                Expression = Visit(context.expression(0)) as ExpressionNode
            };

            var typeSuperClass = context.TYPE() == null ? new TypeNode(node.Expression.Line, node.Expression.Column, node.Expression.StaticType.Text) :
                                 new TypeNode(context.TYPE().Symbol.Line, context.TYPE().Symbol.Column, context.TYPE().GetText());

            node.IdType = typeSuperClass;

            IdNode idNode = new IdNode(context.ID().Symbol.Line, context.ID().Symbol.Column, context.ID().GetText());

            node.IdMethod = idNode;

            node.Arguments = (from x in context.expression().Skip(1) select Visit(x) as ExpressionNode).ToList();
            return(node);
        }
        public override ASTNode VisitDispatchExplicit([NotNull] CoolParser.DispatchExplicitContext context)
        {
            var _base    = Visit(context.expr(0)) as ExpressionNode;
            var idMethod = new IdNode(context.ID().Symbol.Line, context.ID().Symbol.Column, context.ID().GetText());
            var args     = (from x in context.expr().Skip(1) select Visit(x) as ExpressionNode).ToList();

            return(context.TYPE() == null ?
                   new ExplicitDispatch(context.Start.Line, context.Start.Column)
            {
                Base = _base, IdMethod = idMethod, Arguments = args
            } as DispatchNode :
                   new BaseDispatch(context.Start.Line, context.Start.Column)
            {
                Base = _base,
                IdMethod = idMethod,
                Arguments = args,
                TypeBase = new TypeNode(context.TYPE().Symbol.Line, context.TYPE().Symbol.Column, context.TYPE().GetText())
            });
        }
 /// <summary>
 /// Visit a parse tree produced by the <c>dispatchExplicit</c>
 /// labeled alternative in <see cref="CoolParser.expr"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitDispatchExplicit([NotNull] CoolParser.DispatchExplicitContext context)
 {
     return(VisitChildren(context));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Exit a parse tree produced by the <c>dispatchExplicit</c>
 /// labeled alternative in <see cref="CoolParser.expr"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitDispatchExplicit([NotNull] CoolParser.DispatchExplicitContext context)
 {
 }