A tiny (and trivial) "Lisp" to Tinderbox compiler in Python

Hi, there.
I wrote a piece of code for compiling a (tiny) subset of Lisp language to Tinderbox action code, which allows me to write Tinderbox action code in Lispy style.
The motivation is that, firstly, I am a Lisper and I love the s-exp syntax, second and more importantly, I hate some part of Tinderbox syntax, for example, too many $ (dollars), no syntax highlighting and lacking “else if”.
We can solve or bypass those problems by writing an external “compiler”.
In Tinderbox code, dollars are assigned before attributes to get their value, for example, $Text, while constants and variables need not, like “hello, world”(stings) and foovar(variables declared by var foovar(“hello”)).
The Lisp compiler does this automatically for you.
To demonstrate, I’ll show an example here. The lispy code:

(let ((myZ (+ "this is note " Name Text))
      (myX (* 1 2 3 (+ 3 4 5)))
      (myY (. "XX;YY;ZZ" (at 2)))) 
  (set! MyDate (max (list MyDateA, MyDateB)))
  (set! MyDate (. links outbound attended ($ MyDate)))
  (if (> ChildCount 5)
      (begin
       (set! Color "red")
       (set! Width 3.5))
    (set! Color "blue"))
  (cond ((eq Color "red") 
         (set! Color2 "blue"))
        ((eq Color "blue")
         (set! Color2 "red"))
        (else
         (begin
          (set! Color2 "green")
          (set! Text "You are lucky!")))))

compiles to: (I manually indented the code.)

var myZ("this is note "+$Name+$Text);
var myX(1*2*3*3+4+5);
var myY("XX;YY;ZZ".at(2));
$MyDate=max(list($MyDateA,,$MyDateB));$MyDate=$links.outbound.attended.$MyDate;
if(!$Text.contains("like")){
    $Color="red";$Width=3.5
} else {
    $Color="blue"
};
if($Color=="red")
{
    $Color2="blue"
} else {
    if($Color=="blue"){
        $Color2="red"
    } else {
        $Color2="green";
        $Text="You are lucky!"
    }
}

Which seems to be legal Tinderbox action code.
If you would like to know more, about the syntax here’s the repo: https://github.com/libniwtr/LispyTB

The shortage of this “compiler” is that, it won’t report any errors or warnings for your code (except that your parenthesis mismatch). It’s just a translator that does some simple translations, and in some rare case, your generated code will not run correctly. Better check the code manually before feeding them into TB :stuck_out_tongue:

Criticisms are welcomed here!

Amazing. I love Lisp — cannot wait to try this. Thank you for the very creative contribution.

Thank you :slight_smile: I can say that the current version is too simple and may (at high potentiality) generate wrong codes. But I would gain more motivation to maintain it if many people like it.

hmm you may be motivating me to write some NLP for Tinderbox.