Lesson 05 Flashcards
What is syntax directed translation ?
is done by attaching rules or program fragments to productions in a grammar
Attribute ?
any quantity associated with a programming construct
translation scheme ?
a notation for attaching program fragments of a grammar
program fragments
are executed when the production is used during syntax analysis
Examples of attributes are
Data types of expressions , Number of instructions in the generated code,
The location of the first instruction in the generated code
when we say an attribute is synthesized ?
if its value at a parse-tree node N is determined from attribute values at the children of N and at N itself.
Tree traversals
are used for describing attribute evaluation and for specifying the execution of code fragments in a translation scheme.
semantic actions.
Program fragments embedded within production bodies
translation scheme implementation must ensure
Semantic actions are performed in the order they would appear during a postorder traversal of a parse tree.
preorder traversal action
is done when we first visit a node
postorder traversal action
is done just before we leave a node for the last time