-
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 DataWeave language (#2659)
- Loading branch information
Showing
18 changed files
with
502 additions
and
2 deletions.
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,41 @@ | ||
(function (Prism) { | ||
Prism.languages.dataweave = { | ||
'url': /\b[A-Za-z]+:\/\/[\w/:.?=&-]+|\burn:[\w:.?=&-]+/, | ||
'property': { | ||
pattern: /(?:\w+#)?(?:"(?:\\.|[^\\"\r\n])*"|\w+)(?=\s*[:@])/, | ||
greedy: true | ||
}, | ||
'string': { | ||
pattern: /(["'`])(?:\\[\s\S]|(?!\1)[^\\])*\1/, | ||
greedy: true | ||
}, | ||
'mime-type': /\b(?:text|audio|video|application|multipart|image)\/[\w+-]+/, | ||
'date': { | ||
pattern: /\|[\w:+-]+\|/, | ||
greedy: true | ||
}, | ||
'comment': [ | ||
{ | ||
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, | ||
lookbehind: true, | ||
greedy: true | ||
}, | ||
{ | ||
pattern: /(^|[^\\:])\/\/.*/, | ||
lookbehind: true, | ||
greedy: true | ||
} | ||
], | ||
'regex': { | ||
pattern: /\/(?:[^\\\/\r\n]|\\[^\r\n])+\//, | ||
greedy: true | ||
}, | ||
'function': /\b[A-Za-z_]\w*(?=\s*\()/i, | ||
'number': /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i, | ||
'punctuation': /[{}[\];(),.:@]/, | ||
'operator': /<<|>>|->|[<>~=]=?|!=|--?-?|\+\+?|\!|\?/, | ||
'boolean': /\b(?:true|false)\b/, | ||
'keyword': /\b(?:match|input|output|ns|type|update|null|if|else|using|unless|at|is|as|case|do|fun|var|not|and|or)\b/ | ||
}; | ||
|
||
}(Prism)); |
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,39 @@ | ||
<h2>Full example</h2> | ||
<pre><code> | ||
%dw 2.0 | ||
input payalod application/json | ||
ns ns0 http://localhost.com | ||
var a = 123 | ||
type T = String | ||
fun test(a: Number) = a + 123 | ||
output application/json | ||
--- | ||
{ | ||
// This is a comment | ||
/** | ||
This is a multiline comment | ||
**/ | ||
name: payload.name, | ||
string: "this", | ||
'another string': true, | ||
"regex": /123/, | ||
fc: test(1), | ||
"dates": |12-12-2020-T12:00:00|, | ||
number: 123, | ||
"null": null, | ||
|
||
a: {} match { | ||
case is {} -> foo.name | ||
}, | ||
b: {} update { | ||
case name at .user.name -> "123" | ||
}, | ||
stringMultiLine: "This is a multiline | ||
string | ||
", | ||
a: if( !true > 2) a else 2, | ||
b: do { | ||
{} | ||
} | ||
} | ||
</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
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,12 @@ | ||
true | ||
false | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["boolean", "true"], | ||
["boolean", "false"] | ||
] | ||
|
||
---------------------------------------------------- | ||
Check for boolean |
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 @@ | ||
// Line comment "" | ||
/* Block comment */ | ||
/** | ||
* MultiLine Comment | ||
**/ | ||
/* "" */ | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", "// Line comment \"\"\t"], | ||
["comment", "/* Block comment */"], | ||
["comment", "/**\r\n\t* MultiLine Comment\r\n\t**/"], | ||
["comment", "/* \"\" */"] | ||
] | ||
---------------------------------------------------- | ||
Check 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,27 @@ | ||
|12-12-2001-T12:00:00| | ||
|12-12-2001-T12:00:00+03:00| | ||
|12-12-2001-T12:00:00Z| | ||
|12-12-2001| | ||
|12:00:00| | ||
|12:00:00Z| | ||
|12:00:00-03:00| | ||
|P1D| | ||
|P1Y1D| | ||
|P1Y1D2H3M5S| | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["date", "|12-12-2001-T12:00:00|"], | ||
["date", "|12-12-2001-T12:00:00+03:00|"], | ||
["date", "|12-12-2001-T12:00:00Z|"], | ||
["date", "|12-12-2001|"], | ||
["date", "|12:00:00|"], | ||
["date", "|12:00:00Z|"], | ||
["date", "|12:00:00-03:00|"], | ||
["date", "|P1D|"], | ||
["date", "|P1Y1D|"], | ||
["date", "|P1Y1D2H3M5S|"] | ||
] | ||
---------------------------------------------------- | ||
Check for date |
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,28 @@ | ||
myfunction(a, b,123) | ||
payload.myFunction(1,2,3) | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["function", "myfunction"], | ||
["punctuation", "("], | ||
"a", | ||
["punctuation", ","], | ||
" b", | ||
["punctuation", ","], | ||
["number", "123"], | ||
["punctuation", ")"], | ||
|
||
"\npayload", | ||
["punctuation", "."], | ||
["function", "myFunction"], | ||
["punctuation", "("], | ||
["number", "1"], | ||
["punctuation", ","], | ||
["number", "2"], | ||
["punctuation", ","], | ||
["number", "3"], | ||
["punctuation", ")"] | ||
] | ||
---------------------------------------------------- | ||
Check for functions |
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,124 @@ | ||
%dw 2.0 | ||
input payalod application/json | ||
ns ns0 http://localhost.com | ||
var a = 123 | ||
type T = String | ||
fun test(a: Number) = a + 123 | ||
output application/json | ||
--- | ||
{} match { | ||
case a is String -> x as String | ||
} | ||
update { | ||
case a at .name -> | ||
} | ||
if(true or false and not true) do { | ||
|
||
} | ||
else | ||
payload match { | ||
case a is String -> x as String | ||
} | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
"%dw ", | ||
["number", "2.0"], | ||
|
||
["keyword", "input"], | ||
" payalod ", | ||
["mime-type", "application/json"], | ||
|
||
["keyword", "ns"], | ||
" ns0 ", | ||
["url", "http://localhost.com"], | ||
|
||
["keyword", "var"], | ||
" a ", | ||
["operator", "="], | ||
["number", "123"], | ||
|
||
["keyword", "type"], | ||
" T ", | ||
["operator", "="], | ||
" String\n", | ||
|
||
["keyword", "fun"], | ||
["function", "test"], | ||
["punctuation", "("], | ||
["property", "a"], | ||
["punctuation", ":"], | ||
" Number", | ||
["punctuation", ")"], | ||
["operator", "="], | ||
" a ", | ||
["operator", "+"], | ||
["number", "123"], | ||
|
||
["keyword", "output"], | ||
["mime-type", "application/json"], | ||
|
||
["operator", "---"], | ||
|
||
["punctuation", "{"], | ||
["punctuation", "}"], | ||
["keyword", "match"], | ||
["punctuation", "{"], | ||
|
||
["keyword", "case"], | ||
" a ", | ||
["keyword", "is"], | ||
" String ", | ||
["operator", "->"], | ||
" x ", | ||
["keyword", "as"], | ||
" String\n", | ||
|
||
["punctuation", "}"], | ||
|
||
["keyword", "update"], | ||
["punctuation", "{"], | ||
|
||
["keyword", "case"], | ||
" a ", | ||
["keyword", "at"], | ||
["punctuation", "."], | ||
"name ", | ||
["operator", "->"], | ||
|
||
["punctuation", "}"], | ||
|
||
["function", "if"], | ||
["punctuation", "("], | ||
["boolean", "true"], | ||
["keyword", "or"], | ||
["boolean", "false"], | ||
["keyword", "and"], | ||
["keyword", "not"], | ||
["boolean", "true"], | ||
["punctuation", ")"], | ||
["keyword", "do"], | ||
["punctuation", "{"], | ||
|
||
["punctuation", "}"], | ||
|
||
["keyword", "else"], | ||
|
||
" \npayload ", | ||
["keyword", "match"], | ||
["punctuation", "{"], | ||
|
||
["keyword", "case"], | ||
" a ", | ||
["keyword", "is"], | ||
" String ", | ||
["operator", "->"], | ||
" x ", | ||
["keyword", "as"], | ||
" String\n", | ||
|
||
["punctuation", "}"] | ||
] | ||
---------------------------------------------------- | ||
Check for 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,9 @@ | ||
null | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "null"] | ||
] | ||
---------------------------------------------------- | ||
Check for null |
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,25 @@ | ||
0 | ||
123 | ||
3.14159 | ||
5.0e8 | ||
0.2E+2 | ||
47e-5 | ||
-1.23 | ||
-2.34E33 | ||
-4.34E-33 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["number", "0"], | ||
["number", "123"], | ||
["number", "3.14159"], | ||
["number", "5.0e8"], | ||
["number", "0.2E+2"], | ||
["number", "47e-5"], | ||
["number", "-1.23"], | ||
["number", "-2.34E33"], | ||
["number", "-4.34E-33"] | ||
] | ||
---------------------------------------------------- | ||
Check for number |
Oops, something went wrong.