Esempio n. 1
0
        /* throws ParseException */
        /* final */
        public static AstClassDeclList astClassDeclList()
        {
            bool done = false;
            AstClassDecl c; AstClassDeclList cl = new AstClassDeclList();
            jj_consume_token(AstRegExpId.kw56);
            jj_consume_token(AstRegExpId.kwClassDeclList);
            // label_1:
            while (!done)
            {
                switch ((jj_ntk == AstRegExpId.UNDEFINED)?jj_ntk_fn():jj_ntk)
                {
                    case AstRegExpId.kw56:
                        ;
                        break;

                    default:
                        jj_la1[0] = jj_gen;
                        done = true;
                        //break label_1;
                        break;
                }

                if (!done)
                {
                    c = astClassDecl();
                    cl.Add(c);
                }
            }

            jj_consume_token(AstRegExpId.kw57);
            {if (true) return cl;}
            throw new Error("Missing return statement in function");
        }
Esempio n. 2
0
 // DECLARATIONS
 // *** partial implementation, will be fixed in proj2 ****
 // ClassDeclList ---
 public IrFuncList visit(AstClassDeclList n)
 {
     IrFuncList funcs = new IrFuncList();
     for (int i = 0; i < n.Count(); i++)
         funcs.AddRange(n[i].accept(this));
     return funcs;
 }
Esempio n. 3
0
 public void visit(AstClassDeclList n)
 {
     for (int i = 0; i < n.size(); i++)
         n.elementAt(i).accept(this);
 }
Esempio n. 4
0
 public void visit(AstClassDeclList n)
 {
     for (int i = 0; i < n.Count(); i++)
         n[i].accept(this);
 }
Esempio n. 5
0
        private void setupClassHierarchy(AstClassDeclList cl)
        {
            List<AstClassDecl> work = new List<AstClassDecl>();
            List<String> done = new List<String>();

            for (int i = 0; i < cl.Count(); i++)
                work.Add(cl[i]);

            while (work.Count > 0)
            {
                for (int i = 0; i < work.Count; i++)
                {
                    AstClassDecl cd = (AstClassDecl) work[i];
                    if (cd.pid != null)
                    {
                        if (!done.Contains(cd.pid.s))
                        {
                            continue;
                        }

                        ClassRec cr = symTable.GetClass(cd.cid);
                        ClassRec pr = symTable.GetClass(cd.pid);
                        cr.LinkParent(pr);
                    }
                done.Add(cd.cid.s);
                work.Remove(cd);
                }
            }
        }
Esempio n. 6
0
 public AstProgram(AstClassDeclList acl)
 {
     cl = acl;
 }
Esempio n. 7
0
        /* throws ParseException */
        /* final */
        public static AstProgram Program()
        {
            bool done = false;
            AstClassDecl c;
            AstClassDeclList cl = new AstClassDeclList();
            // Get a reference to the Main class and add it to the list of classes
            c = MainClass();
            cl.Add(c);

            // label_1:
            while (!done)
            {
                switch ((jj_ntk == MpRegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk)
                {
                    case MpRegExpId.CLASS:
                        break;
                    default:
                        jj_la1[0] = jj_gen;
                        done = true;
                        break /* label_1 */;
                }
                if (!done)
                {
                    c = ClassDecl();
                    cl.Add(c);
                }
            }
            jj_consume_token(0);
            return new AstProgram( cl );
        }