From 79ad5abdb3bf0b59aa8b48a8fd1c5d7a8bb3f7ce Mon Sep 17 00:00:00 2001 From: Sebastian Pahnke Date: Fri, 5 Oct 2018 17:28:43 +0200 Subject: [PATCH 1/2] Add support for alternate octal integer syntax --- src/javascript/javascript.test.ts | 14 ++++++++++++++ src/typescript/typescript.test.ts | 14 ++++++++++++++ src/typescript/typescript.ts | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/javascript/javascript.test.ts b/src/javascript/javascript.test.ts index f140df15..889286aa 100644 --- a/src/javascript/javascript.test.ts +++ b/src/javascript/javascript.test.ts @@ -346,6 +346,20 @@ testTokenization('javascript', [ ] }], + [{ + line: '0o123', + tokens: [ + { startIndex: 0, type: 'number.octal.js' } + ] + }], + + [{ + line: '0O123', + tokens: [ + { startIndex: 0, type: 'number.octal.js' } + ] + }], + [{ line: '0x', tokens: [ diff --git a/src/typescript/typescript.test.ts b/src/typescript/typescript.test.ts index 6b156a9e..795a4025 100644 --- a/src/typescript/typescript.test.ts +++ b/src/typescript/typescript.test.ts @@ -346,6 +346,20 @@ testTokenization('typescript', [ ] }], + [{ + line: '0o123', + tokens: [ + { startIndex: 0, type: 'number.octal.ts' } + ] + }], + + [{ + line: '0O123', + tokens: [ + { startIndex: 0, type: 'number.octal.ts' } + ] + }], + [{ line: '0x', tokens: [ diff --git a/src/typescript/typescript.ts b/src/typescript/typescript.ts index 01cd0150..1c3e38d5 100644 --- a/src/typescript/typescript.ts +++ b/src/typescript/typescript.ts @@ -146,7 +146,7 @@ export const language = { [/(@digits)[eE]([\-+]?(@digits))?/, 'number.float'], [/(@digits)\.(@digits)([eE][\-+]?(@digits))?/, 'number.float'], [/0[xX](@hexdigits)/, 'number.hex'], - [/0(@octaldigits)/, 'number.octal'], + [/0[oO]?(@octaldigits)/, 'number.octal'], [/0[bB](@binarydigits)/, 'number.binary'], [/(@digits)/, 'number'], From 623dbc1acc3f214e2bb0cfdd2b82e6cd7c209645 Mon Sep 17 00:00:00 2001 From: Sebastian Pahnke Date: Fri, 5 Oct 2018 17:29:11 +0200 Subject: [PATCH 2/2] Add more tests for hex and binary integer literals --- src/javascript/javascript.test.ts | 21 +++++++++++++++++++++ src/typescript/typescript.test.ts | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/javascript/javascript.test.ts b/src/javascript/javascript.test.ts index 889286aa..fd5236c4 100644 --- a/src/javascript/javascript.test.ts +++ b/src/javascript/javascript.test.ts @@ -375,6 +375,27 @@ testTokenization('javascript', [ ] }], + [{ + line: '0X123', + tokens: [ + { startIndex: 0, type: 'number.hex.js' } + ] + }], + + [{ + line: '0b101', + tokens: [ + { startIndex: 0, type: 'number.binary.js' } + ] + }], + + [{ + line: '0B101', + tokens: [ + { startIndex: 0, type: 'number.binary.js' } + ] + }], + // Regular Expressions [{ line: '//', diff --git a/src/typescript/typescript.test.ts b/src/typescript/typescript.test.ts index 795a4025..0154ae57 100644 --- a/src/typescript/typescript.test.ts +++ b/src/typescript/typescript.test.ts @@ -375,6 +375,27 @@ testTokenization('typescript', [ ] }], + [{ + line: '0X123', + tokens: [ + { startIndex: 0, type: 'number.hex.ts' } + ] + }], + + [{ + line: '0b101', + tokens: [ + { startIndex: 0, type: 'number.binary.ts' } + ] + }], + + [{ + line: '0B101', + tokens: [ + { startIndex: 0, type: 'number.binary.ts' } + ] + }], + // Regular Expressions [{ line: '//',