OVERVIEW ^

This is a from-scratch implementation, based primarily on the Tcl man page(s), and the cvs-current test suite for Tcl (8.5.1)

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.)

RUNNING TCL ^

Generated Files ^

When you make Tcl, you're generating several files:

tclsh

While not included in the make all target, you can make tclsh (or whatever the executable would be called on your platform), and this will give you a faux-executable; a C binary that loads in all the Parrot bytecode for partcl. You can then use this in most places where you see parrot tcl.pbc

runtime/tcllib.pbc

This file is used to load all the various commands, ops, etc. into the appropriate namespaces, as well as declare and register the TCL compiler for the compile opcode.

This file is actually built in several steps. First, all the templated commands (src/builtin/*.tmt) are converted to PIR. Next, runtime/builtins.pir is generated from all the pir files in src/builtin/ and runtime/builtin. This file is then included by tcllib.pir and compiled to tcllib.pbc.

tcl.pbc

This is roughly equivalent to 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. You can also specify command line options to be used with this bytecode file.

src/grammar/expr/pge2past.pir

src/grammar/expr/past2pir.pir

src/grammar/expr/expression.pir

This PIR files are generated from their corresponding .tg and .pg files. These grammar files allow us to use PGE's implementation of perl6 rules to more simply specify our parsing rules. We use these rules to handle both the general parsing for Tcl itself, as well as the sub-"language" used by expressions in [expr] and elsewhere.

PMCS ^

The Tcl PMCs (Parrot Magic Cookies) are the user visible data types. These live in the *.pmc files in src/pmc/. They are compiled into a dynamically loadable library which is loaded with the .HLL directive (HLL stands for High Level Language). Most of the functionality associated with these PMCS is derived from the base Parrot classes, except as noted below.

TclString

Scalar string, with an override for the boolean truth values.

TclInt

Scalar integer, with an override for various math. (For example, Parrot Integers automatically promote to float division, while Tcl does not.)

TclFloat

Scalar float, with an override of the stringification: Tcl floats are somewhat unusual compared to other Parrot HLLs in that integer-valued floats stringify with a trailing .0.

TclList

Ordered container, corresponding to values generated by the [list] builtin. Overrides the default stringification provided by Parrot Arrays.

TclArray

Hash like container, corresponding to values created with the [array] builtin.

TclDict

Hash like container, corresponding to values created with the [dict] builtin. Unlike arrays, dictionaries can nest, having dictionaries as values; Also, dictionaries act more like TclLists in terms of their conversion to string and back.

TclObject

A virtual type, which is used to provide some shimmer (aka morph) methods common to all the scalar value types.

TESTS ^

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. Occasional failures are suspected against svn-head; there should be no failures in a released version, however.

To run the Tcl test suite, type make tcl-test. This will checkout the appropriate CVS copy of the tests from the Tcl repository and run them. Warning, this will be slow.

EXAMPLES ^

There are examples in the examples directory that are vaguely more interesting. Change to that directory and type make for directions.


parrot