diff --git a/src/basic-languages/elixir/elixir.test.ts b/src/basic-languages/elixir/elixir.test.ts index fe68c922..25c06294 100644 --- a/src/basic-languages/elixir/elixir.test.ts +++ b/src/basic-languages/elixir/elixir.test.ts @@ -303,6 +303,17 @@ testTokenization('elixir', [ ] } ], + // Sigils (multi-letter uppercase) + [ + { + line: '~DX/foo/', + tokens: [ + { startIndex: 0, type: 'sigil.delimiter.elixir' }, + { startIndex: 4, type: 'sigil.elixir' }, + { startIndex: 7, type: 'sigil.delimiter.elixir' } + ] + } + ], // Sigils (no interpolation) [ { @@ -314,6 +325,17 @@ testTokenization('elixir', [ ] } ], + // Sigils (multi-letter uppercase no interpolation) + [ + { + line: '~WW/foo#{1}/', + tokens: [ + { startIndex: 0, type: 'sigil.delimiter.elixir' }, + { startIndex: 4, type: 'sigil.elixir' }, + { startIndex: 11, type: 'sigil.delimiter.elixir' } + ] + } + ], // Sigils (modifiers) [ { @@ -325,6 +347,17 @@ testTokenization('elixir', [ ] } ], + // Sigils (multi-letter uppercase with modifiers) + [ + { + line: '~DX/custom/az09', + tokens: [ + { startIndex: 0, type: 'sigil.delimiter.elixir' }, + { startIndex: 4, type: 'sigil.elixir' }, + { startIndex: 10, type: 'sigil.delimiter.elixir' } + ] + } + ], // Module attributes [ { diff --git a/src/basic-languages/elixir/elixir.ts b/src/basic-languages/elixir/elixir.ts index 078d1030..bb98e976 100644 --- a/src/basic-languages/elixir/elixir.ts +++ b/src/basic-languages/elixir/elixir.ts @@ -333,7 +333,8 @@ export const language = { // See https://elixir-lang.org/getting-started/sigils.html // Sigils allow for typing values using their textual representation. - // All sigils start with ~ followed by a letter indicating sigil type + // All sigils start with ~ followed by a letter or + // multi-letter uppercase starting at Elixir v1.15.0, indicating sigil type // and then a delimiter pair enclosing the textual representation. // Optional modifiers are allowed after the closing delimiter. // For instance a regular expressions can be written as: @@ -353,16 +354,16 @@ export const language = { sigils: [ [/~[a-z]@sigilStartDelimiter/, { token: '@rematch', next: '@sigil.interpol' }], - [/~[A-Z]@sigilStartDelimiter/, { token: '@rematch', next: '@sigil.noInterpol' }] + [/~([A-Z]+)@sigilStartDelimiter/, { token: '@rematch', next: '@sigil.noInterpol' }] ], sigil: [ - [/~([a-zA-Z])\{/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.{.}' }], - [/~([a-zA-Z])\[/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.[.]' }], - [/~([a-zA-Z])\(/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.(.)' }], - [/~([a-zA-Z])\' }], + [/~([a-z]|[A-Z]+)\{/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.{.}' }], + [/~([a-z]|[A-Z]+)\[/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.[.]' }], + [/~([a-z]|[A-Z]+)\(/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.(.)' }], + [/~([a-z]|[A-Z]+)\' }], [ - /~([a-zA-Z])(@sigilSymmetricDelimiter)/, + /~([a-z]|[A-Z]+)(@sigilSymmetricDelimiter)/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.$2.$2' } ] ], @@ -475,7 +476,7 @@ export const language = { // Fallback to the generic sigil by default 'sigilStart.interpol': [ [ - /~([a-zA-Z])@sigilStartDelimiter/, + /~([a-z]|[A-Z]+)@sigilStartDelimiter/, { token: 'sigil.delimiter', switchTo: '@sigilContinue.$S2.$S3.$S4.$S5' @@ -498,7 +499,7 @@ export const language = { 'sigilStart.noInterpol': [ [ - /~([a-zA-Z])@sigilStartDelimiter/, + /~([a-z]|[A-Z]+)@sigilStartDelimiter/, { token: 'sigil.delimiter', switchTo: '@sigilContinue.$S2.$S3.$S4.$S5'