-
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.
Jexl is the [Javascript Expression Language](https://github.com/TomFrost/Jexl).
- Loading branch information
Showing
11 changed files
with
285 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,13 @@ | ||
Prism.languages.jexl = { | ||
string: /(["'])(?:\\(?:[\s\S])|(?!\1)[^\\])*\1/, | ||
transform: { | ||
pattern: /\|\s*[a-zA-Zа-яА-Я_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$][a-zA-Zа-яА-Я0-9_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$]*/, | ||
alias: "function", | ||
}, | ||
function: /[a-zA-Zа-яА-Я_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$][a-zA-Zа-яА-Я0-9_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF$]*\s*(?=\()/, | ||
number: /-?(?:(?:[0-9]*\.[0-9]+)|[0-9]+)/, | ||
boolean: /\b(?:true|false)\b/, | ||
operator: /[<>]=?|[!=]=?|-|\+|&&|\|\||\/\/?|[?:*^%]/, | ||
keyword: /\bin\b/, | ||
punctuation: /[{}[\](),.]/, | ||
}; |
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,13 @@ | ||
true | ||
false | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["boolean", "true"], | ||
["boolean", "false"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
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,96 @@ | ||
foo() | ||
foo () | ||
foo | ||
() | ||
foo . bar () | ||
foo_bar() | ||
foo_bar ( ) | ||
f42() | ||
_() | ||
$() | ||
ä() | ||
Ý() | ||
foo({ x: 1 }) | ||
foo({ y: fun() }) | ||
foo(bar()) | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["function", "foo"], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
|
||
["function", "foo "], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
|
||
["function", "foo\r\n"], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
|
||
"\r\nfoo ", | ||
["punctuation", "."], | ||
["function", "bar "], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
|
||
["function", "foo_bar"], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
|
||
["function", "foo_bar "], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
|
||
["function", "f42"], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
|
||
["function", "_"], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
|
||
["function", "$"], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
|
||
["function", "ä"], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
|
||
["function", "Ý"], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
|
||
["function", "foo"], | ||
["punctuation", "("], | ||
["punctuation", "{"], | ||
" x", | ||
["operator", ":"], | ||
["number", "1"], | ||
["punctuation", "}"], | ||
["punctuation", ")"], | ||
|
||
["function", "foo"], | ||
["punctuation", "("], | ||
["punctuation", "{"], | ||
" y", | ||
["operator", ":"], | ||
["function", "fun"], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
["punctuation", "}"], | ||
["punctuation", ")"], | ||
|
||
["function", "foo"], | ||
["punctuation", "("], | ||
["function", "bar"], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
["punctuation", ")"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for functions. Also checks for unicode characters in identifiers. |
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,23 @@ | ||
in | ||
"foo" in ["foo"] | ||
"f" in "foo" | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "in"], | ||
|
||
["string", "\"foo\""], | ||
["keyword", "in"], | ||
["punctuation", "["], | ||
["string", "\"foo\""], | ||
["punctuation", "]"], | ||
|
||
["string", "\"f\""], | ||
["keyword", "in"], | ||
["string", "\"foo\""] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for all keywords. |
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,15 @@ | ||
42 | ||
3.14159 | ||
-5.7 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["number", "42"], | ||
["number", "3.14159"], | ||
["number", "-5.7"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for integers, floats, negative 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,33 @@ | ||
- | ||
+ | ||
< <= | ||
> >= | ||
= == | ||
! != | ||
&& || | ||
* | ||
/ // | ||
^ | ||
? : | ||
% | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["operator", "-"], | ||
["operator", "+"], | ||
["operator", "<"], ["operator", "<="], | ||
["operator", ">"], ["operator", ">="], | ||
["operator", "="], ["operator", "=="], | ||
["operator", "!"], ["operator", "!="], | ||
["operator", "&&"], ["operator", "||"], | ||
["operator", "*"], | ||
["operator", "/"], ["operator", "//"], | ||
["operator", "^"], | ||
["operator", "?"], ["operator", ":"], | ||
["operator", "%"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for all 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,35 @@ | ||
'a' | ||
'ä' | ||
'本' | ||
'À' | ||
'\'' | ||
'""' | ||
'Hello, | ||
world!' | ||
|
||
"\n" | ||
"\"" | ||
"Hello, | ||
world!" | ||
"日本語" | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["string", "'a'"], | ||
["string", "'ä'"], | ||
["string", "'本'"], | ||
["string", "'À'"], | ||
["string", "'\\''"], | ||
["string", "'\"\"'"], | ||
["string", "'Hello,\r\nworld!'"], | ||
|
||
["string", "\"\\n\""], | ||
["string", "\"\\\"\""], | ||
["string", "\"Hello,\r\nworld!\""], | ||
["string", "\"日本語\""] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Jexl strings can contain special characters, and even linebreaks. |
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,51 @@ | ||
"foo"|bar | ||
"foo"| bar | ||
"foo" | ||
| | ||
bar | ||
|
||
foo|Ý | ||
|
||
foo|bar() | ||
foo|bar(1,2) | ||
foo|bar( | ||
1,2 | ||
) | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["string", "\"foo\""], ["transform", "|bar"], | ||
["string", "\"foo\""], ["transform", "| bar"], | ||
["string", "\"foo\""], | ||
["transform", "| \r\nbar"], | ||
|
||
"\r\n\r\nfoo", ["transform", "|Ý"], | ||
|
||
"\r\n\r\nfoo", | ||
["transform", "|bar"], | ||
["punctuation", "("], | ||
["punctuation", ")"], | ||
|
||
"\r\nfoo", | ||
["transform", "|bar"], | ||
["punctuation", "("], | ||
["number", "1"], | ||
["punctuation", ","], | ||
["number", "2"], | ||
["punctuation", ")"], | ||
|
||
"\r\nfoo", | ||
["transform", "|bar"], | ||
["punctuation", "("], | ||
|
||
["number", "1"], | ||
["punctuation", ","], | ||
["number", "2"], | ||
|
||
["punctuation", ")"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for transforms. Transforms follow the same naming rules as functions. |