瀏覽代碼

Merge remote-tracking branch 'origin/master' into pr/TiagoDanin/48

Alex Dima 6 年之前
父節點
當前提交
290e35d7b2
共有 5 個文件被更改,包括 109 次插入16 次删除
  1. 35 0
      src/javascript/javascript.test.ts
  2. 35 0
      src/typescript/typescript.test.ts
  3. 1 1
      src/typescript/typescript.ts
  4. 29 0
      src/yaml/yaml.test.ts
  5. 9 15
      src/yaml/yaml.ts

+ 35 - 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',
 		line: '0x',
 		tokens: [
 		tokens: [
@@ -361,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
 	// Regular Expressions
 	[{
 	[{
 		line: '//',
 		line: '//',

+ 35 - 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',
 		line: '0x',
 		tokens: [
 		tokens: [
@@ -361,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
 	// Regular Expressions
 	[{
 	[{
 		line: '//',
 		line: '//',

+ 1 - 1
src/typescript/typescript.ts

@@ -146,7 +146,7 @@ export const language = {
 			[/(@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)/, 'number.hex'],
-			[/0(@octaldigits)/, 'number.octal'],
+			[/0[oO]?(@octaldigits)/, 'number.octal'],
 			[/0[bB](@binarydigits)/, 'number.binary'],
 			[/0[bB](@binarydigits)/, 'number.binary'],
 			[/(@digits)/, 'number'],
 			[/(@digits)/, 'number'],
 
 

+ 29 - 0
src/yaml/yaml.test.ts

@@ -250,6 +250,35 @@ testTokenization('yaml', [
 		},]
 		},]
 	}],
 	}],
 
 
+    // Flow Scalars
+    [{
+        line: '\'this is a single quote string\'',
+        tokens: [{
+            startIndex: 0,
+            type: 'string.yaml'
+        }]
+    }],
+
+    [{
+        line: "\"this is a double \\quote string\\n\"",
+        tokens: [{
+            startIndex: 0,
+            type: 'string.yaml'
+        }, {
+            startIndex: 18,
+            type: 'string.escape.invalid.yaml'
+        }, {
+            startIndex: 20,
+            type: 'string.yaml'
+        }, {
+            startIndex: 31,
+            type: 'string.escape.yaml'
+        }, {
+            startIndex: 33,
+            type: 'string.yaml'
+        }]
+    }],
+
 	// Flow Sequence - Data types
 	// Flow Sequence - Data types
 	[{
 	[{
 		line: '[string,"double",\'single\',1,1.1,2002-04-28]',
 		line: '[string,"double",\'single\',1,1.1,2002-04-28]',

+ 9 - 15
src/yaml/yaml.ts

@@ -156,19 +156,6 @@ export const language = <ILanguage>{
 			}]
 			}]
 		],
 		],
 
 
-		// Flow Scalars (quoted strings)
-		string: [
-			[/[^\\"']+/, 'string'],
-			[/@escapes/, 'string.escape'],
-			[/\\./, 'string.escape.invalid'],
-			[/["']/, {
-				cases: {
-					'$#==$S2': { token: 'string', next: '@pop' },
-					'@default': 'string'
-				}
-			}]
-		],
-
 		// First line of a Block Style
 		// First line of a Block Style
 		multiString: [
 		multiString: [
 			[/^( +).+$/, 'string', '@multiStringContinued.$1']
 			[/^( +).+$/, 'string', '@multiStringContinued.$1']
@@ -204,8 +191,15 @@ export const language = <ILanguage>{
 		flowScalars: [
 		flowScalars: [
 			[/"([^"\\]|\\.)*$/, 'string.invalid'],
 			[/"([^"\\]|\\.)*$/, 'string.invalid'],
 			[/'([^'\\]|\\.)*$/, 'string.invalid'],
 			[/'([^'\\]|\\.)*$/, 'string.invalid'],
-			[/"/, 'string', '@string."'],
-			[/'/, 'string', '@string.\'']
+			[/'[^']*'/, 'string'],
+			[/"/, 'string', '@doubleQuotedString']
+		],
+
+		doubleQuotedString: [
+			[/[^\\"]+/, 'string'],
+			[/@escapes/, 'string.escape'],
+			[/\\./, 'string.escape.invalid'],
+			[/"/, 'string', '@pop']
 		],
 		],
 
 
 		// Start Block Scalar
 		// Start Block Scalar