Language Overview
ScratchScript is a general purpose, strongly typed high-level programming language. That means you can use it for any type of project, however the language was initially created to automate the process of creating emulators and other complex projects.
Intention
This project was started because I wanted to learn programming language design while also doing something unique. It's more of a proof of concept, since the generated Scratch project is not very optimized and may be slower than code that was created manually.
Structure
ScratchScript has three layers:
Frontend, which is the code you write,
Middleware (Optimizer), which isn't implemented yet,
and ScratchIR (Backend), which converts assembly-like instructions to Scratch blocks.
Features
ScratchScript operates on a stack. This means that some typical programming language structures which aren't native or present in Scratch are replicable:
Function return values (
return value;
)Changing function arguments in-place without cloning them (this will be covered later)
Breaking out of control flow structures (
break;
)Ternary operator (
condition ? trueValue: falseValue
)
It also includes several QoL improvements, such as:
for
loopsExponents (
**
) and binary shifts (<<
and>>
)
The compiler also includes helpful diagnostics for errors: