mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 17:25:39 +01:00
Merge pull request #16 from sandyarmstrong/numlits
csharp: add support for binary literals and _ as separator
This commit is contained in:
commit
9865a5f5a0
2 changed files with 59 additions and 3 deletions
|
|
@ -98,9 +98,10 @@ export var language = <ILanguage> {
|
||||||
|
|
||||||
|
|
||||||
// numbers
|
// numbers
|
||||||
[/\d*\.\d+([eE][\-+]?\d+)?[fFdD]?/, 'number.float'],
|
[/[0-9_]*\.[0-9_]+([eE][\-+]?\d+)?[fFdD]?/, 'number.float'],
|
||||||
[/0[xX][0-9a-fA-F]+/, 'number.hex'],
|
[/0[xX][0-9a-fA-F_]+/, 'number.hex'],
|
||||||
[/\d+/, 'number'],
|
[/0[bB][01_]+/, 'number.hex'], // binary: use same theme style as hex
|
||||||
|
[/[0-9_]+/, 'number'],
|
||||||
|
|
||||||
// delimiter: after number because of .\d floats
|
// delimiter: after number because of .\d floats
|
||||||
[/[;,.]/, 'delimiter'],
|
[/[;,.]/, 'delimiter'],
|
||||||
|
|
|
||||||
|
|
@ -525,6 +525,12 @@ testTokenization('csharp', [
|
||||||
{ startIndex: 0, type: 'number.cs' }
|
{ startIndex: 0, type: 'number.cs' }
|
||||||
]}],
|
]}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '123_456',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.cs' }
|
||||||
|
]}],
|
||||||
|
|
||||||
[{
|
[{
|
||||||
line: '0x',
|
line: '0x',
|
||||||
tokens: [
|
tokens: [
|
||||||
|
|
@ -532,18 +538,49 @@ testTokenization('csharp', [
|
||||||
{ startIndex: 1, type: 'identifier.cs' }
|
{ startIndex: 1, type: 'identifier.cs' }
|
||||||
]}],
|
]}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '0b',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.cs' },
|
||||||
|
{ startIndex: 1, type: 'identifier.cs' }
|
||||||
|
]}],
|
||||||
|
|
||||||
[{
|
[{
|
||||||
line: '0x123',
|
line: '0x123',
|
||||||
tokens: [
|
tokens: [
|
||||||
{ startIndex: 0, type: 'number.hex.cs' }
|
{ startIndex: 0, type: 'number.hex.cs' }
|
||||||
]}],
|
]}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '0x123_456',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.hex.cs' }
|
||||||
|
]}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '0b101',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.hex.cs' }
|
||||||
|
]}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '0b1010_0001',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.hex.cs' }
|
||||||
|
]}],
|
||||||
|
|
||||||
[{
|
[{
|
||||||
line: '23.5',
|
line: '23.5',
|
||||||
tokens: [
|
tokens: [
|
||||||
{ startIndex: 0, type: 'number.float.cs' }
|
{ startIndex: 0, type: 'number.float.cs' }
|
||||||
]}],
|
]}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '1_23.5',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.float.cs' }
|
||||||
|
]}],
|
||||||
|
|
||||||
[{
|
[{
|
||||||
line: '23.5e3',
|
line: '23.5e3',
|
||||||
tokens: [
|
tokens: [
|
||||||
|
|
@ -568,6 +605,12 @@ testTokenization('csharp', [
|
||||||
{ startIndex: 0, type: 'number.float.cs' }
|
{ startIndex: 0, type: 'number.float.cs' }
|
||||||
]}],
|
]}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '2_3.5f',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.float.cs' }
|
||||||
|
]}],
|
||||||
|
|
||||||
[{
|
[{
|
||||||
line: '1.72E3F',
|
line: '1.72E3F',
|
||||||
tokens: [
|
tokens: [
|
||||||
|
|
@ -598,6 +641,12 @@ testTokenization('csharp', [
|
||||||
{ startIndex: 0, type: 'number.float.cs' }
|
{ startIndex: 0, type: 'number.float.cs' }
|
||||||
]}],
|
]}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '456_123.5D',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.float.cs' }
|
||||||
|
]}],
|
||||||
|
|
||||||
[{
|
[{
|
||||||
line: '23.5d',
|
line: '23.5d',
|
||||||
tokens: [
|
tokens: [
|
||||||
|
|
@ -616,6 +665,12 @@ testTokenization('csharp', [
|
||||||
{ startIndex: 0, type: 'number.float.cs' }
|
{ startIndex: 0, type: 'number.float.cs' }
|
||||||
]}],
|
]}],
|
||||||
|
|
||||||
|
[{
|
||||||
|
line: '1.720_123E3d',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: 'number.float.cs' }
|
||||||
|
]}],
|
||||||
|
|
||||||
[{
|
[{
|
||||||
line: '1.72e3D',
|
line: '1.72e3D',
|
||||||
tokens: [
|
tokens: [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue