ticol.gif (1129 bytes) Ticol TCL Interpreter

Project Description

This is a hobby project which has been under development for some years. It originally began in 2010 with the idea of creating a simple "C" interpreter and some work was done on a "C" style macro preprocessor and stack-based RPN parser. I noticed Salvatore Sanfilippo's 500-line Picol Tcl interpreter and I decided to migrate everything to a "pocket" Tcl interpreter project, especially as it could be put to some practical use in my field of work.

In recent years I've put Ticol Tcl to use as an alternative to PowerShell which allowed me to quickly wrap scripts around my own custom built DLLs or EXE utils.  I wanted something slightly less convoluted and more reliably portable across Windows platforms than PowerShell; something I could run immediately without altering the host system and which I could customise to my own taste and which would avoid frustrations trying to do anything moderately complex using Windows batch language. I ensured that I created documentation to help others make the most of the language. The Command Line Interface (CLI) has a man file with syntax highlighting which contains over 900 pages.

Very little of the original Picol code remains. The project has grown to around 100,000 lines of C/C++ code for the basic interpreter EXE.  I decided to call it Ticol (like "tickle") as an homage to the orignal Picol project. For an interpreter it is reasonably fast but obviously no match for compiled object code. I have implemented a number of language ideas which have originally been implemented in Tcl by porting them into "C" for higher performance. I've had the opportunity to try out a lot of ideas, some of which were better than others.

Please note that Ticol Tcl is not yet feature-complete or expected to be fully stable. It has a disadvantage in that it does not support Unicode/MBCS characters. Nor does it offer regex functionality. It was written to fit a private design specification rather than a public one.  It was intended to be used on relatively trivial background system scripts and for some years it has satisfied that design requirement. If you need more power and flexibility please consider a 'standard' Tcl.

The program was developed for my own day-to-day use and amusement but I am happy to share the binaries with anyone who finds it useful. Ticol is released under the BSD licence and is a closed-source project.  Please see the licence documentation and terms of use.

See the downloads page to download


screenshot-static-source-x560.png (79031 bytes)

Features

Ticol has the following features:

