<s>
Parsing	B-Language
,	O
syntax	B-Language
analysis	I-Language
,	O
or	O
syntactic	B-Language
analysis	I-Language
is	O
the	O
process	O
of	O
analyzing	O
a	O
string	O
of	O
symbols	O
,	O
either	O
in	O
natural	O
language	O
,	O
computer	B-Language
languages	I-Language
or	O
data	B-General_Concept
structures	I-General_Concept
,	O
conforming	O
to	O
the	O
rules	O
of	O
a	O
formal	O
grammar	O
.	O
</s>
<s>
The	O
term	O
parsing	B-Language
comes	O
from	O
Latin	O
pars	O
(	O
orationis	O
)	O
,	O
meaning	O
part	O
(	O
of	O
speech	O
)	O
.	O
</s>
<s>
The	O
term	O
has	O
slightly	O
different	O
meanings	O
in	O
different	O
branches	O
of	O
linguistics	O
and	O
computer	B-General_Concept
science	I-General_Concept
.	O
</s>
<s>
Traditional	O
sentence	O
parsing	B-Language
is	O
often	O
performed	O
as	O
a	O
method	O
of	O
understanding	O
the	O
exact	O
meaning	O
of	O
a	O
sentence	O
or	O
word	O
,	O
sometimes	O
with	O
the	O
aid	O
of	O
devices	O
such	O
as	O
sentence	O
diagrams	O
.	O
</s>
<s>
Within	O
computational	O
linguistics	O
the	O
term	O
is	O
used	O
to	O
refer	O
to	O
the	O
formal	O
analysis	O
by	O
a	O
computer	O
of	O
a	O
sentence	O
or	O
other	O
string	O
of	O
words	O
into	O
its	O
constituents	O
,	O
resulting	O
in	O
a	O
parse	B-Language
tree	O
showing	O
their	O
syntactic	O
relation	O
to	O
each	O
other	O
,	O
which	O
may	O
also	O
contain	O
semantic	B-Application
and	O
other	O
information	O
(	O
p-values	B-General_Concept
)	O
.	O
</s>
<s>
Some	O
parsing	B-Language
algorithms	O
may	O
generate	O
a	O
parse	B-Language
forest	O
or	O
list	O
of	O
parse	B-Language
trees	O
for	O
a	O
syntactically	O
ambiguous	O
input	O
.	O
</s>
<s>
In	O
this	O
context	O
,	O
parsing	B-Language
refers	O
to	O
the	O
way	O
that	O
human	O
beings	O
analyze	O
a	O
sentence	O
or	O
phrase	O
(	O
in	O
spoken	O
language	O
or	O
text	O
)	O
"	O
in	O
terms	O
of	O
grammatical	O
constituents	O
,	O
identifying	O
the	O
parts	O
of	O
speech	O
,	O
syntactic	O
relations	O
,	O
etc.	O
"	O
</s>
<s>
Within	O
computer	B-General_Concept
science	I-General_Concept
,	O
the	O
term	O
is	O
used	O
in	O
the	O
analysis	O
of	O
computer	B-Language
languages	I-Language
,	O
referring	O
to	O
the	O
syntactic	B-Language
analysis	I-Language
of	O
the	O
input	O
code	O
into	O
its	O
component	O
parts	O
in	O
order	O
to	O
facilitate	O
the	O
writing	O
of	O
compilers	B-Language
and	O
interpreters	B-Application
.	O
</s>
<s>
The	O
traditional	O
grammatical	O
exercise	O
of	O
parsing	B-Language
,	O
sometimes	O
known	O
as	O
clause	O
analysis	O
,	O
involves	O
breaking	O
down	O
a	O
text	O
into	O
its	O
component	O
parts	O
of	O
speech	O
with	O
an	O
explanation	O
of	O
the	O
form	O
,	O
function	O
,	O
and	O
syntactic	O
relationship	O
of	O
each	O
part	O
.	O
</s>
<s>
To	O
parse	B-Language
a	O
phrase	O
such	O
as	O
'	O
man	O
bites	O
dog	O
 '	O
