Skip to content
Draft
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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
*.vsix
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Change Log

- 20191208 Initial version
## v0.0.2 - 2026-03-16

Added keywords and multi-line comment support to the MDL grammar.

Detailed Changes:

- Added `scripts/update-mdl-language-config.js` to regenerate MDL grammar keyword sets from `MDLValidation.def`.
- Updated `syntaxes/mdl.tmLanguage.json` using the new updater output.
- Added automated tests in `test/update-mdl-language-config.test.js` for parser extraction, grammar patching, and CLI integration.
- Expanded `README.md` with updater usage, workflow guidance, and testing instructions.

## v0.0.1 - 2019-12-08

Initial version.
15 changes: 15 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# BSD 3-Clause License

SPDX-License-Identifier: BSD-3-Clause

Copyright (c) 2026 Hans Meine

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145 changes: 135 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,142 @@
# MeVisLab Description Language (MDL) Support

This extension shall be used for editing MeVisLab MDL files (mostly `.def` and `.script`).
VS Code language support for MeVisLab MDL files, including syntax highlighting for core MDL structures and validator-derived keywords.

## Features
## What This Extension Supports

* Single-line comments
* Strings (`""`, `"* ... *"` and `@@ ... @@`)
- MDL-related file extensions:
- `.def`
- `.script`
- `.mdl`
- `.mlab`
- Single-line comments (`// ...`)
- Multi-line comments (`/* ... */`)
- String forms:
- `"..."`
- `"* ... *"`
- `@@ ... @@`
- Syntax categories generated from `MDLValidation.def`:
- Block/group keywords (for example `MacroModule`, `Window`, `Interface`)
- Property/tag names (for example `title`, `dependsOn`, `allowChild`)
- Enum literals (for example `stable`, `deprecated`, `Top`)
- MDL preprocessor-like directives (`#include`, `#ifset`, `#ifnset`)

## TODO
## Installation

* Test/implement multiline strings
* More keywords (cf. `MeVisLab/IDE/Modules/IDE/MDLValidation.def`)
* embeddedLanguage for Python code (e.g. Fiedlisteners)
### Option 1: Install From VSIX

The vsc-extension-quickstart.md gives information on how to develop and use
this extension.
If you already have a `.vsix` package, install it with:

```powershell
code --install-extension .\mdl-0.0.2.vsix --force
```

### Option 2: Build And Install Locally

From this repository root:

```powershell
npm install
npx @vscode/vsce package
code --install-extension .\mdl-0.0.2.vsix --force
```

## Development Setup

- Install dependencies:

```powershell
npm install
```

- Open this folder in VS Code.
- Press `F5` in VS Code to launch an Extension Development Host.
- Open a `.def` or `.script` file in the dev host and verify highlighting.

## Updating Language Keywords From MDLValidation.def

NOTE: The `MDLValidation.def` file is not included in this repository. You must obtain it from your MeVisLab installation or development environment (it is located at `MeVisLab/Modules/MDL/MDLValidation.def` in a typical installation).

The grammar is generated/updated by:

- Script: `scripts/update-mdl-language-config.js`
- Output grammar: `syntaxes/mdl.tmLanguage.json`

### Run The Updater

```powershell
npm run update-language-config -- "C:/path/to/MDLValidation.def"
```

Optional second argument for custom grammar output path:

```powershell
node scripts/update-mdl-language-config.js "C:/path/to/MDLValidation.def" "./syntaxes/mdl.tmLanguage.json"
```

### What The Updater Does

- Parses `Group`, `allow`, and `allowChild` declarations for block keyword candidates.
- Parses assignment keys (`key = value`) for property keyword candidates.
- Parses enum `values = "..."` literals for enum keyword candidates.
- Rewrites repository sections in the grammar (`blockKeywords`, `propertyKeywords`, `enumLiterals`, `directives`).
- Writes metadata under `generatedFrom` with source path, generation timestamp, and keyword counts.

### Recommended Updater Workflow

1. Run the updater against the desired `MDLValidation.def`.
2. Review grammar changes in `syntaxes/mdl.tmLanguage.json`.
3. Run tests.
4. Validate visually in VS Code with representative `.def` and `.script` files.
5. Commit both updater and grammar changes together.

## Testing

Run all tests:

```powershell
npm test
```

Current updater tests include:

- Parser behavior (block/property/enum extraction)
- Grammar patching behavior
- CLI integration behavior with temporary files

Test file location:

- `test/update-mdl-language-config.test.js`

## Project Structure

- `package.json`: Extension manifest and npm scripts
- `language-configuration.json`: Brackets, comments, and auto-closing pairs
- `syntaxes/mdl.tmLanguage.json`: TextMate grammar used for highlighting
- `scripts/update-mdl-language-config.js`: Grammar updater from validator input
- `test/update-mdl-language-config.test.js`: Updater test suite
- `CHANGELOG.md`: Version history

## Packaging For Distribution

```powershell
npx @vscode/vsce package
```

This creates a `.vsix` package in the repository root.

## Troubleshooting

- No highlighting updates after grammar changes:
- Reload VS Code window (`Developer: Reload Window`).
- Ensure the correct extension instance is installed (local VSIX vs published).
- Updater reports missing file:
- Verify the full path to `MDLValidation.def`.
- Tests fail unexpectedly:
- Reinstall dependencies with `npm install`.
- Re-run `npm test` and inspect failing case output.

## Notes

- The repository currently has no license file; `vsce` will warn during packaging.
- See `vsc-extension-quickstart.md` for baseline VS Code extension development notes.
4 changes: 3 additions & 1 deletion language-configuration.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"comments": {
// symbol used for single line comment. Remove this entry if your language does not support line comments
"lineComment": "//"
"lineComment": "//",
// symbols used for block comments
"blockComment": ["/*", "*/"]
},
// symbols used as brackets
"brackets": [
Expand Down
Loading