Studio 4
Getting Started
* Locate and install the Studios/4 project into your eclipse workspace.* Open report.txt in eclipse, fill in your team members' names, and keep the file open so that you can record your findings.
* Browse this studio document to get an idea of the work you will do in this session.
Warm Up:
As you work on each of the problems below, simply rerun the ant build, and the results will be displayed on the console. (Recall you can click on the toolbox green button to rerun the build.) If things seem to be messed up, run the clean task followed by the default (run) build, and that should fix any problems.* Open the CUP User Manual for quick reference.
Main Problems
You will consider a sequence of problems to be solved by bottom-up parsing.Your work will be done in the various cup files found in the root directory for this studio.
Part 1
* cup1a parses a comma-separated list of numerals. The semantic actions are already in place to translate the numerals into a numeric value. Each numeral is parsed as a sequence of digits.Draw a parse tree for the numeral 431 and study how the bottom up parse computes the numeric value of the digits from left to right. The semantic type used for the values is the java.lang.Integer object.
Be prepared to show (to a suitably curious observer) when reductions take place. Be prepared to explain when the semantic actions are performed and what they do.
* cup1b is the same problem, but uses a local class in the action code block to carry the value up the parse tree.
Fill in your group's members' names.
You have to fill in the semantic actions.
* cup2: This grammar looks like the cup1 grammars. This time, instead of producing the numeric value of the numerals, you are to produce the count of the number of digits in the numeral.