Merge pull request #4041 from leandrocp/lp/elixir-multiletter-sigils
Elixir - Add support for multi-letter uppercase sigils
This commit is contained in:
Коммит
b9cda7e6a8
|
@ -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
|
||||
[
|
||||
{
|
||||
|
|
|
@ -333,7 +333,8 @@ export const language = <languages.IMonarchLanguage>{
|
|||
|
||||
// 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 = <languages.IMonarchLanguage>{
|
|||
|
||||
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])\</, { 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]+)\(/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.(.)' }],
|
||||
[/~([a-z]|[A-Z]+)\</, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.<.>' }],
|
||||
[
|
||||
/~([a-zA-Z])(@sigilSymmetricDelimiter)/,
|
||||
/~([a-z]|[A-Z]+)(@sigilSymmetricDelimiter)/,
|
||||
{ token: '@rematch', switchTo: '@sigilStart.$S2.$1.$2.$2' }
|
||||
]
|
||||
],
|
||||
|
@ -475,7 +476,7 @@ export const language = <languages.IMonarchLanguage>{
|
|||
// 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 = <languages.IMonarchLanguage>{
|
|||
|
||||
'sigilStart.noInterpol': [
|
||||
[
|
||||
/~([a-zA-Z])@sigilStartDelimiter/,
|
||||
/~([a-z]|[A-Z]+)@sigilStartDelimiter/,
|
||||
{
|
||||
token: 'sigil.delimiter',
|
||||
switchTo: '@sigilContinue.$S2.$S3.$S4.$S5'
|
||||
|
|
Загрузка…
Ссылка в новой задаче