Skip to content

Commit

Permalink
[PHP] Add support for "match" expression
Browse files Browse the repository at this point in the history
https://wiki.php.net/rfc/match_expression_v2

Signed-off-by: Jack Cherng <jfcherng@gmail.com>
  • Loading branch information
jfcherng committed Jun 20, 2020
1 parent 7c90530 commit b76caad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions PHP/PHP Source.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ contexts:
\b(?xi:
break | case | continue | declare | default | die | do | else |
elseif | enddeclare | endfor | endforeach | endif | endswitch | endwhile | exit |
for | foreach | if | return | switch | use | while
for | foreach | if | match | return | switch | use | while
)\b
scope: keyword.control.php
- match: \b(catch)\b\s*\(\s*
Expand Down Expand Up @@ -435,7 +435,7 @@ contexts:
SplFixedArray | SplFloat | SplHeap | SplInt | SplMaxHeap | SplMinHeap | SplObjectStorage | SplObserver |
SplPriorityQueue | SplQueue | SplStack | SplString | SplSubject | SplTempFileObject | Stringable | Swish | SwishResult |
SwishResults | SwishSearch | TokyoTyrant | TokyoTyrantQuery | TokyoTyrantTable | Transliterator | Traversable | TypeError | UnderflowException |
UnexpectedValueException | V8Js | V8JsException | ValueError | WeakMap | WeakReference | XMLReader | XMLWriter | XSLTProcessor | ZipArchive |
UnexpectedValueException | UnhandledMatchError | V8Js | V8JsException | ValueError | WeakMap | WeakReference | XMLReader | XMLWriter | XSLTProcessor | ZipArchive |
finfo | mysqli | mysqli_driver | mysqli_result | mysqli_stmt | mysqli_warning | stdClass | streamWrapper | tidy | tidyNode
)\b
captures:
Expand Down
18 changes: 18 additions & 0 deletions PHP/syntax_test_php.php
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,24 @@ function generate2()
//^^^^^^^ keyword.control.php - entity.name.label.php
}

$statement = match ($this->lexer->lookahead['type']) {
// ^^^^^ keyword.control
Lexer::T_UPDATE => $this->UpdateStatement(),
// ^^^^^ support.class
// ^^ punctuation.accessor.double-colon
// ^^^^^^^^ constant.other.class
// ^^ keyword.operator.key
// ^^^^^ variable.language
// ^^ punctuation.accessor.arrow
// ^^^^^^^^^^^^^^^ variable.function
// ^^ meta.group
Lexer::T_DELETE => $this->DeleteStatement(),
// ^^ keyword.operator.key
default => $this->syntaxError('UPDATE or DELETE'),
// ^^^^^^^ keyword.control
// ^^ keyword.operator.key
};

$non_sql = "NO SELECT HIGHLIGHTING!";
// ^ string.quoted.double punctuation.definition.string.begin - meta.string-contents
// ^^^^^^^^^^^^^^^^^^^^^^^ meta.string-contents
Expand Down

0 comments on commit b76caad

Please sign in to comment.