Studio 3
Getting Started
* Locate and install the Studios/3 project into your eclipse workspace following the usual instructions.* 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:
1. Read/review the following:If CUP can successfully generate a parser for your grammar, without issuing any shift/reduce or reduce/reduce conflicts, then your grammar is unambiguous and is suitable for deterministic, bottom-up parsing with one symbol of lookahead.
If not then one of the following must be true:
* Your grammar is ambiguous. Then there must be some string for which (at least) two distinct parses can be generated. * The grammar is not ambiguous, but:
- No predeterminable amount of lookahead can resolve the conflict, or
- A certain amount of lookahead can resolve the conflict, but more than one symbol is needed (cup tries just one)
As a group, come up with a simple example of an ambiguous grammar. Please keep your terminals in the alphabet {a,b,c,d,e}. Share this with the group next to you and with the TA or professor to make sure you're in the right track.
Enter your grammar into cup0 and run the build.xml file. Look at the states in cup0.states and verify the ambiguity using the lined-up dots method.
2. Open the CUP User Manual for quick reference.
3. Build and run the project by using the build.xml file..
Not much will be working at this point, and most runs will die in CUP showing Java Error: 100.
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.
If you need to see the states computed by parser construction, look for the relevant file in the outermost autogen folder of your project.
Main Problems
- cup0
- This is a short grammar you'll type in yourself by now, having followed
the warm-up instructions above.
- cup1
- Follow the instructions in the grammar file -- be sure to
check your work with another group and the TA or prof.
- cup2
- Follow the instructions, ask questions as needed, check your
answers with other groups and the TA or prof.
- cup3
- Some lines of this file are NOT to be modified -- check this out before
you start changing things.
- cup4
- Same deal -- ambiguous, not? Figure it out and fix it up