Tree-sitter grammar for the ManV programming language.
This grammar provides syntax highlighting, code folding, and structural analysis for ManV code in editors that support tree-sitter (such as Neovim, VS Code, and others).
The grammar supports the complete ManV language syntax including:
- Basic Types:
int,float,char,str,void,bool,byte - Complex Types: Arrays, pointers, generics, options, GC types, arena types
- Declarations: Functions, structs, typedefs, variables, constants
- Control Flow:
if/else,while,for,return - System Calls:
syscallstatements - OOP Features:
implblocks, constructors, methods - Exception Handling:
try/except/finally,raise - Macros:
macrodeclarations with parameters - Module System:
includestatements - Expressions: Binary/unary operations, method calls, member access, indexing
- Install the tree-sitter parser:
# Clone this repository
git clone https://github.com/manv-lang/tree-sitter-manv.git
cd tree-sitter-manv
# Generate the parser
npm install
npm run build
# Copy to Neovim parsers directory
mkdir -p ~/.local/share/nvim/site/parser
cp parser.so ~/.local/share/nvim/site/parser/manv.so- Configure nvim-treesitter in your Neovim config:
require'nvim-treesitter.configs'.setup {
ensure_installed = { "manv" },
highlight = {
enable = true,
},
indent = {
enable = true,
},
}- Install the Tree-sitter extension
- Add this grammar to your workspace settings:
{
"treeSitter.grammars": {
"manv": {
"path": "./tree-sitter-manv"
}
}
}Once installed, the grammar will automatically provide:
- Syntax Highlighting: Color-coded keywords, types, functions, etc.
- Code Folding: Fold functions, structs, blocks, etc.
- Structural Navigation: Jump between functions, structs, etc.
- Error Detection: Basic syntax error detection
Run the test suite to verify the grammar works correctly:
npm testThis will parse all test files in the corpus/ directory and verify the generated syntax trees match the expected output.
- Fork the repository
- Make your changes to
grammar.js - Add tests to
corpus/syntax_tests.txtfor new features - Run
npm testto verify everything works - Submit a pull request
The grammar is organized into several main sections:
- Source File: Top-level structure containing all declarations
- Declarations: Functions, structs, typedefs, variables, etc.
- Types: All type definitions and type expressions
- Statements: Control flow, assignments, expressions
- Expressions: All expression types and operators
- OOP Features: Impl blocks, constructors, methods
- Advanced Features: Exception handling, macros, re-exports
MIT License - see LICENSE file for details.
- ManV Language - The main ManV compiler
- ManV Standard Library - Standard library modules
- ManV Documentation - Language documentation