Question: Consider the following grammar : stmt assignment subr_call assignment id := expr subr call id ( arg list ) expr

Consider the following grammar:

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 arg_ tail
args tail → , arg_list
               → ∈

(a) Construct a parse tree for the input string foo(a, b).

(b) Give a canonical (right-most) derivation of this same string.

(c) Prove that the grammar is not LL(1).

(d) Modify the grammar so that it is LL(1).

Step by Step Solution

3.49 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a b stmt subr call id arg list id expr args tail id expr arg list id expr expr args tail id expr ex... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Language Pragmatics Questions!