From 77e2e9a4e847e0284253c80c68dd2bce6efd91fc Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Sat, 12 Aug 2017 17:34:43 -0700 Subject: [PATCH] Update PHP grammar --- extensions/php/syntaxes/php.tmLanguage.json | 151 +++++++++++++++----- 1 file changed, 114 insertions(+), 37 deletions(-) diff --git a/extensions/php/syntaxes/php.tmLanguage.json b/extensions/php/syntaxes/php.tmLanguage.json index 121891ebc67..c5bffdce60a 100644 --- a/extensions/php/syntaxes/php.tmLanguage.json +++ b/extensions/php/syntaxes/php.tmLanguage.json @@ -1,10 +1,10 @@ { "information_for_contributors": [ - "This file has been converted from https://github.com/roblourens/language-php/blob/vscode_1.15/grammars/php.cson", + "This file has been converted from https://github.com/atom/language-php/blob/master/grammars/php.cson", "If you want to provide a fix or improvement, please create a pull request against the original repository.", "Once accepted there, we are happy to receive an update request." ], - "version": "https://github.com/roblourens/language-php/commit/91d50ab5f871ea2d11b4c511dc0b9a972e4ac5ce", + "version": "https://github.com/atom/language-php/commit/2091139972d9a5022213697e5ce774cb19053925", "scopeName": "text.html.php", "name": "PHP", "fileTypes": [ @@ -658,7 +658,7 @@ "function-call": { "patterns": [ { - "begin": "(?i)(\\\\?[a-z_\\x{7f}-\\x{ff}][a-z0-9_\\x{7f}-\\x{ff}]*\\\\[a-z_\\x{7f}-\\x{ff}][a-z0-9_\\x{7f}-\\x{ff}]*)\\s*(\\()", + "begin": "(?xi)\n(\n \\\\?\\b # Optional root namespace\n [a-z_\\x{7f}-\\x{ff}][a-z0-9_\\x{7f}-\\x{ff}]* # First namespace\n (?:\\\\[a-z_\\x{7f}-\\x{ff}][a-z0-9_\\x{7f}-\\x{ff}]*)+ # Additional namespaces\n)\\s*(\\()", "beginCaptures": { "1": { "patterns": [ @@ -692,7 +692,11 @@ "begin": "(?i)(\\\\)?\\b([a-z_\\x{7f}-\\x{ff}][a-z0-9_\\x{7f}-\\x{ff}]*)\\s*(\\()", "beginCaptures": { "1": { - "name": "punctuation.separator.inheritance.php" + "patterns": [ + { + "include": "#namespace" + } + ] }, "2": { "patterns": [ @@ -1523,19 +1527,72 @@ ] }, { - "begin": "(?i)(?:^|(?<=<\\?php))\\s*(namespace)\\b\\s+(?=([a-z0-9_\\x{7f}-\\x{ff}\\\\]+\\s*($|[;{]|(/[/*])))|$)", + "match": "(?i)(?:^|(?<=<\\?php))\\s*(namespace)\\s+([a-z0-9_\\x{7f}-\\x{ff}\\\\]+)(?=\\s*;)", + "name": "meta.namespace.php", + "captures": { + "1": { + "name": "keyword.other.namespace.php" + }, + "2": { + "name": "entity.name.type.namespace.php", + "patterns": [ + { + "match": "\\\\", + "name": "punctuation.separator.inheritance.php" + } + ] + } + } + }, + { + "begin": "(?i)(?:^|(?<=<\\?php))\\s*(namespace)\\s+", "beginCaptures": { "1": { "name": "keyword.other.namespace.php" } }, - "contentName": "entity.name.type.namespace.php", - "end": "(?i)(?=\\s*$|[^a-z0-9_\\x{7f}-\\x{ff}\\\\])", + "end": "(?<=})", "name": "meta.namespace.php", "patterns": [ { - "match": "\\\\", - "name": "punctuation.separator.inheritance.php" + "include": "#comments" + }, + { + "match": "(?i)[a-z0-9_\\x{7f}-\\x{ff}\\\\]+", + "name": "entity.name.type.namespace.php", + "captures": { + "0": { + "patterns": [ + { + "match": "\\\\", + "name": "punctuation.separator.inheritance.php" + } + ] + } + } + }, + { + "begin": "{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.namespace.begin.bracket.curly.php" + } + }, + "end": "}", + "endCaptures": { + "0": { + "name": "punctuation.definition.namespace.end.bracket.curly.php" + } + }, + "patterns": [ + { + "include": "#language" + } + ] + }, + { + "match": "[^\\s]+", + "name": "invalid.illegal.identifier.php" } ] }, @@ -1553,38 +1610,26 @@ "name": "meta.use.php", "patterns": [ { - "include": "#comments" - }, - { - "begin": "(?i)\\s*(?=[a-z0-9_\\x{7f}-\\x{ff}\\\\])", - "end": "(?i)(?:\\s*(as)\\s+([a-z0-9_\\x{7f}-\\x{ff}]*))?\\s*(?=,|;|$)", + "begin": "{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.use.group.begin.bracket.curly.php" + } + }, + "end": "}", "endCaptures": { - "1": { - "name": "keyword.other.use-as.php" - }, - "2": { - "name": "support.other.namespace.use-as.php" + "0": { + "name": "punctuation.definition.use.group.end.bracket.curly.php" } }, "patterns": [ { - "include": "#class-builtin" - }, - { - "begin": "(?i)\\s*(?=[a-z0-9_\\x{7f}-\\x{ff}\\\\])", - "end": "$|(?=[\\s,;])", - "name": "support.other.namespace.use.php", - "patterns": [ - { - "match": "\\\\", - "name": "punctuation.separator.inheritance.php" - } - ] + "include": "#use-inner" } ] }, { - "match": "\\s*,\\s*" + "include": "#use-inner" } ] }, @@ -1960,7 +2005,7 @@ } }, { - "match": "(?i)\\b(array|real|double|float|int(eger)?|bool(ean)?|string|class|clone|var|function|interface|trait|parent|self|object)\\b", + "match": "(?i)\\b(array|real|double|float|int(eger)?|bool(ean)?|string|class|var|function|interface|trait|parent|self|object)\\b", "name": "storage.type.php" }, { @@ -1977,6 +2022,10 @@ { "include": "#heredoc" }, + { + "match": "(?i)\\bclone\\b", + "name": "keyword.other.clone.php" + }, { "match": "\\.=?", "name": "keyword.operator.string.php" @@ -2321,7 +2370,7 @@ "match": "(@xlink)\\s+(.+)\\s*$" }, { - "begin": "(@(?:global|param|property(-(read|write))?|return|throws|var))\\s+(?=[A-Za-z_\\x{7f}-\\x{ff}]|\\()", + "begin": "(@(?:global|param|property(-(read|write))?|return|throws|var))\\s+(?=[A-Za-z_\\x{7f}-\\x{ff}\\\\]|\\()", "beginCaptures": { "1": { "name": "keyword.other.phpdoc.php" @@ -2357,7 +2406,7 @@ ] }, "php_doc_types": { - "match": "(?i)[a-z_\\x{7f}-\\x{ff}][a-z0-9_\\x{7f}-\\x{ff}]*(\\|[a-z_\\x{7f}-\\x{ff}][a-z0-9_\\x{7f}-\\x{ff}]*)*", + "match": "(?i)[a-z_\\x{7f}-\\x{ff}\\\\][a-z0-9_\\x{7f}-\\x{ff}\\\\]*(\\|[a-z_\\x{7f}-\\x{ff}\\\\][a-z0-9_\\x{7f}-\\x{ff}\\\\]*)*", "captures": { "0": { "patterns": [ @@ -2383,7 +2432,7 @@ "name": "punctuation.definition.type.begin.bracket.round.phpdoc.php" } }, - "end": "(\\))(\\[\\])", + "end": "(\\))(\\[\\])|(?=\\*/)", "endCaptures": { "1": { "name": "punctuation.definition.type.end.bracket.round.phpdoc.php" @@ -2409,7 +2458,7 @@ ] }, "php_doc_types_array_single": { - "match": "(?i)([a-z_\\x{7f}-\\x{ff}][a-z0-9_\\x{7f}-\\x{ff}]*)(\\[\\])", + "match": "(?i)([a-z_\\x{7f}-\\x{ff}\\\\][a-z0-9_\\x{7f}-\\x{ff}\\\\]*)(\\[\\])", "captures": { "1": { "patterns": [ @@ -3329,6 +3378,34 @@ } ] }, + "use-inner": { + "patterns": [ + { + "include": "#comments" + }, + { + "begin": "(?i)\\b(as)\\s+", + "beginCaptures": { + "1": { + "name": "keyword.other.use-as.php" + } + }, + "end": "(?i)[a-z_\\x{7f}-\\x{ff}][a-z0-9_\\x{7f}-\\x{ff}]*", + "endCaptures": { + "0": { + "name": "support.other.namespace.use-as.php" + } + } + }, + { + "include": "#class-name" + }, + { + "match": ",", + "name": "punctuation.definition.separator.delimiter.php" + } + ] + }, "var_basic": { "patterns": [ {