L-attributed grammar
Encyclopedia
L-attributed grammars are a special type of attribute grammar
Attribute grammar
An attribute grammar is a formal way to define attributes for the productions of a formal grammar, associating these attributes to values. The evaluation occurs in the nodes of the abstract syntax tree, when the language is processed by some parser or compiler....

s. They allow the attributes to be evaluated in one left-to-right traversal of the abstract syntax tree
Abstract syntax tree
In computer science, an abstract syntax tree , or just syntax tree, is a tree representation of the abstract syntactic structure of source code written in a programming language. Each node of the tree denotes a construct occurring in the source code. The syntax is 'abstract' in the sense that it...

. As a result, attribute evaluation in L-attributed grammars can be incorporated conveniently in top-down parsing
Top-down parsing
Top-down parsing is a type of parsing strategy where in one first looks at the highest level of the parse tree and works down the parse tree by using the rewriting rules of a formal grammar...

.
Many programming languages are L-attributed. Special types of compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...

s, the narrow compilers, are based on some form of L-attributed grammar. These are comparable with S-attributed grammar
S-attributed grammar
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...

s. Used for code synthesis.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK