Skip to content

Commit

Permalink
String escape and mos snippets (#3)
Browse files Browse the repository at this point in the history
* String escape for modelica
* Better template definition highlighting
* MOS scripting highlighting improved
  - MOS script snippets
  - MOS script API functions highlighting
  • Loading branch information
AnHeuermann authored Jun 30, 2023
1 parent 60b9621 commit cc8278b
Show file tree
Hide file tree
Showing 7 changed files with 899 additions and 37 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Change Log
All notable changes to the "MetaModelica" extension will be documented in this file.

## [1.1.0] - 2023-06-30

- MOS script snippets
- MOS script API functions highlighting
- Fixed string escapes

## [1.0.0] - 2023-06-29

- Fixed syntax highlighting for Susan template language
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ possible snippets to choose from.
Use the provided dev container to build and publish the extension. See
[https://code.visualstudio.com/api/working-with-extensions/publishing-extension#installation](code.visualstudio.com/api/working-with-extensions/publishing-extension).

Generate .vsix pacakge file:
Generate .vsix package file:
```bash
npx vsce package
```
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "metamodelica",
"displayName": "MetaModelica",
"description": "MetaModelica, Susan and Modelica language support.",
"version": "1.0.0",
"version": "1.1.0",
"publisher": "AnHeuermann",
"license": "See LICENSE.txt",
"engines": {
Expand Down Expand Up @@ -118,6 +118,10 @@
{
"language": "metamodelica",
"path": "./snippets/snippets.json"
},
{
"language": "openmodelica-script",
"path": "./snippets/snippets_script.json"
}
]
},
Expand Down
139 changes: 139 additions & 0 deletions snippets/snippets_script.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{
"API function getErrorString": {
"prefix": "getErrorString",
"body": "getErrorString();",
"scope": "source.openmodelica-script"
},

"Minimal Working Example": {
"prefix": "loadModel",
"body": [
"loadModel(Modelica, {\"4.0\"}); getErrorString();",
"loadString(\"",
" model M",
" $1",
" end M;",
"\"); getErrorString();",
"simulate(M); getErrorString();"
],
"scope": "source.openmodelica-script"
},

"API function simulate (full)": {
"prefix": "simulate",
"body": [
"simulate($1,",
" startTime = 0.0,",
" stopTime = 1.0,",
" numberOfIntervals = 500",
" tolerance = 1e-6",
" method = \"dassl\"",
" fileNamePrefix = \"<default>\"",
" options = \"\"",
" outputFormat = \"mat\"",
" variableFilter = \".*\"",
" cflags = \"\"",
" simflags = \"<default>\");",
"getErrorString();"
],
"scope": "source.openmodelica-script"
},

"API function simulate": {
"prefix": "simulate",
"body": [
"simulate($1);",
"getErrorString();"
],
"scope": "source.openmodelica-script"
},

"API function buildModel (full)": {
"prefix": "buildModel",
"body": [
"buildModel($1,",
" startTime = \"<default>\",",
" stopTime = 1.0,",
" numberOfIntervals = 500,",
" tolerance = 1e-6,",
" method = \"dassl\",",
" fileNamePrefix = \"<default>\",",
" options = \"<default>\",",
" outputFormat = \"mat\",",
" variableFilter = \".*\",",
" cflags = \"<default>\",",
" simflags = \"<default>\");",
"getErrorString();"
],
"scope": "source.openmodelica-script"
},

"API function buildModel": {
"prefix": "buildModel",
"body": [
"buildModel($1);",
"getErrorString();"
],
"scope": "source.openmodelica-script"
},

"API function buildModelFMU (full)": {
"prefix": "buildModelFMU",
"body": [
"buildModelFMU($1",
" version = \"2.0\",",
" fmuType = \"me\"",
" fileNamePrefix = \"<default>\",",
" platforms = {\"static\"},",
" includeResources = false);",
"getErrorString();"
],
"scope": "source.openmodelica-script"
},

"API function buildModelFMU": {
"prefix": "buildModelFMU",
"body": [
"buildModelFMU($1);",
"getErrorString();"
],
"scope": "source.openmodelica-script"
},

"API function loadFile": {
"prefix": "loadFile",
"body": [
"loadFile(\"$1\");",
"getErrorString();"
],
"scope": "source.openmodelica-script"
},

"API function loadModel (full)": {
"prefix": "loadModel",
"body": [
"loadModel($1,",
" priorityVersion = {\"default\"});",
"getErrorString();"
],
"scope": "source.openmodelica-script"
},

"API function loadModel": {
"prefix": "loadModel",
"body": [
"loadModel($1, {\"$2\"});",
"getErrorString();"
],
"scope": "source.openmodelica-script"
},

"API function setCommandLineOptions": {
"prefix": "setCommandLineOptions",
"body": [
"setCommandLineOptions(\"$1\");",
"getErrorString();"
],
"scope": "source.openmodelica-script"
}
}
12 changes: 8 additions & 4 deletions syntaxes/modelica.tmGrammar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,19 @@ patterns:
name: comment.line

# Strings
- begin: '"'
end: '"'
- begin: '(?<!\\)"'
end: '(?<!\\)"'
name: string.quoted.double
patterns:
- match: \\.
name: constant.character.escaped
- include: "#escapes"
- match: '["\w\)\]](\s+".*"\s*);'
captures:
1:
name: string.quoted.double

repository:
escapes:
match: '\\(x\h{2}|[0-2][0-7]{0,2}|3[0-6][0-7]|37[0-7]?|[4-7][0-7]?|.)'
name: constant.character.escape

scopeName: source.modelica
Loading

0 comments on commit cc8278b

Please sign in to comment.