<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
an	O
LALR	B-Application
parser	I-Application
or	O
Look-Ahead	B-Application
LR	I-Application
parser	I-Application
is	O
a	O
simplified	O
version	O
of	O
a	O
canonical	B-Application
LR	I-Application
parser	I-Application
,	O
to	O
parse	B-Language
a	O
text	O
according	O
to	O
a	O
set	O
of	O
production	O
rules	O
specified	O
by	O
a	O
formal	O
grammar	O
for	O
a	O
computer	B-Language
language	I-Language
.	O
</s>
<s>
The	O
LALR	B-Application
parser	I-Application
was	O
invented	O
by	O
Frank	O
DeRemer	O
in	O
his	O
1969	O
PhD	O
dissertation	O
,	O
Practical	O
Translators	O
for	O
LR(k )	O
languages	O
,	O
in	O
his	O
treatment	O
of	O
the	O
practical	O
difficulties	O
at	O
that	O
time	O
of	O
implementing	O
LR(1 )	O
parsers	B-Language
.	O
</s>
<s>
He	O
showed	O
that	O
the	O
LALR	B-Application
parser	I-Application
has	O
more	O
language	O
recognition	O
power	O
than	O
the	O
LR(0 )	O
parser	O
,	O
while	O
requiring	O
the	O
same	O
number	O
of	O
states	O
as	O
the	O
LR(0 )	O
parser	O
for	O
a	O
language	O
that	O
can	O
be	O
recognized	O
by	O
both	O
parsers	B-Language
.	O
</s>
<s>
This	O
makes	O
the	O
LALR	B-Application
parser	I-Application
a	O
memory-efficient	O
alternative	O
to	O
the	O
LR(1 )	O
parser	O
for	O
languages	O
that	O
are	O
LALR	B-Application
.	O
</s>
<s>
It	O
was	O
also	O
proven	O
that	O
there	O
exist	O
LR(1 )	O
languages	O
that	O
are	O
not	O
LALR	B-Application
.	O
</s>
<s>
Despite	O
this	O
weakness	O
,	O
the	O
power	O
of	O
the	O
LALR	B-Application
parser	I-Application
is	O
sufficient	O
for	O
many	O
mainstream	O
computer	B-Language
languages	I-Language
,	O
including	O
Java	B-Device
,	O
though	O
the	O
reference	O
grammars	O
for	O
many	O
languages	O
fail	O
to	O
be	O
LALR	B-Application
due	O
to	O
being	O
ambiguous	O
.	O
</s>
<s>
The	O
first	O
algorithms	O
for	O
LALR	B-Application
parser	I-Application
generation	O
were	O
published	O
in	O
1973	O
.	O
</s>
<s>
In	O
1982	O
,	O
DeRemer	O
and	O
Tom	O
Pennello	O
published	O
an	O
algorithm	O
that	O
generated	O
highly	O
memory-efficient	O
LALR	B-Application
parsers	I-Application
.	O
</s>
<s>
LALR	B-Application
parsers	I-Application
can	O
be	O
automatically	O
generated	O
from	O
a	O
grammar	O
by	O
an	O
LALR	B-Application
parser	I-Application
generator	I-Application
such	O
as	O
Yacc	B-Application
or	O
GNU	B-Application
Bison	I-Application
.	O
</s>
<s>
In	O
1965	O
,	O
Donald	O
Knuth	O
invented	O
the	O
LR	B-Application
parser	I-Application
(	O
Left	O
to	O
Right	O
,	O
Rightmost	O
derivation	O
)	O
.	O
</s>
<s>
The	O
LR	B-Application
parser	I-Application
can	O
recognize	O
any	O
deterministic	O
context-free	O
language	O
in	O
linear-bounded	O
time	O
.	O
</s>
<s>
Rightmost	O
derivation	O
has	O
very	O
large	O
memory	B-General_Concept
requirements	O
and	O
implementing	O
an	O
LR	B-Application
parser	I-Application
was	O
impractical	O
due	O
to	O
the	O
limited	O
memory	B-General_Concept
of	O
computers	O
at	O
that	O
time	O
.	O
</s>
<s>
To	O
address	O
this	O
shortcoming	O
,	O
in	O
1969	O
,	O
Frank	O
DeRemer	O
proposed	O
two	O
simplified	O
versions	O
of	O
the	O
LR	B-Application
parser	I-Application
,	O
namely	O
the	O
Look-Ahead	O
LR	O
(	O
LALR	B-Application
)	O
and	O
the	O
Simple	B-Application
LR	I-Application
parser	I-Application
that	O
had	O
much	O
lower	O
memory	B-General_Concept
requirements	O
at	O
the	O
cost	O
of	O
less	O
language-recognition	O
power	O
,	O
with	O
the	O
LALR	B-Application
parser	I-Application
being	O
the	O
most-powerful	O
alternative	O
.	O
</s>
<s>
In	O
1977	O
,	O
memory	B-General_Concept
optimizations	O
for	O
the	O
LR	B-Application
parser	I-Application
were	O
invented	O
but	O
still	O
the	O
LR	B-Application
parser	I-Application
was	O
less	O
memory-efficient	O
than	O
the	O
simplified	O
alternatives	O
.	O
</s>
<s>
In	O
1979	O
,	O
Frank	O
DeRemer	O
and	O
Tom	O
Pennello	O
announced	O
a	O
series	O
of	O
optimizations	O
for	O
the	O
LALR	B-Application
parser	I-Application
that	O
would	O
further	O
improve	O
its	O
memory	B-General_Concept
efficiency	O
.	O
</s>
<s>
Generally	O
,	O
the	O
LALR	B-Application
parser	I-Application
refers	O
to	O
the	O
LALR(1 )	O
parser	O
,	O
just	O
as	O
the	O
LR	B-Application
parser	I-Application
generally	O
refers	O
to	O
the	O
LR(1 )	O
parser	O
.	O
</s>
<s>
The	O
"	O
(	O
1	O
)	O
"	O
denotes	O
one-token	O
lookahead	O
,	O
to	O
resolve	O
differences	O
between	O
rule	O
patterns	O
during	O
parsing	B-Language
.	O
</s>
<s>
Similarly	O
,	O
there	O
is	O
an	O
LALR(2 )	O
parser	O
with	O
two-token	O
lookahead	O
,	O
and	O
LALR(k )	O
parsers	B-Language
with	O
k-token	O
lookup	O
,	O
but	O
these	O
are	O
rare	O
in	O
actual	O
use	O
.	O
</s>
<s>
The	O
LALR	B-Application
parser	I-Application
is	O
based	O
on	O
the	O
LR(0 )	O
parser	O
,	O
so	O
it	O
can	O
also	O
be	O
denoted	O
LALR(1 )	O
=	O
LA(1 )	O
LR(0 )	O
(	O
1	O
token	O
of	O
lookahead	O
,	O
LR(0 )	O
)	O
or	O
more	O
generally	O
LALR(k )	O
=	O
LA(k )	O
LR(0 )	O
(	O
k	O
tokens	O
of	O
lookahead	O
,	O
LR(0 )	O
)	O
.	O
</s>
<s>
There	O
is	O
in	O
fact	O
a	O
two-parameter	O
family	O
of	O
LA(k )	O
LR(j )	O
parsers	B-Language
for	O
all	O
combinations	O
of	O
j	O
and	O
k	O
,	O
which	O
can	O
be	O
derived	O
from	O
the	O
LR( j+k	O
)	O
parser	O
,	O
but	O
these	O
do	O
not	O
see	O
practical	O
use	O
.	O
</s>
<s>
As	O
with	O
other	O
types	O
of	O
LR	B-Application
parsers	I-Application
,	O
an	O
LALR	B-Application
parser	I-Application
is	O
quite	O
efficient	O
at	O
finding	O
the	O
single	O
correct	O
bottom-up	B-Application
parse	I-Application
in	O
a	O
single	O
left-to-right	O
scan	O
over	O
the	O
input	O
stream	O
,	O
because	O
it	O
does	O
not	O
need	O
to	O
use	O
backtracking	B-Algorithm
.	O
</s>
<s>
The	O
LALR(1 )	O
parser	O
is	O
less	O
powerful	O
than	O
the	O
LR(1 )	O
parser	O
,	O
and	O
more	O
powerful	O
than	O
the	O
SLR(1 )	O
parser	O
,	O
though	O
they	O
all	O
use	O
the	O
same	O
production	O
rules	O
.	O
</s>
<s>
The	O
simplification	O
that	O
the	O
LALR	B-Application
parser	I-Application
introduces	O
consists	O
in	O
merging	O
rules	O
that	O
have	O
identical	O
kernel	O
item	O
sets	O
,	O
because	O
during	O
the	O
LR(0 )	O
state-construction	O
process	O
the	O
lookaheads	O
are	O
not	O
known	O
.	O
</s>
<s>
All	O
conflicts	O
that	O
arise	O
in	O
applying	O
a	O
LALR(1 )	O
parser	O
to	O
an	O
unambiguous	O
LR(1 )	O
grammar	O
are	O
reduce/reduce	O
conflicts	O
.	O
</s>
<s>
The	O
standard	O
example	O
of	O
an	O
LR(1 )	O
grammar	O
that	O
cannot	O
be	O
parsed	B-Language
with	O
the	O
LALR(1 )	O
parser	O
,	O
exhibiting	O
such	O
a	O
reduce/reduce	O
conflict	O
,	O
is	O
:	O
</s>
<s>
In	O
the	O
LALR	B-Application
table	O
construction	O
,	O
two	O
states	O
will	O
be	O
merged	O
into	O
one	O
state	O
and	O
later	O
the	O
lookaheads	O
will	O
be	O
found	O
to	O
be	O
ambiguous	O
.	O
</s>
<s>
In	O
an	O
LALR	B-Application
parser	I-Application
this	O
one	O
state	O
has	O
conflicting	O
actions	O
(	O
given	O
lookahead	O
c	O
or	O
d	O
,	O
reduce	O
to	O
E	O
or	O
F	O
)	O
,	O
a	O
"	O
reduce/reduce	O
conflict	O
"	O
;	O
the	O
above	O
grammar	O
will	O
be	O
declared	O
ambiguous	O
by	O
a	O
LALR	B-Application
parser	I-Application
generator	I-Application
and	O
conflicts	O
will	O
be	O
reported	O
.	O
</s>
<s>
The	O
LALR(j )	O
parsers	B-Language
are	O
incomparable	O
with	O
LL(k )	O
parsers	B-Language
:	O
for	O
any	O
j	O
and	O
k	O
both	O
greater	O
than	O
0	O
,	O
there	O
are	O
LALR(j )	O
grammars	O
that	O
are	O
not	O
LL(k )	O
grammars	O
and	O
conversely	O
.	O
</s>
<s>
In	O
fact	O
,	O
it	O
is	O
undecidable	O
whether	O
a	O
given	O
LL(1 )	O
grammar	O
is	O
LALR(k )	O
for	O
any	O
.	O
</s>
<s>
Depending	O
on	O
the	O
presence	O
of	O
empty	O
derivations	O
,	O
a	O
LL(1 )	O
grammar	O
can	O
be	O
equal	O
to	O
a	O
SLR(1 )	O
or	O
a	O
LALR(1 )	O
grammar	O
.	O
</s>
<s>
If	O
the	O
LL(1 )	O
grammar	O
has	O
no	O
empty	O
derivations	O
it	O
is	O
SLR(1 )	O
and	O
if	O
all	O
symbols	O
with	O
empty	O
derivations	O
have	O
non-empty	O
derivations	O
it	O
is	O
LALR(1 )	O
.	O
</s>
<s>
If	O
symbols	O
having	O
only	O
an	O
empty	O
derivation	O
exist	O
,	O
the	O
grammar	O
may	O
or	O
may	O
not	O
be	O
LALR(1 )	O
.	O
</s>
