An open-source MetaModelica (MetaModelica 2.0) grammar and highlighting-query for tree-sitter.
- Node.js
- Docker
npm install
npm run build
There is a number of tests included. To run all tests defined in test/ just run:
npm run test
To test the parser on a MetaModelica file run:
npx tree-sitter parse examples/Main.mo
There is also a highlighting query included. Make sure that the
tree-sitter per-user configuration
are pointing to the parent directory of tree-sitter-metamodelica
. So if this
directory is in /home/USER/workspace/tree-sitter-metamodelica
add
/home/USER/workspace
to the parser directories:
config.json
{
"parser-directories": [
"/home/USER/workspace"
],
}
To test the highlighting configure run:
npx tree-sitter highlight examples/Main.mo
tree-sitter-metamodelica supports tagging for code navigation systems to provide a list of all definitions.
npx tree-sitter tags examples/Main.mo
Use Web Tree-sitter
tree-sitter-metamodelica.wasm
in your application:
import * as Parser from 'web-tree-sitter'
await Parser.init()
const parser = new Parser
const MetaModelica = await Parser.Language.load(`tree-sitter-metamodelica.wasm`)
parser.setLanguage(MetaModelica)
tree-sitter-metamodelica has been tested on all of the MetaModelica files of the OpenModelica Compiler and can parse all but the following features:
- Susan / Template interface packages
code_equations
npx tree-sitter parse examples/Main.mo
npx tree-sitter highlight examples/Main.mo
npx tree-sitter tags examples/Main.mo