[NEM] ''2014-12-12'': SiCL is the "Simple" Command Language (or Silly depending on your point of view). It is a highly experimental pre-processor that translates a language that is a bit like [Tcl] with a more conventional syntax into equivalent Tcl scripts. ''Update'': Version 0.3 fixes a couple of bugs and adds support for lambda expressions. A SiCL script is a sequence of commands separated by newlines or semicolons (as in Tcl). A command is a sequence of words (not necessarily separated by whitespace). A word is one of: * A string: `foo`, `12`, `3.145`, `"foo bar"`, `{foo bar}` * A variable reference: `$foo`, `${foo}` (Note: no arrays) * A sub-command: `[[foo bar]]` * An expression enclosed in parentheses: `(foo)` * A block of SiCL commands starting with a colon and ending either with a newline, or (if a newline immediately follows the colon) a sequence of three or more dashes (---). A SiCL expression is one of: * A string (as above) - this evaluates to itself * A mathematical expression - compiles to `[[expr {...}]]` * A list of expressions separated by commas: e.g., `(x, y, sin(0.5)*2)` --> `[[list x y [[expr {sin(0.5)*2}]]]]` * A dictionary of expressions separated by commas, where key/value pairs are separated by colons: `(x: 1, y: 2)` --> `[[dict create x 1 y 2]]` * A lambda expression of the form: `args -> body` --> `[[list ::apply $args $body [[namespace current]]]]` Examples: ====== # Avoid problems with double-substitution: proc when(cond, then, (_else: "else"), (else: "")): if {$cond} $then else $else for {set x 0} {$x < 10} {incr x}: when ($x < 5): puts "Small" when ($x > 5): puts "Big" --- when ($x == 5): puts "Just right" --- --- # Functional programming proc map(f, xs): lmap x $xs: uplevel 1 [linsert $f end $x] map (x -> $x*2) {1 2 3 4 5} ====== Here is the code. This is very experimental. It may break your programs and/or your mind. Source code is now available from: http://chiselapp.com/user/nem/repository/sicl/home as a [fossil] repository to ease further development. <>Language