mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 05:50:11 +01:00
Merge pull request #4973 from flofriday/fix-kotlin-number-literals
Fix Kotlin number literals
This commit is contained in:
commit
3a25d8ef40
2 changed files with 161 additions and 21 deletions
|
|
@ -277,6 +277,13 @@ testTokenization('kotlin', [
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
line: '.123',
|
||||||
|
tokens: [{ startIndex: 0, type: 'number.float.kt' }]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
line: '0x',
|
line: '0x',
|
||||||
|
|
@ -301,24 +308,62 @@ testTokenization('kotlin', [
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
line: '0Xff_81_00L',
|
||||||
|
tokens: [{ startIndex: 0, type: 'number.hex.kt' }]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
line: '0x123u',
|
||||||
|
tokens: [{ startIndex: 0, type: 'number.hex.kt' }]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
line: '0x123U',
|
||||||
|
tokens: [{ startIndex: 0, type: 'number.hex.kt' }]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
line: '0x123uL',
|
||||||
|
tokens: [{ startIndex: 0, type: 'number.hex.kt' }]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
line: '0x123UL',
|
||||||
|
tokens: [{ startIndex: 0, type: 'number.hex.kt' }]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
line: '023L',
|
line: '023L',
|
||||||
tokens: [{ startIndex: 0, type: 'number.octal.kt' }]
|
tokens: [{ startIndex: 0, type: 'number.kt' }]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
line: '0123l',
|
line: '0123l',
|
||||||
tokens: [{ startIndex: 0, type: 'number.octal.kt' }]
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.kt' },
|
||||||
|
{ startIndex: 4, type: 'identifier.kt' }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
line: '05_2',
|
line: '05_2',
|
||||||
tokens: [{ startIndex: 0, type: 'number.octal.kt' }]
|
tokens: [{ startIndex: 0, type: 'number.kt' }]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
@ -336,6 +381,41 @@ testTokenization('kotlin', [
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
line: '0b0101L',
|
||||||
|
tokens: [{ startIndex: 0, type: 'number.binary.kt' }]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
line: '0B0101u',
|
||||||
|
tokens: [{ startIndex: 0, type: 'number.binary.kt' }]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
line: '0B1__0U',
|
||||||
|
tokens: [{ startIndex: 0, type: 'number.binary.kt' }]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
line: '0B0101uL',
|
||||||
|
tokens: [{ startIndex: 0, type: 'number.binary.kt' }]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
line: '0B1__0UL',
|
||||||
|
tokens: [{ startIndex: 0, type: 'number.binary.kt' }]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
line: '10e3',
|
line: '10e3',
|
||||||
|
|
@ -401,57 +481,88 @@ testTokenization('kotlin', [
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
line: '23.5D',
|
line: '.001f',
|
||||||
tokens: [{ startIndex: 0, type: 'number.float.kt' }]
|
tokens: [{ startIndex: 0, type: 'number.float.kt' }]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
line: '23.5D',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.float.kt' },
|
||||||
|
{ startIndex: 4, type: 'type.identifier.kt' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
line: '23.5d',
|
line: '23.5d',
|
||||||
tokens: [{ startIndex: 0, type: 'number.float.kt' }]
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.float.kt' },
|
||||||
|
{ startIndex: 4, type: 'identifier.kt' }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
line: '1.72E3D',
|
line: '1.72E3D',
|
||||||
tokens: [{ startIndex: 0, type: 'number.float.kt' }]
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.float.kt' },
|
||||||
|
{ startIndex: 6, type: 'type.identifier.kt' }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
line: '1.72E3d',
|
line: '1.72E3d',
|
||||||
tokens: [{ startIndex: 0, type: 'number.float.kt' }]
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.float.kt' },
|
||||||
|
{ startIndex: 6, type: 'identifier.kt' }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
line: '1.72E-3d',
|
line: '1.72E-3d',
|
||||||
tokens: [{ startIndex: 0, type: 'number.float.kt' }]
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.float.kt' },
|
||||||
|
{ startIndex: 7, type: 'identifier.kt' }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
line: '1.72e3D',
|
line: '1.72e3D',
|
||||||
tokens: [{ startIndex: 0, type: 'number.float.kt' }]
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.float.kt' },
|
||||||
|
{ startIndex: 6, type: 'type.identifier.kt' }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
line: '1.72e3d',
|
line: '1.72e3d',
|
||||||
tokens: [{ startIndex: 0, type: 'number.float.kt' }]
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.float.kt' },
|
||||||
|
{ startIndex: 6, type: 'identifier.kt' }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
line: '1.72e-3d',
|
line: '1.72e-3d',
|
||||||
tokens: [{ startIndex: 0, type: 'number.float.kt' }]
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.float.kt' },
|
||||||
|
{ startIndex: 7, type: 'identifier.kt' }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
@ -465,6 +576,37 @@ testTokenization('kotlin', [
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
line: '23l',
|
line: '23l',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.kt' },
|
||||||
|
{ startIndex: 2, type: 'identifier.kt' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
line: '23u',
|
||||||
|
tokens: [{ startIndex: 0, type: 'number.kt' }]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
line: '23U',
|
||||||
|
tokens: [{ startIndex: 0, type: 'number.kt' }]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
line: '23uL',
|
||||||
|
tokens: [{ startIndex: 0, type: 'number.kt' }]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
line: '23UL',
|
||||||
tokens: [{ startIndex: 0, type: 'number.kt' }]
|
tokens: [{ startIndex: 0, type: 'number.kt' }]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -496,8 +638,7 @@ testTokenization('kotlin', [
|
||||||
tokens: [
|
tokens: [
|
||||||
{ startIndex: 0, type: 'number.kt' },
|
{ startIndex: 0, type: 'number.kt' },
|
||||||
{ startIndex: 1, type: 'identifier.kt' },
|
{ startIndex: 1, type: 'identifier.kt' },
|
||||||
{ startIndex: 2, type: 'delimiter.kt' },
|
{ startIndex: 2, type: 'number.float.kt' }
|
||||||
{ startIndex: 3, type: 'number.float.kt' }
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -567,7 +708,7 @@ testTokenization('kotlin', [
|
||||||
{
|
{
|
||||||
line: '052_',
|
line: '052_',
|
||||||
tokens: [
|
tokens: [
|
||||||
{ startIndex: 0, type: 'number.octal.kt' },
|
{ startIndex: 0, type: 'number.kt' },
|
||||||
{ startIndex: 3, type: 'identifier.kt' }
|
{ startIndex: 3, type: 'identifier.kt' }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -211,13 +211,12 @@ export const language = <languages.IMonarchLanguage>{
|
||||||
[/@\s*[a-zA-Z_\$][\w\$]*/, 'annotation'],
|
[/@\s*[a-zA-Z_\$][\w\$]*/, 'annotation'],
|
||||||
|
|
||||||
// numbers
|
// numbers
|
||||||
[/(@digits)[eE]([\-+]?(@digits))?[fFdD]?/, 'number.float'],
|
[/(@digits)[eE]([\-+]?(@digits))?[fF]?/, 'number.float'],
|
||||||
[/(@digits)\.(@digits)([eE][\-+]?(@digits))?[fFdD]?/, 'number.float'],
|
[/(@digits)?\.(@digits)([eE][\-+]?(@digits))?[fF]?/, 'number.float'],
|
||||||
[/0[xX](@hexdigits)[Ll]?/, 'number.hex'],
|
[/0[xX](@hexdigits)[uU]?L?/, 'number.hex'],
|
||||||
[/0(@octaldigits)[Ll]?/, 'number.octal'],
|
[/0[bB](@binarydigits)[uU]?L?/, 'number.binary'],
|
||||||
[/0[bB](@binarydigits)[Ll]?/, 'number.binary'],
|
[/(@digits)[fF]/, 'number.float'],
|
||||||
[/(@digits)[fFdD]/, 'number.float'],
|
[/(@digits)[uU]?L?/, 'number'],
|
||||||
[/(@digits)[lL]?/, 'number'],
|
|
||||||
|
|
||||||
// delimiter: after number because of .\d floats
|
// delimiter: after number because of .\d floats
|
||||||
[/[;,.]/, 'delimiter'],
|
[/[;,.]/, 'delimiter'],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue