Repeat Project 17 in Chapter 10 with the following modifications. Realize that the user-defined identifiers, or symbols, are the names of all variables, constants, objects, and methods in a program. Instead of adding these identifiers to a list, as in Project 17, a compiler builds a symbol table. In this project, the symbol table will be a dictionary. Each entry in this dictionary will have an identifier as a search key and, as the associated value, a reference to the program component that the symbol represents. When the compiler encounters an identifier, it checks another dictionary to see whether the identifier is a reserved word. If not, it checks to see whether it is in the symbol table (dictionary) already. If the identifier is not in the symbol table, the compiler adds the identifier to it. On the other hand, if the identifier is in the dictionary, the compiler must analyse the context in which it encountered the identifier. If it is in a new declaration statement, the compiler has encountered a programming mistake and so issues an error message. Otherwise, it consults the dictionary for data about the identifier and continues compiling the program. Design and implement a class, Program Symbol, that will be a base class for other symbol classes. Design a class Symbol Table that maintains all programmer-defined symbols in a given Java program.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here