For your weekend entertainment, here's a bit of parrot assembler for the
adventurous to play with. To get the code, just head to:
http://geeksalad.org/basic and download the latest tar bundle you
find. The README.basic file included in the tar bundle is listed after this.
[Small amount of begging: someone please, please, please fix the I/O in
Parrot! :)]
DESCRIPTION
-----------
This is the initial (.01?) release of a BASIC interpreter written
entirely in Parrot bytecode. The NOTES below are intended for Parrot
developers.
This BASIC is of the fairly old school. Line numbers are required, and
the following keywords are recognized:
LIST
LIST expr-expr
RUN
PRINT
PRINT expr
PRINT expr; [supress newline]
DIM stringvar(expr)
LET var=expr
FOR var=expr TO expr
FOR var=expr TO expr STEP expr
GOSUB expr
RETURN
GOTO expr
GO TO expr [syn with GOTO]
IF expr conditional expr THEN STATEMENT
END
REM
QUIT [exits interpreter]
* String variables are noted with a trailing $ (as in A$)
* Variable names are \w characters up to 8 in length (compile directive)
* GOSUB/FOR-NEXT may be nested to arbitrary depths.
* Line numbers are positive integers, up to 8-digits in length
* Expressions are evaluated left-to-right with no thought given
to precedence. They can be string literals or numeric with a
mixture of operators (*+-/) and values.
* Conditionals are >, <, =, or ! (not equal)
* Everything is case-sensitive
* Extra things on the end of a line are often ignored.
This was intended as a true interactive BASIC (see NOTES below) so that
any of the variables and statements work from the prompt as well as in the
body of the stored program. Entering in a new line number overwrites the line
in the existing program
Included in this distribution are the following files, some of which may be
of general interest, some only apply to BASIC:
alpha.pasm Alpha/Numeric library
dumpstack.pasm Diagnostic stack dumping
expressions.pasm Expression evaluator
stackops.pasm Stack operations
tokenize.pasm A simple string tokenizer
basic.pasm The instruction dispatcher
basicvar.pasm Storage/Retrieval of BASIC strings, numbers, code
instructions.pasm BASIC instructions
test.bas Small BASIC example
basic.pl Perl Harness for compiling, starting BASIC in
non-interactive
mode (see NOTES). A small sample set of commands is
embedded
in the file.
basic_io.pl Harness for compiling, starting BASIC in interactive
mode (see NOTES). Not quite finished.
The interactive mode isn't complete, and INPUT still needs to be implemented
(see NOTES). Otherwise this should be fairly functional.
NOTES
-----
Parrot's I/O is really broken now. With all of the registers, stacks, and
code involved
here doing any kind of I/O breaks BASIC very quickly. As a self-contained
program it's
fairly robust.
There's no INPUT statement (yet) and the interactive BASIC doesn't
work. I'd really
like both of these to work. It doesn't feel like BASIC without a friendly
"Ok>" or
"Ready" prompt. :)
Included with the distribution is basic_io.pl which attempts to read
instructions from
STDIN (fd 0). If you can get this to work *consistently* with larger
BASIC programs
(i.e. lots and lots of I/O) let me know, I'd really appreciate it. Try:
basic_io.pl < test.bas
For a taste of SEGV.
CONTACT
-------
Clinton Pierce <[EMAIL PROTECTED]>
"clintp" irc.rhizomatic.net #perl or #parrot
LICENSE
-------
Redistributable under the terms of any current version of Perl