Skip to content
Permalink
Browse files
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
3 people committed Sep 21, 2021
1 parent 99d94fa commit ec25ba6527f59284109df9d3189cea383c7c42ac

Large diffs are not rendered by default.

@@ -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",
@@ -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.

@@ -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>
@@ -239,6 +239,8 @@
"sln": "solution-file",
"rq": "sparql",
"t4": "t4-cs",
"trickle": "tremor",
"troy": "tremor",
"trig": "turtle",
"ts": "typescript",
"tsconfig": "typoscript",

Some generated files are not rendered by default. Learn more.

@@ -227,6 +227,8 @@
"tap": "TAP",
"tt2": "Template Toolkit 2",
"toml": "TOML",
"trickle": "trickle",
"troy": "troy",
"trig": "TriG",
"ts": "TypeScript",
"tsconfig": "TSConfig",

0 comments on commit ec25ba6

Please sign in to comment.