Bulat Kurbanov 0b78c43138 feat: major grammar improvements
- Enable ASCII blocks in print commands
- Add import as expression (not just statement)
- Fix operator precedence (& and | now lower than comparisons)
- Allow comments and newlines as top-level statements
- Fix source_file to handle leading comments and empty lines

Progress: 253 → 98 errors (155 files fixed, 55% success)
2025-11-26 23:32:44 +01:00
2025-11-26 23:32:44 +01:00
2025-11-26 22:20:34 +01:00
2025-11-26 23:32:44 +01:00
2025-11-25 11:43:36 +01:00
2025-11-26 22:20:34 +01:00

tree-sitter-stonescript

A Tree-sitter grammar for the StoneScript programming language.

Overview

This grammar provides syntax parsing support for StoneScript, the scripting language used in the game Stone Story RPG. It enables syntax highlighting, code analysis, and other language features in editors that support Tree-sitter.

Installation

Node.js

npm install tree-sitter-stonescript

From Source

git clone https://github.com/kurbezz/tree-sitter-stonescript.git
cd tree-sitter-stonescript
npm install
npm run build

Usage

Node.js

const Parser = require('tree-sitter');
const StoneScript = require('tree-sitter-stonescript');

const parser = new Parser();
parser.setLanguage(StoneScript);

const sourceCode = `
var x = 5
if x > 3
  weapon sword
`;

const tree = parser.parse(sourceCode);
console.log(tree.rootNode.toString());

Rust

Add this to your Cargo.toml:

[dependencies]
tree-sitter = "0.20"
tree-sitter-stonescript = { path = "path/to/tree-sitter-stonescript" }

Testing

npm test

This will run the corpus tests located in the corpus/ directory.

Language Features

The grammar supports:

  • Variables and assignments
  • Conditional statements (if/else)
  • Functions
  • Operators (arithmetic, comparison, logical)
  • Comments
  • String literals
  • Number literals
  • Built-in game objects and functions

File Extensions

  • .ss
  • .txt (when containing StoneScript code)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details

Resources

Description
No description provided
Readme MIT 1.2 MiB
Languages
C 40.4%
C++ 28.5%
JavaScript 22%
Rust 8.3%
Python 0.8%