Ahoy grammar for tree-sitter.
This grammar provides syntax parsing for the Ahoy programming language, including:
- Variables and assignments
- Functions with typed parameters
- Control flow (
if,else,elseif,anif) - Multiple loop types (
loop:start to end,loop element in array,loop key,val in dict) - Arrays (
<1, 2, 3>) - Dictionaries (
{"key":"value"}) - Word operators (
plus,minus,times,div,mod) - Comparison operators (
greater_than,lesser_than,is) - Comments (
? comment) - Imports (
import "lib.h") - Compile-time conditionals (
when DEBUG then ...)
npm install tree-sitter-ahoygit clone https://github.com/yourusername/tree-sitter-ahoy
cd tree-sitter-ahoy
npm install
npm run generateconst Parser = require('tree-sitter');
const Ahoy = require('tree-sitter-ahoy');
const parser = new Parser();
parser.setLanguage(Ahoy);
const sourceCode = `
x: 42
ahoy|"Hello, World!\\n"|
`;
const tree = parser.parse(sourceCode);
console.log(tree.rootNode.toString());# Parse a file
tree-sitter parse example.ahoy
# Test the grammar
tree-sitter test
# Generate the parser
tree-sitter generatenpm testAfter modifying grammar.js:
npm run generatetree-sitter-ahoy/
├── grammar.js # Grammar definition
├── tree-sitter.json # Configuration
├── src/ # Generated parser (C)
├── bindings/ # Language bindings
│ └── node/ # Node.js bindings
├── queries/ # Syntax queries
│ └── highlights.scm # Syntax highlighting
└── test/ # Test cases
└── corpus/ # Test corpus
Contributions are welcome! Please feel free to submit a Pull Request.
MIT