This assignment reviews the material in Lecture 1. You are to implement and test the list parser discussed in class. You will do this two different ways - 1) a recursive descent parser written by hand as shown in class and 2) an automatically generated parser like the one shown in class that uses bison/yacc (or the Python or Java equivalents Ply and CUP).
Your parser may be written in any of the following languages: C, C++, Java, Python. You may use the corresponding parser generators for the second part: bison and flex for C and C++ (see Lecture 2 for notes on using bison with C++, CUP for Java, and PLY for Python. Some CUP examples can be found in CUP/JFLex examples).
Background information is obtained in chapter 2 of the text and the lecture outline in lecture 1, along with the reference materials for bison/CUP/PLY. Note that lecture 1 contains a bison grammar for the lists that you must parse.
You may want to consult the book:
John R. Levine, Tony Mason, Doug Brown, Lex & Yacc, 2nd/updated edition (October 1992), O'Reilly & Associates.
Your parser should construct an internal data structure containing the list that was read. Use a print routine to print the data structure, in the same format that was read, on a single line, to stdout, to verify correctness.
You will do part 2 again, in a different language.
Each of your parsers will read from
stdin. It will attempt
to parse a list, as described in the grammar, above.
See sample.input .
After the outer-most list is read, print the list to
stdout, on a single line (followed by a newline).
If the input is invalide, print
The list will be denoted by parentheses, elements will be separated by commas.
Given the example in sample.input, you would print:
( 99, ( 43, 86 ), 24, 42 )
Points will be assigned as follows:
|35||part 1 [25 points for correctness, 10 points for style/doc]|
|35||part 2.1 [25 points for correctness, 10 points for style/doc]|
|20||part 2.2 [10 points for correctness, 10 points for style/doc]|
Since you can do this in a number of languages, submit a makefile . Here is a sample makefile. Please ask for help w/makefiles.
Submit the following files to Bb Vista:
moreutility) all source code for part 1
moreutility) all source code for part 2.1
moreutility) all source code for part 2.2
Please just submit files, rather than a tarball. If you *need*
subdirectories, tar up what is needed within your directory; i.e.,
don't include the top-level directory in the tarball, submit your makefile
separately, and include another target,
Note: Please pay attention to file names. E.g.,
makefile is not
README is not