Ejemplo n.º 1
0
        /* throws ParseException */
        /* final */
        public static AstMethodDeclList astMethodDeclList()
        {
            AstMethodDecl m;
            AstMethodDeclList ml = new AstMethodDeclList();
            bool done = false;

            jj_consume_token(AstRegExpId.kw56);
            jj_consume_token(AstRegExpId.kwMethodDeclList);

            // label_3:
            while (!done)
            {
                switch ((jj_ntk == AstRegExpId.UNDEFINED)?jj_ntk_fn():jj_ntk)
                {
                    case AstRegExpId.kw56:
                        break;
                default:
                    jj_la1[2] = jj_gen;
                    done = true;
                    break /* label_3 */;
                }
                if (!done)
                {
                    m = astMethodDecl();
                    ml.Add(m);
                }
            }
            jj_consume_token(AstRegExpId.kw57);
            {if (true) return ml;}
            throw new Error("Missing return statement in function");
        }
Ejemplo n.º 2
0
 // MethodDeclList ---
 public IrFuncList visit(AstMethodDeclList n)
 {
     IrFuncList funcs = new IrFuncList();
     for (int i = 0; i < n.Count(); i++)
         funcs.Add(n[i].accept(this));
     return funcs;
 }
Ejemplo n.º 3
0
 public AstClassDecl(AstId ci, AstId pi, AstVarDeclList avl, AstMethodDeclList aml)
 {
     cid = ci; pid = pi; vl = avl; ml = aml;
 }
Ejemplo n.º 4
0
 public void visit(AstMethodDeclList n) 
 {
     for (int i = 0; i < n.size(); i++)
         n.elementAt(i).accept(this);
 }
Ejemplo n.º 5
0
 public void visit(AstMethodDeclList n)
 {
     for (int i = 0; i < n.Count(); i++)
         n[i].accept(this);
 }
Ejemplo n.º 6
0
        /* throws ParseException */
        // --------------------------------------------------------------------------
        // ClassDecl  -> "class" <ID> ["extends" <ID>] "{" {VarDecl} {MethodDecl} "}"
        // --------------------------------------------------------------------------
        /* final */
        public static AstClassDecl ClassDecl()
        {
            AstId cid;                                     // Name of this class
            AstId pid = null;                              // Name of the super class (if it exists)
            AstMethodDecl m;                               // Reference to a class level method
            AstMethodDeclList ml = new AstMethodDeclList();   // List of class methods
            AstVarDecl v;                                  // Reference to a class level variable
            AstVarDeclList vl = new AstVarDeclList();
            bool done;

            jj_consume_token(MpRegExpId.CLASS);
            cid = Id();

            switch ((jj_ntk == MpRegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk)
            {
                case MpRegExpId.EXTENDS:
                    jj_consume_token(MpRegExpId.EXTENDS);
                    pid = Id();
                    break;
                default:
                    jj_la1[3] = jj_gen;
                    break;
            }

            jj_consume_token(MpRegExpId.LBRACE);

            /* label_4: */
            done = false;
            while (!done)
            {
                switch ((jj_ntk == MpRegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk)
                {
                    case MpRegExpId.BOOLEAN:
                        break;
                    case MpRegExpId.INT:
                        break;
                    case MpRegExpId.ID:
                        break;

                    default:
                        jj_la1[4] = jj_gen;
                        done = true;
                        break /* label_4 */;
                }
                if (!done)
                {
                    v = VarDecl();
                    vl.Add(v);
                }
            }

            /* label_5: */
            done = false;
            while (!done)
            {
                switch ((jj_ntk==MpRegExpId.UNDEFINED)?jj_ntk_fn():jj_ntk)
                {
                    case MpRegExpId.PUBLIC:
                        break;
                    default:
                        jj_la1[5] = jj_gen;
                        done = true;
                        break /* label_5 */;
                }
                if (!done)
                {
                    m = MethodDecl();
                    ml.Add(m);
                }
            }
            jj_consume_token(MpRegExpId.RBRACE);
            return new AstClassDecl( cid, pid, vl, ml );
        }
Ejemplo n.º 7
0
        /* throws ParseException */
        // ----------------------------------------------------------
        // MainClass  -> "class" <ID> "{" MainMethod {MethodDecl} "}"
        // ----------------------------------------------------------
        /* final */
        public static AstClassDecl MainClass()
        {
            AstId cid;                                     // Name of this class
            AstId pid = null;                              // Name of the super class (if it exists)
            AstMethodDecl m;                               // Reference to a class level method
            AstMethodDeclList ml = new AstMethodDeclList();   // List of class methods
            AstVarDecl v;                                  // Reference to a class level variable
            AstVarDeclList vl = new AstVarDeclList();
            bool done = false;

            jj_consume_token(MpRegExpId.CLASS);
            cid = Id();
            jj_consume_token(MpRegExpId.LBRACE);

            /* label_2: */
            while (!done)
            {
                switch ((jj_ntk == MpRegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk)
                {
                    case MpRegExpId.BOOLEAN:
                        break;
                    case MpRegExpId.INT:
                        break;
                    case MpRegExpId.ID:
                        break;
                    default:
                        jj_la1[1] = jj_gen;
                        done = true;
                        break /* label_2 */;
                }
                if (!done)
                {
                    v = VarDecl();
                    vl.Add(v);
                }
            }

            // Get a reference to the Main method and add it to the list of methods in this class
            m = MainMethod();
            ml.Add(m);

            done = false;
            /* label_3: */
            while (!done)
            {
                switch ((jj_ntk == MpRegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk)
                {
                    case MpRegExpId.PUBLIC:
                        break;
                    default:
                        jj_la1[2] = jj_gen;
                        done = true;
                        break /* label_3 */;
                }
                if (!done)
                {
                    m = MethodDecl();
                    ml.Add(m);
                }
            }
            jj_consume_token(MpRegExpId.RBRACE);
            return new AstClassDecl( cid, pid, vl, ml );
        }