This article is in need of attention from an expert on the subject. Please help recruit one, or improve this page yourself if you can.
The attribute modifies any noun or noun phrase irrespective of what part it play in the sentence. The antecedent of the attribute may be the subject,object,predicative or part of an adverbial phrase. It can even itself serve as an attribute to another noun:Italic textJohn,Bold texta rosy cheeked young lad, Italic textanswered the question. When constructing a language translation tool, such as a compiler, an attribute grammar is the formal expression of the syntax-derived semantic checks associated with a grammar. It represents the rules of a language not explicitly imparted by the syntax. A diagram of the operation of a typical multi-language compiler. ...
In a practical way, an attribute grammar defines the information that will need to be in the abstract syntax tree in order to successfully perform semantic analysis. This information is stored as attributes of the nodes of the abstract syntax tree. The attributes are divided into two groups, called synthesised attributes and inherited attributes. The synthesised attributes are the result of the attribute evaluation rules also using the values of the inherited attributes. The values of the inherited attributes are inherited from parent nodes. Basically, synthesized attributes are used to pass semantic information up the parse tree, while inherited attributes are used to pass semantic information down the parse tree. Lloyd smells. ...
The strength of attribute grammars is that they can transport information from anywhere in the abstract syntax tree to anywhere else, in a controlled way.
Types of attribute grammars
L-attributed grammar
S-attributed grammar
L-attributed grammars are a special type of attribute grammars. ... S-attributed grammars are a class of attribute grammars, comparable with L-attributed grammars but characterized by having no inherited attributes at all. ...
External links
Why Attribute Grammars Matter, The Monad Reader, Issue 4, July 5th 2005
Semantics of context-free grammars, by Don Knuth, is the original paper introducing attributed grammars.
Attributegrammars provide a mechanism for annotating the nodes of a tree with so-called 'attributes', by means of so-called 'semantic rules' which can work either bottom-up (for so-called 'synthesized' attribute values) or top-down (for so-called 'inherited' attribute values).
Attributegrammars, on the other hand, are a declarative formalism, whose evaluation visits each node of the input tree only a constant number of times (once for each attribute).
Attributegrammars provide a mechanism for annotating the nodes of a tree with so-called 'attributes', by means of so-called 'semantic rules' which can work either bottom-up (for so- called 'synthesized' attribute values) or top-down (for so- called 'inherited' attribute values).