Esempio n. 1
0
        private void ClassDecl()
        {
            if (Globals.Token != Tokens.ClassT)
            {
                return;
            }

            Globals.ClassT = new ClassType();
            Match(Tokens.ClassT);
            var lex = Globals.Lexeme;

            _symTab.Insert(Globals.Lexeme, Globals.Token, Globals.Depth, EntryType.ClassType);
            _symTab.Lookup(lex).TypeOfEntry = new Union <EntryType>(Globals.ClassT, EntryType.ClassType);

            Match(Tokens.IdT);
            Globals.Depth++;
            Globals.Offset = 0;
            if (Globals.Token == Tokens.ExtendsT)
            {
                Match(Tokens.ExtendsT);
                //_symTab.Insert(Globals.Lexeme, Globals.Token, Globals.Depth, );
                Match(Tokens.IdT);
            }

            Match(Tokens.LBraceT);
            VarDecl();
            MethodDecl();
            Match(Tokens.RBraceT);

            _symTab.DeleteDepth(Globals.Depth);
            Globals.Depth--;
            Globals.Offset = 0;
            var temp = _symTab.Lookup(lex) ?? throw new ParseErrorException();

            temp.TypeOfEntry = new Union <EntryType>(Globals.ClassT, EntryType.ClassType);
        }