Attribute Grammar §
Context Free Grammar: §
- V: vocabulary:
- N: set of non-terminal symbols
- T: set of terminal symbols
- P: set of grammar production rules
- S: the starting symbol
Link to original
Extended by: §
- A: set of attributes
- INH: set of inherited attributes
- INHX: set of inherited attributes for X∈V
- SYN: set of synthesized attributes
- SYNX: set of synthesized attributes for X∈V
- f: semantic rules bound to a∈A and p∈P
- has to be defined ∀ai∈INHx1(1≤i≤np)
- → for every inherited attribute
- and ∀a0∈SYNx0
- → for every synthesized attribute
- parameters: f(p,i,a)
- f evaluates the attribute a of the production rule p at the position i
Norms §
- normal form: an attribute only appears on one side
- well-formed: an attribute grammar AG contains no cycle for every possible derivation tree
Example definition §
- Nonterminals & Terminals
- Attributes
- Rules
Example min amount of f §
- 2p: A → XA
- AG G:
- INHA = {i1}
- INHX = {i2}
- SYNA = {s1}
- SYNX = {s2}
- f(2p,0,s1)
LL-attributed grammar §
- S-attributed grammar = L attributed grammar with only synthesized attributes