-
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 support for Warpscript (#2307)
- Loading branch information
1 parent
1093ceb
commit cde5b0f
Showing
11 changed files
with
203 additions
and
1 deletion.
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,21 @@ | ||
Prism.languages.warpscript = { | ||
'comment': /#.*|\/\/.*|\/\*[\s\S]*?\*\//, | ||
'string': { | ||
pattern: /"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'|<'(?:[^\\']|'(?!>)|\\.)*'>/, | ||
greedy: true | ||
}, | ||
'variable': /\$\S+/, | ||
'macro': { | ||
pattern: /@\S+/, | ||
alias: 'property' | ||
}, | ||
// WarpScript doesn't have any keywords, these are all functions under the control category | ||
// https://www.warp10.io/tags/control | ||
'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/, | ||
'number': /[+-]?\b(?:NaN|Infinity|\d+(?:\.\d*)?(?:[Ee][+-]?\d+)?|0x[\da-fA-F]+|0b[01]+)\b/, | ||
'boolean': /\b(?:false|true|F|T)\b/, | ||
'punctuation': /<%|%>|[{}[\]()]/, | ||
// Some operators from the "operators" category | ||
// https://www.warp10.io/tags/operators | ||
'operator': /==|&&?|\|\|?|\*\*?|>>>?|<<|==|[<>!~]=?|[-/%^]|\+!?|\b(?:AND|NOT|OR)\b/ | ||
}; |
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,22 @@ | ||
<h2>Full example</h2> | ||
<pre><code>// Source: https://www.warp10.io/content/04_Tutorials/01_WarpScript/05_Best_Practices | ||
|
||
//factorial macro. take a number on the stack, push its factorial | ||
<% | ||
'input' STORE | ||
1 | ||
1 $input <% * %> FOR | ||
%> 'factorial' STORE | ||
|
||
//build a map with key from 1 to 10 and value = key! | ||
{} 'result' STORE | ||
|
||
1 10 | ||
<% | ||
'key' STORE | ||
$result $key @factorial $key PUT | ||
DROP //remove the map let by PUT | ||
%> FOR | ||
|
||
//push the result on the stack | ||
$result</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
false | ||
true | ||
F | ||
T | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["boolean", "false"], | ||
["boolean", "true"], | ||
["boolean", "F"], | ||
["boolean", "T"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for booleans. |
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,19 @@ | ||
# Python style comments, starting with a '#' and extending to the end of the line | ||
|
||
// Java style comments, extending to the end of the line after the '//' | ||
|
||
/* | ||
C style block comments, possibly spanning multiple lines | ||
*/ | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", "# Python style comments, starting with a '#' and extending to the end of the line"], | ||
["comment", "// Java style comments, extending to the end of the line after the '//'"], | ||
["comment", "/*\r\n C style block comments, possibly spanning multiple lines\r\n*/"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for comments. |
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,35 @@ | ||
123 | ||
-123 | ||
5e4 | ||
5e-4 | ||
123.546 | ||
123.546E-5 | ||
|
||
0xFFF | ||
0b10101 | ||
|
||
NaN | ||
Infinity | ||
-Infinity | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["number", "123"], | ||
["number", "-123"], | ||
["number", "5e4"], | ||
["number", "5e-4"], | ||
["number", "123.546"], | ||
["number", "123.546E-5"], | ||
|
||
["number", "0xFFF"], | ||
["number", "0b10101"], | ||
|
||
["number", "NaN"], | ||
["number", "Infinity"], | ||
["number", "-Infinity"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for numbers. |
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,45 @@ | ||
!= < > ~= <= == >= | ||
% * + - / ** | ||
! && AND OR NOT || | ||
& ^ | >>> ~ << >> | ||
+! | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["operator", "!="], | ||
["operator", "<"], | ||
["operator", ">"], | ||
["operator", "~="], | ||
["operator", "<="], | ||
["operator", "=="], | ||
["operator", ">="], | ||
|
||
["operator", "%"], | ||
["operator", "*"], | ||
["operator", "+"], | ||
["operator", "-"], | ||
["operator", "/"], | ||
["operator", "**"], | ||
|
||
["operator", "!"], | ||
["operator", "&&"], | ||
["operator", "AND"], | ||
["operator", "OR"], | ||
["operator", "NOT"], | ||
["operator", "||"], | ||
|
||
["operator", "&"], | ||
["operator", "^"], | ||
["operator", "|"], | ||
["operator", ">>>"], | ||
["operator", "~"], | ||
["operator", "<<"], | ||
["operator", ">>"], | ||
|
||
["operator", "+!"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for operators. |
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,19 @@ | ||
<% %> | ||
( ) [ ] { } | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["punctuation", "<%"], | ||
["punctuation", "%>"], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
["punctuation", "["], | ||
["punctuation", "]"], | ||
["punctuation", "{"], | ||
["punctuation", "}"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for punctuation. |
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,19 @@ | ||
'Caf%C3%A9' | ||
|
||
"foo" | ||
|
||
<' | ||
foo | ||
'> | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["string", "'Caf%C3%A9'"], | ||
["string", "\"foo\""], | ||
["string", "<'\r\n foo\r\n'>"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for strings. |