<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://en.formulasearchengine.com/index.php?action=history&amp;feed=atom&amp;title=Algebraically_compact_module</id>
	<title>Algebraically compact module - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://en.formulasearchengine.com/index.php?action=history&amp;feed=atom&amp;title=Algebraically_compact_module"/>
	<link rel="alternate" type="text/html" href="https://en.formulasearchengine.com/index.php?title=Algebraically_compact_module&amp;action=history"/>
	<updated>2026-05-08T12:53:49Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0-wmf.28</generator>
	<entry>
		<id>https://en.formulasearchengine.com/index.php?title=Algebraically_compact_module&amp;diff=231040&amp;oldid=prev</id>
		<title>en&gt;K9re11: removed Category:Abstract algebra; added Category:Module theory using HotCat</title>
		<link rel="alternate" type="text/html" href="https://en.formulasearchengine.com/index.php?title=Algebraically_compact_module&amp;diff=231040&amp;oldid=prev"/>
		<updated>2014-11-08T09:42:50Z</updated>

		<summary type="html">&lt;p&gt;removed &lt;a href=&quot;/index.php?title=Category:Abstract_algebra&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Category:Abstract algebra (page does not exist)&quot;&gt;Category:Abstract algebra&lt;/a&gt;; added &lt;a href=&quot;/index.php?title=Category:Module_theory&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Category:Module theory (page does not exist)&quot;&gt;Category:Module theory&lt;/a&gt; using &lt;a href=&quot;/index.php?title=WP:HC&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;WP:HC (page does not exist)&quot;&gt;HotCat&lt;/a&gt;&lt;/p&gt;
&lt;a href=&quot;https://en.formulasearchengine.com/index.php?title=Algebraically_compact_module&amp;amp;diff=231040&amp;amp;oldid=5094&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>en&gt;K9re11</name></author>
	</entry>
	<entry>
		<id>https://en.formulasearchengine.com/index.php?title=Algebraically_compact_module&amp;diff=5094&amp;oldid=prev</id>
		<title>184.57.94.47: /* References */  The name of the first author, Jensen, was misspelled; I fixed the error</title>
		<link rel="alternate" type="text/html" href="https://en.formulasearchengine.com/index.php?title=Algebraically_compact_module&amp;diff=5094&amp;oldid=prev"/>
		<updated>2010-12-31T04:58:57Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;References: &lt;/span&gt;  The name of the first author, Jensen, was misspelled; I fixed the error&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;An &amp;#039;&amp;#039;&amp;#039;attribute grammar&amp;#039;&amp;#039;&amp;#039; is a formal way to define [[Attribute (computing)|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]].&lt;br /&gt;
