|
Project Information
|
Micker is a very small interpreter written in C++ that accepts TCL-like input. FeaturesSome things are missing, e.g. variable references, but they are emulated as nullary function calls. So while in TCL you would write set foo 42 puts $foo in micker, you only call foo: set foo 42 puts [foo] This means there is only one namespace, namely for commands. Another difference is that if a function call results in a list, which is spliced into some execution context, it will appear as several words, not a word with spaces. If you want it the latter way, you have to put double quotes around the call: set bar "foo 42" set [bar] puts [foo] puts "[bar]" The parser is very simple. It only has two modes, in-string and out-string. A double-quote enters the in-string mode, but when an opening bracket is encountered we enter out-string mode again. This way there is no ugly escaping all the time. Escapes (\) are only needed to hinder the parser changing modes. The {...} construct suppresses certain mode transitions, but deals with escapes. Some examples: puts "a double quote: \"" puts "amount [total] contains [expr [total] * .2] VAT" puts "the words used to be [list "one" [word-two] and "three"]" [Note that the third line is colored incorrectly!] Another in-string mode is called script. In a script no embedded commands get evaluated: puts {a script-like string with unevaluated [command]}I Wish Micker Had That...To keep the implementation straightforward, many things you take for granted in TCL are not present in micker:
This means, there are a lot of problems you can run into, and keep in mind that "set" is a very dangerous command, as it can redefine built-in commands easily where you possibly only mean to initialize a local variable. FutureMicker shall be extended with new features as the need arises, given time. PresentMost of the ideas above are actually implemented. But expect bugs. |