소스 검색

Add support for alternate octal integer syntax

Sebastian Pahnke 6 년 전
부모
커밋
79ad5abdb3
3개의 변경된 파일29개의 추가작업 그리고 1개의 파일을 삭제
  1. 14 0
      src/javascript/javascript.test.ts
  2. 14 0
      src/typescript/typescript.test.ts
  3. 1 1
      src/typescript/typescript.ts

+ 14 - 0
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: [

+ 14 - 0
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: [

+ 1 - 1
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'],