&lt;br /&gt;
The attributes are divided into two groups: &amp;#039;&amp;#039;synthesized&amp;#039;&amp;#039; attributes and &amp;#039;&amp;#039;inherited&amp;#039;&amp;#039; 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.&lt;br /&gt;
&lt;br /&gt;
In some approaches, synthesized attributes are used to pass semantic information up the parse tree, while inherited attributes help pass semantic information down and across 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 definition.&lt;br /&gt;
&lt;br /&gt;
Attribute grammars can also be used to translate the syntax tree directly into code for some specific machine, or into some [[intermediate language]].&lt;br /&gt;
&lt;br /&gt;
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}}&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
The following is a simple [[Context-free grammar]] which can describe a language made up of multiplication and addition of integers. &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;Expr&amp;#039;&amp;#039;&amp;#039; &amp;amp;rarr; &amp;#039;&amp;#039;&amp;#039;Expr&amp;#039;&amp;#039;&amp;#039; + &amp;#039;&amp;#039;&amp;#039;Term&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;Expr&amp;#039;&amp;#039;&amp;#039; &amp;amp;rarr; &amp;#039;&amp;#039;&amp;#039;Term&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;Term&amp;#039;&amp;#039;&amp;#039; &amp;amp;rarr; &amp;#039;&amp;#039;&amp;#039;Term&amp;#039;&amp;#039;&amp;#039; * &amp;#039;&amp;#039;&amp;#039;Factor&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;Term&amp;#039;&amp;#039;&amp;#039; &amp;amp;rarr; &amp;#039;&amp;#039;&amp;#039;Factor&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;Factor&amp;#039;&amp;#039;&amp;#039; &amp;amp;rarr; &amp;quot;(&amp;quot; &amp;#039;&amp;#039;&amp;#039;Expr&amp;#039;&amp;#039;&amp;#039; &amp;quot;)&amp;quot;&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;Factor&amp;#039;&amp;#039;&amp;#039; &amp;amp;rarr; &amp;#039;&amp;#039;integer&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following attribute grammar can be used to calculate the result of an expression written in the grammar. Note that this grammar only uses synthesized values, and is therefore an [[S-attributed grammar]].&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;Expr&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;&amp;#039;&amp;#039;&amp;#039; &amp;amp;rarr; &amp;#039;&amp;#039;&amp;#039;Expr&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&amp;#039;&amp;#039;&amp;#039; + &amp;#039;&amp;#039;&amp;#039;Term&amp;#039;&amp;#039;&amp;#039; [ &amp;#039;&amp;#039;&amp;#039;Expr&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;&amp;#039;&amp;#039;&amp;#039;.value = &amp;#039;&amp;#039;&amp;#039;Expr&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&amp;#039;&amp;#039;&amp;#039;.value + &amp;#039;&amp;#039;&amp;#039;Term&amp;#039;&amp;#039;&amp;#039;.value ]&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;Expr&amp;#039;&amp;#039;&amp;#039; &amp;amp;rarr; &amp;#039;&amp;#039;&amp;#039;Term&amp;#039;&amp;#039;&amp;#039; [ &amp;#039;&amp;#039;&amp;#039;Expr&amp;#039;&amp;#039;&amp;#039;.value = &amp;#039;&amp;#039;&amp;#039;Term&amp;#039;&amp;#039;&amp;#039;.value ]&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;Term&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;&amp;#039;&amp;#039;&amp;#039; &amp;amp;rarr; &amp;#039;&amp;#039;&amp;#039;Term&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&amp;#039;&amp;#039;&amp;#039; * &amp;#039;&amp;#039;&amp;#039;Factor&amp;#039;&amp;#039;&amp;#039; [ &amp;#039;&amp;#039;&amp;#039;Term&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;&amp;#039;&amp;#039;&amp;#039;.value = &amp;#039;&amp;#039;&amp;#039;Term&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&amp;#039;&amp;#039;&amp;#039;.value * &amp;#039;&amp;#039;&amp;#039;Factor&amp;#039;&amp;#039;&amp;#039;.value ]&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;Term&amp;#039;&amp;#039;&amp;#039; &amp;amp;rarr; &amp;#039;&amp;#039;&amp;#039;Factor&amp;#039;&amp;#039;&amp;#039; [ &amp;#039;&amp;#039;&amp;#039;Term&amp;#039;&amp;#039;&amp;#039;.value = &amp;#039;&amp;#039;&amp;#039;Factor&amp;#039;&amp;#039;&amp;#039;.value ]&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;Factor&amp;#039;&amp;#039;&amp;#039; &amp;amp;rarr; &amp;quot;(&amp;quot; &amp;#039;&amp;#039;&amp;#039;Expr&amp;#039;&amp;#039;&amp;#039; &amp;quot;)&amp;quot; [ &amp;#039;&amp;#039;&amp;#039;Factor&amp;#039;&amp;#039;&amp;#039;.value =  &amp;#039;&amp;#039;&amp;#039;Expr&amp;#039;&amp;#039;&amp;#039;.value ]&lt;br /&gt;
  &amp;#039;&amp;#039;&amp;#039;Factor&amp;#039;&amp;#039;&amp;#039; &amp;amp;rarr; &amp;#039;&amp;#039;integer&amp;#039;&amp;#039; [ &amp;#039;&amp;#039;&amp;#039;Factor&amp;#039;&amp;#039;&amp;#039;.value = strToInt(&amp;#039;&amp;#039;integer&amp;#039;&amp;#039;.str) ]&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Synthesized attributes==&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;G=&amp;lt;V_n,V_t,P,S&amp;gt;&amp;lt;/math&amp;gt; be an Attribute grammar, where&lt;br /&gt;
