mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 18:32:56 +01:00
Merge pull request #62 from spahnke/bigint
[JS/TS] Add support for BigInt
This commit is contained in:
commit
e28160f19e
3 changed files with 184 additions and 4 deletions
|
|
@ -396,6 +396,96 @@ testTokenization('javascript', [
|
||||||
]
|
]
|
||||||
}],
|
}],
|
||||||
|
|
||||||
|
// Bigint
|
||||||
|
[{
|
||||||
|
line: '0n',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.js' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: ' 0n',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: '' },
|
||||||
|
{ startIndex: 1, type: 'number.js' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: ' 0n ',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: '' },
|
||||||
|
{ startIndex: 1, type: 'number.js' },
|
||||||
|
{ startIndex: 3, type: '' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '0n ',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.js' },
|
||||||
|
{ startIndex: 2, type: '' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '0n+0n',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.js' },
|
||||||
|
{ startIndex: 2, type: 'delimiter.js' },
|
||||||
|
{ startIndex: 3, type: 'number.js' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '100n+10n',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.js' },
|
||||||
|
{ startIndex: 4, type: 'delimiter.js' },
|
||||||
|
{ startIndex: 5, type: 'number.js' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '0n + 0n',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.js' },
|
||||||
|
{ startIndex: 2, type: '' },
|
||||||
|
{ startIndex: 3, type: 'delimiter.js' },
|
||||||
|
{ startIndex: 4, type: '' },
|
||||||
|
{ startIndex: 5, type: 'number.js' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '0b101n',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.binary.js' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '0123n',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.octal.js' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '0o123n',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.octal.js' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '0x123n',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.hex.js' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
// Regular Expressions
|
// Regular Expressions
|
||||||
[{
|
[{
|
||||||
line: '//',
|
line: '//',
|
||||||
|
|
|
||||||
|
|
@ -396,6 +396,96 @@ testTokenization('typescript', [
|
||||||
]
|
]
|
||||||
}],
|
}],
|
||||||
|
|
||||||
|
// Bigint
|
||||||
|
[{
|
||||||
|
line: '0n',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.ts' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: ' 0n',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: '' },
|
||||||
|
{ startIndex: 1, type: 'number.ts' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: ' 0n ',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: '' },
|
||||||
|
{ startIndex: 1, type: 'number.ts' },
|
||||||
|
{ startIndex: 3, type: '' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '0n ',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.ts' },
|
||||||
|
{ startIndex: 2, type: '' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '0n+0n',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.ts' },
|
||||||
|
{ startIndex: 2, type: 'delimiter.ts' },
|
||||||
|
{ startIndex: 3, type: 'number.ts' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '100n+10n',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.ts' },
|
||||||
|
{ startIndex: 4, type: 'delimiter.ts' },
|
||||||
|
{ startIndex: 5, type: 'number.ts' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '0n + 0n',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.ts' },
|
||||||
|
{ startIndex: 2, type: '' },
|
||||||
|
{ startIndex: 3, type: 'delimiter.ts' },
|
||||||
|
{ startIndex: 4, type: '' },
|
||||||
|
{ startIndex: 5, type: 'number.ts' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '0b101n',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.binary.ts' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '0123n',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.octal.ts' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '0o123n',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.octal.ts' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '0x123n',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.hex.ts' }
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
// Regular Expressions
|
// Regular Expressions
|
||||||
[{
|
[{
|
||||||
line: '//',
|
line: '//',
|
||||||
|
|
|
||||||
|
|
@ -146,10 +146,10 @@ export const language = {
|
||||||
// numbers
|
// numbers
|
||||||
[/(@digits)[eE]([\-+]?(@digits))?/, 'number.float'],
|
[/(@digits)[eE]([\-+]?(@digits))?/, 'number.float'],
|
||||||
[/(@digits)\.(@digits)([eE][\-+]?(@digits))?/, 'number.float'],
|
[/(@digits)\.(@digits)([eE][\-+]?(@digits))?/, 'number.float'],
|
||||||
[/0[xX](@hexdigits)/, 'number.hex'],
|
[/0[xX](@hexdigits)n?/, 'number.hex'],
|
||||||
[/0[oO]?(@octaldigits)/, 'number.octal'],
|
[/0[oO]?(@octaldigits)n?/, 'number.octal'],
|
||||||
[/0[bB](@binarydigits)/, 'number.binary'],
|
[/0[bB](@binarydigits)n?/, 'number.binary'],
|
||||||
[/(@digits)/, 'number'],
|
[/(@digits)n?/, '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