From 6e9a27c91721a7c503c095b8ad7b543eb6067170 Mon Sep 17 00:00:00 2001 From: osman362 <136453917+osman362@users.noreply.github.com> Date: Mon, 6 Nov 2023 10:42:11 +0100 Subject: [PATCH] Update on the README file (#9) * Updated README file - Added installation process - Added explanation on how to run tests, parse and highlight a file - Added current status * Adding workflow badge --------- Co-authored-by: AnHeuermann <38031952+AnHeuermann@users.noreply.github.com> --- .github/workflows/build-parser.yml | 2 +- README.md | 71 +++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-parser.yml b/.github/workflows/build-parser.yml index 4000252..1f28964 100644 --- a/.github/workflows/build-parser.yml +++ b/.github/workflows/build-parser.yml @@ -1,4 +1,4 @@ -name: build-parser +name: Build run-name: Build tree-sitter-modelica on: diff --git a/README.md b/README.md index f4250eb..fe0ecab 100644 --- a/README.md +++ b/README.md @@ -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.