Saturn is a lightweight cpp interpreter :D
It supports variables, math, printing, conditionals, loops, and strings!!!
- Compile the interpreter (once!):
g++ saturn.cpp -o saturn- Run a
.satscript:
./saturn hello.sat- The
saturnexecutable is the interpreter that runs.satfiles - You can run scripts from anywhere once the interpreter is compiled.
let x = 67
let name = "sixseven"
- No explicit types: numbers and strings are inferred
- Stored internally in a key-value map
print "Hello world"
print x
- Strings must be in quotes (
"...") - Variables print their stored value
Supported operators: + - * /
let a = 10
let b = 5
let sum = a + b
let diff = a - b
let prod = a * b
let div = a / b
print sum
print diff
print prod
print div
if x > 5
print "x is MASSIVE"
end
- Comparisons:
> < >= <= == != - Blocks have to end with
end
for i = 1 to 5
print i
end
- Loop variable increments automatically
- Loop ends when the variable exceeds the end value
# Cement
let score = 100
- Lines starting with
#are ignored by the interpreter
let greeting = "Hello Saturn"
print greeting
- Strings always use double quotes
"...".
let grade = "A"
print "Grade: {grade}"
- Similar to python's fstring
input namme "Enter name: "
input age
- Input Variable "prompt text"
- Prompt text is optional
random number 5
random number 1 10
- Random (variable) (max)
- Random (variable) (min) (max)
random hp 10 15
random dmg 1 3
input rounds "Rounds:"
let remaining = hp - dmg
print remaining
#if remaining < 50
# print "low hp"
#end
print "Health: {hp}"
print "Damage: {dmg}"
for i = 1 to rounds
if remaining > 0
print "Round {i}"
let remaining = remaining - dmg
print "Remaining hp: {remaining}, Damage dealt: {dmg}"
end
end
- Scripts should have the
.satextension - Blocks always end with
end
Tysm! <3