Tree-sitter grammar for the microScript programming language used in microStudio.
microScript is a simple, elegant scripting language designed for game development in microStudio. It features:
- Simple syntax - No semicolons, curly braces, or complex punctuation
- Functions - First-class functions with default parameters
- Classes and objects - OOP with inheritance and operator overloading
- Control flow -
if/then/else/elsif/end,while,for,for..in - Async constructs -
do,after,every,sleepfor game timing - Local variables - Explicit
localkeyword for scoping
npm install tree-sitter-microscript# Install dependencies
npm install
# Generate parser from grammar.js
npm run generate
# Build native bindings
npm run build
# Run tests
npm test
# Parse a file
npm run parse -- <path-to-file.ms>For advanced build options and debugging commands, see AGENTS.md.
const Parser = require('tree-sitter');
const MicroScript = require('tree-sitter-microscript');
const parser = new Parser();
parser.setLanguage(MicroScript);
const code = `
// Define a greeting function
greet = function(name)
print("Hello, " + name + "!")
end
// Call the function
greet("World")
`;
const tree = parser.parse(code);
console.log(tree.rootNode.toString());# Parse a file
tree-sitter parse example.ms
# Run syntax highlighting
tree-sitter highlight example.ms| Feature | Status |
|---|---|
| Functions & closures | Supported |
| Default function parameters | Supported |
| Classes & inheritance | Supported |
| Operator overloading | Supported |
| Object literals | Supported |
| Control flow (if/while/for) | Supported |
| Break/continue statements | Supported |
| Return statements | Supported |
| Delete statement | Supported |
| Async constructs (do/after/every/sleep) | Supported |
| Comments (// and /* */) | Supported |
| String escapes | Supported |
| Triple-quoted strings | Supported |
- microScript extension for Zed - Zed editor extension using this grammar
- microStudio - Online game development platform using microScript
Contributions are welcome! Please feel free to submit a Pull Request.
MIT