From 64fd8f8720830ab698c35e56003f7bdebc78ef73 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Thu, 17 Aug 2017 15:22:06 +0200 Subject: [PATCH] [python] update grammar --- .../syntaxes/MagicPython.tmLanguage.json | 85 ++++++++++------- .../syntaxes/MagicRegExp.tmLanguage.json | 33 ++++++- .../python/test/colorize-results/test_py.json | 95 +++++++++++++++++-- 3 files changed, 167 insertions(+), 46 deletions(-) diff --git a/extensions/python/syntaxes/MagicPython.tmLanguage.json b/extensions/python/syntaxes/MagicPython.tmLanguage.json index 3a9f24cc41e..812ddf97357 100644 --- a/extensions/python/syntaxes/MagicPython.tmLanguage.json +++ b/extensions/python/syntaxes/MagicPython.tmLanguage.json @@ -4,7 +4,7 @@ "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/MagicStack/MagicPython/commit/976e59dcb78cb577e79c8f2117216c06718337e0", + "version": "https://github.com/MagicStack/MagicPython/commit/b453f26ed856c9b16a053517c41207e3a72cc7d5", "name": "MagicPython", "scopeName": "source.python", "fileTypes": [ @@ -260,14 +260,6 @@ } } }, - "codetags": { - "match": "(?:\\b(NOTE|XXX|HACK|FIXME|BUG|TODO)\\b)", - "captures": { - "1": { - "name": "keyword.codetag.notation.python" - } - } - }, "statement-keyword": { "patterns": [ { @@ -392,8 +384,13 @@ ] }, "member-access": { - "begin": "\\.\\s*(?!\\.)", + "begin": "(\\.)\\s*(?!\\.)", "end": "(?x)\n # stop when you've just read non-whitespace followed by non-word\n # i.e. when finished reading an identifier or function call\n (?<=\\S)(?=\\W) |\n # stop when seeing the start of something that's not a word,\n # i.e. when seeing a non-identifier\n (^|(?<=\\s))(?=[^\\\\\\w\\s]) |\n $\n", + "beginCaptures": { + "1": { + "name": "punctuation.separator.period.python" + } + }, "patterns": [ { "include": "#function-call" @@ -918,29 +915,6 @@ } ] }, - "fstring-formatting-braces": { - "patterns": [ - { - "comment": "empty braces are illegal", - "match": "({)(\\s*?)(})", - "captures": { - "1": { - "name": "constant.character.format.placeholder.other.python" - }, - "2": { - "name": "invalid.illegal.brace.python" - }, - "3": { - "name": "constant.character.format.placeholder.other.python" - } - } - }, - { - "name": "constant.character.escape.python", - "match": "({{|}})" - } - ] - }, "fstring-formatting-singe-brace": { "name": "invalid.illegal.brace.python", "match": "(}(?!}))" @@ -949,11 +923,14 @@ "comment": "Import statements\n", "patterns": [ { - "match": "(?x)\n \\s* \\b(from)\\b (\\s*\\.+\\s*) (import)?\n", + "match": "(?x)\n \\s* \\b(from)\\b \\s*(\\.+)\\s* (import)?\n", "captures": { "1": { "name": "keyword.control.import.python" }, + "2": { + "name": "punctuation.separator.period.python" + }, "3": { "name": "keyword.control.import.python" } @@ -1077,8 +1054,13 @@ } }, "member-access-class": { - "begin": "\\.\\s*(?!\\.)", + "begin": "(\\.)\\s*(?!\\.)", "end": "(?<=\\S)(?=\\W)|$", + "beginCaptures": { + "1": { + "name": "punctuation.separator.period.python" + } + }, "patterns": [ { "include": "#call-wrapper-inheritance" @@ -1671,7 +1653,7 @@ }, "magic-variable-names": { "comment": "magic variables which a class/module may have.", - "match": "(?x)\n \\b(\n __(?:\n all | bases | builtins | class | code | debug | defaults | dict\n | doc | file | func | kwdefaults | members\n | metaclass | methods | module | mro | name\n | qualname | self | signature | slots | subclasses\n | version | weakref | wrapped | annotations | classcell\n | spec | path | package | future\n )__\n )\\b\n", + "match": "(?x)\n \\b(\n __(?:\n all | bases | builtins | class | code | debug | defaults | dict\n | doc | file | func | kwdefaults | members\n | metaclass | methods | module | mro | name\n | qualname | self | signature | slots | subclasses\n | version | weakref | wrapped | annotations | classcell\n | spec | path | package | future | traceback\n )__\n )\\b\n", "captures": { "1": { "name": "support.variable.magic.python" @@ -1769,6 +1751,29 @@ } ] }, + "fstring-formatting-braces": { + "patterns": [ + { + "comment": "empty braces are illegal", + "match": "({)(\\s*?)(})", + "captures": { + "1": { + "name": "constant.character.format.placeholder.other.python" + }, + "2": { + "name": "invalid.illegal.brace.python" + }, + "3": { + "name": "constant.character.format.placeholder.other.python" + } + } + }, + { + "name": "constant.character.escape.python", + "match": "({{|}})" + } + ] + }, "regexp-base-common": { "patterns": [ { @@ -1891,6 +1896,14 @@ } ] }, + "codetags": { + "match": "(?:\\b(NOTE|XXX|HACK|FIXME|BUG|TODO)\\b)", + "captures": { + "1": { + "name": "keyword.codetag.notation.python" + } + } + }, "comments-base": { "name": "comment.line.number-sign.python", "begin": "(\\#)", diff --git a/extensions/python/syntaxes/MagicRegExp.tmLanguage.json b/extensions/python/syntaxes/MagicRegExp.tmLanguage.json index c6c74610836..0de066f3677 100644 --- a/extensions/python/syntaxes/MagicRegExp.tmLanguage.json +++ b/extensions/python/syntaxes/MagicRegExp.tmLanguage.json @@ -4,7 +4,7 @@ "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/MagicStack/MagicPython/commit/df5bb18c64252f2e7b1aa87e2ed124666d314f1d", + "version": "https://github.com/MagicStack/MagicPython/commit/361a4964a559481330764a447e7bab88d4f1b01b", "name": "MagicRegExp", "scopeName": "source.regexp.python", "fileTypes": [ @@ -43,6 +43,29 @@ } ] }, + "fstring-formatting-braces": { + "patterns": [ + { + "comment": "empty braces are illegal", + "match": "({)(\\s*?)(})", + "captures": { + "1": { + "name": "constant.character.format.placeholder.other.python" + }, + "2": { + "name": "invalid.illegal.brace.python" + }, + "3": { + "name": "constant.character.format.placeholder.other.python" + } + } + }, + { + "name": "constant.character.escape.python", + "match": "({{|}})" + } + ] + }, "regexp-base-common": { "patterns": [ { @@ -165,6 +188,14 @@ } ] }, + "codetags": { + "match": "(?:\\b(NOTE|XXX|HACK|FIXME|BUG|TODO)\\b)", + "captures": { + "1": { + "name": "keyword.codetag.notation.python" + } + } + }, "regexp-expression": { "patterns": [ { diff --git a/extensions/python/test/colorize-results/test_py.json b/extensions/python/test/colorize-results/test_py.json index 5d58f2c7297..b456114b1ed 100644 --- a/extensions/python/test/colorize-results/test_py.json +++ b/extensions/python/test/colorize-results/test_py.json @@ -407,7 +407,29 @@ } }, { - "c": "banana.size", + "c": "banana", + "t": "source.python", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": ".", + "t": "source.python punctuation.separator.period.python", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "size", "t": "source.python", "r": { "dark_plus": "default: #D4D4D4", @@ -2189,7 +2211,7 @@ } }, { - "c": " g.", + "c": " g", "t": "source.python", "r": { "dark_plus": "default: #D4D4D4", @@ -2199,6 +2221,17 @@ "hc_black": "default: #FFFFFF" } }, + { + "c": ".", + "t": "source.python punctuation.separator.period.python", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, { "c": "next", "t": "source.python meta.function-call.python meta.function-call.generic.python", @@ -4499,7 +4532,18 @@ } }, { - "c": ".fn ", + "c": ".", + "t": "source.python punctuation.separator.period.python", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "fn ", "t": "source.python", "r": { "dark_plus": "default: #D4D4D4", @@ -4554,7 +4598,18 @@ } }, { - "c": ".memo ", + "c": ".", + "t": "source.python punctuation.separator.period.python", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "memo ", "t": "source.python", "r": { "dark_plus": "default: #D4D4D4", @@ -4829,7 +4884,18 @@ } }, { - "c": ".memo", + "c": ".", + "t": "source.python punctuation.separator.period.python", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "memo", "t": "source.python", "r": { "dark_plus": "default: #D4D4D4", @@ -4874,7 +4940,7 @@ }, { "c": ".", - "t": "source.python", + "t": "source.python punctuation.separator.period.python", "r": { "dark_plus": "default: #D4D4D4", "light_plus": "default: #000000", @@ -4973,7 +5039,7 @@ }, { "c": ".", - "t": "source.python", + "t": "source.python punctuation.separator.period.python", "r": { "dark_plus": "default: #D4D4D4", "light_plus": "default: #000000", @@ -5083,7 +5149,7 @@ }, { "c": ".", - "t": "source.python", + "t": "source.python punctuation.separator.period.python", "r": { "dark_plus": "default: #D4D4D4", "light_plus": "default: #000000", @@ -5159,7 +5225,7 @@ } }, { - "c": " re.", + "c": " re", "t": "source.python", "r": { "dark_plus": "default: #D4D4D4", @@ -5169,6 +5235,17 @@ "hc_black": "default: #FFFFFF" } }, + { + "c": ".", + "t": "source.python punctuation.separator.period.python", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, { "c": "search", "t": "source.python meta.function-call.python meta.function-call.generic.python",