andrew cooke writes:
Also, am I right in thinking that I can use whatever language I want for
generating the IR?
Sure. languages/BASIC used perl, as did tcl some time back. Most are
generating PIR with PIR these days, though. (ISTR plumhead is generating
PIR multiple ways)
I will check the languages directory, but this confuses me - do people
write parsers in PIR?
... I wasn't entirely accurate here.
Many languages (APL, punie, abc, tcl) use PGE's perl6-like grammars to
define their parser. I've worked on tcl, so I'll use that as an example. ABC
is probably better for actually starting out.
http://svn.perl.org/parrot/trunk/languages/tcl/src/grammar/expr/expression.p
g
This is the grammar for tcl, written in a subset of perl6.
http://svn.perl.org/parrot/trunk/languages/tcl/src/grammar/expr/pge2past.tg
This is a TGE grammar which, given the input and the PGE grammar, generates
an AST. The code inside the transforms here is (must be, at the moment) PIR.
http://svn.perl.org/parrot/trunk/languages/tcl/src/grammar/expr/past2pir.tg
This takes the AST and transforms it to PIR. (again, the transforms here are
written in PIR)
This PIR is then compiled with the PIR compiler available from inside
parrot, which generates an executable chunk of bytecode.
FYI, when tcl is built, all the PGE and TGE grammars are themselves compiled
to PIR, then bytecode.
This is just a high level overview. I'll try to get this (and any followup
questions) incorporated into docs/compiler_faq.pod
Regards.