Skip to content

Commit

Permalink
Extend variable scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
ephread committed May 8, 2020
1 parent 9757df1 commit 861cd7e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 33 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 11 additions & 11 deletions grammars/Ink.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -712,7 +712,7 @@ repository:
(?=\?) | (?=!\?) | (?=\^) |
(?=,) | (?=\)))
captures:
'1': { name: variable.other.ink }
'1': { name: variable.other.ink entity.name.variable.other.ink }
- match: >-
(?x)
Expand All @@ -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: '(?<=\{)(?<!^)\s*{{validIdentifier}}(\.{{validIdentifier}})?\s*(?!$)(?=\})'

operator:
Expand Down
22 changes: 11 additions & 11 deletions grammars/Ink.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@
<key>1</key>
<dict>
<key>name</key>
<string>variable.other.ink</string>
<string>variable.other.ink entity.name.variable.other.ink</string>
</dict>
<key>2</key>
<dict>
Expand Down Expand Up @@ -383,7 +383,7 @@
<key>1</key>
<dict>
<key>name</key>
<string>variable.other.constant.ink</string>
<string>variable.other.constant.ink entity.name.variable.other.constant.ink</string>
</dict>
<key>2</key>
<dict>
Expand Down Expand Up @@ -451,7 +451,7 @@
<key>2</key>
<dict>
<key>name</key>
<string>variable.other.stitch.ink</string>
<string>variable.other.ink entity.name.variable.other.ink</string>
</dict>
<key>3</key>
<dict>
Expand Down Expand Up @@ -1193,7 +1193,7 @@
<key>2</key>
<dict>
<key>name</key>
<string>variable.other.knot.ink</string>
<string>variable.other.knot.ink entity.name.variable.other.knot.ink</string>
</dict>
<key>3</key>
<dict>
Expand All @@ -1203,7 +1203,7 @@
<key>4</key>
<dict>
<key>name</key>
<string>variable.other.stitch.ink</string>
<string>variable.other.stitch.ink entity.name.variable.other.stitch.ink</string>
</dict>
<key>5</key>
<dict>
Expand All @@ -1213,7 +1213,7 @@
<key>6</key>
<dict>
<key>name</key>
<string>variable.other.label.ink</string>
<string>variable.other.label.ink entity.name.variable.other.label.ink</string>
</dict>
</dict>
<key>end</key>
Expand Down Expand Up @@ -1886,7 +1886,7 @@
<key>1</key>
<dict>
<key>name</key>
<string>variable.other.ink</string>
<string>variable.other.ink entity.name.variable.other.ink</string>
</dict>
</dict>
</dict>
Expand All @@ -1903,7 +1903,7 @@
<key>1</key>
<dict>
<key>name</key>
<string>variable.other.ink</string>
<string>variable.other.ink entity.name.variable.other.ink</string>
</dict>
</dict>
</dict>
Expand All @@ -1924,7 +1924,7 @@
<key>1</key>
<dict>
<key>name</key>
<string>variable.other.ink</string>
<string>variable.other.ink entity.name.variable.other.ink</string>
</dict>
</dict>
</dict>
Expand All @@ -1941,7 +1941,7 @@
<key>1</key>
<dict>
<key>name</key>
<string>variable.other.ink</string>
<string>variable.other.ink entity.name.variable.other.ink</string>
</dict>
</dict>
</dict>
Expand All @@ -1953,7 +1953,7 @@
<array>
<dict>
<key>name</key>
<string>variable.other.ink</string>
<string>variable.other.ink entity.name.variable.other.ink</string>
<key>match</key>
<string>(?&lt;=\{)(?&lt;!^)\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*(?!$)(?=\})</string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/choices/fallback_choice_on_thread.ink
Original file line number Diff line number Diff line change
Expand Up @@ -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
* ->
Expand Down
20 changes: 10 additions & 10 deletions tests/cases/extra/variable_declarations.ink
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 861cd7e

Please sign in to comment.