Skip to content

Commit

Permalink
Support infix notations
Browse files Browse the repository at this point in the history
  • Loading branch information
menduz committed Oct 4, 2017
1 parent 362f466 commit ad3c9b3
Show file tree
Hide file tree
Showing 15 changed files with 1,674 additions and 104 deletions.
30 changes: 19 additions & 11 deletions DataWeave.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ repository:
variable-reference:
patterns:
- name: variable.other.dw
match: \b(?!(fun|input|output|type|var|ns|import|%dw|private|---)\s)((\+\+|\-\-|[A-Za-z])[a-zA-Z0-9_]*)
match: \b(?!(fun|input|output|type|var|ns|import|%dw|private|---)\b)((\+\+|\-\-|[A-Za-z])[a-zA-Z0-9_]*)
- name: invalid
match: \b(fun|input|output|type|var|ns|import|private)\b
- name: variable.parameter.dw
match: (\$+)

Expand Down Expand Up @@ -127,9 +129,16 @@ repository:
'2': {name: comment.dw}
end: (?=\n)

infix:
name: support.function.dw
# match: (?<!^,|\[|\(|=|\+|>|<|\-|\*|:|\{|case|is|else|not)[ \t]*(?!(var|match|case|else|fun|input|output|is|as|default|ns|import|null|false|true|using|do|not|and|or)\b)(\+\+|\-\-|[a-zA-Z][a-zA-Z_0-9]*)\b(?![,\)}\]\n])
match: (?<!^|,|\[|\(|=|\+|>|<|\-|\*|:|\{|case|is|else|not|as|and|or)(?<=[a-zA-Z0-9_$\}\])"'`|/])\s*(?!(var|match|case|else|fun|input|output|is|as|default|ns|import|null|false|true|using|do|not|and|or)\s)(\+\+|\-\-|[a-zA-Z][a-zA-Z_0-9]*)(\s+|\s*(?=["'/|{]))

expressions:
name: expression
patterns:
- name: keyword.other.dw
match: \b(not)\s+
- include: '#paren-expression'
- include: '#strings'
- include: '#constants'
Expand All @@ -147,6 +156,7 @@ repository:
- include: '#variable-reference'
- include: '#selectors'
- include: '#directives'
- include: '#infix'


generics:
Expand All @@ -170,7 +180,7 @@ repository:
end: (?=\n)
beginCaptures:
'1': {name: storage.type.dw}
'2': {name: variable.language.dw}
'2': {name: entity.name.variable.dw}
patterns:
- begin: (\:\s*)
beginCaptures:
Expand All @@ -185,26 +195,24 @@ repository:

keywords:
patterns:
- name: support.function.dw
match: \s(match)\s(?!\{)
- name: support.function.dw
match: (?<!case)\s*\b(matches)\b
- name: support.function.dw
match: \b(abs|avg|ceil|contains|distinctBy|endsWith|filter|find|flatten|floor|groupBy|isBlank|isDecimal|isEmpty|isEven|isInteger|isLeapYear|isOdd|joinBy|log|lower|map|mapObject|max|maxBy|min|minBy|mod|native|now|orderBy|orderBy|pluck|pluck|pow|random|read|readUrl|reduce|reduce|replace|round|scan|sizeOf|splitBy|sqrt|startsWith|sum|to|trim|typeOf|unzip|upper|with|write|zip)\b
#- name: support.function.dw
# match: \b(abs|avg|ceil|contains|distinctBy|endsWith|filter|find|flatten|floor|groupBy|isBlank|isDecimal|isEmpty|isEven|isInteger|isLeapYear|isOdd|joinBy|log|lower|map|mapObject|max|maxBy|min|minBy|mod|native|now|orderBy|orderBy|pluck|pluck|pow|random|read|readUrl|reduce|reduce|replace|round|scan|sizeOf|splitBy|sqrt|startsWith|sum|to|trim|typeOf|unzip|upper|with|write|zip)\b
- name: keyword.reserved.dw
match: \b(throw|do|for|yield|enum|private|async)\b
match: \b(throw|for|yield|enum|private|async)\b
- name: invalid
match: \b(not)\b
- name: keyword.control.dw
match: \b(if|else|while|for|do|using|unless|default)\b
- name: keyword.operator.comparison.dw
match: (~=|==|!=|===|!==|<=|>=|<|>)
match: (~=|==|!=|!=|<=|>=|<|>)
- name: keyword.operator.assignment.dw
match: (=)
- name: keyword.operator.declaration.dw
match: (:)
- name: keyword.operator.arithmetic.dw
match: (\-|\+|\*|\/)
- name: keyword.other.dw
match: \b(not|and|or)\b
match: \b(and|or)\b

match-block:
name: match-block.expr.dw
Expand Down
51 changes: 31 additions & 20 deletions DataWeave.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,13 @@
<key>name</key>
<string>variable.other.dw</string>
<key>match</key>
<string>\b(?!(fun|input|output|type|var|ns|import|%dw|private|---)\s)((\+\+|\-\-|[A-Za-z])[a-zA-Z0-9_]*)</string>
<string>\b(?!(fun|input|output|type|var|ns|import|%dw|private|---)\b)((\+\+|\-\-|[A-Za-z])[a-zA-Z0-9_]*)</string>
</dict>
<dict>
<key>name</key>
<string>invalid</string>
<key>match</key>
<string>\b(fun|input|output|type|var|ns|import|private)\b</string>
</dict>
<dict>
<key>name</key>
Expand Down Expand Up @@ -382,12 +388,25 @@
<key>end</key>
<string>(?=\n)</string>
</dict>
<key>infix</key>
<dict>
<key>name</key>
<string>support.function.dw</string>
<key>match</key>
<string>(?&lt;!^|,|\[|\(|=|\+|&gt;|&lt;|\-|\*|:|\{|case|is|else|not|as|and|or)(?&lt;=[a-zA-Z0-9_$\}\])"'`|/])\s*(?!(var|match|case|else|fun|input|output|is|as|default|ns|import|null|false|true|using|do|not|and|or)\s)(\+\+|\-\-|[a-zA-Z][a-zA-Z_0-9]*)(\s+|\s*(?=["'/|{]))</string>
</dict>
<key>expressions</key>
<dict>
<key>name</key>
<string>expression</string>
<key>patterns</key>
<array>
<dict>
<key>name</key>
<string>keyword.other.dw</string>
<key>match</key>
<string>\b(not)\s+</string>
</dict>
<dict>
<key>include</key>
<string>#paren-expression</string>
Expand Down Expand Up @@ -456,6 +475,10 @@
<key>include</key>
<string>#directives</string>
</dict>
<dict>
<key>include</key>
<string>#infix</string>
</dict>
</array>
</dict>
<key>generics</key>
Expand Down Expand Up @@ -519,7 +542,7 @@
<key>2</key>
<dict>
<key>name</key>
<string>variable.language.dw</string>
<string>entity.name.variable.dw</string>
</dict>
</dict>
<key>patterns</key>
Expand Down Expand Up @@ -559,27 +582,15 @@
<array>
<dict>
<key>name</key>
<string>support.function.dw</string>
<key>match</key>
<string>\s(match)\s(?!\{)</string>
</dict>
<dict>
<key>name</key>
<string>support.function.dw</string>
<key>match</key>
<string>(?&lt;!case)\s*\b(matches)\b</string>
</dict>
<dict>
<key>name</key>
<string>support.function.dw</string>
<string>keyword.reserved.dw</string>
<key>match</key>
<string>\b(abs|avg|ceil|contains|distinctBy|endsWith|filter|find|flatten|floor|groupBy|isBlank|isDecimal|isEmpty|isEven|isInteger|isLeapYear|isOdd|joinBy|log|lower|map|mapObject|max|maxBy|min|minBy|mod|native|now|orderBy|orderBy|pluck|pluck|pow|random|read|readUrl|reduce|reduce|replace|round|scan|sizeOf|splitBy|sqrt|startsWith|sum|to|trim|typeOf|unzip|upper|with|write|zip)\b</string>
<string>\b(throw|for|yield|enum|private|async)\b</string>
</dict>
<dict>
<key>name</key>
<string>keyword.reserved.dw</string>
<string>invalid</string>
<key>match</key>
<string>\b(throw|do|for|yield|enum|private|async)\b</string>
<string>\b(not)\b</string>
</dict>
<dict>
<key>name</key>
Expand All @@ -591,7 +602,7 @@
<key>name</key>
<string>keyword.operator.comparison.dw</string>
<key>match</key>
<string>(~=|==|!=|===|!==|&lt;=|&gt;=|&lt;|&gt;)</string>
<string>(~=|==|!=|!=|&lt;=|&gt;=|&lt;|&gt;)</string>
</dict>
<dict>
<key>name</key>
Expand All @@ -615,7 +626,7 @@
<key>name</key>
<string>keyword.other.dw</string>
<key>match</key>
<string>\b(not|and|or)\b</string>
<string>\b(and|or)\b</string>
</dict>
</array>
</dict>
Expand Down
Loading

0 comments on commit ad3c9b3

Please sign in to comment.