Академический Документы
Профессиональный Документы
Культура Документы
Date Due: March 16, 11:59PM (Late submissions will not be accepted)
Requirements:
Guidelines:
I should only be receiving at most 3 files per student. Do not compress your files to one file (zip/rar/tar/etc).
2. Source codes with compilation/runtime errors will automatically get a grade of 0 points for that problem.
3. Both source codes should be of the same programming language. (both in Java or both in Python)
5. Develop your source codes and documentation with a mindset focused on HONOR and EXCELLENCE.
7. I will only start checking after the deadline. You may submit as many times as you want, but I will only check
the latest submission.
Grammar:
1. A' -> A
2. A -> id = E
3. E -> E + T
4. E -> E - T
5. E -> T
6. T -> T * F
7. T -> T / F
8. T -> F
9. F -> ( E )
10. F -> id
11. id -> a
12. id -> b
13. id -> c
Instructions:
Given the grammar above, create a top-down parser implementing the Recursive-Descent algorithm (30pts) and
bottom-up parser using LR Parsing (30pts) in either Java or Python. Given an input string, your program must output
each step of parsing until it reaches the goal. For LR Parsing, output the stack-input-action table. If an error is
encountered, output "Syntax error". (You need to implement the lexical analyzer for you to successfully parse. Refer
to lex() in your book or the paper I gave you before). If the grammar is not valid for top -down parsing, fix the
grammar and implement the fixed grammar using RD algorithm.
LR Parse Table:
Input: (a + b) / c
Output:
Input: (a+b)/c