Constructing LR(1) and LALR(1) Parsing Tables for BNF Grammar G

Consider the following BNF grammar G:
primary-expression ::= variable | function-call
variable ::= identifier | identifier [ primary-expression ]
function-call ::= identifier ( primary-expression )
1. Construct the sets of LR(1) items for G (the original grammar given above).
2. Merge the sets of items having common cores to give the set of LALR(1) items.
3. Construct the LALR(1) parsing table from the set of LALR(1) items.
4. Simplify the LALR parsing table using the compaction techniques discussed at the end of
Section 4.7 (section 4.7.6).
Note: you can simplify or rename the terminals and nonterminals of the above grammar G so
that it will be easier to construct the sets of LR(1) items for G:
E ::= V | F
V := id | id [ E ]
F := id ( E )
Submission:
• You need to create a document (pdf or word) containing the answers of the Assignment
2.
• You will electronically submit to the Assignment 2 dropbox on Canvas by the due date.
• Documents will be checked using a code plagiarism tool against other solutions, including
those found on the Internet, so please ensure that all work submitted is your own. Any
student determined to have cheated may receive an ‘F’ in the course and will be reported
for an academic integrity violation.
• Do not edit your document after you have submitted it on canvas where you might
accidentally re-save the program, causing the timestamp on your file to be later than the
due date. If you want to work on it after submitting, make a copy of your submission and
work off that copy. Should there be any issues with your submission, this timestamp on
your document will be used to validate when the document is completed.

The post Constructing LR(1) and LALR(1) Parsing Tables for BNF Grammar G appeared first on assignmentscribe.blog.