<s>
The	O
Parser	B-Language
Grammar	I-Language
Engine	I-Language
(	O
PGE	B-Language
,	O
originally	O
the	O
Parrot	B-Language
Grammar	I-Language
Engine	I-Language
)	O
is	O
a	O
compiler	B-Language
and	O
runtime	B-Library
for	O
Raku	B-Language
rules	I-Language
for	O
the	O
Parrot	B-Language
virtual	I-Language
machine	I-Language
.	O
</s>
<s>
PGE	B-Language
uses	O
these	O
rules	O
to	O
convert	O
a	O
parsing	O
expression	O
grammar	O
into	O
Parrot	B-Language
bytecode	O
.	O
</s>
<s>
It	O
is	O
therefore	O
compiling	B-Language
rules	O
into	O
a	O
program	O
,	O
unlike	O
most	O
virtual	O
machines	O
and	O
runtimes	B-Library
,	O
which	O
store	O
regular	B-Language
expressions	I-Language
in	O
a	O
secondary	O
internal	O
format	O
that	O
is	O
then	O
interpreted	O
at	B-Library
runtime	I-Library
by	O
a	O
regular	B-Language
expression	I-Language
engine	O
.	O
</s>
<s>
The	O
rules	O
format	O
used	O
by	O
PGE	B-Language
can	O
express	O
any	O
regular	B-Language
expression	I-Language
and	O
most	O
formal	O
grammars	O
,	O
and	O
as	O
such	O
it	O
forms	O
the	O
first	O
link	O
in	O
the	O
compiler	B-Language
chain	O
for	O
all	O
of	O
Parrot	B-Language
's	O
front-end	O
languages	O
.	O
</s>
<s>
When	O
executed	O
,	O
the	O
bytecode	O
generated	O
by	O
PGE	B-Language
will	O
parse	O
text	O
as	O
described	O
in	O
the	O
input	O
rules	O
,	O
generating	O
a	O
parse	O
tree	O
.	O
</s>
<s>
The	O
parse	O
tree	O
can	O
be	O
manipulated	O
directly	O
,	O
or	O
fed	O
into	O
the	O
next	O
stage	O
of	O
the	O
Parrot	B-Language
compiler	B-Language
toolchain	O
in	O
order	O
to	O
generate	O
an	O
AST	B-Data_Structure
from	O
which	O
code	O
generation	O
can	O
occur	O
(	O
if	O
the	O
grammar	O
describes	O
a	O
programming	O
language	O
)	O
.	O
</s>
<s>
Originally	O
named	O
P6GE	O
and	O
written	O
in	O
C	O
,	O
PGE	B-Language
was	O
translated	O
to	O
native	O
Parrot	B-Language
and	O
renamed	O
not	O
long	O
after	O
its	O
initial	O
release	O
in	O
November	O
2004	O
.	O
</s>
<s>
PGE	B-Language
was	O
written	O
in	O
order	O
to	O
reduce	O
the	O
amount	O
of	O
work	O
required	O
to	O
implement	O
a	O
compiler	B-Language
on	O
top	O
of	O
Parrot	B-Language
.	O
</s>
<s>
It	O
was	O
also	O
written	O
to	O
allow	O
Perl	O
6	O
to	O
easily	O
self-host	O
,	O
though	O
current	O
Pugs	B-Language
development	O
no	O
longer	O
uses	O
PGE	B-Language
as	O
its	O
primary	O
rules	O
back-end	O
in	O
favor	O
of	O
a	O
native	O
engine	O
called	O
PCR	O
.	O
</s>
<s>
PGE	B-Language
combines	O
three	O
styles	O
of	O
parsing	O
:	O
</s>
<s>
The	O
primary	O
form	O
is	O
Raku	B-Language
rules	I-Language
,	O
so	O
a	O
PGE	B-Language
rule	O
might	O
look	O
like	O
this	O
for	O
an	O
addition-only	O
grammar	O
:	O
</s>
<s>
The	O
operator	B-Application
precedence	I-Application
parser	I-Application
allows	O
an	O
operator	O
table	O
to	O
be	O
built	O
and	O
used	O
directly	O
in	O
a	O
Perl	O
6	O
rule	O
style	O
parser	O
like	O
so	O
:	O
</s>
<s>
This	O
accomplishes	O
the	O
same	O
goal	O
of	O
defining	O
a	O
simple	O
,	O
addition-only	O
grammar	O
,	O
but	O
does	O
so	O
using	O
a	O
combination	O
of	O
a	O
Raku	O
style	O
regex/rules	O
for	O
term	O
and	O
number	O
and	O
a	O
shift-reduce	O
optable	O
for	O
everything	O
else	O
.	O
</s>
<s>
Though	O
PGE	B-Language
outputs	O
code	O
which	O
will	O
parse	O
the	O
grammar	O
described	O
by	O
a	O
rule	O
,	O
and	O
can	O
be	O
used	O
at	O
run	B-Library
time	I-Library
to	O
handle	O
simple	O
grammars	O
and	O
regular	B-Language
expressions	I-Language
found	O
in	O
code	O
,	O
its	O
primary	O
purpose	O
is	O
for	O
the	O
parsing	O
of	O
high	B-Language
level	I-Language
languages	I-Language
.	O
</s>
<s>
The	O
Parrot	B-Language
compiler	B-Language
toolchain	O
is	O
broken	O
into	O
several	O
parts	O
,	O
of	O
which	O
PGE	B-Language
is	O
the	O
first	O
.	O
</s>
<s>
PGE	B-Language
converts	O
source	O
code	O
to	O
parse	O
trees	O
.	O
</s>
<s>
The	O
Tree	O
Grammar	O
Engine	O
(	O
TGE	O
)	O
then	O
converts	O
these	O
into	O
Parrot	B-Language
Abstract	B-Data_Structure
Syntax	I-Data_Structure
Trees	I-Data_Structure
(	O
PAST	O
)	O
.	O
</s>
<s>
A	O
second	O
TGE	O
pass	O
then	O
converts	O
a	O
PAST	O
into	O
Parrot	B-Language
Opcode	O
Syntax	O
Trees	O
(	O
POST	O
)	O
which	O
can	O
be	O
directly	O
transformed	O
into	O
executable	O
bytecode	O
.	O
</s>