* &amp;lt;math&amp;gt;V_n&amp;lt;/math&amp;gt; is the set of non terminal symbols&lt;br /&gt;
* &amp;lt;math&amp;gt;V_t&amp;lt;/math&amp;gt; is the set of terminal symbols&lt;br /&gt;
* &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt; is the set of [[Formal_grammar#The_syntax_of_grammars|productions]]&lt;br /&gt;
* &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; is the distinguished symbol, that is the start symbol&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;A.a&amp;lt;/math&amp;gt; is a synthesized attribute if,&lt;br /&gt;
* &amp;lt;math&amp;gt;A \rightarrow \alpha \in P&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\alpha = \alpha_1 \ldots \alpha_n, \forall_{i, 1 \leq i \leq n}: \alpha_i \in (V_n \cup V_t)&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\{\alpha_{j1}, \ldots ,\alpha_{jm}\} \subseteq \{\alpha_1, \ldots ,\alpha_n\}&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;A.a = f(\alpha_{j1}.a_1, \ldots ,\alpha_{jm}.a_m)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Inherited attributes==&lt;br /&gt;
An &amp;#039;&amp;#039;inherited attribute&amp;#039;&amp;#039; at a node in parse tree is defined using the attribute values at the parent or siblings. Inherited attributes are convenient for expressing the dependence of a programming language construct on the context in which it appears. For example, we can use an inherited attribute to keep track of whether an identifier appears on the left or the right side of an assignment in order to decide whether the address or the value of the identifier is needed. &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Production rule !! Semantic rule&lt;br /&gt;
|-&lt;br /&gt;
| S → T L || L.in:=T.type&lt;br /&gt;
|-&lt;br /&gt;
| T → int || T.type:=integer&lt;br /&gt;
|-&lt;br /&gt;
| T → float || T.type:=float&lt;br /&gt;
|-&lt;br /&gt;
| T → char || T.type:=char&lt;br /&gt;
|-&lt;br /&gt;
| T → double || T.type:=double&lt;br /&gt;
|-&lt;br /&gt;
| L → L&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, id || L&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;.in=L.in&lt;br /&gt;
enter_type(id.entry, L.in)&lt;br /&gt;
|-&lt;br /&gt;
| L → id || enter_type(id.entry, L.in)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Special types of attribute grammars==&lt;br /&gt;
* [[L-attributed grammar]] : &amp;#039;&amp;#039;inherited attributes&amp;#039;&amp;#039; can be evaluated in one left-to-right traversal of the abstract syntax tree&lt;br /&gt;
* [[LR-attributed grammar]] : an L-attributed grammar whose &amp;#039;&amp;#039;inherited attributes&amp;#039;&amp;#039; can also be evaluated in [[bottom-up parsing]].&lt;br /&gt;
* [[ECLR-attributed grammar]] : a subset of LR-attributed grammars where equivalence classes can be used to optimize the evaluation of inherited attributes.&lt;br /&gt;
* [[S-attributed grammar]] : a simple type of attribute grammar, using only &amp;#039;&amp;#039;synthesized attributes&amp;#039;&amp;#039;, but no &amp;#039;&amp;#039;inherited attributes&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[Affix grammar]]&lt;br /&gt;
*[[Van Wijngaarden grammar]]&lt;br /&gt;
*[[Syntax-directed translation]]&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
*[http://www.haskell.org/haskellwiki/The_Monad.Reader/Issue4/Why_Attribute_Grammars_Matter Why Attribute Grammars Matter], The Monad Reader, Issue 4, July 5, 2005. (This article narrates on how the formalism of attribute grammars brings [[aspect-oriented programming]] to [[functional programming]] by helping writing [[catamorphism]]s [[compositionality|compositional]]ly. It refers to the [http://www.cs.uu.nl/wiki/bin/view/HUT/AttributeGrammarSystem Utrecht University Attribute Grammar] system as the implementation used in the examples.)&lt;br /&gt;
*[http://www.haskell.org/haskellwiki/Attribute_grammar Attribute grammar] in relation to [[Haskell (programming language)|Haskell]] and [[functional programming]].&lt;br /&gt;
*&amp;#039;&amp;#039;Semantics of context-free languages&amp;#039;&amp;#039;, by [[Donald Knuth|Don Knuth]], is the original paper introducing attributed grammars&lt;br /&gt;
*D. E. Knuth: [http://www-cs-faculty.stanford.edu/~knuth/papers/gag.tex.gz The genesis of attribute grammars]. &amp;#039;&amp;#039;Proceedings of the international conference on Attribute grammars and their applications&amp;#039;&amp;#039; (1990), LNCS, [http://www.springerlink.com/content/w35h4669q16j/ vol. 461], 1–12. Some informal, historical information.&lt;br /&gt;
*Jukka Paakki: Attribute grammar paradigms—a high-level methodology in language implementation. &amp;#039;&amp;#039;ACM Computing Surveys&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;27&amp;#039;&amp;#039;&amp;#039;:2 (June 1995), 196–255.&lt;br /&gt;
&lt;br /&gt;
[[Category:Formal languages]]&lt;br /&gt;
[[Category:Compiler construction]]&lt;br /&gt;
[[Category:Parsing]]&lt;/div&gt;</summary>
		<author><name>184.57.94.47</name></author>
	</entry>
</feed>