<s>
An	O
attribute	B-Application
grammar	I-Application
is	O
a	O
formal	O
way	O
to	O
supplement	O
a	O
formal	O
grammar	O
with	O
semantic	O
information	O
processing	O
.	O
</s>
<s>
Semantic	O
information	O
is	O
stored	O
in	O
attributes	B-General_Concept
associated	O
with	O
terminal	B-Algorithm
and	I-Algorithm
nonterminal	I-Algorithm
symbols	I-Algorithm
of	O
the	O
grammar	O
.	O
</s>
<s>
The	O
values	O
of	O
attributes	B-General_Concept
are	O
result	O
of	O
attribute	O
evaluation	O
rules	O
associated	O
with	O
productions	O
of	O
the	O
grammar	O
.	O
</s>
<s>
Attributes	B-General_Concept
allow	O
to	O
transfer	O
information	O
from	O
anywhere	O
in	O
the	O
abstract	B-Data_Structure
syntax	I-Data_Structure
tree	I-Data_Structure
to	O
anywhere	O
else	O
,	O
in	O
a	O
controlled	O
and	O
formal	O
way	O
.	O
</s>
<s>
Each	O
semantic	O
function	O
deals	O
with	O
attributes	B-General_Concept
of	O
symbols	O
occurring	O
only	O
in	O
one	O
production	O
rule	O
:	O
both	O
semantic	O
function	O
parameters	O
and	O
its	O
result	O
are	O
attributes	B-General_Concept
of	O
symbols	O
from	O
one	O
particular	O
rule	O
.	O
</s>
<s>
Thus	O
,	O
synthesized	O
attributes	B-General_Concept
serve	O
to	O
pass	O
semantic	O
information	O
up	O
the	O
parse	O
tree	O
,	O
while	O
inherited	O
attributes	B-General_Concept
allow	O
values	O
to	O
be	O
passed	O
from	O
the	O
parent	O
nodes	O
down	O
and	O
across	O
the	O
syntax	O
tree	O
.	O
</s>
<s>
In	O
simple	O
applications	O
,	O
such	O
as	O
evaluation	O
of	O
arithmetic	O
expressions	O
,	O
attribute	B-Application
grammar	I-Application
may	O
be	O
used	O
to	O
describe	O
the	O
entire	O
task	O
to	O
be	O
performed	O
besides	O
parsing	O
in	O
straightforward	O
way	O
;	O
in	O
complicated	O
systems	O
,	O
for	O
instance	O
,	O
when	O
constructing	O
a	O
language	O
translation	O
tool	O
,	O
such	O
as	O
a	O
compiler	B-Language
,	O
it	O
may	O
be	O
used	O
to	O
validate	O
semantic	O
checks	O
associated	O
with	O
a	O
grammar	O
,	O
representing	O
the	O
rules	O
of	O
a	O
language	O
not	O
explicitly	O
imparted	O
by	O
the	O
syntax	O
definition	O
.	O
</s>
<s>
It	O
may	O
be	O
also	O
used	O
by	O
parsers	B-Language
or	O
compilers	B-Language
to	O
translate	O
the	O
syntax	O
tree	O
directly	O
into	O
code	O
for	O
some	O
specific	O
machine	O
,	O
or	O
into	O
some	O
intermediate	O
language	O
.	O
</s>
<s>
Attribute	B-Application
grammars	I-Application
were	O
invented	O
by	O
Donald	O
Knuth	O
and	O
Peter	O
Wegner	O
.	O
</s>
<s>
While	O
Donald	O
Knuth	O
is	O
credited	O
for	O
the	O
overall	O
concept	O
,	O
Peter	O
Wegner	O
invented	O
inherited	O
attributes	B-General_Concept
during	O
a	O
conversation	O
with	O
Knuth	O
.	O
</s>
<s>
Some	O
embryonic	O
ideas	O
trace	O
back	O
to	O
the	O
work	O
of	O
Edgar	O
T	O
.	O
"	O
Ned	O
"	O
Irons	O
,	O
the	O
author	O
of	O
IMP	B-Language
.	O
</s>
<s>
The	O
following	O
attribute	B-Application
grammar	I-Application
can	O
be	O
used	O
to	O
calculate	O
the	O
result	O
of	O
an	O
expression	O
written	O
in	O
the	O
grammar	O
.	O
</s>
<s>
Note	O
that	O
this	O
grammar	O
only	O
uses	O
synthesized	O
values	O
,	O
and	O
is	O
therefore	O
an	O
S-attributed	B-Application
grammar	I-Application
.	O
</s>
<s>
A	O
synthesized	O
attribute	O
is	O
computed	O
from	O
the	O
values	O
of	O
attributes	B-General_Concept
of	O
the	O
children	O
.	O
</s>
<s>
Then	O
,	O
given	O
a	O
string	O
of	O
nonterminal	B-Algorithm
symbols	O
and	O
an	O
attribute	O
name	O
,	O
is	O
a	O
synthesized	O
attribute	O
if	O
all	O
three	O
of	O
these	O
conditions	O
are	O
met	O
:	O
</s>
<s>
Inherited	O
attributes	B-General_Concept
are	O
convenient	O
for	O
expressing	O
the	O
dependence	O
of	O
a	O
programming	O
language	O
construct	O
on	O
the	O
context	O
in	O
which	O
it	O
appears	O
.	O
</s>
<s>
In	O
contrast	O
to	O
synthesized	O
attributes	B-General_Concept
,	O
inherited	O
attributes	B-General_Concept
can	O
take	O
values	O
from	O
parent	O
and/or	O
siblings	O
.	O
</s>
<s>
where	O
A	O
can	O
get	O
values	O
from	O
S	O
,	O
B	O
,	O
and	O
C	B-Language
.	O
B	O
can	O
take	O
values	O
from	O
S	O
,	O
A	O
,	O
and	O
C	B-Language
.	O
Likewise	O
,	O
C	B-Language
can	O
take	O
values	O
from	O
S	O
,	O
A	O
,	O
and	O
B	O
.	O
</s>
<s>
LR-attributed	B-Application
grammar	I-Application
:	O
an	O
L-attributed	B-Application
grammar	I-Application
whose	O
inherited	O
attributes	B-General_Concept
can	O
also	O
be	O
evaluated	O
in	O
bottom-up	B-Application
parsing	I-Application
.	O
</s>
<s>
ECLR-attributed	B-Application
grammar	I-Application
:	O
a	O
subset	O
of	O
LR-attributed	B-Application
grammars	I-Application
where	O
equivalence	O
classes	O
can	O
be	O
used	O
to	O
optimize	O
the	O
evaluation	O
of	O
inherited	O
attributes	B-General_Concept
.	O
</s>
