<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
the	O
Earley	B-Algorithm
parser	I-Algorithm
is	O
an	O
algorithm	O
for	O
parsing	B-Language
strings	O
that	O
belong	O
to	O
a	O
given	O
context-free	O
language	O
,	O
though	O
(	O
depending	O
on	O
the	O
variant	O
)	O
it	O
may	O
suffer	O
problems	O
with	O
certain	O
nullable	O
grammars	O
.	O
</s>
<s>
The	O
algorithm	O
,	O
named	O
after	O
its	O
inventor	O
,	O
Jay	O
Earley	O
,	O
is	O
a	O
chart	B-Application
parser	I-Application
that	O
uses	O
dynamic	B-Algorithm
programming	I-Algorithm
;	O
it	O
is	O
mainly	O
used	O
for	O
parsing	B-Language
in	O
computational	O
linguistics	O
.	O
</s>
<s>
Earley	B-Algorithm
parsers	I-Algorithm
are	O
appealing	O
because	O
they	O
can	O
parse	B-Language
all	O
context-free	O
languages	O
,	O
unlike	O
LR	B-Application
parsers	I-Application
and	O
LL	B-Language
parsers	I-Language
,	O
which	O
are	O
more	O
typically	O
used	O
in	O
compilers	B-Language
but	O
which	O
can	O
only	O
handle	O
restricted	O
classes	O
of	O
languages	O
.	O
</s>
<s>
The	O
Earley	B-Algorithm
parser	I-Algorithm
executes	O
in	O
cubic	O
time	O
in	O
the	O
general	O
case	O
,	O
where	O
n	O
is	O
the	O
length	O
of	O
the	O
parsed	B-Language
string	O
,	O
quadratic	O
time	O
for	O
unambiguous	O
grammars	O
,	O
and	O
linear	O
time	O
for	O
all	O
deterministic	O
context-free	O
grammars	O
.	O
</s>
<s>
It	O
performs	O
particularly	O
well	O
when	O
the	O
rules	O
are	O
written	O
left-recursively	B-Application
.	O
</s>
<s>
The	O
recogniser	O
can	O
be	O
modified	O
to	O
create	O
a	O
parse	B-Language
tree	O
as	O
it	O
recognises	O
,	O
and	O
in	O
that	O
way	O
can	O
be	O
turned	O
into	O
a	O
parser	O
.	O
</s>
<s>
In	O
the	O
following	O
descriptions	O
,	O
α	O
,	O
β	O
,	O
and	O
γ	O
represent	O
any	O
string	O
of	O
terminals/nonterminals	B-Algorithm
(	O
including	O
the	O
empty	O
string	O
)	O
,	O
X	O
and	O
Y	O
represent	O
single	O
nonterminals	B-Algorithm
,	O
and	O
a	O
represents	O
a	O
terminal	O
symbol	O
.	O
</s>
<s>
Earley	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
is	O
a	O
top-down	O
dynamic	B-Algorithm
programming	I-Algorithm
algorithm	O
.	O
</s>
<s>
In	O
the	O
following	O
,	O
we	O
use	O
Earley	O
's	O
dot	O
notation	O
:	O
given	O
a	O
production	O
X	O
→	O
αβ	O
,	O
the	O
notation	O
X	O
→	O
α	O
•	O
β	O
represents	O
a	O
condition	O
in	O
which	O
α	O
has	O
already	O
been	O
parsed	B-Language
and	O
β	O
is	O
expected	O
.	O
</s>
<s>
Input	O
position	O
n	O
is	O
the	O
position	O
after	O
accepting	O
the	O
nth	O
token	B-Application
.	O
</s>
<s>
(	O
Informally	O
,	O
input	O
positions	O
can	O
be	O
thought	O
of	O
as	O
locations	O
at	O
token	B-Application
boundaries	O
.	O
)	O
</s>
<s>
(	O
Earley	O
's	O
original	O
algorithm	O
included	O
a	O
look-ahead	O
in	O
the	O
state	O
;	O
later	O
research	O
showed	O
this	O
to	O
have	O
little	O
practical	O
effect	O
on	O
the	O
parsing	B-Language
efficiency	O
,	O
and	O
it	O
has	O
subsequently	O
been	O
dropped	O
from	O
most	O
implementations	O
.	O
)	O
</s>
<s>
The	O
state	O
(	O
P	O
→	O
S	O
•	O
,	O
0	O
)	O
represents	O
a	O
completed	O
parse	B-Language
.	O
</s>
<s>
Earley	O
's	O
dissertation	O
briefly	O
describes	O
an	O
algorithm	O
for	O
constructing	O
parse	B-Language
trees	O
by	O
adding	O
a	O
set	O
of	O
pointers	O
from	O
each	O
non-terminal	B-Algorithm
in	O
an	O
Earley	O
item	O
back	O
to	O
the	O
items	O
that	O
caused	O
it	O
to	O
be	O
recognized	O
.	O
</s>
<s>
Another	O
method	O
is	O
to	O
build	O
the	O
parse	B-Language
forest	O
as	O
you	O
go	O
,	O
augmenting	O
each	O
Earley	O
item	O
with	O
a	O
pointer	O
to	O
a	O
shared	O
packed	O
parse	B-Language
forest	O
(	O
SPPF	O
)	O
node	O
labelled	O
with	O
a	O
triple	O
(	O
s	O
,	O
i	O
,	O
j	O
)	O
where	O
s	O
is	O
a	O
symbol	O
or	O
an	O
LR(0 )	O
item	O
(	O
production	O
rule	O
with	O
dot	O
)	O
,	O
and	O
i	O
and	O
j	O
give	O
the	O
section	O
of	O
the	O
input	O
string	O
derived	O
by	O
this	O
node	O
.	O
</s>
<s>
SPPF	O
nodes	O
are	O
unique	O
(	O
there	O
is	O
only	O
one	O
with	O
a	O
given	O
label	O
)	O
,	O
but	O
may	O
contain	O
more	O
than	O
one	O
derivation	O
for	O
ambiguous	O
parses	B-Language
.	O
</s>
<s>
So	O
even	O
if	O
an	O
operation	O
does	O
not	O
add	O
an	O
Earley	O
item	O
(	O
because	O
it	O
already	O
exists	O
)	O
,	O
it	O
may	O
still	O
add	O
a	O
derivation	O
to	O
the	O
item	O
's	O
parse	B-Language
forest	O
.	O
</s>
<s>
The	O
scanner	B-Application
creates	O
an	O
SPPF	O
node	O
representing	O
the	O
non-terminal	B-Algorithm
it	O
is	O
scanning	O
.	O
</s>
<s>
Then	O
when	O
the	O
scanner	B-Application
or	O
completer	O
advance	O
an	O
item	O
,	O
they	O
add	O
a	O
derivation	O
whose	O
children	O
are	O
the	O
node	O
from	O
the	O
item	O
whose	O
dot	O
was	O
advanced	O
,	O
and	O
the	O
one	O
for	O
the	O
new	O
symbol	O
that	O
was	O
advanced	O
over	O
(	O
the	O
non-terminal	B-Algorithm
or	O
completed	O
item	O
)	O
.	O
</s>
<s>
Philippe	O
McLean	O
and	O
R	O
.	O
Nigel	O
Horspool	O
in	O
their	O
paper	O
combine	O
Earley	B-Algorithm
parsing	I-Algorithm
with	O
LR	B-Application
parsing	I-Application
and	O
achieve	O
an	O
improvement	O
in	O
an	O
order	O
of	O
magnitude	O
.	O
</s>
