Write the parser, the second phase of your compiler. The parser should
use your previous scanner (or modify the ones provided) to read all tokens
of an input program and check whether the program is grammatically correct.
The specific requirements are:
As in the scanner project, your parser should ignore (but copy) "meta-statements".
The grammer definition is here. Regardless the
choice of your implementation, you must convert the grammar into an LL(1)
grammar and submit the modified grammar in writing.
(new and optional) When submitting your grammar, put down the number of
production rules and the number of distinct non-terminals used in your
grammar. For example, A -> aA | epsilon should be counted as two
production rules and one non-terminal.
For each input program, your parser should report "pass" or "error" as
the result of grammar analysis. It suffices to include only one of
these two words in the output (stdout or stderr) of your program.
Count the number of global and local variables (<data decls>), functions
(<func list> but not function declarations), and statements (<statements>)
in correct programs. Output the result in the following format: variable
_num_variables function _num_functions statement _num_statements.
For example, for a correct program with 4 variables, 2 functions and 6
statements, your compiler should output at least the following:
Pass variable 4 function 2 statement 6
As in the Scanner project, a set of test programs can
be downloaded from here.