Skip to content

Commit

Permalink
Added support of for ..., ... in reverse highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyklay committed Jan 2, 2018
1 parent aba8e7f commit ccc9bba
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added
- Added support of `for ..., ... in reverse` highlighting

### Changed
- Improved constants recognition
- Improved support of `this` highlighting
Expand Down
97 changes: 79 additions & 18 deletions syntaxes/zephir.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
"name": "entity.other.inherited-class.zephir"
},
{
"match": ",",
"name": "punctuation.separator.classes.zephir"
"include": "#punctuation-comma"
}
]
},
Expand Down Expand Up @@ -204,8 +203,7 @@
}
},
{
"match": ";",
"name": "punctuation.terminator.expression.zephir"
"include": "#punctuation-semicolon"
},
{
"include": "#use-inner"
Expand Down Expand Up @@ -343,12 +341,10 @@
"include": "#switch_statement"
},
{
"match": "\\s*(?<!\\$)\\b(break|case|continue|declare|default|die|let|var|do|else(if)?|exit|for|fetch|reverse|(?:un)?likely|if|return|match|switch|use|while|loop|yield)\\b",
"captures": {
"1": {
"name": "keyword.control.${1:/downcase}.zephir"
}
}
"include": "#for-loop"
},
{
"include": "#control-flow"
},
{
"begin": "(?i)\\b((?:require|include)(?:_once)?)\\s+",
Expand Down Expand Up @@ -548,8 +544,7 @@
"include": "#object"
},
{
"match": ";",
"name": "punctuation.terminator.expression.zephir"
"include": "#punctuation-semicolon"
},
{
"match": ":",
Expand Down Expand Up @@ -713,8 +708,7 @@
"include": "#constants"
},
{
"match": ",",
"name": "punctuation.separator.delimiter.zephir"
"include": "#punctuation-comma"
}
],
"repository": {
Expand Down Expand Up @@ -905,8 +899,7 @@
"include": "#comments"
},
{
"match": ",",
"name": "punctuation.separator.delimiter.zephir"
"include": "#punctuation-comma"
},
{
"begin": "(?i)(array)\\s+((&)?\\s*(\\$+)?[a-z_\\x{7f}-\\x{7fffffff}][a-z0-9_\\x{7f}-\\x{7fffffff}]*)\\s*(=)\\s*(array)\\s*(\\()",
Expand Down Expand Up @@ -1597,6 +1590,14 @@
}
]
},
"punctuation-semicolon": {
"name": "punctuation.terminator.statement.zephir",
"match": ";"
},
"punctuation-comma": {
"name": "punctuation.separator.comma.zephir",
"match": ","
},
"regex-double-quoted": {
"begin": "\"/(?=(\\\\.|[^\"/])++/[imsxeADSUXu]*\")",
"beginCaptures": {
Expand Down Expand Up @@ -1777,8 +1778,7 @@
"include": "#class-name"
},
{
"match": ",",
"name": "punctuation.separator.delimiter.zephir"
"include": "#punctuation-comma"
}
]
},
Expand Down Expand Up @@ -1936,6 +1936,67 @@
}
]
},
"control-flow": {
"match": "\\s*(?<!\\$)\\b(break|case|continue|declare|default|die|let|var|do|else(if)?|exit|fetch|(?:un)?likely|if|return|match|switch|use|while|loop|yield)\\b",
"captures": {
"1": {
"name": "keyword.control.${1:/downcase}.zephir"
}
}
},
"for-loop": {
"name": "meta.loop.zephir",
"begin": "(?<!->|\\$)\\b(for)\\b(?:\\s*(\\())?\\s*",
"beginCaptures": {
"1": {
"name": "keyword.control.loop.zephir"
},
"2": {
"name": "meta.brace.round.zephir"
}
},
"end": "(?:\\s*(\\)))?\\s*(\\{)",
"endCaptures": {
"1": {
"name": "meta.brace.round.zephir"
},
"2": {
"name": "punctuation.definition.block.zephir"
}
},
"patterns": [
{
"include": "#comments"
},
{
"begin": "(,)\\s*(?!\\S)",
"beginCaptures": {
"1": {
"name": "punctuation.separator.comma.zephir"
}
},
"end": "(?<!,)((?=(\\s+(in)\\s+(reverse\\s+)?)|^\\s*$))|((?<=\\S)(?=\\s*$))",
"patterns": [
{
"include": "#comments"
},
{
"include": "#variable-name"
}
]
},
{
"include": "#function-call"
},
{
"include": "#punctuation-comma"
},
{
"match": "\\b(in|reverse)\\b",
"name": "keyword.operator.expression.${1:/downcase}.zephir"
}
]
},
"null_coalescing": {
"match": "\\?\\?",
"name": "keyword.operator.null-coalescing.zephir"
Expand Down

0 comments on commit ccc9bba

Please sign in to comment.