Okay, I've finished version 0.02 of babyperl.  In addition to constants,
variables, operators, and functions, it now understands comments (in a
rudimentary way--watch out if a constant string contains #), if,
if/else, unless, unless/else, while, and do/while.  I relented and put
in _ for concat.  It also understands parenthesis-less function calls.
It has new and improved error messages, and a -v command with version
information.  It also has improved internals, with a much more flexible
function table.

As before, it takes the name of the file you want to compile as its
input parameter and spits out assembly on STDOUT.  All error messages
leave via STDERR; the debugging messages from babyperl 0.01 are now
turned off and can be reactivated by changing the 'use constant' line in
the source.

Most parser errors are of the form "Error (L###C###): <message>".  The
first series of numbers is the line number, while the second series of
numbers is the (approximate) column number.  For example, if you
commented out the curly brace on line 20 of the test file, you would get
the following message:

        Error (L20C1): An if or unless statement was started, but was
incomplete

Followed by the catch-all:

        Cannot continue after parsing errors

I've pasted a program below that shows much of what it can handle.
babyperl.pl is attached to this e-mail.  It's over 600 lines, and very
messy.  I will likely rewrite the whole thing Real Soon Now to make it
cleaner and more powerful.

--Brent Dax
[EMAIL PROTECTED]
Configure pumpking for Perl 6

They *will* pay for what they've done.




our int($one);
our int($two);

$one=1;
$two=2;
#This is a comment.

if($one) {
        unless($two) {
                print("The universe is"_"sane!\n");
        }
        else {
                print "The universe isn't sane!\n";
        }
}
else {
        print("The universe isn't sane!\n");
}

if($one) {
        print("The universe is still sane!\n");
        unless($two) {
                print("No it isn't!\n");
        }
}

our int($i);
$i=10;

while($i) {
        print("Looping...\n");
        $i=$i-1;
}

$i=10;

do {
        print("Looping again...\n");
        $i=$i-1;
} while($i);

Attachment: babyperl.pl
Description: Binary data

Reply via email to