Defining Interpreters Using Attribute Grammars Like other language processing, convenient to define interpreters using grammatical syntax framework. As first step, can define interpreter using an attribute grammar. Types of attributes and form of rules vary widely. If S.inh is an inherited attribute, it must be defined each time S appears in any grammar production right-hand side. If S.syn is a synthesized attribute, it must be defined each time S appears as a grammar production left-hand side.
Evaluation can occur in any order consistent with data dependencies among attribute rules.
First evaluate children's inherited attributes. Then recursively evaluate children, obtaining their synthesized attributes. Finally evaluate own synthesized attributes. It is easy to turn imperative attribute grammars into recursive descent C programs that process tree data structures. Each nonterminal N gets corresponding C function N .