Ejemplo n.º 1
0
        /*************************************************************
        ** Function    : CheckDuplicates                            **
        ** Inputs      : None                                       **
        ** Return      : Void                                       **
        **************************************************************
        ** Description : checks for duplicates                      **
        *************************************************************/
        void CheckDuplicates(string lex)
        {
            int x = ObjTable.hashWrap(lex);

            for (int i = 0; i < ObjTable.theSymbolTable[x].Count; ++i)
            {
                EntryNode temp = ObjTable.theSymbolTable[x][i];
                if (temp.depth == Vari.depth && lex == temp.lexeme)
                {
                    Console.WriteLine("Error: There is a duplicate id: " + lex + " on line: " + Vari.lineNo);
                }
            }
        }
Ejemplo n.º 2
0
        /*************************************************************
        ** Function    : insert                                     **
        ** Inputs      : lex, token, and depth                      **
        ** Return      : void                                       **
        **************************************************************
        ** Description : Inserts the lexeme, token and depth into a **
        **               record in the symbol table.                **
        **************************************************************/
        public void insert(string lex, Vari.Symbol Token, int depth)
        {
            int       x     = hash(lex);
            EntryNode entry = new EntryNode();

            entry.lexeme = lex;
            entry.token  = Token;
            entry.depth  = depth;
            entry.type   = Vari.entryType;

            if (theSymbolTable[x].Count != 0)
            {
                theSymbolTable[x].Insert(0, entry);
            }
            else
            {
                theSymbolTable[x].Add(entry);
            }
        }
Ejemplo n.º 3
0
        /*************************************************************
        ** Function    : A5Display                                  **
        ** Inputs      : none                                       **
        ** Return      : vod                                        **
        **************************************************************
        ** Description : Displays the depth for assignment 5        **
        **************************************************************/
        public void A5Display()
        {
            EntryNode temp = new EntryNode();

            Console.WriteLine("\n Depth: " + Vari.depth);
            Console.WriteLine("-----------------------------------");
            for (int listIndex = 0; listIndex < TABLESIZE; ++listIndex)
            {
                for (int arrayIndex = 0; arrayIndex < theSymbolTable[listIndex].Count; ++arrayIndex)
                {
                    if (theSymbolTable[listIndex][arrayIndex].depth == Vari.depth)
                    {
                        temp = theSymbolTable[listIndex][arrayIndex];
                        Console.WriteLine("Lexeme: " + temp.lexeme + "   Type: " + temp.type.ToString());
                    }
                }
            }
            Console.WriteLine("---------------------------------------------");
        }