Knuth, Donald E.

Semantics for context-free language


"Meaning" may be assigned to a string in a context-free language by defining "attributes" of the symbols in a derivation tree for that string. The attributes can be defined by functions associated with each production in the grammar. This paper examines the implications of this process when some of the attributes are "synthesized", i.e., defined solely in terms of attributes of thedescendants of the corresponding nonterminal symbol, while other attributes are "inherited", i.e., defined in terms of attributes of theancestors of the nonterminal symbol. An example is given of a simple programming language defined with both inherited and synthesized attributes, and the method of definition is compared to other techniques for formal specification of semantics which have appeared in the literature.