From 216bba8e4150a86e5e5c398ec94776d8f22bda95 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Wed, 3 Aug 2016 12:13:12 +0200 Subject: [PATCH] Update go grammar to atom/language-go@93594df (2015-12-10). Fixes #9841. --- extensions/go/package.json | 3 + extensions/go/syntaxes/go.json | 1075 ++++++++++++++++---------------- 2 files changed, 554 insertions(+), 524 deletions(-) diff --git a/extensions/go/package.json b/extensions/go/package.json index 190424da466..1b4e598f764 100644 --- a/extensions/go/package.json +++ b/extensions/go/package.json @@ -3,6 +3,9 @@ "version": "0.1.0", "publisher": "vscode", "engines": { "vscode": "*" }, + "scripts": { + "update-grammar": "node ../../build/npm/update-grammar.js atom/language-go grammars/go.cson ./syntaxes/go.json" + }, "contributes": { "languages": [{ "id": "go", diff --git a/extensions/go/syntaxes/go.json b/extensions/go/syntaxes/go.json index 80daa3bd7b6..aac3cac72fe 100644 --- a/extensions/go/syntaxes/go.json +++ b/extensions/go/syntaxes/go.json @@ -1,526 +1,553 @@ { - "scopeName": "source.go", - "name": "Go", - "comment": "Go language", - "fileTypes": [ - "go" - ], - "foldingStartMarker": "({|\\()\\s*$", - "foldingStopMarker": "(}|\\))\\s*$", - "patterns": [ - { - "comment": "Block comments", - "begin": "/\\*", - "end": "\\*/", - "captures": { - "0": { - "name": "punctuation.definition.comment.go" - } - }, - "name": "comment.block.go" - }, - { - "comment": "Line comments", - "begin": "//", - "beginCaptures": { - "0": { - "name": "punctuation.definition.comment.go" - } - }, - "end": "$", - "name": "comment.line.double-slash.go" - }, - { - "comment": "Interpreted string literals", - "begin": "\"", - "beginCaptures": { - "0": { - "name": "punctuation.definition.string.begin.go" - } - }, - "end": "\"", - "endCaptures": { - "0": { - "name": "punctuation.definition.string.end.go" - } - }, - "name": "string.quoted.double.go", - "patterns": [ - { - "include": "#string_escaped_char" - }, - { - "include": "#string_placeholder" - } - ] - }, - { - "comment": "Raw string literals", - "begin": "`", - "beginCaptures": { - "0": { - "name": "punctuation.definition.string.begin.go" - } - }, - "end": "`", - "endCaptures": { - "0": { - "name": "punctuation.definition.string.end.go" - } - }, - "name": "string.quoted.raw.go", - "patterns": [ - { - "include": "#string_placeholder" - } - ] - }, - { - "comment": "Syntax error receiving channels", - "match": "<\\-([\\t ]+)chan\\b", - "captures": { - "1": { - "name": "invalid.illegal.receive-channel.go" - } - } - }, - { - "comment": "Syntax error sending channels", - "match": "\\bchan([\\t ]+)<-", - "captures": { - "1": { - "name": "invalid.illegal.send-channel.go" - } - } - }, - { - "comment": "Syntax error using slices", - "match": "\\[\\](\\s+)", - "captures": { - "1": { - "name": "invalid.illegal.slice.go" - } - } - }, - { - "comment": "Syntax error numeric literals", - "match": "\\b0[0-7]*[89]\\d*\\b", - "name": "invalid.illegal.numeric.go" - }, - { - "comment": "Built-in functions", - "match": "\\b(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)\\b(?=\\()", - "name": "support.function.builtin.go" - }, - { - "comment": "Function declarations", - "match": "^(\\bfunc\\b)(?:\\s+(\\([^\\)]+\\)\\s+)?([a-zA-Z_]\\w*)(?=\\())?", - "captures": { - "1": { - "name": "keyword.function.go" - }, - "2": { - "patterns": [ - { - "include": "#brackets" - }, - { - "include": "#operators" - } - ] - }, - "3": { - "name": "entity.name.function" - } - } - }, - { - "comment": "Functions", - "match": "(\\bfunc\\b)|([a-zA-Z_]\\w*)(?=\\()", - "captures": { - "1": { - "name": "keyword.function.go" - }, - "2": { - "name": "support.function.go" - } - } - }, - { - "comment": "Floating-point literals", - "match": "(\\.\\d+([Ee][-+]\\d+)?i?)\\b|\\b\\d+\\.\\d*(([Ee][-+]\\d+)?i?\\b)?", - "name": "constant.numeric.floating-point.go" - }, - { - "comment": "Integers", - "match": "\\b((0x[0-9a-fA-F]+)|(0[0-7]+i?)|(\\d+([Ee]\\d+)?i?)|(\\d+[Ee][-+]\\d+i?))\\b", - "name": "constant.numeric.integer.go" - }, - { - "comment": "Language constants", - "match": "\\b(true|false|nil|iota)\\b", - "name": "constant.language.go" - }, - { - "comment": "Package declarations", - "match": "(?<=package)\\s+([a-zA-Z_]\\w*)", - "captures": { - "1": { - "name": "entity.name.package.go" - } - } - }, - { - "comment": "Type declarations", - "match": "(?<=type)\\s+([a-zA-Z_]\\w*)", - "captures": { - "1": { - "name": "entity.name.type.go" - } - } - }, - { - "comment": "Shorthand variable declaration and assignments", - "match": "[a-zA-Z_]\\w*(?:,\\s*[a-zA-Z_]\\w*)*(?=\\s*:=)", - "captures": { - "0": { - "patterns": [ - { - "match": "[a-zA-Z_]\\w*", - "name": "variable.other.assignment.go" - }, - { - "include": "#delimiters" - } - ] - } - } - }, - { - "comment": "Assignments to existing variables", - "match": "(?=|<[^<]|>[^>])", - "name": "keyword.operator.comparison.go" - }, - { - "match": "(&&|\\|\\||!)", - "name": "keyword.operator.logical.go" - }, - { - "match": "(=|\\+=|\\-=|\\|=|\\^=|\\*=|/=|:=|%=|<<=|>>=|&\\^=|&=)", - "name": "keyword.operator.assignment.go" - }, - { - "match": "(\\+|\\-|\\*|/|%)", - "name": "keyword.operator.arithmetic.go" - }, - { - "match": "(&(?!\\^)|\\||\\^|&\\^|<<|>>)", - "name": "keyword.operator.arithmetic.bitwise.go" - }, - { - "match": "\\.\\.\\.", - "name": "keyword.operator.ellipsis.go" - } - ] - }, - "runes": { - "patterns": [ - { - "match": "\\'(\\\\([0-7]{3}|[abfnrtv\\\\'\"]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})|\\p{Any})\\'", - "name": "constant.other.rune.go" - }, - { - "match": "\\'.*\\'", - "name": "invalid.illegal.unknown-rune.go" - } - ] - }, - "storage_types": { - "patterns": [ - { - "match": "\\bbool\\b", - "name": "storage.type.boolean.go" - }, - { - "match": "\\bbyte\\b", - "name": "storage.type.byte.go" - }, - { - "match": "\\berror\\b", - "name": "storage.type.error.go" - }, - { - "match": "\\b(complex(64|128)|float(32|64)|u?int(8|16|32|64)?)\\b", - "name": "storage.type.numeric.go" - }, - { - "match": "\\brune\\b", - "name": "storage.type.rune.go" - }, - { - "match": "\\bstring\\b", - "name": "storage.type.string.go" - }, - { - "match": "\\buintptr\\b", - "name": "storage.type.uintptr.go" - } - ] - }, - "string_escaped_char": { - "patterns": [ - { - "match": "\\\\([0-7]{3}|[abfnrtv\\\\'\"]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})", - "name": "constant.character.escape.go" - }, - { - "match": "\\\\[^0-7xuUabfnrtv\\'\"]", - "name": "invalid.illegal.unknown-escape.go" - } - ] - }, - "string_placeholder": { - "patterns": [ - { - "match": "%(\\[\\d+\\])?([\\+#\\-0\\x20]{,2}((\\d+|\\*)?(\\.?(\\d+|\\*|(\\[\\d+\\])\\*?)?(\\[\\d+\\])?)?))?[vT%tbcdoqxXUbeEfFgGsp]", - "name": "constant.other.placeholder.go" - } - ] - }, - "variables": { - "comment": "First add tests and make sure existing tests still pass when changing anything here!", - "patterns": [ - { - "match": "([a-zA-Z_]\\w*(?:,\\s*[a-zA-Z_]\\w*)*)\\s*(=.*)", - "captures": { - "1": { - "patterns": [ - { - "match": "[a-zA-Z_]\\w*", - "name": "variable.other.assignment.go" - }, - { - "include": "#delimiters" - } - ] - }, - "2": { - "patterns": [ - { - "include": "$self" - } - ] - } - } - }, - { - "match": "([a-zA-Z_]\\w*(?:,\\s*[a-zA-Z_]\\w*)*)(\\s+[\\*]?[a-zA-Z_]\\w*\\s*)(=.*)", - "captures": { - "1": { - "patterns": [ - { - "match": "[a-zA-Z_]\\w*", - "name": "variable.other.assignment.go" - }, - { - "include": "#delimiters" - } - ] - }, - "2": { - "patterns": [ - { - "include": "$self" - } - ] - }, - "3": { - "patterns": [ - { - "include": "$self" - } - ] - } - } - }, - { - "match": "([a-zA-Z_]\\w*(?:,\\s*[a-zA-Z_]\\w*)*)(\\s+[\\*]?[a-zA-Z_]\\w*\\s*[^=].*)", - "captures": { - "1": { - "patterns": [ - { - "match": "[a-zA-Z_]\\w*", - "name": "variable.other.declaration.go" - }, - { - "include": "#delimiters" - } - ] - }, - "2": { - "patterns": [ - { - "include": "$self" - } - ] - } - } - } - ] - } - } + "scopeName": "source.go", + "name": "Go", + "comment": "Go language", + "fileTypes": [ + "go" + ], + "foldingStartMarker": "({|\\()\\s*$", + "foldingStopMarker": "(}|\\))\\s*$", + "patterns": [ + { + "comment": "Block comments", + "begin": "/\\*", + "end": "\\*/", + "captures": { + "0": { + "name": "punctuation.definition.comment.go" + } + }, + "name": "comment.block.go" + }, + { + "comment": "Line comments", + "begin": "//", + "beginCaptures": { + "0": { + "name": "punctuation.definition.comment.go" + } + }, + "end": "$", + "name": "comment.line.double-slash.go" + }, + { + "comment": "Interpreted string literals", + "begin": "\"", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.go" + } + }, + "end": "\"", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.go" + } + }, + "name": "string.quoted.double.go", + "patterns": [ + { + "include": "#string_escaped_char" + }, + { + "include": "#string_placeholder" + } + ] + }, + { + "comment": "Raw string literals", + "begin": "`", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.go" + } + }, + "end": "`", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.go" + } + }, + "name": "string.quoted.raw.go", + "patterns": [ + { + "include": "#string_placeholder" + } + ] + }, + { + "comment": "Syntax error receiving channels", + "match": "<\\-([\\t ]+)chan\\b", + "captures": { + "1": { + "name": "invalid.illegal.receive-channel.go" + } + } + }, + { + "comment": "Syntax error sending channels", + "match": "\\bchan([\\t ]+)<-", + "captures": { + "1": { + "name": "invalid.illegal.send-channel.go" + } + } + }, + { + "comment": "Syntax error using slices", + "match": "\\[\\](\\s+)", + "captures": { + "1": { + "name": "invalid.illegal.slice.go" + } + } + }, + { + "comment": "Syntax error numeric literals", + "match": "\\b0[0-7]*[89]\\d*\\b", + "name": "invalid.illegal.numeric.go" + }, + { + "comment": "Built-in functions", + "match": "\\b(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)\\b(?=\\()", + "name": "support.function.builtin.go" + }, + { + "comment": "Function declarations", + "match": "^(\\bfunc\\b)(?:\\s+(\\([^\\)]+\\)\\s+)?([a-zA-Z_]\\w*)(?=\\())?", + "captures": { + "1": { + "name": "keyword.function.go" + }, + "2": { + "patterns": [ + { + "include": "#brackets" + }, + { + "include": "#operators" + } + ] + }, + "3": { + "name": "entity.name.function" + } + } + }, + { + "comment": "Functions", + "match": "(\\bfunc\\b)|([a-zA-Z_]\\w*)(?=\\()", + "captures": { + "1": { + "name": "keyword.function.go" + }, + "2": { + "name": "support.function.go" + } + } + }, + { + "comment": "Floating-point literals", + "match": "(\\.\\d+([Ee][-+]\\d+)?i?)\\b|\\b\\d+\\.\\d*(([Ee][-+]\\d+)?i?\\b)?", + "name": "constant.numeric.floating-point.go" + }, + { + "comment": "Integers", + "match": "\\b((0x[0-9a-fA-F]+)|(0[0-7]+i?)|(\\d+([Ee]\\d+)?i?)|(\\d+[Ee][-+]\\d+i?))\\b", + "name": "constant.numeric.integer.go" + }, + { + "comment": "Language constants", + "match": "\\b(true|false|nil|iota)\\b", + "name": "constant.language.go" + }, + { + "comment": "Package declarations", + "match": "(?<=package)\\s+([a-zA-Z_]\\w*)", + "captures": { + "1": { + "name": "entity.name.package.go" + } + } + }, + { + "comment": "Type declarations", + "match": "(?<=type)\\s+([a-zA-Z_]\\w*)", + "captures": { + "1": { + "name": "entity.name.type.go" + } + } + }, + { + "comment": "Shorthand variable declaration and assignments", + "match": "[a-zA-Z_]\\w*(?:,\\s*[a-zA-Z_]\\w*)*(?=\\s*:=)", + "captures": { + "0": { + "patterns": [ + { + "match": "[a-zA-Z_]\\w*", + "name": "variable.other.assignment.go" + }, + { + "include": "#delimiters" + } + ] + } + } + }, + { + "comment": "Assignments to existing variables", + "match": "(?=|<[^<]|>[^>])", + "name": "keyword.operator.comparison.go" + }, + { + "match": "(&&|\\|\\||!)", + "name": "keyword.operator.logical.go" + }, + { + "match": "(=|\\+=|\\-=|\\|=|\\^=|\\*=|/=|:=|%=|<<=|>>=|&\\^=|&=)", + "name": "keyword.operator.assignment.go" + }, + { + "match": "(\\+|\\-|\\*|/|%)", + "name": "keyword.operator.arithmetic.go" + }, + { + "match": "(&(?!\\^)|\\||\\^|&\\^|<<|>>)", + "name": "keyword.operator.arithmetic.bitwise.go" + }, + { + "match": "\\.\\.\\.", + "name": "keyword.operator.ellipsis.go" + } + ] + }, + "runes": { + "patterns": [ + { + "match": "\\'(\\\\([0-7]{3}|[abfnrtv\\\\'\"]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})|\\p{Any})\\'", + "name": "constant.other.rune.go" + }, + { + "match": "\\'.*\\'", + "name": "invalid.illegal.unknown-rune.go" + } + ] + }, + "storage_types": { + "patterns": [ + { + "match": "\\bbool\\b", + "name": "storage.type.boolean.go" + }, + { + "match": "\\bbyte\\b", + "name": "storage.type.byte.go" + }, + { + "match": "\\berror\\b", + "name": "storage.type.error.go" + }, + { + "match": "\\b(complex(64|128)|float(32|64)|u?int(8|16|32|64)?)\\b", + "name": "storage.type.numeric.go" + }, + { + "match": "\\brune\\b", + "name": "storage.type.rune.go" + }, + { + "match": "\\bstring\\b", + "name": "storage.type.string.go" + }, + { + "match": "\\buintptr\\b", + "name": "storage.type.uintptr.go" + } + ] + }, + "string_escaped_char": { + "patterns": [ + { + "match": "\\\\([0-7]{3}|[abfnrtv\\\\'\"]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})", + "name": "constant.character.escape.go" + }, + { + "match": "\\\\[^0-7xuUabfnrtv\\'\"]", + "name": "invalid.illegal.unknown-escape.go" + } + ] + }, + "string_placeholder": { + "patterns": [ + { + "match": "%(\\[\\d+\\])?([\\+#\\-0\\x20]{,2}((\\d+|\\*)?(\\.?(\\d+|\\*|(\\[\\d+\\])\\*?)?(\\[\\d+\\])?)?))?[vT%tbcdoqxXUbeEfFgGsp]", + "name": "constant.other.placeholder.go" + } + ] + }, + "variables": { + "comment": "First add tests and make sure existing tests still pass when changing anything here!", + "patterns": [ + { + "match": "([a-zA-Z_]\\w*(?:,\\s*[a-zA-Z_]\\w*)*)\\s*(=.*)", + "captures": { + "1": { + "patterns": [ + { + "match": "[a-zA-Z_]\\w*", + "name": "variable.other.assignment.go" + }, + { + "include": "#delimiters" + } + ] + }, + "2": { + "patterns": [ + { + "include": "$self" + } + ] + } + } + }, + { + "match": "([a-zA-Z_]\\w*(?:,\\s*[a-zA-Z_]\\w*)*)(\\s+[\\*]?[a-zA-Z_]\\w*\\s*)(=.*)", + "captures": { + "1": { + "patterns": [ + { + "match": "[a-zA-Z_]\\w*", + "name": "variable.other.assignment.go" + }, + { + "include": "#delimiters" + } + ] + }, + "2": { + "patterns": [ + { + "include": "$self" + } + ] + }, + "3": { + "patterns": [ + { + "include": "$self" + } + ] + } + } + }, + { + "match": "([a-zA-Z_]\\w*(?:,\\s*[a-zA-Z_]\\w*)*)(\\s+[\\[\\]\\*]{0,3}[a-zA-Z_]\\w*\\s*[^=].*)", + "captures": { + "1": { + "patterns": [ + { + "match": "[a-zA-Z_]\\w*", + "name": "variable.other.declaration.go" + }, + { + "include": "#delimiters" + } + ] + }, + "2": { + "patterns": [ + { + "include": "$self" + } + ] + } + } + } + ] + } + }, + "version": "https://github.com/atom/language-go/commit/93594dfb138a664f0914d54e408527e136899fb2" } \ No newline at end of file