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

Compatibility with Linguist #111

Merged
merged 16 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1,955 changes: 706 additions & 1,249 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
{
"language": "lflang",
"scopeName": "source.lf",
"path": "./syntax/lflang.tmLanguage.json",
"path": "./syntaxes/lflang.tmLanguage.json",
"embeddedLanguages": {
"meta.embedded.block.c": "c",
"meta.embedded.block.cpp": "cpp",
Expand Down Expand Up @@ -151,7 +151,7 @@
"rimraf": "^4.1.2",
"simple-git": "^3.16.1",
"ts-node": "^10.9.1",
"typescript": "^4.6.5",
"typescript": "^4.9.5",
"url-exist": "^3.0.1",
"vscode-oniguruma": "^1.7.0",
"vscode-textmate": "^9.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/test/check_highlighting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const registry = new vsctm.Registry({
onigLib: vscodeOnigurumaLib,
loadGrammar: async (_: string) => {
const grammarFile = path.join(
root, "syntax", "lflang.tmLanguage.json"
root, "syntaxes", "lflang.tmLanguage.json"
)
const data: any = fs.readFileSync(grammarFile)
return vsctm.parseRawGrammar(data.toString(), grammarFile)
Expand Down
76 changes: 36 additions & 40 deletions syntax/lflang.tmLanguage.json → syntaxes/lflang.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
},
{
"include": "#context-insensitive"
},
{
"include": "#type"
}
]
},
Expand Down Expand Up @@ -75,9 +78,6 @@
{
"include": "#timer"
},
{
"include": "#type"
},
{
"include": "#number"
},
Expand Down Expand Up @@ -118,10 +118,22 @@
},
"c-target": {
"begin": "(?=\\btarget\\s+C\\b)",
"patterns": [{
"include": "#c-or-cpp-target"
}]
},
"cpp-target": {
"begin": "(?=\\btarget\\s+C?Cpp\\b)",
"patterns": [{
"include": "#c-or-cpp-target"
}]
},
"c-or-cpp-target": {
"patterns": [
{
"begin": "(?<=(input|output|action|state).*:)",
"end": "[\\(;\\n]",
"begin": "(?<=(input|state))\\s+\\w+\\s*:",
"end": "[\\(;\\n]|(?=\\{=)",
"name": "meta.embedded.block.cpp",
"patterns": [
{
"include": "source.cpp"
Expand All @@ -132,24 +144,9 @@
]
},
{
"include": "#post-targetspec"
},
{
"begin": "\\{=(?!=\\})",
"end": "([<>]?[<>+\\-*/%&\\^|]?=\\})",
"name": "meta.embedded.block.c",
"patterns": [{
"include": "source.cpp"
}]
}
]
},
"cpp-target": {
"begin": "(?=\\btarget\\s+C?Cpp\\b)",
"patterns": [
{
"begin": "(?<=(input|output|action|state).*:)",
"end": "[\\(;\\n]",
"begin": "(?<=(output|action))\\s+\\w+\\s*:",
"end": "[\\(;\\n]|(?=\\{=)",
"name": "meta.embedded.block.cpp",
"patterns": [
{
"include": "source.cpp"
Expand All @@ -163,8 +160,8 @@
"include": "#post-targetspec"
},
{
"begin": "\\{=(?!=\\})",
"end": "([<>]?[<>+\\-*/%&\\^|]?=\\})",
"begin": "\\{=",
"end": "(([<>]?[<>+\\-*/%&\\^|]?=\\}))",
"name": "meta.embedded.block.cpp",
"patterns": [{
"include": "source.cpp"
Expand Down Expand Up @@ -217,10 +214,6 @@
"rs-target": {
"begin": "(?=\\btarget\\s+Rust\\b)",
"patterns": [
{
"name": "entity.name.type.lflang",
"match": "(?<=(input|output|action|state).*:(\\s*))(\\b(\\w+)\\b)"
},
{
"include": "#post-targetspec"
},
Expand All @@ -237,7 +230,7 @@
"target-specification": {
"name": "meta.targetspec.lflang",
"begin": "(?=\\btarget\\b)",
"end": ";|(?<=}.*)$|(?<=target[^\\{]*)$",
"end": "(?<=;)\\s*$|(?<=})\\s*$|(?<=Python)\\s*$|(?<=(CCpp|Rust))\\s*$|(?<=C)\\s*$|(?<=Cpp)\\s*$|(?<=TypeScript)\\s*$",
"patterns": [
{
"include": "#context-insensitive"
Expand All @@ -252,17 +245,20 @@
},
{
"name": "variable.parameter.lflang",
"match": "(?<=(^|,|\\{)(\\s)*)\\b([\\w\\-]+)\\b(?=(\\s)*:)"
"match": "(^|(?<=(,|\\{)))\\s*\\b([\\w\\-]+)\\b(?=\\s*:)"
}
]
},
"import-statement": {
"begin": "(?=^\\s*import\\b)",
"end": ";|(?<=}.*)$|(?<=import[^\\{]*)$",
"end": ";|(?<=\")\\s*$",
"patterns": [
{
"include": "#context-insensitive"
},
{
"include": "#type"
},
{
"name": "keyword.control.import.lflang",
"match": "\\b(import)\\b|\\b(as)\\b|\\b(from)\\b"
Expand Down Expand Up @@ -301,7 +297,7 @@
},
{
"name": "entity.name.type.lflang",
"match": "(?<=\\breactor\\b\\s*)(?!at)(?!extends)(\\w+)\\b"
"match": "(?<=\\breactor\\b\\s)\\s*(?!at)(?!extends)(\\w+)\\b"
}
]
},
Expand All @@ -325,7 +321,7 @@
},
{
"name": "entity.name.function.member.lflang",
"match": "(?<=\\bmethod\\b\\s+)\\w+\\b"
"match": "(?<=\\bmethod\\b)\\s+(\\w+)\\b"
}
]
},
Expand Down Expand Up @@ -381,11 +377,11 @@
"patterns": [
{
"name": "entity.name.type.lflang",
"match": "(?<=(input|output|action|state).*:(\\s*))(\\b([A-Z]\\w*)\\b)"
"match": "(?<=:)\\s*(\\b([A-Z]\\w*)\\b)"
},
{
"name": "storage.type.lflang",
"match": "(?<=(input|output|action|state).*:(\\s*))(\\b(\\w+)\\b)"
"match": "(?<=:)\\s*(\\b(\\w+)\\b)"
}
]
},
Expand Down Expand Up @@ -422,15 +418,15 @@
{
"name": "string.quoted.double.lflang",
"begin": "\"",
"end": "(?<=(\\\\.|[^\"\\\\])*)(\"|$)",
"end": "(\"|$)",
"patterns": [{
"include": "#string-helper"
}]
},
{
"name": "string.quoted.single.lflang",
"begin": "'",
"end": "(?<=(\\\\.|[^'\\\\])*)('|$)",
"end": "('|$)",
"patterns": [{
"include": "#string-helper"
}]
Expand Down Expand Up @@ -477,7 +473,7 @@
},
{
"name": "entity.name.type.lflang",
"match": "(?<=\\s*=\\s*new\\s*(\\[[^\\]]*\\])?\\s+)\\w+\\b"
"match": "(?<=new\\s)\\s*(\\[[^\\]]*\\])?\\s*(\\w+)\\b"
}
]
},
Expand All @@ -493,7 +489,7 @@
},
{
"name": "variable.other.lflang",
"match": "(?<=\\w+((\\.)|(::)))(\\b\\w+\\b)"
"match": "(?<=((\\w\\.)|(::)))(\\b\\w+\\b)"
}
]
},
Expand Down
10 changes: 5 additions & 5 deletions test/known-good/C/src/ActionDelay.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<span class="source-lf meta-targetspec-lflang keyword-control-lflang">target</span><span class="source-lf meta-targetspec-lflang"> </span><span class="source-lf meta-targetspec-lflang constant-language-lflang">C</span>
<span class="source-lf"></span>
<span class="source-lf storage-modifier-lflang">reactor</span><span class="source-lf"> </span><span class="source-lf entity-name-type-lflang">GeneratedDelay</span><span class="source-lf"> {</span>
<span class="source-lf"> </span><span class="source-lf storage-modifier-lflang">input</span><span class="source-lf"> y_in:</span><span class="source-lf"> </span><span class="source-lf storage-type-lflang">int</span>
<span class="source-lf"> </span><span class="source-lf storage-modifier-lflang">output</span><span class="source-lf"> y_out:</span><span class="source-lf"> </span><span class="source-lf storage-type-lflang">int</span>
<span class="source-lf"> </span><span class="source-lf storage-modifier-lflang">state</span><span class="source-lf"> y_state:</span><span class="source-lf"> </span><span class="source-lf storage-type-lflang">int</span><span class="source-lf">(</span><span class="source-lf constant-numeric-int-lflang">0</span><span class="source-lf">)</span>
<span class="source-lf"> </span><span class="source-lf storage-modifier-lflang">input</span><span class="source-lf"> y_in:</span><span class="source-lf storage-type-lflang"> int</span>
<span class="source-lf"> </span><span class="source-lf storage-modifier-lflang">output</span><span class="source-lf"> y_out:</span><span class="source-lf storage-type-lflang"> int</span>
<span class="source-lf"> </span><span class="source-lf storage-modifier-lflang">state</span><span class="source-lf"> y_state:</span><span class="source-lf storage-type-lflang"> int</span><span class="source-lf">(</span><span class="source-lf constant-numeric-int-lflang">0</span><span class="source-lf">)</span>
<span class="source-lf"> </span><span class="source-lf storage-modifier-lflang">logical</span><span class="source-lf"> </span><span class="source-lf storage-modifier-lflang">action</span><span class="source-lf"> act(</span><span class="source-lf constant-numeric-int-lflang">100</span><span class="source-lf"> </span><span class="source-lf constant-numeric-lflang">msec</span><span class="source-lf">)</span>
<span class="source-lf"></span>
<span class="source-lf"> </span><span class="source-lf keyword-control-lflang">reaction</span><span class="source-lf">(y_in) </span><span class="source-lf keyword-operator-lflang">-></span><span class="source-lf"> act {</span><span class="source-lf keyword-operator-lflang">=</span>
Expand All @@ -16,13 +16,13 @@
<span class="source-lf">}</span>
<span class="source-lf"></span>
<span class="source-lf storage-modifier-lflang">reactor</span><span class="source-lf"> </span><span class="source-lf entity-name-type-lflang">Source</span><span class="source-lf"> {</span>
<span class="source-lf"> </span><span class="source-lf storage-modifier-lflang">output</span><span class="source-lf"> out:</span><span class="source-lf"> </span><span class="source-lf storage-type-lflang">int</span>
<span class="source-lf"> </span><span class="source-lf storage-modifier-lflang">output</span><span class="source-lf"> out:</span><span class="source-lf storage-type-lflang"> int</span>
<span class="source-lf"></span>
<span class="source-lf"> </span><span class="source-lf keyword-control-lflang">reaction</span><span class="source-lf">(</span><span class="source-lf support-variable-lflang">startup</span><span class="source-lf">) </span><span class="source-lf keyword-operator-lflang">-></span><span class="source-lf"> out {</span><span class="source-lf keyword-operator-lflang">=</span><span class="source-lf"> lf_set(out, </span><span class="source-lf constant-numeric-int-lflang">1</span><span class="source-lf">); </span><span class="source-lf keyword-operator-lflang">=</span><span class="source-lf">}</span>
<span class="source-lf">}</span>
<span class="source-lf"></span>
<span class="source-lf storage-modifier-lflang">reactor</span><span class="source-lf"> </span><span class="source-lf entity-name-type-lflang">Sink</span><span class="source-lf"> {</span>
<span class="source-lf"> </span><span class="source-lf storage-modifier-lflang">input</span><span class="source-lf"> in:</span><span class="source-lf"> </span><span class="source-lf storage-type-lflang">int</span>
<span class="source-lf"> </span><span class="source-lf storage-modifier-lflang">input</span><span class="source-lf"> in:</span><span class="source-lf storage-type-lflang"> int</span>
<span class="source-lf"></span>
<span class="source-lf"> </span><span class="source-lf keyword-control-lflang">reaction</span><span class="source-lf">(in) {</span><span class="source-lf keyword-operator-lflang">=</span>
<span class="source-lf"> interval_t elapsed_logical </span><span class="source-lf keyword-operator-lflang">=</span><span class="source-lf"> lf_time_logical_elapsed();</span>
Expand Down
4 changes: 2 additions & 2 deletions test/known-good/C/src/ActionIsPresent.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<span class="source-lf comment-line-double-dash-lflang">// Tests the is_present variable for actions.</span>
<span class="source-lf meta-targetspec-lflang keyword-control-lflang">target</span><span class="source-lf meta-targetspec-lflang"> </span><span class="source-lf meta-targetspec-lflang constant-language-lflang">C</span>
<span class="source-lf"></span>
<span class="source-lf storage-modifier-lflang">main</span><span class="source-lf"> </span><span class="source-lf storage-modifier-lflang">reactor</span><span class="source-lf"> </span><span class="source-lf entity-name-type-lflang">ActionIsPresent</span><span class="source-lf">(offset: </span><span class="source-lf storage-type-lflang">time</span><span class="source-lf">(</span><span class="source-lf constant-numeric-int-lflang">1</span><span class="source-lf"> </span><span class="source-lf constant-numeric-lflang">nsec</span><span class="source-lf">), period: </span><span class="source-lf storage-type-lflang">time</span><span class="source-lf">(</span><span class="source-lf constant-numeric-int-lflang">500</span><span class="source-lf"> </span><span class="source-lf constant-numeric-lflang">msec</span><span class="source-lf">)) {</span>
<span class="source-lf storage-modifier-lflang">main</span><span class="source-lf"> </span><span class="source-lf storage-modifier-lflang">reactor</span><span class="source-lf"> </span><span class="source-lf entity-name-type-lflang">ActionIsPresent</span><span class="source-lf">(offset:</span><span class="source-lf storage-type-lflang"> time</span><span class="source-lf">(</span><span class="source-lf constant-numeric-int-lflang">1</span><span class="source-lf"> </span><span class="source-lf constant-numeric-lflang">nsec</span><span class="source-lf">), period:</span><span class="source-lf storage-type-lflang"> time</span><span class="source-lf">(</span><span class="source-lf constant-numeric-int-lflang">500</span><span class="source-lf"> </span><span class="source-lf constant-numeric-lflang">msec</span><span class="source-lf">)) {</span>
<span class="source-lf"> </span><span class="source-lf storage-modifier-lflang">logical</span><span class="source-lf"> </span><span class="source-lf storage-modifier-lflang">action</span><span class="source-lf"> a</span>
<span class="source-lf"> </span><span class="source-lf storage-modifier-lflang">state</span><span class="source-lf"> success:</span><span class="source-lf"> </span><span class="source-lf storage-type-lflang">bool</span><span class="source-lf">(</span><span class="source-lf constant-language-lflang">false</span><span class="source-lf">)</span>
<span class="source-lf"> </span><span class="source-lf storage-modifier-lflang">state</span><span class="source-lf"> success:</span><span class="source-lf storage-type-lflang"> bool</span><span class="source-lf">(</span><span class="source-lf constant-language-lflang">false</span><span class="source-lf">)</span>
<span class="source-lf"></span>
<span class="source-lf"> </span><span class="source-lf keyword-control-lflang">reaction</span><span class="source-lf">(</span><span class="source-lf support-variable-lflang">startup</span><span class="source-lf">, a) </span><span class="source-lf keyword-operator-lflang">-></span><span class="source-lf"> a {</span><span class="source-lf keyword-operator-lflang">=</span>
<span class="source-lf"> if (!a</span><span class="source-lf keyword-operator-lflang">-></span><span class="source-lf">is_present) {</span>
Expand Down
Loading
Loading