Lab3: Parser
Introduction
This assignment requires you to write a parser for our C programming language.
Instruction
- To Run Lab3
-
- Download this package, and extract somewhere
- In command-line, enter the path and run:
- ml-yacc c.grm
- ml-lex c.lex
- MLton: mlton lab3.mlb and Run lab3 like "lab3 test.c".
- SML/NJ: sml sources.cm and Run lab3 like Main.parse_file "test.c".
- File Description
-
c.lex ml-lex file * c.grm ml-yacc file ** main.sml call the parser sources.cm for SML/NJ lab3.mlb for MLton test.c a test file LICENSE License of our code - To Do Lab3
-
- Read ML Yacc Manual
- Refer to specification of our C language
- You need to finish "c.lex" and "c.grm"
- You can copy a lot of code in "c.lex" from Lab2.
- Finish "c.grm". In Lab3, you don't need to add semantic rules. If your "c.grm" is correct, parser will return "Success!"
program : function_protos struct_decls functions () function_protos : type id LPAREN var_decls RPAREN SEMICOLON () ....
Note
Lab4 will be quite easy if you do Lab3 well!