From 861cd7edd364bc3d281c2a466f5e3b880ea6e166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Maquin?= Date: Fri, 8 May 2020 11:41:15 +0200 Subject: [PATCH] Extend variable scopes --- README.md | 3 +++ grammars/Ink.YAML-tmLanguage | 22 +++++++++---------- grammars/Ink.tmLanguage | 22 +++++++++---------- .../choices/fallback_choice_on_thread.ink | 2 +- tests/cases/extra/variable_declarations.ink | 20 ++++++++--------- 5 files changed, 36 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index f492319..7739439 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,9 @@ Most of the captures are multi-scoped, with the first scope defined by the theme - `keyword.divert.ink` → `->` or `<-` - `keyword.alternative.type.ink` → `&` or `~` or `!` inside `{ }` - `storage.knot.ink` → Identifier after / between `=` +- `variable.other.knot.ink` → a knot identifier in a divert +- `variable.other.stitch.ink` → a stitch identifier in a divert +- `variable.other.label.ink` → a label identifier in a divert ## Availability through npm diff --git a/grammars/Ink.YAML-tmLanguage b/grammars/Ink.YAML-tmLanguage index 2254371..8ab6525 100644 --- a/grammars/Ink.YAML-tmLanguage +++ b/grammars/Ink.YAML-tmLanguage @@ -147,7 +147,7 @@ repository: patterns: - begin: ({{validIdentifier}})\s*(=) beginCaptures: - '1': { name: variable.other.ink } + '1': { name: variable.other.ink entity.name.variable.other.ink } '2': { name: keyword.operator.assignment.ink } end: (?=$) patterns: @@ -163,7 +163,7 @@ repository: patterns: - begin: ({{validIdentifier}})\s*(=) beginCaptures: - '1': { name: variable.other.constant.ink } + '1': { name: variable.other.constant.ink entity.name.variable.other.constant.ink } '2': { name: keyword.operator.assignment.ink } end: (?=$) patterns: @@ -188,7 +188,7 @@ repository: (=) beginCaptures: '1': { name: storage.modifier.ink } - '2': { name: variable.other.stitch.ink } + '2': { name: variable.other.ink entity.name.variable.other.ink } '3': { name: keyword.assignment.ink } end: (?=$) patterns: @@ -465,11 +465,11 @@ repository: ) beginCaptures: '1': { name: support.constant.ink } - '2': { name: variable.other.knot.ink } + '2': { name: variable.other.knot.ink entity.name.variable.other.knot.ink } '3': { name: punctuation.accessor.ink } - '4': { name: variable.other.stitch.ink } + '4': { name: variable.other.stitch.ink entity.name.variable.other.stitch.ink } '5': { name: punctuation.accessor.ink } - '6': { name: variable.other.label.ink } + '6': { name: variable.other.label.ink entity.name.variable.other.label.ink } end: (?=($|\}|\)|\||\#)) patterns: - include: "#comment" @@ -688,7 +688,7 @@ repository: ({{validIdentifier}} (?:\.{{validIdentifier}})?) captures: - '1': { name: variable.other.ink } + '1': { name: variable.other.ink entity.name.variable.other.ink } - match: >- (?x) @@ -698,7 +698,7 @@ repository: ({{validIdentifier}} (?:\.{{validIdentifier}})?) captures: - '1': { name: variable.other.ink } + '1': { name: variable.other.ink entity.name.variable.other.ink } - match: >- (?x) @@ -712,7 +712,7 @@ repository: (?=\?) | (?=!\?) | (?=\^) | (?=,) | (?=\))) captures: - '1': { name: variable.other.ink } + '1': { name: variable.other.ink entity.name.variable.other.ink } - match: >- (?x) @@ -722,11 +722,11 @@ repository: {{anyNonIdentifierCharacter}} (?:(?=not) | (?=and) | (?=or) | (?=has) | (?=hasnt) | (?=mod)) captures: - '1': { name: variable.other.ink } + '1': { name: variable.other.ink entity.name.variable.other.ink } interpolatedIdentifier: patterns: - - name: variable.other.ink + - name: variable.other.ink entity.name.variable.other.ink match: '(?<=\{)(?1 name - variable.other.ink + variable.other.ink entity.name.variable.other.ink 2 @@ -383,7 +383,7 @@ 1 name - variable.other.constant.ink + variable.other.constant.ink entity.name.variable.other.constant.ink 2 @@ -451,7 +451,7 @@ 2 name - variable.other.stitch.ink + variable.other.ink entity.name.variable.other.ink 3 @@ -1193,7 +1193,7 @@ 2 name - variable.other.knot.ink + variable.other.knot.ink entity.name.variable.other.knot.ink 3 @@ -1203,7 +1203,7 @@ 4 name - variable.other.stitch.ink + variable.other.stitch.ink entity.name.variable.other.stitch.ink 5 @@ -1213,7 +1213,7 @@ 6 name - variable.other.label.ink + variable.other.label.ink entity.name.variable.other.label.ink end @@ -1886,7 +1886,7 @@ 1 name - variable.other.ink + variable.other.ink entity.name.variable.other.ink @@ -1903,7 +1903,7 @@ 1 name - variable.other.ink + variable.other.ink entity.name.variable.other.ink @@ -1924,7 +1924,7 @@ 1 name - variable.other.ink + variable.other.ink entity.name.variable.other.ink @@ -1941,7 +1941,7 @@ 1 name - variable.other.ink + variable.other.ink entity.name.variable.other.ink @@ -1953,7 +1953,7 @@ name - variable.other.ink + variable.other.ink entity.name.variable.other.ink match (?<=\{)(?<!^)\s*[a-zA-Z0-9_\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0600}-\x{06FF}\x{0530}-\x{058F}\x{0400}-\x{04FF}\x{0370}-\x{03FF}\x{0590}-\x{05FF}]*[a-zA-Z_\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0600}-\x{06FF}\x{0530}-\x{058F}\x{0400}-\x{04FF}\x{0370}-\x{03FF}\x{0590}-\x{05FF}][a-zA-Z0-9_\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0600}-\x{06FF}\x{0530}-\x{058F}\x{0400}-\x{04FF}\x{0370}-\x{03FF}\x{0590}-\x{05FF}]*(\.[a-zA-Z0-9_\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0600}-\x{06FF}\x{0530}-\x{058F}\x{0400}-\x{04FF}\x{0370}-\x{03FF}\x{0590}-\x{05FF}]*[a-zA-Z_\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0600}-\x{06FF}\x{0530}-\x{058F}\x{0400}-\x{04FF}\x{0370}-\x{03FF}\x{0590}-\x{05FF}][a-zA-Z0-9_\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0600}-\x{06FF}\x{0530}-\x{058F}\x{0400}-\x{04FF}\x{0370}-\x{03FF}\x{0590}-\x{05FF}]*)?\s*(?!$)(?=\}) diff --git a/tests/cases/choices/fallback_choice_on_thread.ink b/tests/cases/choices/fallback_choice_on_thread.ink index 3ef8deb..a90b241 100644 --- a/tests/cases/choices/fallback_choice_on_thread.ink +++ b/tests/cases/choices/fallback_choice_on_thread.ink @@ -13,7 +13,7 @@ // ^ keyword.logic.ink keyword.operator.arithmetic.ink // ^ source.ink // ^^^^ storage.modifier.ink -// ^ variable.other.stitch.ink +// ^ variable.other.ink // ^ keyword.assignment.ink // ^ constant.numeric.ink * -> diff --git a/tests/cases/extra/variable_declarations.ink b/tests/cases/extra/variable_declarations.ink index 0831f5e..78a9d10 100644 --- a/tests/cases/extra/variable_declarations.ink +++ b/tests/cases/extra/variable_declarations.ink @@ -186,7 +186,7 @@ CONST string = "Hello" /* //<~- source.ink //^^^^ storage.modifier.ink // ^ source.ink -// ^^^^ variable.other.stitch.ink +// ^^^^ variable.other.ink // ^ source.ink // ^ keyword.assignment.ink // ^^ source.ink @@ -199,7 +199,7 @@ CONST string = "Hello" /* //<~- source.ink //^^^^ storage.modifier.ink // ^ source.ink -// ^^^^^^ variable.other.stitch.ink +// ^^^^^^ variable.other.ink // ^ source.ink // ^ keyword.assignment.ink // ^ source.ink @@ -211,7 +211,7 @@ CONST string = "Hello" /* //<~- source.ink //^^^^ storage.modifier.ink // ^ source.ink -// ^^^^^^^^^^^^ variable.other.stitch.ink +// ^^^^^^^^^^^^ variable.other.ink // ^ source.ink // ^ keyword.assignment.ink // ^ source.ink @@ -224,7 +224,7 @@ CONST string = "Hello" /* //<~- source.ink //^^^^ storage.modifier.ink // ^ source.ink -// ^^^^^^ variable.other.stitch.ink +// ^^^^^^ variable.other.ink // ^ source.ink // ^ keyword.assignment.ink // ^ source.ink @@ -234,7 +234,7 @@ CONST string = "Hello" /* //<~- source.ink //^^^^ storage.modifier.ink // ^ source.ink -// ^^^^^^^ variable.other.stitch.ink +// ^^^^^^^ variable.other.ink // ^ source.ink // ^ keyword.assignment.ink // ^ source.ink @@ -244,7 +244,7 @@ CONST string = "Hello" /* //<~- source.ink //^^^^ storage.modifier.ink // ^ source.ink -// ^^^^^^^ variable.other.stitch.ink +// ^^^^^^^ variable.other.ink // ^ source.ink // ^ keyword.assignment.ink // ^ source.ink @@ -254,7 +254,7 @@ CONST string = "Hello" /* //<~- source.ink //^^^^ storage.modifier.ink // ^ source.ink -// ^^^^^^^^ variable.other.stitch.ink +// ^^^^^^^^ variable.other.ink // ^ source.ink // ^ keyword.assignment.ink // ^ source.ink @@ -264,7 +264,7 @@ CONST string = "Hello" /* //<~- source.ink //^^^^ storage.modifier.ink // ^ source.ink -// ^^^^^^^ variable.other.stitch.ink +// ^^^^^^^ variable.other.ink // ^ source.ink // ^ keyword.assignment.ink // ^ source.ink @@ -294,7 +294,7 @@ CONST string = "Hello" /* //<~- source.ink //^^^^ storage.modifier.ink // ^ source.ink -// ^^^^^^^^ variable.other.stitch.ink +// ^^^^^^^^ variable.other.ink // ^ source.ink // ^ keyword.assignment.ink // ^ source.ink @@ -326,7 +326,7 @@ CONST string = "Hello" /* //<~- source.ink //^^^^ storage.modifier.ink // ^ source.ink -// ^^^^^^ variable.other.stitch.ink +// ^^^^^^ variable.other.ink // ^ source.ink // ^ keyword.assignment.ink // ^ source.ink