Due by 11:59pm 09/29/2010
Extend the parser of your calculator to support the full input language. The parser should check whether the program is grammatically correct. The specific requirements are:
<program> --> <data decls> <func list>
<func list> --> empty | <func> <func list>
<func> --> <func decl> semicolon | <func decl> left_brace <data decls> <statements> right_brace
<func decl> --> <type name> ID left_parenthesis <parameter list> right_parenthesis
<type name> --> int | void
<parameter list> --> empty | void | <non-empty list>
<non-empty list> --> <type name> ID | <non-empty list> comma <type name> ID
<data decls> --> empty | <type name> <id list> semicolon <data decls>
<id list> --> <id> | <id list> comma <id>
<id> --> ID | ID left_bracket <expression> right_bracket
<block statements> --> left_brace <statements> right_brace
<statements> --> empty | <statement> <statements>
<statement> --> <assignment> | <general func call> | <printf func call> | <scanf func call> | <if statement> | <while statement> | <return statement> | <break statement> | <continue statement>
<assignment> --> <id> equal_sign <expression> semicolon
<general func call> --> ID left_parenthesis <expr list> right_parenthesis semicolon (ID is not "printf" or "scanf".)
<printf func call> --> ID left_parenthesis <string> right_parenthesis semicolon | ID left_parenthesis string comma <expression> right_parenthesis semicolon (ID is "printf".)
<scanf func call> --> ID left_parenthesis string comma and_sign <expression> right_parenthesis semicolon (ID is "scanf".)
<expr list> --> empty | <non-empty expr list>
<non-empty expr list> --> <expression> | <non-empty expr list> comma <expression>
<if statement> --> if left_parenthesis <condition expression> right_parenthesis <block statements>
<condition expression> --> <condition> | <condition> <condition op> <condition>
<condition op> --> double_end_sign | double_or_sign
<condition> --> <expression> <comparison op> <expression>
<comparison op> --> == | != | > | >= | < | <=
<while statement> --> while left_parenthesis <condition expression> right_parenthesis <block statements>
<return statement> --> return <expression> semicolon | return semicolon
<break statement> ---> break semicolon
<continue statement> ---> continue semicolon
<expression> --> <term> | <expression> <addop> <term>
<addop> --> plus_sign | minus_sign
<term> --> <factor> | <term> <mulop> <factor>
<mulop> --> star_sign | forward_slash
<factor> --> ID | ID left_bracket <expression> right_bracket | ID left_parenthesis <expr list> right_parenthesis | NUMBER | minus_sign NUMBER | left_parenthesis <expression> right_parenthesis
Turn in your code with a report of your design including the used LL(1) grammar with instructions to run your compiler. Put the results for all passed test cases and the problems for other test cases. In the report, write down the name of passed test cases with the results, e.g., "Pass variable 4 function 2 statement 6" and the reasons for failure in other test cases. List the provided test cases first and then those provided by you and others. Submit these files in project_code/parser/user_id before 11:59pm Wednesday 09/29/2010.
Turn in your parser with your intra-func code generator to project_code/intra/user_id. Use a single copy of source code and report. Do the required statistical countings along with code-gen. If you want the TA to do grading for your parser again, put "I NEED REGRADING FOR THE PARSER ASSIGNMENT" at the beginning of the report. Put the results for all the provided test cases in your report. (All the provided test cases in project_code/c_test are correct now.)