Rewrite the Homework 1 grammar into a form suitable for Bison's default LALR(1) grammar generator, and use the rewritten grammar as the basis for implementing an LALR(1) parser in C.
Submit your program electronically. Your main file should be called parse.y, and if Expression is a file, possibly containing an Awk expression according to the grammar, then:
bison parse.y gcc -o parse parse.tab.c ./parse < Expression
should output the same thing that your answer to Homework 1 should output, with one exception: if the expression is not valid, the output should be an arbitrary line of text (which may be empty, or may contain partial output), followed by a line saying just "Parse error" with no line number. When we grade your assignment we will ignore the first line of output if there is a parse error.
Here is an example Bison grammar to help you get started. It is similar (but not identical) to Appel's Grammar 3.1. The language SLP and its parser is defined by an example Bison grammar slp.y. You should be able to reproduce the following transcript of a shell session on SEASnet; follow the URLs to see what the files look like.
$ bison -v slp.y $ gcc -O -Wall -W -g slp.tab.c $ ./a.out <sample.slp >sample.txt syntax error
The -v option causes Bison to generate a report file slp.output, which is well worth looking at.