Skip to content

Commit cde5b0f

Browse files
Added support for Warpscript (#2307)
1 parent 1093ceb commit cde5b0f

11 files changed

+203
-1
lines changed

components.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components.json

+4
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,10 @@
11051105
"alias": "vb",
11061106
"owner": "Golmote"
11071107
},
1108+
"warpscript": {
1109+
"title": "WarpScript",
1110+
"owner": "RunDevelopment"
1111+
},
11081112
"wasm": {
11091113
"title": "WebAssembly",
11101114
"owner": "Golmote"

components/prism-warpscript.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Prism.languages.warpscript = {
2+
'comment': /#.*|\/\/.*|\/\*[\s\S]*?\*\//,
3+
'string': {
4+
pattern: /"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'|<'(?:[^\\']|'(?!>)|\\.)*'>/,
5+
greedy: true
6+
},
7+
'variable': /\$\S+/,
8+
'macro': {
9+
pattern: /@\S+/,
10+
alias: 'property'
11+
},
12+
// WarpScript doesn't have any keywords, these are all functions under the control category
13+
// https://www.warp10.io/tags/control
14+
'keyword': /\b(?:BREAK|CHECKMACRO|CONTINUE|CUDF|DEFINED|DEFINEDMACRO|EVAL|FAIL|FOR|FOREACH|FORSTEP|IFT|IFTE|MSGFAIL|NRETURN|RETHROW|RETURN|SWITCH|TRY|UDF|UNTIL|WHILE)\b/,
15+
'number': /[+-]?\b(?:NaN|Infinity|\d+(?:\.\d*)?(?:[Ee][+-]?\d+)?|0x[\da-fA-F]+|0b[01]+)\b/,
16+
'boolean': /\b(?:false|true|F|T)\b/,
17+
'punctuation': /<%|%>|[{}[\]()]/,
18+
// Some operators from the "operators" category
19+
// https://www.warp10.io/tags/operators
20+
'operator': /==|&&?|\|\|?|\*\*?|>>>?|<<|==|[<>!~]=?|[-/%^]|\+!?|\b(?:AND|NOT|OR)\b/
21+
};

components/prism-warpscript.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-warpscript.html

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<h2>Full example</h2>
2+
<pre><code>// Source: https://www.warp10.io/content/04_Tutorials/01_WarpScript/05_Best_Practices
3+
4+
//factorial macro. take a number on the stack, push its factorial
5+
&lt;%
6+
'input' STORE
7+
1
8+
1 $input &lt;% * %> FOR
9+
%> 'factorial' STORE
10+
11+
//build a map with key from 1 to 10 and value = key!
12+
{} 'result' STORE
13+
14+
1 10
15+
&lt;%
16+
'key' STORE
17+
$result $key @factorial $key PUT
18+
DROP //remove the map let by PUT
19+
%> FOR
20+
21+
//push the result on the stack
22+
$result</code></pre>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
false
2+
true
3+
F
4+
T
5+
6+
----------------------------------------------------
7+
8+
[
9+
["boolean", "false"],
10+
["boolean", "true"],
11+
["boolean", "F"],
12+
["boolean", "T"]
13+
]
14+
15+
----------------------------------------------------
16+
17+
Checks for booleans.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Python style comments, starting with a '#' and extending to the end of the line
2+
3+
// Java style comments, extending to the end of the line after the '//'
4+
5+
/*
6+
C style block comments, possibly spanning multiple lines
7+
*/
8+
9+
----------------------------------------------------
10+
11+
[
12+
["comment", "# Python style comments, starting with a '#' and extending to the end of the line"],
13+
["comment", "// Java style comments, extending to the end of the line after the '//'"],
14+
["comment", "/*\r\n C style block comments, possibly spanning multiple lines\r\n*/"]
15+
]
16+
17+
----------------------------------------------------
18+
19+
Checks for comments.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
123
2+
-123
3+
5e4
4+
5e-4
5+
123.546
6+
123.546E-5
7+
8+
0xFFF
9+
0b10101
10+
11+
NaN
12+
Infinity
13+
-Infinity
14+
15+
----------------------------------------------------
16+
17+
[
18+
["number", "123"],
19+
["number", "-123"],
20+
["number", "5e4"],
21+
["number", "5e-4"],
22+
["number", "123.546"],
23+
["number", "123.546E-5"],
24+
25+
["number", "0xFFF"],
26+
["number", "0b10101"],
27+
28+
["number", "NaN"],
29+
["number", "Infinity"],
30+
["number", "-Infinity"]
31+
]
32+
33+
----------------------------------------------------
34+
35+
Checks for numbers.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
!= < > ~= <= == >=
2+
% * + - / **
3+
! && AND OR NOT ||
4+
& ^ | >>> ~ << >>
5+
+!
6+
7+
----------------------------------------------------
8+
9+
[
10+
["operator", "!="],
11+
["operator", "<"],
12+
["operator", ">"],
13+
["operator", "~="],
14+
["operator", "<="],
15+
["operator", "=="],
16+
["operator", ">="],
17+
18+
["operator", "%"],
19+
["operator", "*"],
20+
["operator", "+"],
21+
["operator", "-"],
22+
["operator", "/"],
23+
["operator", "**"],
24+
25+
["operator", "!"],
26+
["operator", "&&"],
27+
["operator", "AND"],
28+
["operator", "OR"],
29+
["operator", "NOT"],
30+
["operator", "||"],
31+
32+
["operator", "&"],
33+
["operator", "^"],
34+
["operator", "|"],
35+
["operator", ">>>"],
36+
["operator", "~"],
37+
["operator", "<<"],
38+
["operator", ">>"],
39+
40+
["operator", "+!"]
41+
]
42+
43+
----------------------------------------------------
44+
45+
Checks for operators.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<% %>
2+
( ) [ ] { }
3+
4+
----------------------------------------------------
5+
6+
[
7+
["punctuation", "<%"],
8+
["punctuation", "%>"],
9+
["punctuation", "("],
10+
["punctuation", ")"],
11+
["punctuation", "["],
12+
["punctuation", "]"],
13+
["punctuation", "{"],
14+
["punctuation", "}"]
15+
]
16+
17+
----------------------------------------------------
18+
19+
Checks for punctuation.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'Caf%C3%A9'
2+
3+
"foo"
4+
5+
<'
6+
foo
7+
'>
8+
9+
----------------------------------------------------
10+
11+
[
12+
["string", "'Caf%C3%A9'"],
13+
["string", "\"foo\""],
14+
["string", "<'\r\n foo\r\n'>"]
15+
]
16+
17+
----------------------------------------------------
18+
19+
Checks for strings.

0 commit comments

Comments
 (0)