Johan-Mi / scratch-compiler-2

Yet another language that compiles to Scratch
The Unlicense
2 stars 0 forks source link

Scratch Compiler 2

TODO: come up with a name for the language

A compiled programming language that targets Scratch.

To learn the language, see the language reference. For a high-level overview of the compiler, see the architecture.

Scratch is a project of the Scratch Foundation, in collaboration with the Lifelong Kindergarten Group at the MIT Media Lab. It is available for free at https://scratch.mit.edu

Usage

# Only check
scratch-compiler-2 check main.sc2

# Compile to a Scratch project
scratch-compiler-2 compile main.sc2

Editor support

Helix

Copy/symlink the Tree-sitter queries to queries/sc2 in the Helix runtime directory and add the following to languages.toml:

[[language]]
name = "sc2"
scope = "source.sc2"
injection-regex = "sc2"
roots = [".git"]
file-types = ["sc2"]
comment-token = "#"
indent = { tab-width = 4, unit = "    " }
formatter = { command = "/path/to/compiled-executable", args = ["format"] }
auto-format = true

[language.auto-pairs]
'(' = ')'
'{' = '}'
'[' = ']'
'"' = '"'

[[grammar]]
name = "sc2"
source = { path = "/path/to/repo/tree-sitter-sc2" }