This is for a class assignment, and I need some help getting my head wrapped around the problem.
The problem is to create a symbol table for a c++ program. I know what a symbol table is, but figuring out how to create one is my difficulty.
The only way I can think to create a symbol table is to have a list of valid keywords which I then use to search through the source code. This would enable me to find the declarations of variables, however, it would require me to:
1) search through the entire file for every keyword
2) To search through any header files for classes which would need to be added to the list of keywords
3)I would have to create a list of all keywords from the header files or I would need to have a list of all keywords in the c++ language. (or just have a keyword list tailored to the program I parse for identifiers)
I have to write a program which creates a symbol table of a c++ program, so I want to make sure i'm approaching this problem in the right way before I create a detailed algorithm.
Any ideas/help or comments are appreciated.