Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update on the README file #9

Merged
merged 4 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-parser.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build-parser
name: Build
run-name: Build tree-sitter-modelica

on:
Expand Down
71 changes: 69 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,72 @@
[![build-parser](https://github.com/OpenModelica/tree-sitter-modelica/actions/workflows/build-parser.yml/badge.svg)](https://github.com/OpenModelica/tree-sitter-modelica/actions/workflows/build-parser.yml)

# tree-sitter-modelica

An [open-source](OSMC-License.txt) Modelica ([Modelica Language Specification v3.5](https://specification.modelica.org/maint/3.5/MLS.html)) grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).
An [open-source](OSMC-License.txt) Modelica
([Modelica Language Specification v3.5](https://specification.modelica.org/maint/3.5/MLS.html))
grammar and highlighting-query for
[tree-sitter](https://github.com/tree-sitter/tree-sitter).

## Installation

```bash
npm install
npm run build
```

To generate the C code to parse Modelica run:

```bash
npx tree-sitter generate
```

> [!NOTE]
> If you have ./node_modules/.bin in your `PATH` environment variable you can skip `npx`
> ```bash
> tree-sitter generate
> ```

## Unit Tests

There is a number of tests included. To run all tests defined in [test/](./test/) just run:

```bash
npx tree-sitter test
```

### Examples

To test the parser on a Modelica file run:

```bash
npx tree-sitter parse examples/SimpleMath.mo
```

## Highlighting

There is also a highlighting query included.
Make sure that the
[tree-sitter per-user configuration](https://tree-sitter.github.io/tree-sitter/syntax-highlighting#per-user-configuration)
are pointing to the parent directory of `tree-sitter-modelica`.
So if this directory is in `/home/USER/workspace/tree-sitter-modelica` add
`/home/USER/workspace` to the parser directories:

**config.json**
```json
{
"parser-directories": [
"/home/USER/workspace"
],
}
```

To test the highlighting configure run:

```bash
npx tree-sitter highlight examples/SimpleMath.mo
```

## Current Status

Currently used by [OMFrontend.js](https://github.com/OpenModelica/OMFrontend.js).
Tree-sitter-modelica has been tested on a "Save Total" version of the DrumBoiler.mo file
which was successfully parsed and highlighted.