Parsing and Attribute Stack

122 views Asked by At

Can someone please help me with the question below:

Consider the following grammar with action routines:

params → mode ID par_tail
     { params.list := insert(<mode.val, ID.name>, par_tail.list) }
par_tail → , params { par_tail.list := params.list }
     → { par_tail.list := null }
mode → IN { mode.val := IN }
 → OUT { mode.val := OUT }
 → IN OUT { mode.val := IN OUT }  

Suppose we are parsing the input:

IN a, OUT b  

and that our compiler uses an automatically maintained attribute stack to hold the active slice of the parse tree. Show the contents of this attribute stack immediately before the parser predicts the production par_tail → ε. Be sure to indicate where lhs and rhs point in the attribute stack.

This is an homework problem. If solution is not possible, are there any easy examples i can refer to for solving the problem? Thanks in advance!

0

There are 0 answers