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

Add tremor project DSL langauge definitions #3087

Merged
merged 8 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,18 @@
"title": "TOML",
"owner": "RunDevelopment"
},
"tremor": {
"title": "Tremor",
"alias": [
"trickle",
"troy"
],
"owner": "darach",
"aliasTitles": {
"trickle": "trickle",
"troy": "troy"
}
},
"turtle": {
"title": "Turtle",
"alias": "trig",
Expand Down
39 changes: 39 additions & 0 deletions components/prism-tremor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// NOTE: Tremor supports recursive nested interpolation in strings
// but we do support intperpolation in this definition as nested
// recursive interpolation isn't yet fully supported by prism.

Prism.languages.tremor = {
'comment': {
pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
lookbehind: true
},
'heredoc': {
pattern: /"""(?:[^"]|("[^"])|(""[^"]))+"""/,
darach marked this conversation as resolved.
Show resolved Hide resolved
greedy: true,
alias: "string"
},
'string': {
pattern: /"(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])+"|""/,
darach marked this conversation as resolved.
Show resolved Hide resolved
greedy: true,
alias: "string"
},
'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,
'variable': {
pattern: /(`[^`]*`)|\b([_a-z][_a-zA-Z0-9]*\b)/,
darach marked this conversation as resolved.
Show resolved Hide resolved
greedy: true
},
'number': /\b(0b[0-1_]*)|(0x[0-9a-fA-F_]*)|(([0-9][0-9_]*)(\.[0-9][0-9_]*)?((e|E)(\+|-)?[0-9_]+)?)\b/,
darach marked this conversation as resolved.
Show resolved Hide resolved
'operator': /\b[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|\b(?:not|and|or|xor|present|absent)\b/,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
'punctuation': /[;\[\]()\{\},.]/,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
'namespace': {
pattern: /(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
inside: {
'punctuation': /::/
}
},
};

Prism.languages.troy = Prism.languages['tremor'];
Prism.languages.trickle = Prism.languages['tremor'];
1 change: 1 addition & 0 deletions components/prism-tremor.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 82 additions & 0 deletions examples/prism-tremor.html
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>
2 changes: 2 additions & 0 deletions plugins/autoloader/prism-autoloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@
"sln": "solution-file",
"rq": "sparql",
"t4": "t4-cs",
"trickle": "tremor",
"troy": "tremor",
"trig": "turtle",
"ts": "typescript",
"tsconfig": "typoscript",
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@
"tap": "TAP",
"tt2": "Template Toolkit 2",
"toml": "TOML",
"trickle": "trickle",
"troy": "troy",
"trig": "TriG",
"ts": "TypeScript",
"tsconfig": "TSConfig",
Expand Down
Loading