S-attributed grammar

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Tom.Reding (talk | contribs) at 20:54, 29 June 2016 (→‎See also: Rem stub tag (class = non-stub & non-list) using AWB). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

S-Attributed Grammars are a class of attribute grammars characterized by having no inherited attributes, but only synthesized attributes. Inherited attributes, which must be passed down from parent nodes to children nodes of the abstract syntax tree during the semantic analysis of the parsing process, are a problem for bottom-up parsing because in bottom-up parsing, the parent nodes of the abstract syntax tree are created after creation of all of their children. Attribute evaluation in S-attributed grammars can be incorporated conveniently in both top-down parsing and bottom-up parsing.

Specifications for parser generators in the Yacc family can be broadly considered S-attributed grammars. However, these parser generators usually include the capacity to reference global variables and/or fields from within any given grammar rule, meaning that this is not a pure S-attributed approach.

Any S-attributed grammar is also an L-attributed grammar.

See also