How to . ?
. Use formal methods
- Context sensitive grammars
- Extended attribute grammars
. Use ad-hoc techniques
- Symbol table
- Ad-hoc code
. Something in between !!!
- Use attributes
- Do analysis along with parsing
- Use code for attribute value computation
- However, code is developed in a systematic way
In syntax analysis we used context free grammar. Here we put lot of attributes around it. So it consists of context sensitive grammars along with extended attribute grammars. Ad-hoc methods also good as there is no structure in it and the formal method is simply just too tough. So we would like to use something in between. Formalism may be so difficult that writing specifications itself may become tougher than writing compiler itself. So we do use attributes but we do analysis along with parse tree itself instead of using context sensitive grammars.
We have already seen some technique, like in the calculator program, we used $$,$1,$2 etc. as temporary variables.
$$ = $1 + $3; // Attribute computation
For actual language it won't be so simple but the framework will be same . |