What is #Rhai Script? It's a #RustLang-like Scripting Language that we're porting to #BL602 Simulator
https://github.com/lupyuen/bl602-simulator/tree/main/bl602-script
#Rhai lets us register our #RustLang Module with the Script Engine ... So calling the #BL602 Rust Wrapper is no problemo!
https://github.com/lupyuen/bl602-simulator/blob/main/bl602-script/src/lib.rs
#Rhai Script runs OK on #BL602 WebAssembly Simulator ... But to run on Real BL602 Hardware we shall transcode to uLisp
https://lupyuen.github.io/articles/rustsim?25#appendix-rhai-scripts-on-bl602
How to Transcode #Rhai Script to #uLisp? We walk the Abstract Syntax Tree and convert every node
https://github.com/lupyuen/bl602-simulator/blob/main/bl602-script/src/lib.rs#L158-L192
#Rhai Abstract Syntax Tree will have Gnarly Nested Nodes ... Transcoding to uLisp will be an interesting challenge!
https://github.com/lupyuen/bl602-simulator/blob/main/bl602-script/src/lib.rs#L193-L284
Here's how we compile #Rhai Script to Abstract Syntax Tree ... Then walk the tree and transcode to uLisp #BL602
https://github.com/lupyuen/bl602-simulator/blob/transcode/bl602-script/src/transcode.rs
How we transcode #Rhai Statements and Expressions to uLisp for #BL602
https://github.com/lupyuen/bl602-simulator/blob/transcode/bl602-script/src/transcode.rs#L54-L105
Transcoding #Rhai Function Calls to uLisp #BL602 ... Needs more work because of the "StackSlot" parameters 🤔
https://github.com/lupyuen/bl602-simulator/blob/transcode/bl602-script/src/transcode.rs#L107-L141
OK transcoding a #Rhai StackSlot to uLisp #BL602 wasn't so hard!
https://github.com/lupyuen/bl602-simulator/blob/transcode/bl602-script/src/transcode.rs#L110-L156
Our #Rhai Script to uLisp #BL602 Transcoder ... So far so good!
https://github.com/lupyuen/bl602-simulator/blob/transcode/bl602-script/src/transcode.rs#L158-L370
#Rhai Loops are now transcoded to uLisp #BL602 yay!
https://github.com/lupyuen/bl602-simulator/blob/transcode/bl602-script/src/transcode.rs#L279-L443
Let's add a #RustLang Module to manage the Nested uLisp Scopes for #BL602 ... Like "let*" and "dotimes"
https://github.com/lupyuen/bl602-simulator/blob/transcode/bl602-script/src/scope.rs
Now #Rhai Script is transcoded to uLisp #BL602 with the proper scopes
https://github.com/lupyuen/bl602-simulator/blob/transcode/bl602-script/src/transcode.rs#L393-L622
Our #Rhai Script transcoded into uLisp #BL602 runs correctly! 🎉
https://github.com/lupyuen/bl602-simulator/blob/transcode/bl602-script/src/transcode.rs#L393-L622
Here's how we add the #Rhai Scripting Engine to our BL602 Simulator in #RustLang
https://lupyuen.github.io/articles/rhai?5#add-rhai-scripting-to-simulator
Converting #Rhai Script to uLisp ... In #BL602 WebAssembly Simulator
https://lupyuen.github.io/articles/rhai?8#convert-rhai-to-ulisp
What's an Abstract Syntax Tree? Why is it perfect for converting #Rhai Script to #uLisp?
https://lupyuen.github.io/articles/rhai?9#abstract-syntax-tree
Rewriting "let" and "for" statements ... From #Rhai Script to #uLisp
https://lupyuen.github.io/articles/rhai?11#transcode-statement
Extending #uLisp with our own #BL602 C Functions
https://lupyuen.github.io/articles/rhai?17#appendix-add-c-functions-to-ulisp
Drag-n-Drop #Rhai Scripts for BL602 with #Blockly
https://lupyuen.github.io/articles/rhai?18#drag-and-drop-rhai-scripting
How we customised #Blockly for #Rhai Script and BL602
https://lupyuen.github.io/articles/rhai?19#appendix-customise-blockly-for-rhai
Running the Transcoded #uLisp on #BL602
https://lupyuen.github.io/articles/rhai?16#run-the-transcoded-ulisp