{*} expansion operator Line-continuation \ character and flexible string definitions
$$ multi-level dereferencing (complex double dereferencing) loop (iterator) command
4 byte double arithmetic to 15 decimal places Macro preprocessor with conditional #define, #if #else #endif, #undef
64 bit integer math as default Macro conditional expressions using #if, #exec, #echo and #halt
after, delayed execution Macro #__LINE__ , #__DATE__ and #__TIME__ debugging options
array set Macro brace/bracket/quote parity with bug location line number for braces
array_foreach Macro preprocessor including optimisation of [expr] alias [calc]
assert Math functions for [expr] handler, separately callable via [funct]
at_exit cleanup routine MD5 commands
Autoexec unknown commands MD5 self-checking of scripts
autoexec.tcl initialisation file Messagebox
base64 encode/decode More console commands, e.g. [console], [gotoxy], [box], [textcolor]
Base conversion between decimal, hex, and octal Multi-line strings with format continuation
Basic macro preprocessor with comment removal native stacks
BEDMAS (PEDMAS, BOMDAS) evaluation in [expr] and [calc] Numerous additional functions/commands
Big math plug Octal math
Binary math Online (command line) help with keyword find
Binary structs (no instantiation) Performance graphing and timing using /G
Built-in help (console and command-line) Play WAV files
C/C++ style long comments /* ... */ Plugins to extend the interpreter
CGI compatible, works well with Apache Plugin LIB API interface for C/C++
CLI command-history (up/down cursors) Portable. Requires only ticol.exe. Everything else is optional
catch and try...catch Preconfigured environment consts
Code execution timing via catch and /G printf / puts / format
Code obfuscation/encryption binding to user/hostname/mac address or password  proc with default args
Command line args: $argc, $argv() Pseudo-namespace scoped vars x::y
Command line Interface (CLI) capable of use as a windows shell Random number commands using Mersenne-twister algorithms
Conditional breakpoint debugging with halt, single-stepping and simple watches Restricted execution. Bind to workstation, username, IP, password etc.
Configurable CLI prompt Runtime reconfiguration using [option]
Const arrays shell to O/S command
Const variables Simple HTTP data retrieval
CRC plugin Single-step debugging
CSV file input to Tcl list or array Some Variant handling for DLL interaction
Customisable console prompt Source code echo from command line (MPP parsed code)
Date and time commands using decimal/VB/C# format spawn application command
DLL lib version in progress (call from other languages) Stacks
dump loaded source file Stack trace on error
dump variable or arrays Standard expression math functions
Dynamic configuration using [option] Standard Tcl associative arrays using efficient, dynamic hash tables
Dynamic memory allocation for source code loading Static variables in procedures
elseif String comparison and handling functions
encrypt/decrypt to a base64 string using simple, symmetric encryption String splitting
Enhanced info command with networking info String wrapping
enum enumerated consts structs. Basic C-like binary structs for DLL interface marshalling usable  by Tcl
Environment variable $env() struct instantiation using another struct as a template (new)
Escape sequences (standard Tcl such as \r \n, \[ \$ etc.) subst command
exec application command Switch (multi-line and single-line)
Execution counter [info cmdcount] Syntax check at macro preprocess time. Basic checks on braces, quotes etc.
Execution locking via TCX files to user, hostname, IP address, MAC etc. Syntax highlighter in command line interface
Expression handler [expr] Tcl command-line arguments
Expression simplifier converts [expr] format to native Tcl Tcl math expressions via [expr] and in flow control with many functions
Extendable via C++ plugin API Tcl v9-compatible octal notation 0oNN
External DLL calling for __stdcall and __cdecl DLLs TCX obfuscated scripts,  embedded obfuscated soure, execution locking
File handling routines [file]. [read], [write] etc. Ternary (conditional) if (?:) within expr
Floating point handling and math Test scripts
for flow control Tested for memory leaks
foreach flow control time timer command
fraction, integral Type detection is automatic (hard and soft)
global command UAC elevation
global scope ::proc unknown/autoexec control
Global scope reference ::y uplevel
goto_block with goto and gosub upvar
Hex math (integer unary and binary) upvar arrays
INI configuration file Watch variable trace for use with debugger
inputbox WAV file playing
Introspection via various means Windows API copyfile command
json to tcl list data conversion (rudimentary) Windows input dialog with password masking
list processing, including lassign, lsearch, lindex, lsort Windows msgbox
let command with multiple argument styles Windows shell spawn and external execution with errorlevel return (exec)

Top

Advantages Disdvantages
  • Works on a wide range of Windows from NT to Win 10, ReactOS and WINE
  • Very compact, flexible, reasonably fast
  • A number of extension plugins are availalable
  • Ability to call external DLLs easily with binary structs
  • Well-documented, comprehensive manual with example code
  • Good introspection and debugging with single-step debugger and stacktrace
  • Suited to home, educational and specialist administrative IT use
  • Big math, registry, ftp and email capabilities etc.
  • File and database operations including SQLite and DBase III/IV
  • Script obfuscation, tamper-protection
  • Script execution locking via either username, hostname, MAC, IP etc.
  • Can work with Windows webservers as a CGI application
  • C++ plugin API available*
  • Built in console and Windows help
  • Command shell can be used as a Windows shell
  • Sub-language plugins (fast ASM interpreter, BF)
  • DLL version, callable from C++
  • Easy to learn once you realise it's not C++
  • Freeware
  • Windows only, no Linux version but can run under WINE
  • An interpreter, so slower than ActiveState Tcl and many other script languages
  • Does not support Unicode / non-Roman languages
  • Not a full Tcl implementation
  • There are some differences to standard Tcl
  • Some parts of the language are feature-incomplete
  • No TCP sockets or multithreading
  • Minimal static code error checking. Most checking is dynamic
  • Big math plugin is integer-only and lacks floating point
  • No true classes or objects
  • Minimal implementation binary string handling
  • No bytecode compiler
  • No regular expressions
  • SMTP TLS and HTTPS not supported
  • In many cases ActiveState Tcl, Jim or PowerShell would be better
  • The Tcl language has some peculiarities compared to others
  • Tcl is often not taken as a serious programming language
  • Closed source
  • No support is offered

Ticol Plugins

The following plugin DLLs are available. These are loadable using the [lib] command. See the manual for more information

Arbitrary precision math CRC checksums Network Letter Mapping SMTP emailer
ANSI text mode graphic display CScript (VBScript) Number to words conversion Socket ping a host
ARP and RARP commands Dbase 3/4 Database Random access database SQLite 3 plugin
Assembler Interpreter (TicASM) DHCP commands Roman to decimal conversion TCX encoding
Basic CPU information DNS lookup Scientific numbers Text as an array
Bitmap encoding Embedded TCX handling Simple FTP client Traditional Linked Lists
Brainfuck interpreter HTML code processing Simple registry services VARIANT handling
C-like arrays ICMP ping Simple RLE compression Windows Event Logging
Call an external DLL INI file handling Simple RTF text output Windows service query
CGI web interface Misc routines Simple ZIP package Word or char count

Top

Compatibility

Ticol Tcl has been tested with the aim of having it work with everything from Windows NT4.0 SP6a to Server 2016 and it has been in live daily use on Server 2012R2 and Server 2016. The language was developed under Windows 7

It is less compatible with versions of Windows prior to XP but almost all built-in features work fine. The test suite is run on Windows NT4/SP6 and Win2k.

Some of the more advanced features don't work well with ReactOS at present (e.g. ticol_ping.dll) but basic tests work ok with ReactOS v0.4.8. The screenshot here shows an earlier version of Ticol working fine on ReactOS under Oracle Virtualbox

Ticol implements around 90% of standard Tcl commands. Many Tcl scripts will run without modification. Ticol contains many additional and enhanced commands. Check the online documentation / man file for more details

reactos-zip-demo-x450.png (77762 bytes)

Top

Configuring an IDE

Notepad++ is the recommended IDE

An IDE (Integrated Developement Environment) is not the same thing as the Command line Interface (CLI). The Ticol CLI can be used to load, run and view scripts but not to edit them. You can, however, enter single line scripts from the CLI, even if these are comprised of multiple commands

This page dicusses settting up and using Notepad++ syntax highlighting and run shortcuts

npp-screenshot-x450.png (101200 bytes)
Sub Project - Pseudo-Assembler Interpreter

This was an experiment in creating a fast interpreter using ideas for a minimalist languge. Both a Tcl script and plugin DLL are included which implement a 'pseudo-assembler' interpreter. The language is quite fast. Some Tcl scripts can be impemented in the pseudo assember language and run at little more than compiled EXE speed

The  native C++ plugin (ticol_asm.dll)  runs some code faster than the parent Tcl interpreter so it might  be handy for intensive number-crunching

The ASM language specification is included and there is potential to generate a true compiler from the language spec. The language might be useful as a teaching-study aid in learning  basic assembler concepts. It may also be fun seeing what can be done with the language

A small library of "C" functions are available internally including, strlen, strstr, malloc, free etc. Externall DLLs such as MSVCRT may be linked and called and Ticol parent [eval] can be called to exploit the full range of Tcl commands

The language and specification is working but feature-incomplete and subject to change

See: help asm

ticol_asm.dll - 63Kb - (plugin - Build date 15/May/2023)

maze-asm-sourcex450.png (43014 bytes)
Sub Project - Brainfuck Interpreter

A Brainfuck interpreter script is included. This is also included as a compiled add-on plugin DLL written in native C++ and is also available as a standalone exe for performance comparison

A selection of BF script files are included including a translation of a BASIC maze program and a simple fractal program, also ported to ASM from BASIC.

The script versions is very slow as  interpreter scripts running on an interpreter. However, this offers the challenge of writing code as efficiently as possible to enhance speed and has shown the benefit of invariant code optimisation in Ticol Tcl scripts

See: help bf

brainfuck.exe v1.01 - 40Kb (standalone)

ticol_bf.dll - 39Kb - (plugin - Build date 15/May/2023)

bf-source-x450.png (45633 bytes)

Top

Testing

Security

Screenshots

More screenshots of Ticol in action are available


* API available when I get time to publish a detailed, worked example!

Back | Top

Last updated on 14 May 2023 - This page is designed for 1024 x760 and higher resolution displays