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.

The attributes are divided into two groups: "synthesized" attributes and "inherited" attributes. The synthesized attributes are the result of the attribute evaluation rules, and may also use the values of the inherited attributes. The inherited attributes are passed down from parent nodes.

In some approaches, synthesized attributes are used to pass semantic information up the parse tree, while inherited attributes help pass semantic information down it. For instance, when constructing a language translation tool, such as a compiler, it may be used to assign semantic values to syntax constructions. Also, it is possible to validate semantic checks associated with a grammar, representing the rules of a language not explicitly imparted by the syntax.

Attribute grammars can also be used to translate the syntax tree directly into code for some specific machine, or into some intermediate language.

One strength of attribute grammars is that they can transport information from anywhere in the abstract syntax tree to anywhere else, in a controlled and formal way.Fact|date=February 2007

Types of attribute grammars

*L-attributed grammar
*S-attributed grammar
*LR-attributed grammar
*ECLR-attributed grammar

External links

* [http://www.haskell.org/tmrwiki/WhyAttributeGrammarsMatter Why Attribute Grammars Matter] , The Monad Reader, Issue 4, July 5, 2005
*"Semantics of context-free grammars", by Don Knuth, is the original paper introducing attributed grammars.
*D. E. Knuth: [http://www-cs-faculty.stanford.edu/~knuth/papers/gag.tex.gz The genesis of attribute grammars] . "Proceedings of the international conference on Attribute grammars and their applications" (1990), 1–12. Some informal, historical information.
*Jukka Paakki: Attribute grammar paradigms—a high-level methodology in language implementation. "ACM Computing Surveys" 27:2 (June 1995), 196–255.


Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • attribute — noun /ˈætrəbjut / (say atruhbyooht) 1. something attributed as belonging; a quality, character, characteristic, or property: wisdom is one of his attributes. 2. Grammar a. a word or phrase grammatically subordinate to another, serving to limit… …  

  • attribute — at·trib·ute || É™ trɪbjuːt n. quality, characteristic; adjective (Grammar) v. ascribe to; credit with …   English contemporary dictionary

  • ECLR-attributed grammar — ECLR attributed grammars are a special type of attribute grammars. They are a variant of LR attributed grammars where an equivalence relation on inherited attributes is used to optimize attribute evaluation. EC stands for equivalence class. Rie… …   Wikipedia

  • Formal grammar — In formal semantics, computer science and linguistics, a formal grammar (also called formation rules) is a precise description of a formal language ndash; that is, of a set of strings over some alphabet. In other words, a grammar describes which… …   Wikipedia

  • S-attributed grammar — S attributed grammars are a class of attribute grammars characterized by having no inherited attributes. Inherited attributes, which must be passed down from parent nodes to children nodes of the abstract syntax tree during the semantic analysis… …   Wikipedia

  • LR-attributed grammar — LR attributed grammars are a special type of attribute grammars. They allow the attributes to be evaluated on LR parsing. As a result, attribute evaluation in LR attributed grammars can be incorporated conveniently in bottom up parsing. zyacc is… …   Wikipedia

  • Affix grammar — An affix grammar is a kind of formal grammar; it is used to describe the syntax of languages, mainly computer languages, using an approach based on how natural language is typically described.The grammatical rules of an affix grammar are those of …   Wikipedia

  • L-attributed grammar — L attributed grammars are a special type of attribute grammars. They allow the attributes to be evaluated in one left to right traversal of the abstract syntax tree. As a result, attribute evaluation in L attributed grammars can be incorporated… …   Wikipedia

  • Romanian grammar — Romanian (technically called Daco Romanian ) shares practically the same grammar and most of the vocabulary and phonological processes with the other three surviving Eastern Romance languages: Aromanian, Megleno Romanian, and Istro Romanian.As a… …   Wikipedia

  • HEBREW GRAMMAR — The following entry is divided into two sections: an Introduction for the non specialist and (II) a detailed survey. [i] HEBREW GRAMMAR: AN INTRODUCTION There are four main phases in the history of the Hebrew language: the biblical or classical,… …   Encyclopedia of Judaism

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”