-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Tremor project DSL language definition (#3087)
* Add tremor project DSL langauge definitions Signed-off-by: Darach Ennis <darach@gmail.com> * Update components/prism-tremor.js Apply fix worst-case time complexity per @RunDevelopment's insight Co-authored-by: Michael Schmidt <msrd0000@gmail.com> * Update components/prism-tremor.js Terser formulation of pattern Co-authored-by: Michael Schmidt <msrd0000@gmail.com> * Update components/prism-tremor.js Terser formulation of pattern Co-authored-by: Michael Schmidt <msrd0000@gmail.com> * Update components/prism-tremor.js Terser formulation of pattern Co-authored-by: Michael Schmidt <msrd0000@gmail.com> * Add partial interpolation, expand tests, attend to lints Signed-off-by: Darach Ennis <darach@gmail.com> * Improved Tremor tokenization Signed-off-by: Michael Schmidt <mitchi5000.ms@googlemail.com> Co-authored-by: Michael Schmidt <msrd0000@gmail.com> Co-authored-by: Michael Schmidt <mitchi5000.ms@googlemail.com>
- Loading branch information
1 parent
99d94fa
commit ec25ba6
Showing
20 changed files
with
689 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
(function (Prism) { | ||
|
||
Prism.languages.tremor = { | ||
'comment': { | ||
pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/, | ||
lookbehind: true | ||
}, | ||
'interpolated-string': null, // see below | ||
'extractor': { | ||
pattern: /\b[a-z_]\w*\|(?:[^\r\n\\|]|\\(?:\r\n|[\s\S]))*\|/i, | ||
greedy: true, | ||
inside: { | ||
'function': /^\w+/, | ||
'regex': /\|[\s\S]+/, | ||
} | ||
}, | ||
'identifier': { | ||
pattern: /`[^`]*`/, | ||
greedy: true | ||
}, | ||
|
||
'function': /\b[a-z_]\w*(?=\s*(?:::\s*<|\())\b/, | ||
|
||
'keyword': /\b(?:event|state|select|create|define|deploy|operator|script|connector|pipeline|flow|config|links|connect|to|from|into|with|group|by|args|window|stream|tumbling|sliding|where|having|set|each|emit|drop|const|let|for|match|of|case|when|default|end|patch|insert|update|erase|move|copy|merge|fn|intrinsic|recur|use|as|mod)\b/, | ||
'boolean': /\b(?:true|false|null)\b/i, | ||
|
||
'number': /\b(?:0b[0-1_]*|0x[0-9a-fA-F_]*|\d[0-9_]*(?:\.\d[0-9_]*)?(?:[Ee][+-]?[0-9_]+)?)\b/, | ||
|
||
'pattern-punctuation': { | ||
pattern: /%(?=[({[])/, | ||
alias: 'punctuation' | ||
}, | ||
'operator': /[-+*\/%~!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?>?=?|(?:not|and|or|xor|present|absent)\b/, | ||
'punctuation': /::|[;\[\]()\{\},.:]/, | ||
}; | ||
|
||
var interpolationPattern = /#\{(?:[^"{}]|\{[^{}]*\}|"(?:[^"\\\r\n]|\\(?:\r\n|[\s\S]))*")*\}/.source; | ||
|
||
Prism.languages.tremor['interpolated-string'] = { | ||
pattern: RegExp( | ||
/(^|[^\\])/.source + | ||
'(?:' + | ||
'"""(?:' + /[^"\\#]|\\[\s\S]|"(?!"")|#(?!\{)/.source + '|' + interpolationPattern + ')*"""' + | ||
'|' + | ||
'"(?:' + /[^"\\\r\n#]|\\(?:\r\n|[\s\S])|#(?!\{)/.source + '|' + interpolationPattern + ')*"' + | ||
')' | ||
), | ||
lookbehind: true, | ||
greedy: true, | ||
inside: { | ||
'interpolation': { | ||
pattern: RegExp(interpolationPattern), | ||
inside: { | ||
'punctuation': /^#\{|\}$/, | ||
'expression': { | ||
pattern: /[\s\S]+/, | ||
inside: Prism.languages.tremor | ||
} | ||
} | ||
}, | ||
'string': /[\s\S]+/ | ||
} | ||
}; | ||
|
||
Prism.languages.troy = Prism.languages['tremor']; | ||
Prism.languages.trickle = Prism.languages['tremor']; | ||
|
||
}(Prism)); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<h2>Comments</h2> | ||
<pre><code># Single line comment | ||
### Module level documentation comment | ||
## Statement level documentation comment | ||
# Regular code comment | ||
</code></pre> | ||
|
||
<h2>Strings</h2> | ||
<pre><code> | ||
# double quote single line strings | ||
"foo \"bar\" baz" | ||
|
||
# heredocs or multiline strings | ||
""" | ||
{ "snot": "badger" } | ||
""" | ||
</code></pre> | ||
|
||
<h2>Variables</h2> | ||
<pre><code> | ||
# Immutable constants | ||
const snot = "fleek"; | ||
|
||
# Mutable variables | ||
let badger = "flook"; | ||
</code></pre> | ||
|
||
<h2>Operators</h2> | ||
<pre><code> | ||
merge {} of | ||
{ "snot": "badger" } | ||
end; | ||
|
||
patch {} of | ||
insert snot = "badger" | ||
end; | ||
</code></pre> | ||
|
||
<h2>Functions and keywords</h2> | ||
<pre><code> | ||
fn fib_(a, b, n) of | ||
case (a, b, n) when n > 0 => recur(b, a + b, n - 1) | ||
default => a | ||
end; | ||
|
||
fn fib(n) with | ||
fib_(0, 1, n) | ||
end; | ||
|
||
fib(event) | ||
</code></pre> | ||
|
||
<h2>Queries</h2> | ||
<pre><code> | ||
define script fib | ||
script | ||
fn fib_(a, b, n) of | ||
case (a, b, n) when n > 0 => recur(b, a + b, n - 1) | ||
default => a | ||
end; | ||
|
||
fn fib(n) with | ||
fib_(0, 1, n) | ||
end; | ||
|
||
{ "fib": fib(event.n) } | ||
end; | ||
|
||
create script fib; | ||
select event.n from in into fib; | ||
select event from fib into out; | ||
</code></pre> | ||
|
||
<h2>Deployments</h2> | ||
<pre><code> | ||
define pipeline passthrough | ||
pipeline | ||
select event from in into out; | ||
end; | ||
|
||
deploy pipeline passthrough; | ||
</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.