ScrapShell was an experiment to see if it was possible to create an interpreted Programming language in ReCT.
Turns out it very much is possible (even if my example language is pretty simplistic)
ScrapShell is now a compiled language! I swapped out the Interpreter with an Emitter and now it compiles down to IL. (requires ilasm to be installed)
The code for the interpreter is still part of the project so if you like the Interpreted mode more you can use that one instead.
Just letting you peeps know that to work around ReCTs limitations i had to do quite some badness. So uh please dont be too hard on me.
Because ReCT currently doesnt accept Commandline args the path to the source file is hard coded, meaning youll have to change it. At the beginning of the main.rct file there are 2 variables you can change.
set verbose <- false;
set file <- "./Resources/simpletest.scs";
ScrapShell currently onyl supports Strings and Ints. The lang itself is weakly typed.
print and write do pretty much the same thing, only that print also starts a new line.
write "hello "
print "world"
You can get User input by using the input command. On its own it can be used to pause the Program, but it becomes much more useful in combination with the [] expression (more on that later).
input
On the topic of pausing, you can sleep for a given amount of Milliseconds by using the sleep command.
sleep 1000
To clear the Console just use the clear command.
clear
If you want to give your Text some Color you can use the color command. It uses the same Color Codes as ReCT
color 10
color 12
color 15
To set a variable you can simply use the set command. For using a variable just use the $ prefix followed by the name.
set someVar = "test"
print $someVar
To use goto you will first have to declare labels to jump to. You can declare labels by using the : prefix.
:loop
print "infinite loop"
goto loop
To do if statements you can use the if command followed by a label. There is no else because if the condition is false it will just keep executing downwards anyways so i felt like its not needed.
:loop
set variable = 1
if $variable = 1 :loop
Supported operators are = != < > <= >=
[] Expressions are probably one of the most important parts of ScrapShell. They allow you to feed the result of one command into another one.
print [input]
set someVar = [input]
To do Add, Subtract, Multiply, Divide or Concat you would use the add, sub, mul, div, con commands. These too can be used in [] Expressions
set var = [add 1 1]
set var = [sub $var 2]
set var = [mul $var 5]
set var = [div $var 2]
print [con "Var is: " $var]
Note that [] Expressions can be nested.
set var = [add [mul 5 3] 5]
To make a comment just use the # or ; prefix.
# this is a comment
; this too is a comment
To completely Halt the program you can use the die command.
die