Beispiel #1
0
        //private Node s;

        public CaseNode(CoolParser.CaseExpContext context, Node s) : base(s.Childs)
        {
            this.context = context;

            //this.s = s;
            this.Expresion  = context.expresion(0);
            this.IDs        = context.ID();
            this.Types      = context.TYPE();
            this.Expresions = context.expresion();
        }
        public override object VisitCaseExp([NotNull] CoolParser.CaseExpContext context)
        {
            Expression        mainExp = (Expression)Visit(context.expresion()[0]);
            List <Identifier> ids     = new List <Identifier>();

            for (int i = 0; i < context.ID().Length; i++)
            {
                Expression ithExp  = (Expression)Visit(context.expresion()[i]);
                Type       ithType = null;
                if (p.Types.ContainsKey(context.TYPE()[i].GetText()))
                {
                    ithType = p.Types[context.TYPE()[i].GetText()];
                }
                else
                {
                    ithType = new Type(context.TYPE()[i].GetText(), "Object", new Coord(-1, -1));
                }

                Identifier ithId = new Identifier(context.ID()[i].GetText(), ithExp, ithType, GetCoord(context));
                ids.Add(ithId);
            }

            return(new Case(mainExp, ids, GetCoord(context)));
        }
Beispiel #3
0
        public override Node VisitCaseExp([NotNull] CoolParser.CaseExpContext context)
        {
            var s = VisitChildren(context);

            return(new CaseNode(context, s));
        }
Beispiel #4
0
 public override object VisitCaseExp([NotNull] CoolParser.CaseExpContext context)
 {
     VisitExpr(context);
     return(VisitChildren(context));
 }
Beispiel #5
0
 /// <summary>
 /// Exit a parse tree produced by the <c>caseExp</c>
 /// labeled alternative in <see cref="CoolParser.expresion"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitCaseExp([NotNull] CoolParser.CaseExpContext context)
 {
 }
 /// <summary>
 /// Visit a parse tree produced by the <c>caseExp</c>
 /// labeled alternative in <see cref="CoolParser.expresion"/>.
 /// <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 VisitCaseExp([NotNull] CoolParser.CaseExpContext context)
 {
     return(VisitChildren(context));
 }
Beispiel #7
0
 public override bool VisitCaseExp([NotNull] CoolParser.CaseExpContext context)
 {
     return(VisitChildren(context));
 }