Skip to content

Commit

Permalink
Fixing string and doc string detection (#34)
Browse files Browse the repository at this point in the history
Co-authored-by: phannebohm <[email protected]>
  • Loading branch information
AnHeuermann and phannebohm authored Mar 13, 2024
1 parent bf87110 commit 1b30b5b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"preLaunchTask": "npm: prebuild"
"preLaunchTask": "Build"
}
]
}
10 changes: 10 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"group": {
"kind": "build",
"isDefault": true
},
"type": "npm",
"script": "prebuild"
},
{
"label": "tmGrammar tests",
"dependsOn": ["Build"],
"type": "shell",
"command": "npx vscode-tmgrammar-test -c 'test/**/*.test.*'",
"group": "test",
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ npm install
```

Translate the `*tmGrammar.yaml` files to `*.tmGrammar.json` JSON files.
Start build task (Ctrl+Shift+B)

```bash
npm run prebuild
Expand All @@ -96,7 +97,7 @@ Run the `tmGrammer tests` task:
or run it manually:

```bash
npx vscode-tmgrammar-test test/**/*.test.*
npm run test
```

### Build Package
Expand Down
8 changes: 4 additions & 4 deletions syntaxes/modelica.tmGrammar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ patterns:
- include: '#annotations'

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

repository:
escapes:
Expand Down
20 changes: 18 additions & 2 deletions test/modelica/Comments.test.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,26 @@

model M "Documentation"
// ^^^^^^^^^^^^^^^ comment.line
Real x "Variable x";
Real x "Variable \"x\"";
// ^^^^^^^^^^^^ comment.line
Real y = 1.0 "Variable y";
String z = "hello" "Variable z";
// ^^^^^^^^^^^^ comment.line
String z1 = "hello" "Variable z1";
// ^^^^^^^^^^^^^ comment.line
String z2 = "hello";
// ^^^^^^^ string.quoted.double
Foo foo(x=1) "Variable foo";
// ^^^^^^^^^^^^^^ comment.line
Real a = foo("hello") "Function foo";
// ^^^^^^^ string.quoted.double
// ^^^^^^^^^^^^^^ comment.line
Real b = bar("hello");
// ^^^^^^^ string.quoted.double
String v = "a" + "b" "Variable v";
// ^^^ string.quoted.double
// ^^^ string.quoted.double
// ^^^^^^^^^^^^ comment.line
String w = "a" + "b";
// ^^^ string.quoted.double
// ^^^ string.quoted.double
end M;

0 comments on commit 1b30b5b

Please sign in to comment.