Modify the Java code for the PredictiveParser (see Section 2.2) to accommodate the changes to the calculator
Question:
Modify the Java code for the PredictiveParser (see Section 2.2) to accommodate the changes to the calculator grammar G0 that you made for the Topic 1 assignment.
These changes modify the parser to include:
- add true and false alternate right-side productions to thefactorproduction
- add "int id;" and "bool id;" alternatives to thestmtproduction
- add a semi-colon that ends each alternativestmtproduction
- add thedeclarationsproduction
- add a "!expr" alternative production to thefactorproduction
- add a new idTail production that handles assignment or a function call
- modify thestmtproduction to use the new idTail production
Note that those changes presuppose that you have a working scanner first.
Make sure the Parse Tree is correctly constructed and displayed on the Java console.
This Parser is implemented as a NetBeans project that you can import into your IDE: CS390_TopDown.zip. To use this Parser, as with the previous Scanner,you need to define a source file in the main method located in the CS390_TopDown.java class. Currently, the location of this file is simply defined as, "test.txt"which refers to a file included in the root folder of the project. So the program might be able to compile and run. Depending on your OS, you might need to replace the location of the file with the complete file path on your machine.The contents of this file correspond to Scott's example:
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill