Download CS340_Lab4.zip. Import it into Eclipse (File->Import...->General->Existing projects into workspace->Archive file). You should see a project called CS340_Lab4 in the package explorer.
You will modify the code in the Parser class.
The Notes for Lecture 10 will be helpful.
Your task is to write a recursive-descent parser for the following expression grammar:
E → T E'E' → + T E'E' → - T E'E' → εT → F T'T' → * F T'T' → / F T'T' → εF → a | b | 0 | 1 | 2 | ... | 9
Implement parse methods for each nonterminal symbol.
When you have fully implemented the parse methods for each nonterminal, you can run the main method of the Parser class. Type an expression in the terminal window. Assuming that your expression is legal (can be derived from the start symbol of the grammar), you will see a parse tree printed using text characters.
a + b * 3 end of input Done parsing! Syntax tree is: E +-T | +-F | | +-a | +-T' +-E' | +-+ | +-T | | +-F | | | +-b | | +-T' | | | +-* | | | +-F | | | | +-3 | | | +-T' | +-E'