Exemple #1
0
        public override AST_Node VisitMultdiv([NotNull] CoolParser.MultdivContext context)
        {
            AST_Expresion l = (AST_Expresion)Visit(context.expr(0));
            AST_Expresion r = (AST_Expresion)Visit(context.expr(1));

            return(new AST_BinaryOp(context, l, r, context.op));
        }
Exemple #2
0
        public override AST_Node VisitWhile([NotNull] CoolParser.WhileContext context)
        {
            AST_Expresion cond    = (AST_Expresion)Visit(context.expr(0));
            AST_Expresion corpus1 = (AST_Expresion)Visit(context.expr(1));

            return(new AST_While(context, cond, corpus1));
        }
Exemple #3
0
        public override AST_Node VisitIf([NotNull] CoolParser.IfContext context)
        {
            AST_Expresion cond   = (AST_Expresion)Visit(context.expr(0));
            AST_Expresion corpus = (AST_Expresion)Visit(context.expr(1));

            return(new AST_If(context, cond, corpus, null));
        }
Exemple #4
0
        public override AST_Node VisitAsignacion([NotNull] CoolParser.AsignacionContext context)
        {
            AST_Expresion exp = (AST_Expresion)Visit(context.expr());
            string        id  = context.ID().GetText();

            return(new AST_Asignacion(context, id, exp));
        }
Exemple #5
0
        public override AST_Node VisitIfelse([NotNull] CoolParser.IfelseContext context)
        {
            AST_Expresion cond    = (AST_Expresion)Visit(context.expr(0));
            AST_Expresion corpus1 = (AST_Expresion)Visit(context.expr(1));
            AST_Expresion corpus2 = (AST_Expresion)Visit(context.expr(2));

            return(new AST_If(context, cond, corpus1, corpus2));
        }
Exemple #6
0
        public override AST_Node VisitExplicitdispatch([NotNull] CoolParser.ExplicitdispatchContext context)
        {
            AST_Expresion expr = (AST_Expresion)Visit(context.expr());
            var           typ  = (context.TYPE() == null) ? null : new AST_Type_Node(context.TYPE(), context.TYPE().GetText());;
            var           arg  = (AST_StamentList)Visit(context.argexpr());
            var           id   = new AST_Id(context.ID(), context.ID().GetText());

            return(new AST_ExpCall(context, expr, id, typ, arg));
        }
Exemple #7
0
        public override AST_Node VisitFeatureprop([NotNull] CoolParser.FeaturepropContext context)
        {
            var           v      = context.property();
            var           formal = v.formal();
            AST_Id        id     = new AST_Id(formal.ID(), formal.ID().GetText());
            AST_Type_Node type   = new AST_Type_Node(formal.TYPE(), formal.TYPE().GetText());
            AST_Expresion exp    = null;

            if (v.expr() != null)
            {
                exp = (AST_Expresion)Visit(v.expr());
            }
            var formald = new AST_FormalDec(v.formal(), id, type);

            return(new AST_ClassProperty(context, formald, exp));
        }
Exemple #8
0
        public override AST_Node VisitMethod([NotNull] CoolParser.MethodContext context)
        {
            AST_Id                   id     = new AST_Id(context.ID(), context.ID().GetText());
            AST_Type_Node            type   = new AST_Type_Node(context.TYPE(), context.TYPE().GetText());
            List <AST_ClassProperty> param  = new List <AST_ClassProperty>();
            AST_Expresion            corpus = (AST_Expresion)Visit(context.expr());

            foreach (var item in context.formal())
            {
                var iid             = new AST_Id(item.ID(), item.ID().GetText());
                var ity             = new AST_Type_Node(item.TYPE(), item.TYPE().GetText());
                var formald         = new AST_FormalDec(item, iid, ity);
                AST_ClassProperty i = new AST_ClassProperty(item, formald, null);
                param.Add(i);
            }
            return(new AST_MethodDef(context, id, type, new AST_ListProp(context, param), corpus));
        }
Exemple #9
0
        public override AST_Node VisitLet([NotNull] CoolParser.LetContext context)
        {
            List <AST_ClassProperty> param  = new List <AST_ClassProperty>();
            AST_Expresion            corpus = (AST_Expresion)Visit(context.expr());

            foreach (var item in context.property())
            {
                var           iid     = new AST_Id(item.formal().ID(), item.formal().ID().GetText());
                var           ity     = new AST_Type_Node(item.formal().TYPE(), item.formal().TYPE().GetText());
                var           formald = new AST_FormalDec(item, iid, ity);
                AST_Expresion subexp  = null;
                if (item.expr() != null)
                {
                    subexp = (AST_Expresion)Visit(item.expr());
                }
                AST_ClassProperty i = new AST_ClassProperty(item, formald, subexp);
                param.Add(i);
            }
            return(new AST_Let(context, new AST_ListProp(context, param), corpus));
        }
Exemple #10
0
        public override AST_Node VisitLog_arit([NotNull] CoolParser.Log_aritContext context)
        {
            AST_Expresion l = (AST_Expresion)Visit(context.expr());

            return(new AST_UnaryOp(context, l, context.op));
        }
Exemple #11
0
        public override AST_Node VisitLog_neg([NotNull] CoolParser.Log_negContext context)
        {
            AST_Expresion l = (AST_Expresion)Visit(context.expr());

            return(new AST_UnaryOp(context, l, context.NOT().Symbol));
        }