A compiler uses a symbol table to keep track of scope and binding information about names. The symbol table is searched every time a name is encountered in the source text. Changes to the symbol table occur if a new name or new information about an existing name is discovered. A symbol table mechanism must allow us to add new entries and find existing entries. The two symbol table mechanisms are linear lists and hash tables. Each scheme is evaluated on the basis of time required to add n entries and make e inquiries. A linear list is the simplest to implement, but its performance is poor when n and e are large. Hashing schemes provide better performance for greater programming effort and space overhead. It is useful for a compiler to be able to grow the symbol table dynamically at compile time. If the symbol table is fixed when the compiler is written, the size must be chosen large enough to handle any source program that might be presented. SYMBOL-TABLE ENTRIES Each entry in the symbol table is for the declaration of a name. The format of entries does have to be uniform, because the information saved about a same depends on the usage of time. Each entry can be implemented as a record consisting of a sequence of consecutive words of memory. To keep symbol table entries uniform, it may be convenient for some of the information about a name to be kept outside the table entry, with only a pointer to this information stored in the record. Information is entered into the symbol table at various times. Keywords are entered initially. The lexical analyzer looks up sequences of letters and digits in the symbol table to determine if a reserved keyword or a name has been collected. With this approach, keywords must be in the symbol table before lexical analysis begins. Alternatively, if lexical analyzer intercepts reserved keywords, they should be entered into the symbol table with a warning of their possible
A compiler uses a symbol table to keep track of scope and binding information about names. The symbol table is searched every time a name is encountered in the source text. Changes to the symbol table occur if a new name or new information about an existing name is discovered. A symbol table mechanism must allow us to add new entries and find existing entries. The two symbol table mechanisms are linear lists and hash tables. Each scheme is evaluated on the basis of time required to add n entries and make e inquiries. A linear list is the simplest to implement, but its performance is poor when n and e are large. Hashing schemes provide better performance for greater programming effort and space overhead. It is useful for a compiler to be able to grow the symbol table dynamically at compile time. If the symbol table is fixed when the compiler is written, the size must be chosen large enough to handle any source program that might be presented. SYMBOL-TABLE ENTRIES Each entry in the symbol table is for the declaration of a name. The format of entries does have to be uniform, because the information saved about a same depends on the usage of time. Each entry can be implemented as a record consisting of a sequence of consecutive words of memory. To keep symbol table entries uniform, it may be convenient for some of the information about a name to be kept outside the table entry, with only a pointer to this information stored in the record. Information is entered into the symbol table at various times. Keywords are entered initially. The lexical analyzer looks up sequences of letters and digits in the symbol table to determine if a reserved keyword or a name has been collected. With this approach, keywords must be in the symbol table before lexical analysis begins. Alternatively, if lexical analyzer intercepts reserved keywords, they should be entered into the symbol table with a warning of their possible