mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-28 17:20:22 +00:00
Add DataWeave language (#3804)
* Add DataWeave language * Add Licence * Update to latest DataWeave revision
This commit is contained in:
committed by
Colin Seymour
parent
5d48ccd757
commit
fc1404985a
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -869,6 +869,9 @@
|
||||
[submodule "vendor/grammars/sublime-nearley"]
|
||||
path = vendor/grammars/sublime-nearley
|
||||
url = https://github.com/Hardmath123/sublime-nearley
|
||||
[submodule "vendor/grammars/data-weave-tmLanguage"]
|
||||
path = vendor/grammars/data-weave-tmLanguage
|
||||
url = https://github.com/mulesoft-labs/data-weave-tmLanguage
|
||||
[submodule "vendor/grammars/squirrel-language"]
|
||||
path = vendor/grammars/squirrel-language
|
||||
url = https://github.com/mathewmariani/squirrel-language
|
||||
|
||||
@@ -252,6 +252,8 @@ vendor/grammars/d.tmbundle:
|
||||
vendor/grammars/dartlang:
|
||||
- source.dart
|
||||
- source.yaml-ext
|
||||
vendor/grammars/data-weave-tmLanguage:
|
||||
- source.data-weave
|
||||
vendor/grammars/desktop.tmbundle:
|
||||
- source.desktop
|
||||
vendor/grammars/diff.tmbundle:
|
||||
|
||||
@@ -988,6 +988,14 @@ Dart:
|
||||
codemirror_mode: dart
|
||||
codemirror_mime_type: application/dart
|
||||
language_id: 87
|
||||
DataWeave:
|
||||
type: programming
|
||||
color: "#003a52"
|
||||
extensions:
|
||||
- ".dwl"
|
||||
ace_mode: text
|
||||
tm_scope: source.data-weave
|
||||
language_id: 974514097
|
||||
Diff:
|
||||
type: data
|
||||
extensions:
|
||||
@@ -1488,8 +1496,8 @@ Gerber Image:
|
||||
- ".gtp"
|
||||
- ".gts"
|
||||
interpreters:
|
||||
- "gerbv"
|
||||
- "gerbview"
|
||||
- gerbv
|
||||
- gerbview
|
||||
tm_scope: source.gerber
|
||||
ace_mode: text
|
||||
language_id: 404627610
|
||||
|
||||
12
samples/DataWeave/customInterpolator.dwl
Normal file
12
samples/DataWeave/customInterpolator.dwl
Normal file
@@ -0,0 +1,12 @@
|
||||
fun SQL(literals, parts) = ''
|
||||
---
|
||||
[
|
||||
SQL `SELECT * FROM table WHERE id = $(1) AND name = $('a')`,
|
||||
SQL `$('p')`,
|
||||
SQL `$('a')$('b')`,
|
||||
SQL `$('a')---$('b')`,
|
||||
SQL `---$('a')---$('b')---`,
|
||||
SQL `$('p')bbb`,
|
||||
SQL `aaa$('p')`,
|
||||
SQL `aaa$('p')bbb`
|
||||
]
|
||||
9
samples/DataWeave/directives.dwl
Normal file
9
samples/DataWeave/directives.dwl
Normal file
@@ -0,0 +1,9 @@
|
||||
%dw 2.0
|
||||
var number = 1234
|
||||
fun foo(func,name="Mariano") = func(name)
|
||||
input payload application/test arg="value"
|
||||
output application/json
|
||||
---
|
||||
{
|
||||
foo: "bar"
|
||||
}
|
||||
27
samples/DataWeave/functions.dwl
Normal file
27
samples/DataWeave/functions.dwl
Normal file
@@ -0,0 +1,27 @@
|
||||
%dw 2.0
|
||||
var x=(param1, param2) -> { "$param1": param2 }
|
||||
var y=(param1, param2 = "c") -> { "$param1": param2 }
|
||||
var toUser = (user) -> { name: user.name, lastName: user.lastName }
|
||||
fun z(param1, param2) = { "$param1": param2 }
|
||||
var a = { name: "Mariano" , toUser: ((param1, param2) -> { "$param1": param2 }) }
|
||||
var applyFirst = (array, func) -> (func(array[0]) ++ array[1 to -1])
|
||||
|
||||
var nested = (array, func) -> (a) -> (b) -> (c) -> array map func(a ++ b ++ c)
|
||||
|
||||
|
||||
fun f2(a1, a2) = ""
|
||||
fun f3(a1:String, a2:Number):String = a1
|
||||
fun f4(a1:String, a2:(a:Number) -> Number):String = a1
|
||||
---
|
||||
result: {
|
||||
a: x("a", "b"),
|
||||
b: y("a"),
|
||||
c: y("a", "b"),
|
||||
users: { (in1 map ((user) -> { user: (toUser(user) ++ user) })) },
|
||||
d: z("a", "b"),
|
||||
e: a.toUser("name","Mariano"),
|
||||
f: a.toUser("name","Mariano").name,
|
||||
f: applyFirst("mariano", (s) -> upper(s) ),
|
||||
g: [] map (s) -> upper(s),
|
||||
h: 1 f2 2
|
||||
}
|
||||
36
samples/DataWeave/literals.dwl
Normal file
36
samples/DataWeave/literals.dwl
Normal file
@@ -0,0 +1,36 @@
|
||||
%dw 2.0
|
||||
---
|
||||
{
|
||||
"boolean":{
|
||||
"true" : true,
|
||||
"false": false
|
||||
},
|
||||
"Number": {
|
||||
"int": 123,
|
||||
"decimal": 123.23
|
||||
},
|
||||
"string": {
|
||||
"singleQuote" : 'A String',
|
||||
"doubleQuote" : "A String"
|
||||
},
|
||||
"regex": /foo/,
|
||||
"date": {
|
||||
a: |2003-10-01|,
|
||||
b: |2005-045|,
|
||||
c: |2003-W14-3|,
|
||||
d: |23:57:59|,
|
||||
e: |23:57:30.700|,
|
||||
f: |23:50:30Z|,
|
||||
g: |+13:00|,
|
||||
h: |Z|,
|
||||
i: |-02:00|,
|
||||
j: |2005-06-02T15:10:16|,
|
||||
k: |2005-06-02T15:10:16Z|,
|
||||
l: |2005-06-02T15:10:16+03:00|,
|
||||
m: |P12Y7M11D|,
|
||||
n: |P12Y5M|,
|
||||
o: |P45DT9H20M8S|,
|
||||
p: |PT9H20M8S|
|
||||
}
|
||||
}
|
||||
|
||||
33
samples/DataWeave/match.dwl
Normal file
33
samples/DataWeave/match.dwl
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
// Regex Pattern Matching (Can be named or unnamed)
|
||||
a: in0.phones map $ match {
|
||||
case matches /\+(\d+)\s\((\d+)\)\s(\d+\-\d+)/ -> { country: $[0], area: $[1], number: $[2] }
|
||||
case matches /\((\d+)\)\s(\d+\-\d+)/ -> { area: $[1], number: $[2] }
|
||||
case phone matches /\((\d+)\)\s(\d+\-\d+)/ -> { area: phone[1], number: phone[2] }
|
||||
},
|
||||
// Type Pattern Matching (Can be named or unnamed)
|
||||
b: in0.object match {
|
||||
case is Object -> { object: $ }
|
||||
case is Number -> { number: $ }
|
||||
// This is how you name variables if needed
|
||||
case y is Boolean -> { boolean: y }
|
||||
},
|
||||
// Literal Pattern Matching (Can be named or unnamed)
|
||||
c: in0.value match {
|
||||
case "Emiliano" -> { string: $ }
|
||||
case 123 -> { number: $ }
|
||||
// This is how you name variables if needed
|
||||
case value: "Mariano" -> { name: value }
|
||||
},
|
||||
// Boolean Expression Pattern Matching (Always named)
|
||||
d: in0.value match {
|
||||
case x if x > 30 -> { biggerThan30: x }
|
||||
case x if x == 9 -> { nine: x }
|
||||
},
|
||||
// Default matches
|
||||
e: in0.value match {
|
||||
case "Emiliano" -> "string"
|
||||
case 3.14 -> number
|
||||
else -> "1234"
|
||||
}
|
||||
}
|
||||
1
vendor/README.md
vendored
1
vendor/README.md
vendored
@@ -85,6 +85,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
|
||||
- **D:** [textmate/d.tmbundle](https://github.com/textmate/d.tmbundle)
|
||||
- **D-ObjDump:** [nanoant/assembly.tmbundle](https://github.com/nanoant/assembly.tmbundle)
|
||||
- **Dart:** [dart-atom/dartlang](https://github.com/dart-atom/dartlang)
|
||||
- **DataWeave:** [mulesoft-labs/data-weave-tmLanguage](https://github.com/mulesoft-labs/data-weave-tmLanguage)
|
||||
- **desktop:** [Mailaender/desktop.tmbundle](https://github.com/Mailaender/desktop.tmbundle)
|
||||
- **Diff:** [textmate/diff.tmbundle](https://github.com/textmate/diff.tmbundle)
|
||||
- **DM:** [PJB3005/atomic-dreams](https://github.com/PJB3005/atomic-dreams)
|
||||
|
||||
1
vendor/grammars/data-weave-tmLanguage
vendored
Submodule
1
vendor/grammars/data-weave-tmLanguage
vendored
Submodule
Submodule vendor/grammars/data-weave-tmLanguage added at c20cee1c62
27
vendor/licenses/grammar/data-weave-tmLanguage.txt
vendored
Normal file
27
vendor/licenses/grammar/data-weave-tmLanguage.txt
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
type: grammar
|
||||
name: data-weave-tmLanguage
|
||||
license: mit
|
||||
---
|
||||
Copyright (c) Mulesoft inc
|
||||
All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
Reference in New Issue
Block a user