involves	O
noting	O
that	O
the	O
singular	O
noun	O
'	O
man	O
 '	O
is	O
the	O
subject	O
of	O
the	O
sentence	O
,	O
the	O
verb	O
'	O
bites	O
 '	O
is	O
the	O
third	O
person	O
singular	O
of	O
the	O
present	O
tense	O
of	O
the	O
verb	O
'	O
to	O
bite	O
 '	O
,	O
and	O
the	O
singular	O
noun	O
'	O
dog	O
 '	O
is	O
the	O
object	O
of	O
the	O
sentence	O
.	O
</s>
<s>
Parsing	B-Language
was	O
formerly	O
central	O
to	O
the	O
teaching	O
of	O
grammar	O
throughout	O
the	O
English-speaking	O
world	O
,	O
and	O
widely	O
regarded	O
as	O
basic	O
to	O
the	O
use	O
and	O
understanding	O
of	O
written	O
language	O
.	O
</s>
<s>
In	O
some	O
machine	B-Application
translation	I-Application
and	O
natural	B-Language
language	I-Language
processing	I-Language
systems	O
,	O
written	O
texts	O
in	O
human	O
languages	O
are	O
parsed	B-Language
by	O
computer	O
programs	O
.	O
</s>
<s>
Human	O
sentences	O
are	O
not	O
easily	O
parsed	B-Language
by	O
programs	O
,	O
as	O
there	O
is	O
substantial	O
ambiguity	O
in	O
the	O
structure	O
of	O
human	O
language	O
,	O
whose	O
usage	O
is	O
to	O
convey	O
meaning	O
(	O
or	O
semantics	B-Application
)	O
amongst	O
a	O
potentially	O
unlimited	O
range	O
of	O
possibilities	O
but	O
only	O
some	O
of	O
which	O
are	O
germane	O
to	O
the	O
particular	O
case	O
.	O
</s>
<s>
In	O
order	O
to	O
parse	B-Language
natural	O
language	O
data	O
,	O
researchers	O
must	O
first	O
agree	O
on	O
the	O
grammar	O
to	O
be	O
used	O
.	O
</s>
<s>
The	O
choice	O
of	O
syntax	B-Application
is	O
affected	O
by	O
both	O
linguistic	O
and	O
computational	O
concerns	O
;	O
for	O
instance	O
some	O
parsing	B-Language
systems	O
use	O
lexical	O
functional	O
grammar	O
,	O
but	O
in	O
general	O
,	O
parsing	B-Language
for	O
grammars	O
of	O
this	O
type	O
is	O
known	O
to	O
be	O
NP-complete	O
.	O
</s>
<s>
Head-driven	O
phrase	O
structure	O
grammar	O
is	O
another	O
linguistic	O
formalism	O
which	O
has	O
been	O
popular	O
in	O
the	O
parsing	B-Language
community	O
,	O
but	O
other	O
research	O
efforts	O
have	O
focused	O
on	O
less	O
complex	O
formalisms	O
such	O
as	O
the	O
one	O
used	O
in	O
the	O
Penn	O
Treebank	O
.	O
</s>
<s>
Shallow	B-General_Concept
parsing	I-General_Concept
aims	O
to	O
find	O
only	O
the	O
boundaries	O
of	O
major	O
constituents	O
such	O
as	O
noun	O
phrases	O
.	O
</s>
<s>
Another	O
popular	O
strategy	O
for	O
avoiding	O
linguistic	O
controversy	O
is	O
dependency	O
grammar	O
parsing	B-Language
.	O
</s>
<s>
Most	O
modern	O
parsers	B-Language
are	O
at	O
least	O
partly	O
statistical	B-General_Concept
;	O
that	O
is	O
,	O
they	O
rely	O
on	O
a	O
corpus	O
of	O
training	O
data	O
which	O
has	O
already	O
been	O
annotated	O
(	O
parsed	B-Language
by	O
hand	O
)	O
.	O
</s>
<s>
Approaches	O
which	O
have	O
been	O
used	O
include	O
straightforward	O
PCFGs	B-General_Concept
(	O
probabilistic	B-General_Concept
context-free	I-General_Concept
grammars	I-General_Concept
)	O
,	O
maximum	O
entropy	O
,	O
and	O
neural	B-Architecture
nets	I-Architecture
.	O
</s>
<s>
However	O
such	O
systems	O
are	O
vulnerable	O
to	O
overfitting	B-Error_Name
and	O
require	O
some	O
kind	O
of	O
smoothing	B-Application
to	O
be	O
effective	O
.	O
</s>
<s>
Parsing	B-Language
algorithms	O
for	O
natural	O
language	O
cannot	O
rely	O
on	O
the	O
grammar	O
having	O
'	O
nice	O
 '	O
