Starting from:

$30

Assignment 3 Solution


Assignment 3
Total: 32 Points
General Instruction
• I recommend that you type your answers to exercise questions by using a word processor
(Microsoft word, LibreOffice writer, LATEX, etc.).
• Submit a PDF file via BeachBoard (Not email or in class).
1. (14 points) Chapter 2.6 – Exercise 2.4 (a) and (b).
2. (8 points) Show the left-most parse tree for the string a b a a.
Terminal symbols: {a, b}
S - A M
M - S | ?
A - a E | b A A
E - a B | b A | ?
B - b E | a B B
3. (10 points) Construct a parse tree for the input string foo(a,b).
Terminal symbols: {id, =, +, -, *, ‘,’, (, ), ?}
stmt - assignment | subr_call
assignment - id = expr
subr_call - id ( arg_list )
expr - primary expr_tail
expr_tail - op expr | ?
primary - id | subr_call | ( expr )
op - + | - | * | /
arg_list - expr args_tail
args_tail -, arg_list | ?

More products