Syntax Directed Definitions for a desk calculator program
L E n |
Print (E.val)
|
E E + T |
E.val = E.val + T.val
|
E T |
E.val = T.val
|
T T * F |
T.val = T.val * F.val
|
T F |
T.val = F.val
|
F (E) |
F.val = E.val
|
F digit |
F.val = digit.lexval
|
. terminals are assumed to have only synthesized attribute values of which are supplied by lexical analyzer
. start symbol does not have any inherited attribute
This is a grammar which uses only synthesized attributes. Start symbol has no parents, hence no inherited attributes.
|