properties	O
as	O
with	O
manually	O
designed	O
grammars	O
for	O
programming	O
languages	O
.	O
</s>
<s>
As	O
mentioned	O
earlier	O
some	O
grammar	O
formalisms	O
are	O
very	O
difficult	O
to	O
parse	B-Language
computationally	O
;	O
in	O
general	O
,	O
even	O
if	O
the	O
desired	O
structure	O
is	O
not	O
context-free	O
,	O
some	O
kind	O
of	O
context-free	O
approximation	O
to	O
the	O
grammar	O
is	O
used	O
to	O
perform	O
a	O
first	O
pass	O
.	O
</s>
<s>
Algorithms	O
which	O
use	O
context-free	O
grammars	O
often	O
rely	O
on	O
some	O
variant	O
of	O
the	O
CYK	B-Application
algorithm	I-Application
,	O
usually	O
with	O
some	O
heuristic	B-Algorithm
to	O
prune	O
away	O
unlikely	O
analyses	O
to	O
save	O
time	O
.	O
</s>
<s>
(	O
See	O
chart	B-Application
parsing	I-Application
.	O
)	O
</s>
<s>
However	O
some	O
systems	O
trade	O
speed	O
for	O
accuracy	O
using	O
,	O
e.g.	O
,	O
linear-time	O
versions	O
of	O
the	O
shift-reduce	B-Application
algorithm	O
.	O
</s>
<s>
A	O
somewhat	O
recent	O
development	O
has	O
been	O
parse	B-Language
reranking	O
in	O
which	O
the	O
parser	O
proposes	O
some	O
large	O
number	O
of	O
analyses	O
,	O
and	O
a	O
more	O
complex	O
system	O
selects	O
the	O
best	O
option	O
.	O
</s>
<s>
In	O
natural	B-General_Concept
language	I-General_Concept
understanding	I-General_Concept
applications	O
,	O
semantic	B-Application
parsers	I-Application
convert	O
the	O
text	O
into	O
a	O
representation	O
of	O
its	O
meaning	O
.	O
</s>
<s>
In	O
psycholinguistics	O
,	O
parsing	B-Language
involves	O
not	O
just	O
the	O
assignment	O
of	O
words	O
to	O
categories	O
(	O
formation	O
of	O
ontological	O
insights	O
)	O
,	O
but	O
the	O
evaluation	O
of	O
the	O
meaning	O
of	O
a	O
sentence	O
according	O
to	O
the	O
rules	O
of	O
syntax	B-Application
drawn	O
by	O
inferences	O
made	O
from	O
each	O
word	O
in	O
the	O
sentence	O
(	O
known	O
as	O
connotation	O
)	O
.	O
</s>
<s>
Consequently	O
,	O
psycholinguistic	O
models	O
of	O
parsing	B-Language
are	O
of	O
necessity	O
incremental	O
,	O
meaning	O
that	O
they	O
build	O
up	O
an	O
interpretation	O
as	O
the	O
sentence	O
is	O
being	O
processed	O
,	O
which	O
is	O
normally	O
expressed	O
in	O
terms	O
of	O
a	O
partial	O
syntactic	O
structure	O
.	O
</s>
<s>
A	O
parser	O
is	O
a	O
software	O
component	O
that	O
takes	O
input	O
data	O
(	O
frequently	O
text	O
)	O
and	O
builds	O
a	O
data	B-General_Concept
structure	I-General_Concept
–	O
often	O
some	O
kind	O
of	O
parse	B-Language
tree	O
,	O
abstract	B-Data_Structure
syntax	I-Data_Structure
tree	I-Data_Structure
or	O
other	O
hierarchical	O
structure	O
,	O
giving	O
a	O
structural	O
representation	O
of	O
the	O
input	O
while	O
checking	O
for	O
correct	O
syntax	B-Application
.	O
</s>
<s>
The	O
parsing	B-Language
may	O
be	O
preceded	O
or	O
followed	O
by	O
other	O
steps	O
,	O
or	O
these	O
may	O
be	O
combined	O
into	O
a	O
single	O
step	O
.	O
</s>
<s>
The	O
parser	O
is	O
often	O
preceded	O
by	O
a	O
separate	O
lexical	B-Application
analyser	I-Application
,	O
which	O
creates	O
tokens	O
from	O
the	O
sequence	O
of	O
input	O
characters	O
;	O
alternatively	O
,	O
these	O
can	O
be	O
combined	O
in	O
scannerless	B-Application
parsing	I-Application
.	O
</s>
<s>
Parsers	B-Language
may	O
be	O
programmed	O
by	O
hand	O
or	O
may	O
be	O
automatically	O
or	O
semi-automatically	O
generated	O
by	O
a	O
parser	B-Language
generator	I-Language
.	O
</s>
<s>
Parsing	B-Language
is	O
complementary	O
to	O
templating	B-Language
,	O
which	O
produces	O
formatted	O
output	O
.	O
</s>
<s>
These	O
may	O
be	O
applied	O
to	O
different	O
domains	O
,	O
but	O
often	O
appear	O
together	O
,	O
such	O
as	O
the	O
scanf/printf	O
pair	O
,	O
or	O
the	O
input	O
(	O
front	O
end	O
parsing	B-Language
)	O
and	O
output	O
(	O
back	O
end	O
code	O
generation	O
)	O
stages	O
of	O
a	O
compiler	B-Language
.	O
</s>
<s>
The	O
input	O
to	O
a	O
parser	O
is	O
often	O
text	O
in	O
some	O
computer	B-Language
language	I-Language
,	O
but	O
may	O
also	O
be	O
text	O
in	O
a	O
natural	O
language	O
or	O
less	O
structured	O
textual	O
data	O
,	O
in	O
which	O
case	O
generally	O
only	O
certain	O
parts	O
of	O
the	O
text	O
are	O
extracted	O
,	O
rather	O
than	O
a	O
parse	B-Language
tree	O
being	O
constructed	O
.	O
</s>
<s>
Parsers	B-Language
range	O
from	O
very	O
simple	O
functions	O
such	O
as	O
scanf	B-Language
,	O
to	O
complex	O
programs	O
such	O
as	O
the	O
frontend	O
of	O
a	O
C++	O
compiler	B-Language
or	O
the	O
HTML	B-Language
parser	O
of	O
a	O
web	B-Application
browser	I-Application
.	O
</s>
<s>
An	O
important	O
class	O
of	O
simple	O
parsing	B-Language
is	O
done	O
using	O
regular	B-Language
expressions	I-Language
,	O
in	O
which	O
a	O
group	O
of	O
regular	B-Language
expressions	I-Language
defines	O
a	O
regular	B-General_Concept
language	I-General_Concept
and	O
a	O
regular	B-Language
expression	I-Language
engine	O
automatically	O
generating	O
a	O
parser	O
for	O
that	O
language	O
,	O
allowing	O
pattern	B-Language
matching	I-Language
and	O
extraction	O
of	O
text	O
.	O
</s>
<s>
In	O
other	O
contexts	O
regular	B-Language
expressions	I-Language
are	O
instead	O
used	O
prior	O
to	O
parsing	B-Language
,	O
as	O
the	O
lexing	B-Application
step	O
whose	O
output	O
is	O
then	O
used	O
by	O
the	O
parser	O
.	O
</s>
<s>
The	O
use	O
of	O
parsers	B-Language
varies	O
by	O
input	O
.	O
</s>
<s>
In	O
the	O
case	O
of	O
data	O
languages	O
,	O
a	O
parser	O
is	O
often	O
found	O
as	O
the	O
file	O
reading	O
facility	O
of	O
a	O
program	O
,	O
such	O
as	O
reading	O
in	O
HTML	B-Language
or	O
XML	B-Protocol
text	O
;	O
these	O
examples	O
are	O
markup	O
languages	O
.	O
</s>
<s>
In	O
the	O
case	O
of	O
programming	O
languages	O
,	O
a	O
parser	O
is	O
a	O
component	O
of	O
a	O
compiler	B-Language
or	O
interpreter	B-Application
,	O
which	O
parses	B-Language
the	O
source	O
code	O
of	O
a	O
computer	O
programming	O
language	O
to	O
create	O
some	O
form	O
of	O
internal	O
representation	O
;	O
the	O
parser	O
is	O
a	O
key	O
step	O
in	O
the	O
compiler	B-Language
frontend	O
.	O
</s>
<s>
Programming	O
languages	O
tend	O
to	O
be	O
specified	O
in	O
terms	O
of	O
a	O
deterministic	O
context-free	O
grammar	O
because	O
fast	O
and	O
efficient	O
parsers	B-Language
can	O
be	O
written	O
for	O
them	O
.	O
</s>
<s>
For	O
compilers	B-Language
,	O
the	O
parsing	B-Language
itself	O
can	O
be	O
done	O
in	O
one	O
pass	O
or	O
multiple	O
passes	O
–	O
see	O
one-pass	B-Language
compiler	I-Language
and	O
multi-pass	B-Application
compiler	I-Application
.	O
</s>
<s>
The	O
implied	O
disadvantages	O
of	O
a	O
one-pass	B-Language
compiler	I-Language
can	O
largely	O
be	O
overcome	O
by	O
adding	O
fix-ups	B-Library
,	O
where	O
provision	O
is	O
made	O
for	O
code	B-Library
relocation	I-Library
during	O
the	O
forward	O
pass	O
,	O
and	O
the	O
fix-ups	B-Library
are	O
applied	O
backwards	O
when	O
the	O
current	O
program	O
segment	O
has	O
been	O
recognized	O
as	O
having	O
been	O
completed	O
.	O
</s>
<s>
More	O
powerful	O
grammars	O
that	O
can	O
express	O
this	O
constraint	O
,	O
however	O
,	O
cannot	O
be	O
parsed	B-Language
efficiently	O
.	O
</s>
<s>
Thus	O
,	O
it	O
is	O
a	O
common	O
strategy	O
to	O
create	O
a	O
relaxed	O
parser	O
for	O
a	O
context-free	O
grammar	O
which	O
accepts	O
a	O
superset	O
of	O
the	O
desired	O
language	O
constructs	O
(	O
that	O
is	O
,	O
it	O
accepts	O
some	O
invalid	O
constructs	O
)	O
;	O
later	O
,	O
the	O
unwanted	O
constructs	O
can	O
be	O
filtered	O
out	O
at	O
the	O
semantic	B-Application
analysis	O
(	O
contextual	O
analysis	O
)	O
step	O
.	O
</s>
<s>
For	O
example	O
,	O
in	O
Python	B-Language
the	O
following	O
is	O
syntactically	O
valid	O
code	O
:	O
</s>
<s>
The	O
following	O
code	O
,	O
however	O
,	O
is	O
syntactically	O
valid	O
in	O
terms	O
of	O
the	O
context-free	O
grammar	O
,	O
yielding	O
a	O
syntax	B-Application
tree	O
with	O
the	O
same	O
structure	O
as	O
the	O
previous	O
,	O
but	O
violates	O
the	O
semantic	B-Application
rule	O
requiring	O
variables	O
to	O
be	O
initialized	O
before	O
use	O
:	O
</s>
<s>
The	O
following	O
example	O
demonstrates	O
the	O
common	O
case	O
of	O
parsing	B-Language
a	O
computer	B-Language
language	I-Language
with	O
two	O
levels	O
of	O
grammar	O
:	O
lexical	O
and	O
syntactic	O
.	O
</s>
<s>
The	O
first	O
stage	O
is	O
the	O
token	O
generation	O
,	O
or	O
lexical	B-Application
analysis	I-Application
,	O
by	O
which	O
the	O
input	O
character	O
stream	O
is	O
split	O
into	O
meaningful	O
symbols	O
defined	O
by	O
a	O
grammar	O
of	O
regular	B-Language
expressions	I-Language
.	O
</s>
<s>
The	O
lexer	B-Application
would	O
contain	O
rules	O
to	O
tell	O
it	O
that	O
the	O
characters	O
*	O
,	O
+	O
,	O
^	O
,	O
(	O
and	O
)	O
mark	O
the	O
start	O
of	O
a	O
new	O
token	O
,	O
so	O
meaningless	O
tokens	O
like	O
"	O
12*	O
"	O
or	O
"	O
(	O
3	O
"	O
will	O
not	O
be	O
generated	O
.	O
</s>
<s>
The	O
next	O
stage	O
is	O
parsing	B-Language
or	O
syntactic	B-Language
analysis	I-Language
,	O
which	O
is	O
checking	O
that	O
the	O
tokens	O
form	O
an	O
allowable	O
expression	O
.	O
</s>
<s>
These	O
rules	O
can	O
be	O
formally	O
expressed	O
with	O
attribute	B-Application
grammars	I-Application
.	O
</s>
<s>
The	O
final	O
phase	O
is	O
semantic	B-Application
parsing	I-Application
or	O
analysis	O
,	O
which	O
is	O
working	O
out	O
the	O
implications	O
of	O
the	O
expression	O
just	O
validated	O
and	O
taking	O
the	O
appropriate	O
action	O
.	O
</s>
<s>
In	O
the	O
case	O
of	O
a	O
calculator	O
or	O
interpreter	B-Application
,	O
the	O
action	O
is	O
to	O
evaluate	O
the	O
expression	O
or	O
program	O
;	O
a	O
compiler	B-Language
,	O
on	O
the	O
other	O
hand	O
,	O
would	O
generate	O
some	O
kind	O
of	O
code	O
.	O
</s>
<s>
Attribute	B-Application
grammars	I-Application
can	O
also	O
be	O
used	O
to	O
define	O
these	O
actions	O
.	O
</s>
<s>
Top-down	B-Application
parsing	I-Application
-	O
Top-down	B-Application
parsing	I-Application
can	O
be	O
viewed	O
as	O
an	O
attempt	O
to	O
find	O
left-most	O
derivations	O
of	O
an	O
input-stream	O
by	O
searching	O
for	O
parse	B-Language
trees	O
using	O
a	O
top-down	O
expansion	O
of	O
the	O
given	O
formal	O
grammar	O
rules	O
.	O
</s>
<s>
Bottom-up	B-Application
parsing	I-Application
-	O
A	O
parser	O
can	O
start	O
with	O
the	O
input	O
and	O
attempt	O
to	O
rewrite	O
it	O
to	O
the	O
start	O
symbol	O
.	O
</s>
<s>
LR	B-Application
parsers	I-Application
are	O
examples	O
of	O
bottom-up	B-Application
parsers	I-Application
.	O
</s>
<s>
Another	O
term	O
used	O
for	O
this	O
type	O
of	O
parser	O
is	O
Shift-Reduce	B-Application
parsing	I-Application
.	O
</s>
<s>
LL	B-Language
parsers	I-Language
and	O
recursive-descent	B-Application
parser	I-Application
are	O
examples	O
of	O
top-down	B-Application
parsers	I-Application
that	O
cannot	O
accommodate	O
left	B-Application
recursive	I-Application
production	O
rules	O
.	O
</s>
<s>
Although	O
it	O
has	O
been	O
believed	O
that	O
simple	O
implementations	O
of	O
top-down	B-Application
parsing	I-Application
cannot	O
accommodate	O
direct	O
and	O
indirect	O
left-recursion	O
and	O
may	O
require	O
exponential	O
time	O
and	O
space	O
complexity	O
while	O
parsing	B-Language
ambiguous	O
context-free	O
grammars	O
,	O
more	O
sophisticated	O
algorithms	O
for	O
top-down	B-Application
parsing	I-Application
have	O
been	O
created	O
by	O
Frost	O
,	O
Hafiz	O
,	O
and	O
Callaghan	O
which	O
accommodate	O
ambiguity	O
and	O
left	B-Application
recursion	I-Application
in	O
polynomial	O
time	O
and	O
which	O
generate	O
polynomial-size	O
representations	O
of	O
the	O
potentially	O
exponential	O
number	O
of	O
parse	B-Language
trees	O
.	O
</s>
<s>
An	O
important	O
distinction	O
with	O
regard	O
to	O
parsers	B-Language
is	O
whether	O
a	O
parser	O
generates	O
a	O
leftmost	O
derivation	O
or	O
a	O
rightmost	O
derivation	O
(	O
see	O
context-free	O
grammar	O
)	O
.	O
</s>
<s>
LL	B-Language
parsers	I-Language
will	O
generate	O
a	O
leftmost	O
derivation	O
and	O
LR	B-Application
parsers	I-Application
will	O
generate	O
a	O
rightmost	O
derivation	O
(	O
although	O
usually	O
in	O
reverse	O
)	O
.	O
</s>
<s>
Some	O
algorithms	O
have	O
been	O
designed	O
for	O
visual	B-Language
programming	I-Language
languages	I-Language
.	O
</s>
<s>
Parsers	B-Language
for	O
visual	O
languages	O
are	O
sometimes	O
based	O
on	O
graph	B-Application
grammars	I-Application
.	O
</s>
<s>
Adaptive	O
parsing	B-Language
algorithms	O
have	O
been	O
used	O
to	O
construct	O
"	O
self-extending	O
"	O
natural	B-General_Concept
language	I-General_Concept
user	I-General_Concept
interfaces	I-General_Concept
.	O
</s>
<s>
(	O
Such	O
as	O
in-memory	O
multi-pass	B-Application
compilers	I-Application
)	O
.	O
</s>
<s>
Those	O
simple	O
parsers	B-Language
wo	O
n't	O
work	O
when	O
there	O
is	O
n't	O
enough	O
memory	O
to	O
store	O
the	O
entire	O
input	O
file	O
or	O
the	O
entire	O
output	O
file	O
.	O
</s>
<s>
Some	O
alternative	O
API	O
approaches	O
for	O
parsing	B-Language
such	O
data	O
:	O
</s>
<s>
incremental	O
parsers	B-Language
(	O
such	O
as	O
incremental	O
chart	B-Application
parsers	I-Application
)	O
that	O
,	O
as	O
the	O
text	O
of	O
the	O
file	O
is	O
edited	O
by	O
a	O
user	O
,	O
does	O
not	O
need	O
to	O
completely	O
re-parse	O
the	O
entire	O
file	O
.	O
</s>
<s>
Lookahead	O
is	O
especially	O
relevant	O
to	O
LL	B-Language
,	O
LR	B-Application
,	O
and	O
LALR	B-Application
parsers	I-Application
,	O
where	O
it	O
is	O
often	O
explicitly	O
indicated	O
by	O
affixing	O
the	O
lookahead	O
to	O
the	O
algorithm	O
name	O
in	O
parentheses	O
,	O
such	O
as	O
LALR(1 )	O
.	O
</s>
<s>
Most	O
programming	O
languages	O
,	O
the	O
primary	O
target	O
of	O
parsers	B-Language
,	O
are	O
carefully	O
defined	O
in	O
such	O
a	O
way	O
that	O
a	O
parser	O
with	O
limited	O
lookahead	O
,	O
typically	O
one	O
,	O
can	O
parse	B-Language
them	O
,	O
because	O
parsers	B-Language
with	O
limited	O
lookahead	O
are	O
often	O
more	O
efficient	O
.	O
</s>
<s>
One	O
important	O
change	O
to	O
this	O
trend	O
came	O
in	O
1990	O
when	O
Terence	O
Parr	O
created	O
ANTLR	B-Application
for	O
his	O
Ph.D.	O
thesis	O
,	O
a	O
parser	B-Language
generator	I-Language
for	O
efficient	O
LL(k )	O
parsers	B-Language
,	O
where	O
k	O
is	O
any	O
fixed	O
value	O
.	O
</s>
<s>
LR	B-Application
parsers	I-Application
typically	O
have	O
only	O
a	O
few	O
actions	O
after	O
seeing	O
each	O
token	O
.	O
</s>
<s>
For	O
example	O
,	O
parsing	B-Language
the	O
if	O
statement	O
in	O
the	O
case	O
of	O
an	O
else	O
clause	O
.	O
</s>
<s>
A	O
C	B-Language
language	I-Language
non-lookahead	O
parser	O
will	O
have	O
around	O
10,000	O
states	O
.	O
</s>
<s>
Set	O
of	O
expression	O
parsing	B-Language
rules	O
(	O
called	O
grammar	O
)	O
is	O
as	O
follows	O
,	O
Rule1	O
:	O
E	O
→	O
E	O
+	O
E	O
Expression	O
is	O
the	O
sum	O
of	O
two	O
expressions	O
.	O
</s>
<s>
Note	O
that	O
Rule4	O
above	O
is	O
a	O
semantic	B-Application
rule	O
.	O
</s>
<s>
It	O
is	O
possible	O
to	O
rewrite	O
the	O
grammar	O
to	O
incorporate	O
this	O
into	O
the	O
syntax	B-Application
.	O
</s>
<s>
However	O
,	O
not	O
all	O
such	O
rules	O
can	O
be	O
translated	O
into	O
syntax	B-Application
.	O
</s>
<s>
The	O
parse	B-Language
tree	O
and	O
resulting	O
code	O
from	O
it	O
is	O
not	O
correct	O
according	O
to	O
language	O
semantics	B-Application
.	O
</s>
<s>
To	O
correctly	O
parse	B-Language
without	O
lookahead	O
,	O
there	O
are	O
three	O
solutions	O
:	O
</s>
<s>
The	O
similar	O
method	O
is	O
followed	O
in	O
LL	B-Language
parsers	I-Language
.	O
</s>
<s>
This	O
method	O
is	O
used	O
in	O
LR	B-Application
parsers	I-Application
.	O
</s>
<s>
This	O
correctly	O
parses	B-Language
the	O
expression	O
but	O
with	O
many	O
more	O
states	O
and	O
increased	O
stack	O
depth	O
.	O
</s>
<s>
The	O
parse	B-Language
tree	O
generated	O
is	O
correct	O
and	O
simply	O
than	O
non-lookahead	O
parsers	B-Language
.	O
</s>
<s>
This	O
is	O
the	O
strategy	O
followed	O
in	O
LALR	B-Application
parsers	I-Application
.	O
</s>
