parrotcode: Untitled | |
Contents | Language Implementations | TCL |
This was originally written as a perl5 script. Rather than doing bootstrapping, I foolishly decided it would be fun to write the parser IN parrot assembly, esp. as this would help implementing "eval" and "proc" (Of course, in retrospect, I really wish I had kept with the bootstrapping effort, as I think it would have generated usable results sooner. Ah well, I now know more than I want to about PIR.
This is a from-scratch implementation, based primarily on the tcl man page(s), and the cvs-current test suite for tcl.
Another interesting project would have been to modify the tcl source and have it generate parrot directly. Many people smarter than I am have declared this hard, so I'm rather happy I'm working on it this way. (Apparently Tcl's bytecode engine is very optimized for Tcl (big surprise). So, converting the tcl-specific bytecodes there to parrot would be a big deal.)
When you make tcl, you're generating several files:
compile
opcode.tcl.pl
to generate lib/tcllib.imc
,
using tcl.imc_template
as a template.
The file is basically passed through unchanged,
except for a few ${ }
-style substitutions.
INCLUDES
make sure all the required .imc
files are included properly.
It adds a HEADER
,
and removes any XXX
comments.tclsh
- It takes the command line arguments (currently,
the name of the file you wish to parse),
and reads in the file,
and uses the tcl library to parse those contents as tcl.The classes are not user-visible,
but are internal helper classes designed to simplify the parser/interpreter.
They are written in PIR and are in lib
.
All the helper classes provide an interpret
method,
which can be called to calculate its value.
For TclConst
,
this is a very straightforward return,
while for TclCommandList
does dynamic lookup on the various commands,
executing each in turn,
returning the value of the last command.
puts ab$c
The Tcl PMCs (Parrot Magic Cookies) are the user visible data types. These live in the *.pmc
files in classes/
. They are compiled into a dynamically loadable library. Most of the functionality associated with these pmcs is derived from the base parrot classes.
.0
.[list]
values. Overrides the default stringification provided by parrot Arrays.[array]
values.To run the test suite, make test
. If you want to also get output from the TODO tests, make devtest
instead. This is NOT the tcl test suite. No failures are expected.
To run the tcl test suite, type "make tcl-test". This will checkout the latest cvs copy of the tests from the tcl repository and run them. Warning:
killall parrot
several times during the run.There are examples in the examples
directory that are vaguely more interesting. To run one of the foo.tcl
files in that directory, type make foo
.
|