exit final exam
NAME
1–4 CHARACTERS CODE (if you want your final grade posted)
CSE 756: Final Exam
Monday, June 2, 1:30—3:28
Open Notes, Open Books
The exam consists of four problems
Answers not appearing in designated spaces WILL NOT be graded
Consider the programming language having the following grammar
| prog | ::= | body |
| body | ::= | body stat |
| | | ϵ |
| stat | ::= | DO body REPEAT |
| | | COPY |
| | | EXIT_0 |
where the following semantics holds.
- COPY. Read a value from the input and print it into the output
- DO body REPEAT. Repeatedly execute the body
- EXIT_0. Exit the execution of the loop that directly embeds the
instruction or the program execution for non-nested cases, if the most
recent read value is 0 or no value has been read so far.
Example.
EXIT_0
DO
COPY
EXIT_0
COPY
EXIT_0
DO
EXIT_0
COPY
EXIT_0
COPY
EXIT_0
REPEAT
COPY
EXIT_0
REPEAT
COPY
EXIT_0
-
Problem #1 (10 points)
-
Write a (J)FLEX program that generates a scanner for the language
-
Problem #2 (10 points)
-
Write a Bison/CUP program that provides a translation into MINI MACHINE
code.
-
Problem #3 (10 points)
-
Provide the parsing table for the following LALR(1)-like transition diagram of
the grammar. (The cores of the states are identical to those of the LALR(1)
diagram. The lookahead symbols are different.)
-
Problem #4 (10 points)
-
Determine the LR(0), SLR(1), and LR(1) transition diagrams for the
grammar.