parrotcode: This is the readme file for PIRC, a PIR Compiler written in C. | |
Contents | Compilers |
README.pod - This is the readme file for PIRC, a PIR Compiler written in C.
This is the readme file for PIRC, a PIR Compiler written in C.
This is an attempt to implement Parrot Intermediate Representation (PIR) using a top-down approach. This is still in its early phases, and only the parser is being worked on.
As the current implementation of PIR (IMCC) is a bit messy, this is an attempt to write a clean implementation to see what constructs should be allowed, and which should be forbidden. It's also a nice experiment to see whether a top-down parser has any advantages over a YACC implementation. (For instance, it's much smaller).
This implementation is as complete as I can currently oversee. Of course, things will be fixed as I encounter them.
More importantly, ops cannot be parsed yet, because the distinction between an op and a plain identifiers can only be decided during runtime. This is because Parrot allows for runtime loading of op-libraries. Currently, I hardcoded the "print" op, so you can compile:
.sub main :main
print "Hello World"
.end
On the other hand, most of the "sugar" that PIR adds to Parrot assembly syntax has been implemented, and can be parsed successfully.
For more documentation, please run:
make docs
This will generate the documentation in HTML format. The documentation of pirparser.c contains the grammar that is accepted by PIRC. The documentation of pirlexer.c contains the lexical specifiction as accepted by PIRC. See the doc
directory for documentation, or run perldoc
on the source files.
Some highlights of PIRC:
.sub main
foo(<<'A, <<'B', <<'C', 10, "hello", <<'D')
This is arugment A
A
This is argument B
B
This is argument C
C
This is argument D
D
.end
Unlike IMCC, this is accepted by PIRC.
doc/design.pod
for details..include
directives.print
and null
, as null
is a PIR keyword (used in the if
and unless
statements).Comments, improvements etc. are most welcome and may be sent to the author.
Run make docs
and see the generated files in the doc
directory.
klaas-Jan stol <parrotcode at gmail dot com>
|