Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Allison (3003)

  (email not shown publicly)

Human (I think).

Journal of Allison (3003)

Friday December 02, 2005
12:34 AM

Punie: AST to OST to PIR

[ #27827 ]

This week I worked on the tree grammar to transform Punie's abstract syntax tree (PAST) to an opcode syntax tree (POST). That went along pretty quickly, even with a little time wasted down an odd rabbit hole or two. The current set of POST nodes are minimal because I'm still only trying to compile "print 1;". They'll grow and change as I expand the compiler.

Since I had a little time left over, I went ahead and started working on the next step: converting POST into something executable. For now, PIR output is good enough. I just need to close the final gap so I can run tests on Perl 1 code. So, I threw together a little mock-up to fill the gap. It's a TGE tree grammar, but instead of transforming one tree to another tree, it transforms a tree to a string of source code. It's kind of like a PGE grammar in reverse.

That also went pretty fast and I still had a little time left over, so I went ahead with the last step, which is compiling and excuting the PIR code. That part only takes a few lines of code.

So, I swapped punie2.pir in as the main punie.pir, ran the language tests and they passed. Yay!

Next week I'll expand Punie so it does more than just print a single digit.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Sounds good. So tonight, or this weekend, I can teach 'Parrot bc' to execute via bc -> PAST -> POST -> PIR -> PBC. The 'bc -> PAST' step would be a Python parser, lexer and tree parser generated from an ANTLR grammmar.
    /* */