PPL Unit-1
PPL Unit-1
1) Attribute Grammar
E → E + T { E.value = E.value + T.value }
Synthesized attributes
These attributes get values from the attribute values of their
child nodes. To illustrate, assume the following production:
S → ABC
Inherited attributes
In contrast to synthesized attributes, inherited attributes can
take values from parent and/or siblings. As in the following
production,
S → ABC
S-attributed SDT
If an SDT uses only synthesized attributes, it is called as S-
attributed SDT.
L-attributed SDT
This form of SDT uses both synthesized and inherited attributes
with restriction of not taking values from right siblings.
Attributes in L-attributed SDTs are evaluated by depth-first and
left-to-right parsing manner.
2) Types of Parser:
3) Lexical Analyzer:
Note:
4)Runtime(Referencing) Environment:
A translation needs to relate the static source text of a program
to the dynamic actions that must occur at runtime.
Runtime environment is a state of the target machine.
The program consists of names for procedures, identifiers, etc.,
that require mapping with the actual memory location at runtime.
Activation Tree:
Activation Records:
o Control stack is a run time stack which is used to keep track of
the live procedure activations i.e. it is used to find out the
procedures whose execution have not been completed.
o When it is called (activation begins) then the procedure name
will push on to the stack and when it returns (activation ends)
then it will popped.
o Activation record is used to manage the information needed by
a single execution of a procedure.
o An activation record is pushed into the stack when a procedure
is called and it is popped when the control returns to the caller
function.
The diagram below shows the contents of activation records: