Initial release

This commit is contained in:
Alex Dima 2016-06-09 19:01:53 +02:00
parent 82734bfad1
commit c4177ec697
54 changed files with 15061 additions and 2 deletions

48
test/all.js Normal file
View file

@ -0,0 +1,48 @@
var requirejs = require("requirejs");
var jsdom = require('jsdom-no-contextify');
requirejs.config({
baseUrl: '',
paths: {
'vs': 'node_modules/monaco-editor-core/dev/vs'
},
nodeRequire: require
});
global.document = jsdom.jsdom('<!doctype html><html><body></body></html>');
global.document.queryCommandSupported = function() {};
global.self = global.window = global.document.parentWindow;
global.navigator = global.window.navigator;
global.window.require = requirejs;
function MyWorker() {}
MyWorker.prototype.postMessage = function() {};
global.Worker = MyWorker;
requirejs([
'vs/editor/editor.main'
], function() {
requirejs([
'out/test/bat.test',
'out/test/coffee.test',
'out/test/cpp.test',
'out/test/csharp.test',
'out/test/dockerfile.test',
'out/test/fsharp.test',
'out/test/go.test',
'out/test/jade.test',
'out/test/java.test',
'out/test/lua.test',
'out/test/objective-c.test',
'out/test/powershell.test',
'out/test/python.test',
'out/test/r.test',
'out/test/ruby.test',
'out/test/swift.test',
'out/test/sql.test',
'out/test/vb.test',
'out/test/xml.test',
], function() {
run(); // We can launch the tests!
});
});

44
test/assert.d.ts vendored Normal file
View file

@ -0,0 +1,44 @@
declare module "assert" {
function internal (value: any, message?: string): void;
namespace internal {
export class AssertionError implements Error {
name: string;
message: string;
actual: any;
expected: any;
operator: string;
generatedMessage: boolean;
constructor(options?: {message?: string; actual?: any; expected?: any;
operator?: string; stackStartFunction?: Function});
}
export function fail(actual?: any, expected?: any, message?: string, operator?: string): void;
export function ok(value: any, message?: string): void;
export function equal(actual: any, expected: any, message?: string): void;
export function notEqual(actual: any, expected: any, message?: string): void;
export function deepEqual(actual: any, expected: any, message?: string): void;
export function notDeepEqual(acutal: any, expected: any, message?: string): void;
export function strictEqual(actual: any, expected: any, message?: string): void;
export function notStrictEqual(actual: any, expected: any, message?: string): void;
export function deepStrictEqual(actual: any, expected: any, message?: string): void;
export function notDeepStrictEqual(actual: any, expected: any, message?: string): void;
export var throws: {
(block: Function, message?: string): void;
(block: Function, error: Function, message?: string): void;
(block: Function, error: RegExp, message?: string): void;
(block: Function, error: (err: any) => boolean, message?: string): void;
};
export var doesNotThrow: {
(block: Function, message?: string): void;
(block: Function, error: Function, message?: string): void;
(block: Function, error: RegExp, message?: string): void;
(block: Function, error: (err: any) => boolean, message?: string): void;
};
export function ifError(value: any): void;
}
export = internal;
}

332
test/bat.test.ts Normal file
View file

@ -0,0 +1,332 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {testTokenization} from './testRunner';
testTokenization('bat', [
// support.functions
[{
line: '@echo off title Selfhost',
tokens: [
{ startIndex: 0, type: 'support.function.bat' },
{ startIndex: 1, type: 'support.function.echo.bat' },
{ startIndex: 5, type: '' },
{ startIndex: 10, type: 'support.function.title.bat' },
{ startIndex: 15, type: '' }
]}],
// Comments - single line
[{
line: 'REM',
tokens: [
{ startIndex: 0, type: 'comment.bat' }
]}],
[{
line: ' REM a comment',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'comment.bat' }
]}],
[{
line: 'REM a comment',
tokens: [
{ startIndex: 0, type: 'comment.bat' }
]}],
[{
line: 'REMnot a comment',
tokens: [
{ startIndex: 0, type: '' }
]}],
// constant.numerics
[{
line: '0',
tokens: [
{ startIndex: 0, type: 'constant.numeric.bat' }
]}],
[{
line: '0.0',
tokens: [
{ startIndex: 0, type: 'constant.numeric.float.bat' }
]}],
[{
line: '0x123',
tokens: [
{ startIndex: 0, type: 'constant.numeric.hex.bat' }
]}],
[{
line: '23.5',
tokens: [
{ startIndex: 0, type: 'constant.numeric.float.bat' }
]}],
[{
line: '23.5e3',
tokens: [
{ startIndex: 0, type: 'constant.numeric.float.bat' }
]}],
[{
line: '23.5E3',
tokens: [
{ startIndex: 0, type: 'constant.numeric.float.bat' }
]}],
[{
line: '1.72e-3',
tokens: [
{ startIndex: 0, type: 'constant.numeric.float.bat' }
]}],
[{
line: '0+0',
tokens: [
{ startIndex: 0, type: 'constant.numeric.bat' },
{ startIndex: 1, type: 'punctuation.bat' },
{ startIndex: 2, type: 'constant.numeric.bat' }
]}],
[{
line: '100+10',
tokens: [
{ startIndex: 0, type: 'constant.numeric.bat' },
{ startIndex: 3, type: 'punctuation.bat' },
{ startIndex: 4, type: 'constant.numeric.bat' }
]}],
[{
line: '0 + 0',
tokens: [
{ startIndex: 0, type: 'constant.numeric.bat' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'punctuation.bat' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'constant.numeric.bat' }
]}],
// Strings
[{
line: 'set s = "string"',
tokens: [
{ startIndex: 0, type: 'support.function.set.bat' },
{ startIndex: 3, type: '' },
{ startIndex: 6, type: 'punctuation.bat' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'string.bat' }
]}],
[{
line: '"use strict";',
tokens: [
{ startIndex: 0, type: 'string.bat' },
{ startIndex: 12, type: 'punctuation.bat' }
]}],
// Tags
[{
line: 'setlocal endlocal',
tokens: [
{ startIndex: 0, type: 'support.function.tag-setlocal.bat' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'support.function.tag-setlocal.bat' }
]}],
[{
line: 'setlocal ENDLOCAL',
tokens: [
{ startIndex: 0, type: 'support.function.tag-setlocal.bat' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'support.function.tag-setlocal.bat' }
]}],
[{
line: 'SETLOCAL endlocal',
tokens: [
{ startIndex: 0, type: 'support.function.tag-setlocal.bat' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'support.function.tag-setlocal.bat' }
]}],
[{
line: 'setlocal setlocal endlocal',
tokens: [
{ startIndex: 0, type: 'support.function.tag-setlocal.bat' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'support.function.tag-setlocal.bat' },
{ startIndex: 17, type: '' },
{ startIndex: 18, type: 'support.function.tag-setlocal.bat' }
]}],
// Monarch generated
[{
line: 'rem asdf',
tokens: [
{ startIndex: 0, type: 'comment.bat' }
]}, {
line: '',
tokens: [
]}, {
line: 'REM',
tokens: [
{ startIndex: 0, type: 'comment.bat' }
]}, {
line: '',
tokens: [
]}, {
line: 'REMOVED not a comment really',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 8, type: 'support.function.not.bat' },
{ startIndex: 11, type: '' }
]}, {
line: '',
tokens: [
]}, {
line: 'echo cool',
tokens: [
{ startIndex: 0, type: 'support.function.echo.bat' },
{ startIndex: 4, type: '' }
]}, {
line: '@echo off',
tokens: [
{ startIndex: 0, type: 'support.function.bat' },
{ startIndex: 1, type: 'support.function.echo.bat' },
{ startIndex: 5, type: '' }
]}, {
line: '',
tokens: [
]}, {
line: 'setlocAL',
tokens: [
{ startIndex: 0, type: 'support.function.tag-setlocal.bat' }
]}, {
line: ' asdf',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: ' asdf',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: 'endLocaL',
tokens: [
{ startIndex: 0, type: 'support.function.tag-setlocal.bat' }
]}, {
line: '',
tokens: [
]}, {
line: 'call',
tokens: [
{ startIndex: 0, type: 'support.function.call.bat' }
]}, {
line: '',
tokens: [
]}, {
line: ':MyLabel',
tokens: [
{ startIndex: 0, type: 'metatag.bat' }
]}, {
line: 'some command',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: '',
tokens: [
]}, {
line: '%sdfsdf% ',
tokens: [
{ startIndex: 0, type: 'variable.bat' },
{ startIndex: 8, type: '' }
]}, {
line: '',
tokens: [
]}, {
line: 'this is "a string %sdf% asdf"',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 8, type: 'string.bat' },
{ startIndex: 18, type: 'variable.bat' },
{ startIndex: 23, type: 'string.bat' }
]}, {
line: '',
tokens: [
]}, {
line: '',
tokens: [
]}, {
line: 'FOR %%A IN (1 2 3) DO (',
tokens: [
{ startIndex: 0, type: 'support.function.for.bat' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'variable.bat' },
{ startIndex: 7, type: '' },
{ startIndex: 11, type: 'punctuation.parenthesis.bat' },
{ startIndex: 12, type: 'constant.numeric.bat' },
{ startIndex: 13, type: '' },
{ startIndex: 14, type: 'constant.numeric.bat' },
{ startIndex: 15, type: '' },
{ startIndex: 16, type: 'constant.numeric.bat' },
{ startIndex: 17, type: 'punctuation.parenthesis.bat' },
{ startIndex: 18, type: '' },
{ startIndex: 22, type: 'punctuation.parenthesis.bat' }
]}, {
line: ' SET VAR1=%VAR1%%%A',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'support.function.set.bat' },
{ startIndex: 4, type: '' },
{ startIndex: 9, type: 'punctuation.bat' },
{ startIndex: 10, type: 'variable.bat' }
]}, {
line: ' SET VAR2=%VAR2%%%A',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'support.function.set.bat' },
{ startIndex: 4, type: '' },
{ startIndex: 9, type: 'punctuation.bat' },
{ startIndex: 10, type: 'variable.bat' }
]}, {
line: ' use \'string %%a asdf asdf\'',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 5, type: 'string.bat' },
{ startIndex: 13, type: 'variable.bat' },
{ startIndex: 16, type: 'string.bat' }
]}, {
line: ' non terminated "string %%aaa sdf',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 16, type: 'string.bat' },
{ startIndex: 24, type: 'variable.bat' },
{ startIndex: 29, type: 'string.bat' }
]}, {
line: ' this shold NOT BE red',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 12, type: 'support.function.not.bat' },
{ startIndex: 15, type: '' }
]}, {
line: ')',
tokens: [
{ startIndex: 0, type: 'punctuation.parenthesis.bat' }
]}]
]);

1983
test/coffee.test.ts Normal file

File diff suppressed because it is too large Load diff

666
test/cpp.test.ts Normal file
View file

@ -0,0 +1,666 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {testTokenization} from './testRunner';
testTokenization('cpp', [
// Keywords
[{
line: 'int _tmain(int argc, _TCHAR* argv[])',
tokens: [
{ startIndex: 0, type: 'keyword.int.cpp' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.cpp' },
{ startIndex: 10, type: 'delimiter.parenthesis.cpp' },
{ startIndex: 11, type: 'keyword.int.cpp' },
{ startIndex: 14, type: '' },
{ startIndex: 15, type: 'identifier.cpp' },
{ startIndex: 19, type: 'delimiter.cpp' },
{ startIndex: 20, type: '' },
{ startIndex: 21, type: 'identifier.cpp' },
{ startIndex: 27, type: 'delimiter.cpp' },
{ startIndex: 28, type: '' },
{ startIndex: 29, type: 'identifier.cpp' },
{ startIndex: 33, type: 'delimiter.square.cpp' },
{ startIndex: 35, type: 'delimiter.parenthesis.cpp' }
]}],
// Comments - single line
[{
line: '//',
tokens: [
{ startIndex: 0, type: 'comment.cpp' }
]}],
[{
line: ' // a comment',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'comment.cpp' }
]}],
[{
line: '// a comment',
tokens: [
{ startIndex: 0, type: 'comment.cpp' }
]}],
[{
line: '//sticky comment',
tokens: [
{ startIndex: 0, type: 'comment.cpp' }
]}],
[{
line: '/almost a comment',
tokens: [
{ startIndex: 0, type: 'delimiter.cpp' },
{ startIndex: 1, type: 'identifier.cpp' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'identifier.cpp' },
{ startIndex: 9, type: '' },
{ startIndex: 10, type: 'identifier.cpp' }
]}],
[{
line: '/* //*/ a',
tokens: [
{ startIndex: 0, type: 'comment.cpp' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'identifier.cpp' }
]}],
[{
line: '1 / 2; /* comment',
tokens: [
{ startIndex: 0, type: 'number.cpp' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.cpp' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'number.cpp' },
{ startIndex: 5, type: 'delimiter.cpp' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'comment.cpp' }
]}],
[{
line: 'int x = 1; // my comment // is a nice one',
tokens: [
{ startIndex: 0, type: 'keyword.int.cpp' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.cpp' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.cpp' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'number.cpp' },
{ startIndex: 9, type: 'delimiter.cpp' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'comment.cpp' }
]}],
// Comments - range comment, single line
[{
line: '/* a simple comment */',
tokens: [
{ startIndex: 0, type: 'comment.cpp' }
]}],
[{
line: 'int x = /* a simple comment */ 1;',
tokens: [
{ startIndex: 0, type: 'keyword.int.cpp' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.cpp' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.cpp' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'comment.cpp' },
{ startIndex: 30, type: '' },
{ startIndex: 31, type: 'number.cpp' },
{ startIndex: 32, type: 'delimiter.cpp' }
]}],
[{
line: 'int x = /* comment */ 1; */',
tokens: [
{ startIndex: 0, type: 'keyword.int.cpp' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.cpp' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.cpp' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'comment.cpp' },
{ startIndex: 21, type: '' },
{ startIndex: 22, type: 'number.cpp' },
{ startIndex: 23, type: 'delimiter.cpp' },
{ startIndex: 24, type: '' }
]}],
[{
line: 'x = /**/;',
tokens: [
{ startIndex: 0, type: 'identifier.cpp' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.cpp' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'comment.cpp' },
{ startIndex: 8, type: 'delimiter.cpp' }
]}],
[{
line: 'x = /*/;',
tokens: [
{ startIndex: 0, type: 'identifier.cpp' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.cpp' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'comment.cpp' }
]}],
// Numbers
[{
line: '0',
tokens: [
{ startIndex: 0, type: 'number.cpp' }
]}],
[{
line: '12l',
tokens: [
{ startIndex: 0, type: 'number.cpp' }
]}],
[{
line: '34U',
tokens: [
{ startIndex: 0, type: 'number.cpp' }
]}],
[{
line: '55LL',
tokens: [
{ startIndex: 0, type: 'number.cpp' }
]}],
[{
line: '34ul',
tokens: [
{ startIndex: 0, type: 'number.cpp' }
]}],
[{
line: '55llU',
tokens: [
{ startIndex: 0, type: 'number.cpp' }
]}],
[{
line: '5\'5llU',
tokens: [
{ startIndex: 0, type: 'number.cpp' }
]}],
[{
line: '100\'000\'000',
tokens: [
{ startIndex: 0, type: 'number.cpp' }
]}],
[{
line: '0x100\'aafllU',
tokens: [
{ startIndex: 0, type: 'number.hex.cpp' }
]}],
[{
line: '0342\'325',
tokens: [
{ startIndex: 0, type: 'number.octal.cpp' }
]}],
[{
line: '0x123',
tokens: [
{ startIndex: 0, type: 'number.hex.cpp' }
]}],
[{
line: '23.5',
tokens: [
{ startIndex: 0, type: 'number.float.cpp' }
]}],
[{
line: '23.5e3',
tokens: [
{ startIndex: 0, type: 'number.float.cpp' }
]}],
[{
line: '23.5E3',
tokens: [
{ startIndex: 0, type: 'number.float.cpp' }
]}],
[{
line: '23.5F',
tokens: [
{ startIndex: 0, type: 'number.float.cpp' }
]}],
[{
line: '23.5f',
tokens: [
{ startIndex: 0, type: 'number.float.cpp' }
]}],
[{
line: '1.72E3F',
tokens: [
{ startIndex: 0, type: 'number.float.cpp' }
]}],
[{
line: '1.72E3f',
tokens: [
{ startIndex: 0, type: 'number.float.cpp' }
]}],
[{
line: '1.72e3F',
tokens: [
{ startIndex: 0, type: 'number.float.cpp' }
]}],
[{
line: '1.72e3f',
tokens: [
{ startIndex: 0, type: 'number.float.cpp' }
]}],
[{
line: '23.5L',
tokens: [
{ startIndex: 0, type: 'number.float.cpp' }
]}],
[{
line: '23.5l',
tokens: [
{ startIndex: 0, type: 'number.float.cpp' }
]}],
[{
line: '1.72E3L',
tokens: [
{ startIndex: 0, type: 'number.float.cpp' }
]}],
[{
line: '1.72E3l',
tokens: [
{ startIndex: 0, type: 'number.float.cpp' }
]}],
[{
line: '1.72e3L',
tokens: [
{ startIndex: 0, type: 'number.float.cpp' }
]}],
[{
line: '1.72e3l',
tokens: [
{ startIndex: 0, type: 'number.float.cpp' }
]}],
[{
line: '0+0',
tokens: [
{ startIndex: 0, type: 'number.cpp' },
{ startIndex: 1, type: 'delimiter.cpp' },
{ startIndex: 2, type: 'number.cpp' }
]}],
[{
line: '100+10',
tokens: [
{ startIndex: 0, type: 'number.cpp' },
{ startIndex: 3, type: 'delimiter.cpp' },
{ startIndex: 4, type: 'number.cpp' }
]}],
[{
line: '0 + 0',
tokens: [
{ startIndex: 0, type: 'number.cpp' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.cpp' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'number.cpp' }
]}],
// Monarch Generated
[{
line: '#include<iostream>',
tokens: [
{ startIndex: 0, type: 'keyword.cpp' },
{ startIndex: 8, type: 'delimiter.angle.cpp' },
{ startIndex: 9, type: 'identifier.cpp' },
{ startIndex: 17, type: 'delimiter.angle.cpp' }
]}, {
line: '#include "/path/to/my/file.h"',
tokens: [
{ startIndex: 0, type: 'keyword.cpp' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'string.cpp' }
]}, {
line: '',
tokens: [
]}, {
line: '#ifdef VAR',
tokens: [
{ startIndex: 0, type: 'keyword.cpp' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'identifier.cpp' }
]}, {
line: '#define SUM(A,B) (A) + (B)',
tokens: [
{ startIndex: 0, type: 'keyword.cpp' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'identifier.cpp' },
{ startIndex: 11, type: 'delimiter.parenthesis.cpp' },
{ startIndex: 12, type: 'identifier.cpp' },
{ startIndex: 13, type: 'delimiter.cpp' },
{ startIndex: 14, type: 'identifier.cpp' },
{ startIndex: 15, type: 'delimiter.parenthesis.cpp' },
{ startIndex: 16, type: '' },
{ startIndex: 17, type: 'delimiter.parenthesis.cpp' },
{ startIndex: 18, type: 'identifier.cpp' },
{ startIndex: 19, type: 'delimiter.parenthesis.cpp' },
{ startIndex: 20, type: '' },
{ startIndex: 21, type: 'delimiter.cpp' },
{ startIndex: 22, type: '' },
{ startIndex: 23, type: 'delimiter.parenthesis.cpp' },
{ startIndex: 24, type: 'identifier.cpp' },
{ startIndex: 25, type: 'delimiter.parenthesis.cpp' }
]}, {
line: '',
tokens: [
]}, {
line: 'int main(int argc, char** argv)',
tokens: [
{ startIndex: 0, type: 'keyword.int.cpp' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.cpp' },
{ startIndex: 8, type: 'delimiter.parenthesis.cpp' },
{ startIndex: 9, type: 'keyword.int.cpp' },
{ startIndex: 12, type: '' },
{ startIndex: 13, type: 'identifier.cpp' },
{ startIndex: 17, type: 'delimiter.cpp' },
{ startIndex: 18, type: '' },
{ startIndex: 19, type: 'keyword.char.cpp' },
{ startIndex: 23, type: '' },
{ startIndex: 26, type: 'identifier.cpp' },
{ startIndex: 30, type: 'delimiter.parenthesis.cpp' }
]}, {
line: '{',
tokens: [
{ startIndex: 0, type: 'delimiter.curly.cpp' }
]}, {
line: ' return 0;',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'keyword.return.cpp' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'number.cpp' },
{ startIndex: 9, type: 'delimiter.cpp' }
]}, {
line: '}',
tokens: [
{ startIndex: 0, type: 'delimiter.curly.cpp' }
]}, {
line: '',
tokens: [
]}, {
line: 'namespace TestSpace',
tokens: [
{ startIndex: 0, type: 'keyword.namespace.cpp' },
{ startIndex: 9, type: '' },
{ startIndex: 10, type: 'identifier.cpp' }
]}, {
line: '{',
tokens: [
{ startIndex: 0, type: 'delimiter.curly.cpp' }
]}, {
line: ' using Asdf.CDE;',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'keyword.using.cpp' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'identifier.cpp' },
{ startIndex: 11, type: 'delimiter.cpp' },
{ startIndex: 12, type: 'identifier.cpp' },
{ startIndex: 15, type: 'delimiter.cpp' }
]}, {
line: ' template <typename T>',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'keyword.template.cpp' },
{ startIndex: 9, type: '' },
{ startIndex: 10, type: 'delimiter.angle.cpp' },
{ startIndex: 11, type: 'keyword.typename.cpp' },
{ startIndex: 19, type: '' },
{ startIndex: 20, type: 'identifier.cpp' },
{ startIndex: 21, type: 'delimiter.angle.cpp' }
]}, {
line: ' class CoolClass : protected BaseClass',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'keyword.class.cpp' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'identifier.cpp' },
{ startIndex: 16, type: '' },
{ startIndex: 17, type: 'delimiter.cpp' },
{ startIndex: 18, type: '' },
{ startIndex: 19, type: 'keyword.protected.cpp' },
{ startIndex: 28, type: '' },
{ startIndex: 29, type: 'identifier.cpp' }
]}, {
line: ' {',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.curly.cpp' }
]}, {
line: ' private:',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'keyword.private.cpp' },
{ startIndex: 9, type: 'delimiter.cpp' }
]}, {
line: ' ',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: ' static T field;',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'keyword.static.cpp' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'identifier.cpp' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'identifier.cpp' },
{ startIndex: 16, type: 'delimiter.cpp' }
]}, {
line: ' ',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: ' public:',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'keyword.public.cpp' },
{ startIndex: 8, type: 'delimiter.cpp' }
]}, {
line: ' ',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: ' [[deprecated]]',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'annotation.cpp' }
]}, {
line: ' foo method() const override',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'identifier.cpp' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'identifier.cpp' },
{ startIndex: 12, type: 'delimiter.parenthesis.cpp' },
{ startIndex: 14, type: '' },
{ startIndex: 15, type: 'keyword.const.cpp' },
{ startIndex: 20, type: '' },
{ startIndex: 21, type: 'keyword.override.cpp' }
]}, {
line: ' {',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'delimiter.curly.cpp' }
]}, {
line: ' auto s = new Bar();',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 3, type: 'keyword.auto.cpp' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'identifier.cpp' },
{ startIndex: 9, type: '' },
{ startIndex: 10, type: 'delimiter.cpp' },
{ startIndex: 11, type: '' },
{ startIndex: 12, type: 'keyword.new.cpp' },
{ startIndex: 15, type: '' },
{ startIndex: 16, type: 'identifier.cpp' },
{ startIndex: 19, type: 'delimiter.parenthesis.cpp' },
{ startIndex: 21, type: 'delimiter.cpp' }
]}, {
line: ' ',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: ' if (s.field) {',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 3, type: 'keyword.if.cpp' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.parenthesis.cpp' },
{ startIndex: 7, type: 'identifier.cpp' },
{ startIndex: 8, type: 'delimiter.cpp' },
{ startIndex: 9, type: 'identifier.cpp' },
{ startIndex: 14, type: 'delimiter.parenthesis.cpp' },
{ startIndex: 15, type: '' },
{ startIndex: 16, type: 'delimiter.curly.cpp' }
]}, {
line: ' for(const auto & b : s.field) {',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'keyword.for.cpp' },
{ startIndex: 7, type: 'delimiter.parenthesis.cpp' },
{ startIndex: 8, type: 'keyword.const.cpp' },
{ startIndex: 13, type: '' },
{ startIndex: 14, type: 'keyword.auto.cpp' },
{ startIndex: 18, type: '' },
{ startIndex: 19, type: 'delimiter.cpp' },
{ startIndex: 20, type: '' },
{ startIndex: 21, type: 'identifier.cpp' },
{ startIndex: 22, type: '' },
{ startIndex: 23, type: 'delimiter.cpp' },
{ startIndex: 24, type: '' },
{ startIndex: 25, type: 'identifier.cpp' },
{ startIndex: 26, type: 'delimiter.cpp' },
{ startIndex: 27, type: 'identifier.cpp' },
{ startIndex: 32, type: 'delimiter.parenthesis.cpp' },
{ startIndex: 33, type: '' },
{ startIndex: 34, type: 'delimiter.curly.cpp' }
]}, {
line: ' break;',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 5, type: 'keyword.break.cpp' },
{ startIndex: 10, type: 'delimiter.cpp' }
]}, {
line: ' }',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'delimiter.curly.cpp' }
]}, {
line: ' }',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 3, type: 'delimiter.curly.cpp' }
]}, {
line: ' }',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'delimiter.curly.cpp' }
]}, {
line: ' ',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: ' std::string s = "hello wordld\\n";',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'identifier.cpp' },
{ startIndex: 5, type: '' },
{ startIndex: 7, type: 'identifier.cpp' },
{ startIndex: 13, type: '' },
{ startIndex: 14, type: 'identifier.cpp' },
{ startIndex: 15, type: '' },
{ startIndex: 16, type: 'delimiter.cpp' },
{ startIndex: 17, type: '' },
{ startIndex: 18, type: 'string.cpp' },
{ startIndex: 31, type: 'string.escape.cpp' },
{ startIndex: 33, type: 'string.cpp' },
{ startIndex: 34, type: 'delimiter.cpp' }
]}, {
line: ' ',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: ' int number = 123\'123\'123Ull;',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'keyword.int.cpp' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'identifier.cpp' },
{ startIndex: 12, type: '' },
{ startIndex: 13, type: 'delimiter.cpp' },
{ startIndex: 14, type: '' },
{ startIndex: 15, type: 'number.cpp' },
{ startIndex: 29, type: 'delimiter.cpp' }
]}, {
line: ' }',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.curly.cpp' }
]}, {
line: '}',
tokens: [
{ startIndex: 0, type: 'delimiter.curly.cpp' }
]}, {
line: '',
tokens: [
]}, {
line: '#endif',
tokens: [
{ startIndex: 0, type: 'keyword.cpp' }
]}]
]);

744
test/csharp.test.ts Normal file
View file

@ -0,0 +1,744 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {testTokenization} from './testRunner';
testTokenization('csharp', [
// Generated from sample
[{
line: 'using System;',
tokens: [
{ startIndex: 0, type: 'keyword.using.cs' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'namespace.cs' },
{ startIndex: 12, type: 'delimiter.cs' }
]}, {
line: 'using System.Collections.Generic;',
tokens: [
{ startIndex: 0, type: 'keyword.using.cs' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'namespace.cs' },
{ startIndex: 12, type: 'delimiter.cs' },
{ startIndex: 13, type: 'namespace.cs' },
{ startIndex: 24, type: 'delimiter.cs' },
{ startIndex: 25, type: 'namespace.cs' },
{ startIndex: 32, type: 'delimiter.cs' }
]}, {
line: 'using System.Diagnostics;',
tokens: [
{ startIndex: 0, type: 'keyword.using.cs' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'namespace.cs' },
{ startIndex: 12, type: 'delimiter.cs' },
{ startIndex: 13, type: 'namespace.cs' },
{ startIndex: 24, type: 'delimiter.cs' }
]}, {
line: 'using System.Linq;',
tokens: [
{ startIndex: 0, type: 'keyword.using.cs' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'namespace.cs' },
{ startIndex: 12, type: 'delimiter.cs' },
{ startIndex: 13, type: 'namespace.cs' },
{ startIndex: 17, type: 'delimiter.cs' }
]}, {
line: 'using System.Text;',
tokens: [
{ startIndex: 0, type: 'keyword.using.cs' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'namespace.cs' },
{ startIndex: 12, type: 'delimiter.cs' },
{ startIndex: 13, type: 'namespace.cs' },
{ startIndex: 17, type: 'delimiter.cs' }
]}, {
line: 'using System.Threading.Tasks;',
tokens: [
{ startIndex: 0, type: 'keyword.using.cs' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'namespace.cs' },
{ startIndex: 12, type: 'delimiter.cs' },
{ startIndex: 13, type: 'namespace.cs' },
{ startIndex: 22, type: 'delimiter.cs' },
{ startIndex: 23, type: 'namespace.cs' },
{ startIndex: 28, type: 'delimiter.cs' }
]}, {
line: '',
tokens: [
]}, {
line: 'namespace VS',
tokens: [
{ startIndex: 0, type: 'keyword.namespace.cs' },
{ startIndex: 9, type: '' },
{ startIndex: 10, type: 'namespace.cs' }
]}, {
line: '{',
tokens: [
{ startIndex: 0, type: 'delimiter.curly.cs' }
]}, {
line: ' class Program',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'keyword.class.cs' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'identifier.cs' }
]}, {
line: ' {',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.curly.cs' }
]}, {
line: ' static void Main(string[] args)',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'keyword.static.cs' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'keyword.void.cs' },
{ startIndex: 13, type: '' },
{ startIndex: 14, type: 'identifier.cs' },
{ startIndex: 18, type: 'delimiter.parenthesis.cs' },
{ startIndex: 19, type: 'keyword.string.cs' },
{ startIndex: 25, type: 'delimiter.square.cs' },
{ startIndex: 27, type: '' },
{ startIndex: 28, type: 'identifier.cs' },
{ startIndex: 32, type: 'delimiter.parenthesis.cs' }
]}, {
line: ' {',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'delimiter.curly.cs' }
]}, {
line: ' ProcessStartInfo si = new ProcessStartInfo();',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 3, type: 'identifier.cs' },
{ startIndex: 19, type: '' },
{ startIndex: 20, type: 'identifier.cs' },
{ startIndex: 22, type: '' },
{ startIndex: 23, type: 'delimiter.cs' },
{ startIndex: 24, type: '' },
{ startIndex: 25, type: 'keyword.new.cs' },
{ startIndex: 28, type: '' },
{ startIndex: 29, type: 'identifier.cs' },
{ startIndex: 45, type: 'delimiter.parenthesis.cs' },
{ startIndex: 47, type: 'delimiter.cs' }
]}, {
line: ' float load= 3.2e02f;',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 3, type: 'keyword.float.cs' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'identifier.cs' },
{ startIndex: 13, type: 'delimiter.cs' },
{ startIndex: 14, type: '' },
{ startIndex: 15, type: 'number.float.cs' },
{ startIndex: 22, type: 'delimiter.cs' }
]}, {
line: '',
tokens: [
]}, {
line: ' si.FileName = @"tools\\\\node.exe";',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 3, type: 'identifier.cs' },
{ startIndex: 5, type: 'delimiter.cs' },
{ startIndex: 6, type: 'identifier.cs' },
{ startIndex: 14, type: '' },
{ startIndex: 15, type: 'delimiter.cs' },
{ startIndex: 16, type: '' },
{ startIndex: 17, type: 'string.quote.cs' },
{ startIndex: 19, type: 'string.cs' },
{ startIndex: 34, type: 'string.quote.cs' },
{ startIndex: 35, type: 'delimiter.cs' }
]}, {
line: ' si.Arguments = "tools\\\\simpl3server.js";',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 3, type: 'identifier.cs' },
{ startIndex: 5, type: 'delimiter.cs' },
{ startIndex: 6, type: 'identifier.cs' },
{ startIndex: 15, type: '' },
{ startIndex: 16, type: 'delimiter.cs' },
{ startIndex: 17, type: '' },
{ startIndex: 18, type: 'string.quote.cs' },
{ startIndex: 19, type: 'string.cs' },
{ startIndex: 24, type: 'string.escape.cs' },
{ startIndex: 26, type: 'string.cs' },
{ startIndex: 41, type: 'string.quote.cs' },
{ startIndex: 42, type: 'delimiter.cs' }
]}, {
line: ' ',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: ' string someString = $"hello{outside+variable}the string again {{ escaped";',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 3, type: 'keyword.string.cs' },
{ startIndex: 9, type: '' },
{ startIndex: 10, type: 'identifier.cs' },
{ startIndex: 20, type: '' },
{ startIndex: 21, type: 'delimiter.cs' },
{ startIndex: 22, type: '' },
{ startIndex: 23, type: 'string.quote.cs' },
{ startIndex: 25, type: 'string.cs' },
{ startIndex: 30, type: 'string.quote.cs' },
{ startIndex: 31, type: 'identifier.cs' },
{ startIndex: 38, type: 'delimiter.cs' },
{ startIndex: 39, type: 'identifier.cs' },
{ startIndex: 47, type: 'string.quote.cs' },
{ startIndex: 48, type: 'string.cs' },
{ startIndex: 65, type: 'string.escape.cs' },
{ startIndex: 67, type: 'string.cs' },
{ startIndex: 75, type: 'string.quote.cs' },
{ startIndex: 76, type: 'delimiter.cs' }
]}, {
line: ' var @string = 5;',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 3, type: 'keyword.var.cs' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'identifier.cs' },
{ startIndex: 14, type: '' },
{ startIndex: 15, type: 'delimiter.cs' },
{ startIndex: 16, type: '' },
{ startIndex: 17, type: 'number.cs' },
{ startIndex: 18, type: 'delimiter.cs' }
]}, {
line: ' ',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: ' if (x == 4)',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 3, type: 'keyword.if.cs' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.parenthesis.cs' },
{ startIndex: 7, type: 'identifier.cs' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'delimiter.cs' },
{ startIndex: 11, type: '' },
{ startIndex: 12, type: 'number.cs' },
{ startIndex: 13, type: 'delimiter.parenthesis.cs' }
]}, {
line: ' {',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 3, type: 'delimiter.curly.cs' }
]}, {
line: ' for (int i = 4; i<10; i++)',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'keyword.for.cs' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'delimiter.parenthesis.cs' },
{ startIndex: 9, type: 'keyword.int.cs' },
{ startIndex: 12, type: '' },
{ startIndex: 13, type: 'identifier.cs' },
{ startIndex: 14, type: '' },
{ startIndex: 15, type: 'delimiter.cs' },
{ startIndex: 16, type: '' },
{ startIndex: 17, type: 'number.cs' },
{ startIndex: 18, type: 'delimiter.cs' },
{ startIndex: 19, type: '' },
{ startIndex: 20, type: 'identifier.cs' },
{ startIndex: 21, type: 'delimiter.angle.cs' },
{ startIndex: 22, type: 'number.cs' },
{ startIndex: 24, type: 'delimiter.cs' },
{ startIndex: 25, type: '' },
{ startIndex: 26, type: 'identifier.cs' },
{ startIndex: 27, type: 'delimiter.cs' },
{ startIndex: 29, type: 'delimiter.parenthesis.cs' }
]}, {
line: ' {',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'delimiter.curly.cs' }
]}, {
line: ' var d = i;',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 5, type: 'keyword.var.cs' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'identifier.cs' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'delimiter.cs' },
{ startIndex: 12, type: '' },
{ startIndex: 13, type: 'identifier.cs' },
{ startIndex: 14, type: 'delimiter.cs' }
]}, {
line: ' }',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'delimiter.curly.cs' }
]}, {
line: ' }',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 3, type: 'delimiter.curly.cs' }
]}, {
line: ' else',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 3, type: 'keyword.else.cs' }
]}, {
line: ' {',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 3, type: 'delimiter.curly.cs' }
]}, {
line: ' return;',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'keyword.return.cs' },
{ startIndex: 10, type: 'delimiter.cs' }
]}, {
line: ' }',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 3, type: 'delimiter.curly.cs' }
]}, {
line: ' ',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: '',
tokens: [
]}, {
line: ' Process.Start(si);',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 3, type: 'identifier.cs' },
{ startIndex: 10, type: 'delimiter.cs' },
{ startIndex: 11, type: 'identifier.cs' },
{ startIndex: 16, type: 'delimiter.parenthesis.cs' },
{ startIndex: 17, type: 'identifier.cs' },
{ startIndex: 19, type: 'delimiter.parenthesis.cs' },
{ startIndex: 20, type: 'delimiter.cs' }
]}, {
line: ' }',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'delimiter.curly.cs' }
]}, {
line: ' }',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.curly.cs' }
]}, {
line: '}',
tokens: [
{ startIndex: 0, type: 'delimiter.curly.cs' }
]}, {
line: '',
tokens: [
]}, {
line: '#pragma region /MapLayer/*Image* /// ',
tokens: [
{ startIndex: 0, type: 'namespace.cpp.cs' }
]}, {
line: 'namespace ShouldNotBeAComment {}',
tokens: [
{ startIndex: 0, type: 'keyword.namespace.cs' },
{ startIndex: 9, type: '' },
{ startIndex: 10, type: 'namespace.cs' },
{ startIndex: 29, type: '' },
{ startIndex: 30, type: 'delimiter.curly.cs' }
]}, {
line: '#pragma endregion Region_1',
tokens: [
{ startIndex: 0, type: 'namespace.cpp.cs' }
]}],
// Keywords
[{
line: 'namespace VS { class Program { static void Main(string[] args) {} } }',
tokens: [
{ startIndex: 0, type: 'keyword.namespace.cs' },
{ startIndex: 9, type: '' },
{ startIndex: 10, type: 'namespace.cs' },
{ startIndex: 12, type: '' },
{ startIndex: 13, type: 'delimiter.curly.cs' },
{ startIndex: 14, type: '' },
{ startIndex: 15, type: 'keyword.class.cs' },
{ startIndex: 20, type: '' },
{ startIndex: 21, type: 'identifier.cs' },
{ startIndex: 28, type: '' },
{ startIndex: 29, type: 'delimiter.curly.cs' },
{ startIndex: 30, type: '' },
{ startIndex: 31, type: 'keyword.static.cs' },
{ startIndex: 37, type: '' },
{ startIndex: 38, type: 'keyword.void.cs' },
{ startIndex: 42, type: '' },
{ startIndex: 43, type: 'identifier.cs' },
{ startIndex: 47, type: 'delimiter.parenthesis.cs' },
{ startIndex: 48, type: 'keyword.string.cs' },
{ startIndex: 54, type: 'delimiter.square.cs' },
{ startIndex: 56, type: '' },
{ startIndex: 57, type: 'identifier.cs' },
{ startIndex: 61, type: 'delimiter.parenthesis.cs' },
{ startIndex: 62, type: '' },
{ startIndex: 63, type: 'delimiter.curly.cs' },
{ startIndex: 65, type: '' },
{ startIndex: 66, type: 'delimiter.curly.cs' },
{ startIndex: 67, type: '' },
{ startIndex: 68, type: 'delimiter.curly.cs' }
]}],
// Comments - single line
[{
line: '//',
tokens: [
{ startIndex: 0, type: 'comment.cs' }
]}],
[{
line: ' // a comment',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'comment.cs' }
]}],
[{
line: '// a comment',
tokens: [
{ startIndex: 0, type: 'comment.cs' }
]}],
[{
line: '//sticky comment',
tokens: [
{ startIndex: 0, type: 'comment.cs' }
]}],
[{
line: '/almost a comment',
tokens: [
{ startIndex: 0, type: 'delimiter.cs' },
{ startIndex: 1, type: 'identifier.cs' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'identifier.cs' },
{ startIndex: 9, type: '' },
{ startIndex: 10, type: 'identifier.cs' }
]}],
[{
line: '1 / 2; /* comment',
tokens: [
{ startIndex: 0, type: 'number.cs' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.cs' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'number.cs' },
{ startIndex: 5, type: 'delimiter.cs' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'comment.cs' }
]}],
[{
line: 'var x = 1; // my comment // is a nice one',
tokens: [
{ startIndex: 0, type: 'keyword.var.cs' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.cs' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.cs' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'number.cs' },
{ startIndex: 9, type: 'delimiter.cs' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'comment.cs' }
]}],
// Comments - range comment, single line
[{
line: '/* a simple comment */',
tokens: [
{ startIndex: 0, type: 'comment.cs' }
]}],
[{
line: 'var x = /* a simple comment */ 1;',
tokens: [
{ startIndex: 0, type: 'keyword.var.cs' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.cs' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.cs' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'comment.cs' },
{ startIndex: 30, type: '' },
{ startIndex: 31, type: 'number.cs' },
{ startIndex: 32, type: 'delimiter.cs' }
]}],
[{
line: 'var x = /* comment */ 1; */',
tokens: [
{ startIndex: 0, type: 'keyword.var.cs' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.cs' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.cs' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'comment.cs' },
{ startIndex: 21, type: '' },
{ startIndex: 22, type: 'number.cs' },
{ startIndex: 23, type: 'delimiter.cs' },
{ startIndex: 24, type: '' }
]}],
[{
line: 'x = /**/;',
tokens: [
{ startIndex: 0, type: 'identifier.cs' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.cs' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'comment.cs' },
{ startIndex: 8, type: 'delimiter.cs' }
]}],
[{
line: 'x = /*/;',
tokens: [
{ startIndex: 0, type: 'identifier.cs' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.cs' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'comment.cs' }
]}],
// Numbers
[{
line: '0',
tokens: [
{ startIndex: 0, type: 'number.cs' }
]}],
[{
line: '0x',
tokens: [
{ startIndex: 0, type: 'number.cs' },
{ startIndex: 1, type: 'identifier.cs' }
]}],
[{
line: '0x123',
tokens: [
{ startIndex: 0, type: 'number.hex.cs' }
]}],
[{
line: '23.5',
tokens: [
{ startIndex: 0, type: 'number.float.cs' }
]}],
[{
line: '23.5e3',
tokens: [
{ startIndex: 0, type: 'number.float.cs' }
]}],
[{
line: '23.5E3',
tokens: [
{ startIndex: 0, type: 'number.float.cs' }
]}],
[{
line: '23.5F',
tokens: [
{ startIndex: 0, type: 'number.float.cs' }
]}],
[{
line: '23.5f',
tokens: [
{ startIndex: 0, type: 'number.float.cs' }
]}],
[{
line: '1.72E3F',
tokens: [
{ startIndex: 0, type: 'number.float.cs' }
]}],
[{
line: '1.72E3f',
tokens: [
{ startIndex: 0, type: 'number.float.cs' }
]}],
[{
line: '1.72e3F',
tokens: [
{ startIndex: 0, type: 'number.float.cs' }
]}],
[{
line: '1.72e3f',
tokens: [
{ startIndex: 0, type: 'number.float.cs' }
]}],
[{
line: '23.5D',
tokens: [
{ startIndex: 0, type: 'number.float.cs' }
]}],
[{
line: '23.5d',
tokens: [
{ startIndex: 0, type: 'number.float.cs' }
]}],
[{
line: '1.72E3D',
tokens: [
{ startIndex: 0, type: 'number.float.cs' }
]}],
[{
line: '1.72E3d',
tokens: [
{ startIndex: 0, type: 'number.float.cs' }
]}],
[{
line: '1.72e3D',
tokens: [
{ startIndex: 0, type: 'number.float.cs' }
]}],
[{
line: '1.72e3d',
tokens: [
{ startIndex: 0, type: 'number.float.cs' }
]}],
[{
line: '0+0',
tokens: [
{ startIndex: 0, type: 'number.cs' },
{ startIndex: 1, type: 'delimiter.cs' },
{ startIndex: 2, type: 'number.cs' }
]}],
[{
line: '100+10',
tokens: [
{ startIndex: 0, type: 'number.cs' },
{ startIndex: 3, type: 'delimiter.cs' },
{ startIndex: 4, type: 'number.cs' }
]}],
[{
line: '0 + 0',
tokens: [
{ startIndex: 0, type: 'number.cs' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.cs' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'number.cs' }
]}],
// Strings
[{
line: 'x = "string";',
tokens: [
{ startIndex: 0, type: 'identifier.cs' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.cs' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'string.quote.cs' },
{ startIndex: 5, type: 'string.cs' },
{ startIndex: 11, type: 'string.quote.cs' },
{ startIndex: 12, type: 'delimiter.cs' }
]}],
[{
line: 'x = "stri\\"ng";',
tokens: [
{ startIndex: 0, type: 'identifier.cs' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.cs' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'string.quote.cs' },
{ startIndex: 5, type: 'string.cs' },
{ startIndex: 9, type: 'string.escape.cs' },
{ startIndex: 11, type: 'string.cs' },
{ startIndex: 13, type: 'string.quote.cs' },
{ startIndex: 14, type: 'delimiter.cs' }
]}],
// Verbatim Strings
[{
line: 'x = @"verbatimstring";',
tokens: [
{ startIndex: 0, type: 'identifier.cs' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.cs' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'string.quote.cs' },
{ startIndex: 6, type: 'string.cs' },
{ startIndex: 20, type: 'string.quote.cs' },
{ startIndex: 21, type: 'delimiter.cs' }
]}],
[{
line: 'x = @"verbatim""string";',
tokens: [
{ startIndex: 0, type: 'identifier.cs' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.cs' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'string.quote.cs' },
{ startIndex: 6, type: 'string.cs' },
{ startIndex: 14, type: 'string.escape.cs' },
{ startIndex: 16, type: 'string.cs' },
{ startIndex: 22, type: 'string.quote.cs' },
{ startIndex: 23, type: 'delimiter.cs' }
]}],
[{
line: 'x = @"verbatim\\string\\";',
tokens: [
{ startIndex: 0, type: 'identifier.cs' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.cs' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'string.quote.cs' },
{ startIndex: 6, type: 'string.cs' },
{ startIndex: 22, type: 'string.quote.cs' },
{ startIndex: 23, type: 'delimiter.cs' }
]}],
[{
line: 'x = @"verbatim',
tokens: [
{ startIndex: 0, type: 'identifier.cs' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.cs' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'string.quote.cs' },
{ startIndex: 6, type: 'string.cs' }
]},{
line: 'string";',
tokens: [
{ startIndex: 0, type: 'string.cs' },
{ startIndex: 6, type: 'string.quote.cs' },
{ startIndex: 7, type: 'delimiter.cs' }
]}]
]);

189
test/dockerfile.test.ts Normal file
View file

@ -0,0 +1,189 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {testTokenization} from './testRunner';
testTokenization('dockerfile', [
// All
[{
line: 'FROM mono:3.12',
tokens: [
{ startIndex: 0, type: 'keyword.dockerfile' },
{ startIndex: 4, type: '' }
]}, {
line: '',
tokens: [
]}, {
line: 'ENV KRE_FEED https://www.myget.org/F/aspnetvnext/api/v2',
tokens: [
{ startIndex: 0, type: 'keyword.dockerfile' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'variable.dockerfile' },
{ startIndex: 12, type: '' }
]}, {
line: 'ENV KRE_USER_HOME /opt/kre',
tokens: [
{ startIndex: 0, type: 'keyword.dockerfile' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'variable.dockerfile' },
{ startIndex: 17, type: '' }
]}, {
line: '',
tokens: [
]}, {
line: 'RUN apt-get -qq update && apt-get -qqy install unzip ',
tokens: [
{ startIndex: 0, type: 'keyword.dockerfile' },
{ startIndex: 3, type: '' }
]}, {
line: '',
tokens: [
]}, {
line: 'ONBUILD RUN curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/kvminstall.sh | sh',
tokens: [
{ startIndex: 0, type: 'keyword.dockerfile' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'keyword.dockerfile' },
{ startIndex: 11, type: '' }
]}, {
line: 'ONBUILD RUN bash -c "source $KRE_USER_HOME/kvm/kvm.sh \\',
tokens: [
{ startIndex: 0, type: 'keyword.dockerfile' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'keyword.dockerfile' },
{ startIndex: 11, type: '' },
{ startIndex: 20, type: 'string.dockerfile' },
{ startIndex: 28, type: 'variable.dockerfile' },
{ startIndex: 42, type: 'string.dockerfile' }
]}, {
line: ' && kvm install latest -a default \\',
tokens: [
{ startIndex: 0, type: 'string.dockerfile' }
]}, {
line: ' && kvm alias default | xargs -i ln -s $KRE_USER_HOME/packages/{} $KRE_USER_HOME/packages/default"',
tokens: [
{ startIndex: 0, type: 'string.dockerfile' },
{ startIndex: 42, type: 'variable.dockerfile' },
{ startIndex: 56, type: 'string.dockerfile' },
{ startIndex: 69, type: 'variable.dockerfile' },
{ startIndex: 83, type: 'string.dockerfile' }
]}, {
line: '',
tokens: [
]}, {
line: '# Install libuv for Kestrel from source code (binary is not in wheezy and one in jessie is still too old)',
tokens: [
{ startIndex: 0, type: 'comment.dockerfile' }
]}, {
line: 'RUN apt-get -qqy install \\',
tokens: [
{ startIndex: 0, type: 'keyword.dockerfile' },
{ startIndex: 3, type: '' }
]}, {
line: ' autoconf \\',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: ' automake \\',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: ' build-essential \\',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: ' libtool ',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: 'RUN LIBUV_VERSION=1.0.0-rc2 \\',
tokens: [
{ startIndex: 0, type: 'keyword.dockerfile' },
{ startIndex: 3, type: '' }
]}, {
line: ' && curl -sSL https://github.com/joyent/libuv/archive/v${LIBUV_VERSION}.tar.gz | tar zxfv - -C /usr/local/src \\',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 58, type: 'variable.dockerfile' },
{ startIndex: 74, type: '' }
]}, {
line: ' && cd /usr/local/src/libuv-$LIBUV_VERSION \\',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 31, type: 'variable.dockerfile' },
{ startIndex: 45, type: '' }
]}, {
line: ' && sh autogen.sh && ./configure && make && make install \\',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: ' && rm -rf /usr/local/src/libuv-$LIBUV_VERSION \\',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 35, type: 'variable.dockerfile' },
{ startIndex: 49, type: '' }
]}, {
line: ' && ldconfig',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: '',
tokens: [
]}, {
line: 'ENV PATH $PATH:$KRE_USER_HOME/packages/default/bin',
tokens: [
{ startIndex: 0, type: 'keyword.dockerfile' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'variable.dockerfile' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'variable.dockerfile' },
{ startIndex: 14, type: '' },
{ startIndex: 15, type: 'variable.dockerfile' },
{ startIndex: 29, type: '' }
]}, {
line: '',
tokens: [
]}, {
line: '# Extra things to test',
tokens: [
{ startIndex: 0, type: 'comment.dockerfile' }
]}, {
line: 'RUN echo "string at end"',
tokens: [
{ startIndex: 0, type: 'keyword.dockerfile' },
{ startIndex: 3, type: '' },
{ startIndex: 9, type: 'string.dockerfile' }
]}, {
line: 'RUN echo must work \'some str\' and some more',
tokens: [
{ startIndex: 0, type: 'keyword.dockerfile' },
{ startIndex: 3, type: '' },
{ startIndex: 19, type: 'string.dockerfile' },
{ startIndex: 29, type: '' }
]}, {
line: 'RUN echo hi this is # not a comment',
tokens: [
{ startIndex: 0, type: 'keyword.dockerfile' },
{ startIndex: 3, type: '' }
]}, {
line: 'RUN echo \'String with ${VAR} and another $one here\'',
tokens: [
{ startIndex: 0, type: 'keyword.dockerfile' },
{ startIndex: 3, type: '' },
{ startIndex: 9, type: 'string.dockerfile' },
{ startIndex: 22, type: 'variable.dockerfile' },
{ startIndex: 28, type: 'string.dockerfile' },
{ startIndex: 41, type: 'variable.dockerfile' },
{ startIndex: 45, type: 'string.dockerfile' }
]}]
]);

392
test/fsharp.test.ts Normal file
View file

@ -0,0 +1,392 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {testTokenization} from './testRunner';
testTokenization('fsharp', [
// comments - single line
[{
line: '// one line comment',
tokens: [
{ startIndex: 0, type: 'comment.fs' }
]}],
[{
line: '//',
tokens: [
{ startIndex: 0, type: 'comment.fs' }
]}],
[{
line: ' // a comment',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'comment.fs' }
]}],
[{
line: '// a comment',
tokens: [
{ startIndex: 0, type: 'comment.fs' }
]}],
[{
line: '//sticky comment',
tokens: [
{ startIndex: 0, type: 'comment.fs' }
]}],
[{
line: '/almost a comment',
tokens: [
{ startIndex: 0, type: 'delimiter.fs' },
{ startIndex: 1, type: 'identifier.fs' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'identifier.fs' },
{ startIndex: 9, type: '' },
{ startIndex: 10, type: 'identifier.fs' }
]}],
[{
line: '(/*almost a comment',
tokens: [
{ startIndex: 0, type: 'delimiter.parenthesis.fs' },
{ startIndex: 1, type: 'delimiter.fs' },
{ startIndex: 3, type: 'identifier.fs' },
{ startIndex: 9, type: '' },
{ startIndex: 10, type: 'identifier.fs' },
{ startIndex: 11, type: '' },
{ startIndex: 12, type: 'identifier.fs' }
]}],
[{
line: '1 / 2; (* comment',
tokens: [
{ startIndex: 0, type: 'number.fs' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.fs' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'number.fs' },
{ startIndex: 5, type: 'delimiter.fs' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'comment.fs' }
]}],
[{
line: 'let x = 1; // my comment // is a nice one',
tokens: [
{ startIndex: 0, type: 'keyword.let.fs' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.fs' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.fs' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'number.fs' },
{ startIndex: 9, type: 'delimiter.fs' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'comment.fs' }
]}],
// Keywords
[{
line: 'namespace Application1',
tokens: [
{ startIndex: 0, type: 'keyword.namespace.fs' },
{ startIndex: 9, type: '' },
{ startIndex: 10, type: 'identifier.fs' }
]}],
[{
line: 'type MyType',
tokens: [
{ startIndex: 0, type: 'keyword.type.fs' },
{ startIndex: 4, type: '' },
{ startIndex: 5, type: 'identifier.fs' }
]}],
[{
line: 'module App =',
tokens: [
{ startIndex: 0, type: 'keyword.module.fs' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'identifier.fs' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'delimiter.fs' }
]}],
[{
line: 'let AppName = "App1"',
tokens: [
{ startIndex: 0, type: 'keyword.let.fs' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.fs' },
{ startIndex: 11, type: '' },
{ startIndex: 12, type: 'delimiter.fs' },
{ startIndex: 13, type: '' },
{ startIndex: 14, type: 'string.fs' }
]}],
// Comments - range comment
[{
line: '(* a simple comment *)',
tokens: [
{ startIndex: 0, type: 'comment.fs' }
]}],
[{
line: 'let x = (* a simple comment *) 1',
tokens: [
{ startIndex: 0, type: 'keyword.let.fs' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.fs' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.fs' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'comment.fs' },
{ startIndex: 30, type: '' },
{ startIndex: 31, type: 'number.fs' }
]}],
[{
line: 'x = (**)',
tokens: [
{ startIndex: 0, type: 'identifier.fs' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.fs' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'comment.fs' }
]}],
[{
line: 'x = (*)',
tokens: [
{ startIndex: 0, type: 'identifier.fs' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.fs' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'comment.fs' }
]}],
// Numbers
[{
line: '0',
tokens: [
{ startIndex: 0, type: 'number.fs' }
]}],
[{
line: '0x123',
tokens: [
{ startIndex: 0, type: 'number.hex.fs' }
]}],
[{
line: '23.5',
tokens: [
{ startIndex: 0, type: 'number.float.fs' }
]}],
[{
line: '23.5e3',
tokens: [
{ startIndex: 0, type: 'number.float.fs' }
]}],
[{
line: '23.5E3',
tokens: [
{ startIndex: 0, type: 'number.float.fs' }
]}],
[{
line: '23.5F',
tokens: [
{ startIndex: 0, type: 'number.float.fs' }
]}],
[{
line: '23.5f',
tokens: [
{ startIndex: 0, type: 'number.float.fs' }
]}],
[{
line: '1.72E3F',
tokens: [
{ startIndex: 0, type: 'number.float.fs' }
]}],
[{
line: '1.72E3f',
tokens: [
{ startIndex: 0, type: 'number.float.fs' }
]}],
[{
line: '1.72e3F',
tokens: [
{ startIndex: 0, type: 'number.float.fs' }
]}],
[{
line: '1.72e3f',
tokens: [
{ startIndex: 0, type: 'number.float.fs' }
]}],
[{
line: '23.5M',
tokens: [
{ startIndex: 0, type: 'number.float.fs' }
]}],
[{
line: '23.5m',
tokens: [
{ startIndex: 0, type: 'number.float.fs' }
]}],
[{
line: '1.72E3M',
tokens: [
{ startIndex: 0, type: 'number.float.fs' }
]}],
[{
line: '1.72E3m',
tokens: [
{ startIndex: 0, type: 'number.float.fs' }
]}],
[{
line: '1.72e3M',
tokens: [
{ startIndex: 0, type: 'number.float.fs' }
]}],
[{
line: '1.72e3m',
tokens: [
{ startIndex: 0, type: 'number.float.fs' }
]}],
[{
line: '0+0',
tokens: [
{ startIndex: 0, type: 'number.fs' },
{ startIndex: 1, type: 'delimiter.fs' },
{ startIndex: 2, type: 'number.fs' }
]}],
[{
line: '100+10',
tokens: [
{ startIndex: 0, type: 'number.fs' },
{ startIndex: 3, type: 'delimiter.fs' },
{ startIndex: 4, type: 'number.fs' }
]}],
[{
line: '0 + 0',
tokens: [
{ startIndex: 0, type: 'number.fs' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.fs' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'number.fs' }
]}],
[{
line: '0b00000101',
tokens: [
{ startIndex: 0, type: 'number.bin.fs' }
]}],
[{
line: '86y',
tokens: [
{ startIndex: 0, type: 'number.fs' }
]}],
[{
line: '0b00000101y',
tokens: [
{ startIndex: 0, type: 'number.bin.fs' }
]}],
[{
line: '86s',
tokens: [
{ startIndex: 0, type: 'number.fs' }
]}],
[{
line: '86us',
tokens: [
{ startIndex: 0, type: 'number.fs' }
]}],
[{
line: '86',
tokens: [
{ startIndex: 0, type: 'number.fs' }
]}],
[{
line: '86l',
tokens: [
{ startIndex: 0, type: 'number.fs' }
]}],
[{
line: '86u',
tokens: [
{ startIndex: 0, type: 'number.fs' }
]}],
[{
line: '86ul',
tokens: [
{ startIndex: 0, type: 'number.fs' }
]}],
[{
line: '0x00002D3Fn',
tokens: [
{ startIndex: 0, type: 'number.hex.fs' }
]}],
[{
line: '0x00002D3Fun',
tokens: [
{ startIndex: 0, type: 'number.hex.fs' }
]}],
[{
line: '86L',
tokens: [
{ startIndex: 0, type: 'number.fs' }
]}],
[{
line: '86UL',
tokens: [
{ startIndex: 0, type: 'number.fs' }
]}],
[{
line: '9999999999999999999999999999I',
tokens: [
{ startIndex: 0, type: 'number.fs' }
]}],
[{
line: '0x00002D3FLF',
tokens: [
{ startIndex: 0, type: 'number.float.fs' }
]}]
]);

1167
test/go.test.ts Normal file

File diff suppressed because it is too large Load diff

380
test/jade.test.ts Normal file
View file

@ -0,0 +1,380 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {testTokenization} from './testRunner';
testTokenization('jade', [
// Tags [Jade]
[{
line: 'p 5',
tokens: [
{ startIndex: 0, type: 'tag.jade' },
{ startIndex: 1, type: '' }
]}],
[{
line: 'div#container.stuff',
tokens: [
{ startIndex: 0, type: 'tag.jade' },
{ startIndex: 3, type: 'tag.id.jade' },
{ startIndex: 13, type: 'tag.class.jade' }
]}],
[{
line: 'div.container#stuff',
tokens: [
{ startIndex: 0, type: 'tag.jade' },
{ startIndex: 3, type: 'tag.class.jade' },
{ startIndex: 13, type: 'tag.id.jade' }
]}],
[{
line: 'div.container#stuff .container',
tokens: [
{ startIndex: 0, type: 'tag.jade' },
{ startIndex: 3, type: 'tag.class.jade' },
{ startIndex: 13, type: 'tag.id.jade' },
{ startIndex: 19, type: '' }
]}],
[{
line: '#tag-id-1',
tokens: [
{ startIndex: 0, type: 'tag.id.jade' }
]}],
[{
line: '.tag-id-1',
tokens: [
{ startIndex: 0, type: 'tag.class.jade' }
]}],
// Attributes - Single Line [Jade]
[{
line: 'input(type="checkbox")',
tokens: [
{ startIndex: 0, type: 'tag.jade' },
{ startIndex: 5, type: 'delimiter.parenthesis.jade' },
{ startIndex: 6, type: 'attribute.name.jade' },
{ startIndex: 10, type: 'delimiter.jade' },
{ startIndex: 11, type: 'attribute.value.jade' },
{ startIndex: 21, type: 'delimiter.parenthesis.jade' }
]}],
[{
line: 'input (type="checkbox")',
tokens: [
{ startIndex: 0, type: 'tag.jade' },
{ startIndex: 5, type: '' }
]}],
[{
line: 'input(type="checkbox",name="agreement",checked)',
tokens: [
{ startIndex: 0, type: 'tag.jade' },
{ startIndex: 5, type: 'delimiter.parenthesis.jade' },
{ startIndex: 6, type: 'attribute.name.jade' },
{ startIndex: 10, type: 'delimiter.jade' },
{ startIndex: 11, type: 'attribute.value.jade' },
{ startIndex: 21, type: 'attribute.delimiter.jade' },
{ startIndex: 22, type: 'attribute.name.jade' },
{ startIndex: 26, type: 'delimiter.jade' },
{ startIndex: 27, type: 'attribute.value.jade' },
{ startIndex: 38, type: 'attribute.delimiter.jade' },
{ startIndex: 39, type: 'attribute.name.jade' },
{ startIndex: 46, type: 'delimiter.parenthesis.jade' }
]}],
[{
line: 'input(type="checkbox"',
tokens: [
{ startIndex: 0, type: 'tag.jade' },
{ startIndex: 5, type: 'delimiter.parenthesis.jade' },
{ startIndex: 6, type: 'attribute.name.jade' },
{ startIndex: 10, type: 'delimiter.jade' },
{ startIndex: 11, type: 'attribute.value.jade' }
]}, {
line: 'name="agreement"',
tokens: [
{ startIndex: 0, type: 'attribute.name.jade' },
{ startIndex: 4, type: 'delimiter.jade' },
{ startIndex: 5, type: 'attribute.value.jade' }
]}, {
line: 'checked)',
tokens: [
{ startIndex: 0, type: 'attribute.name.jade' },
{ startIndex: 7, type: 'delimiter.parenthesis.jade' }
]}, {
line: 'body',
tokens: [
{ startIndex: 0, type: 'tag.jade' }
]}],
// Attributes - MultiLine [Jade]
[{
line: 'input(type="checkbox"',
tokens: [
{ startIndex: 0, type: 'tag.jade' },
{ startIndex: 5, type: 'delimiter.parenthesis.jade' },
{ startIndex: 6, type: 'attribute.name.jade' },
{ startIndex: 10, type: 'delimiter.jade' },
{ startIndex: 11, type: 'attribute.value.jade' }
]}, {
line: 'disabled',
tokens: [
{ startIndex: 0, type: 'attribute.name.jade' }
]}, {
line: 'checked)',
tokens: [
{ startIndex: 0, type: 'attribute.name.jade' },
{ startIndex: 7, type: 'delimiter.parenthesis.jade' }
]}, {
line: 'body',
tokens: [
{ startIndex: 0, type: 'tag.jade' }
]}],
// Interpolation [Jade]
[{
line: 'p print #{count} lines',
tokens: [
{ startIndex: 0, type: 'tag.jade' },
{ startIndex: 1, type: '' },
{ startIndex: 8, type: 'interpolation.delimiter.jade' },
{ startIndex: 10, type: 'interpolation.jade' },
{ startIndex: 15, type: 'interpolation.delimiter.jade' },
{ startIndex: 16, type: '' }
]}],
[{
line: 'p print "#{count}" lines',
tokens: [
{ startIndex: 0, type: 'tag.jade' },
{ startIndex: 1, type: '' },
{ startIndex: 9, type: 'interpolation.delimiter.jade' },
{ startIndex: 11, type: 'interpolation.jade' },
{ startIndex: 16, type: 'interpolation.delimiter.jade' },
{ startIndex: 17, type: '' }
]}],
[{
line: '{ key: 123 }',
tokens: [
{ startIndex: 0, type: 'delimiter.curly.jade' },
{ startIndex: 1, type: '' },
{ startIndex: 5, type: 'delimiter.jade' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'number.jade' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'delimiter.curly.jade' }
]}],
// Comments - Single Line [Jade]
[{
line: '// html#id1.class1',
tokens: [
{ startIndex: 0, type: 'comment.jade' }
]}],
[{
line: 'body hello // not a comment 123',
tokens: [
{ startIndex: 0, type: 'tag.jade' },
{ startIndex: 4, type: '' }
]}],
// Comments - MultiLine [Jade]
[{
line: '//',
tokens: [
{ startIndex: 0, type: 'comment.jade' }
]}, {
line: ' should be a comment',
tokens: [
{ startIndex: 0, type: 'comment.jade' }
]}, {
line: ' should still be a comment',
tokens: [
{ startIndex: 0, type: 'comment.jade' }
]}, {
line: 'div should not be a comment',
tokens: [
{ startIndex: 0, type: 'tag.jade' },
{ startIndex: 3, type: '' }
]}],
// Code [Jade]
[{
line: '- var a = 1',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'keyword.var.jade' },
{ startIndex: 5, type: '' },
{ startIndex: 8, type: 'delimiter.jade' },
{ startIndex: 9, type: '' },
{ startIndex: 10, type: 'number.jade' }
]}],
[{
line: 'each item in items',
tokens: [
{ startIndex: 0, type: 'keyword.each.jade' },
{ startIndex: 4, type: '' },
{ startIndex: 10, type: 'keyword.in.jade' },
{ startIndex: 12, type: '' }
]}],
[{
line: '- var html = "<script></script>"',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'keyword.var.jade' },
{ startIndex: 5, type: '' },
{ startIndex: 11, type: 'delimiter.jade' },
{ startIndex: 12, type: '' },
{ startIndex: 13, type: 'string.jade' }
]}],
// Generated from sample
[{
line: 'doctype 5',
tokens: [
{ startIndex: 0, type: 'keyword.doctype.jade' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'number.jade' }
]}, {
line: 'html(lang="en")',
tokens: [
{ startIndex: 0, type: 'tag.jade' },
{ startIndex: 4, type: 'delimiter.parenthesis.jade' },
{ startIndex: 5, type: 'attribute.name.jade' },
{ startIndex: 9, type: 'delimiter.jade' },
{ startIndex: 10, type: 'attribute.value.jade' },
{ startIndex: 14, type: 'delimiter.parenthesis.jade' }
]}, {
line: ' head',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'tag.jade' }
]}, {
line: ' title= pageTitle',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 8, type: 'tag.jade' },
{ startIndex: 13, type: '' }
]}, {
line: ' script(type=\'text/javascript\')',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 8, type: 'tag.jade' },
{ startIndex: 14, type: 'delimiter.parenthesis.jade' },
{ startIndex: 15, type: 'attribute.name.jade' },
{ startIndex: 19, type: 'delimiter.jade' },
{ startIndex: 20, type: 'attribute.value.jade' },
{ startIndex: 37, type: 'delimiter.parenthesis.jade' }
]}, {
line: ' if (foo) {',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 12, type: 'keyword.if.jade' },
{ startIndex: 14, type: '' },
{ startIndex: 15, type: 'delimiter.parenthesis.jade' },
{ startIndex: 16, type: '' },
{ startIndex: 19, type: 'delimiter.parenthesis.jade' },
{ startIndex: 20, type: '' },
{ startIndex: 21, type: 'delimiter.curly.jade' }
]}, {
line: ' bar()',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 19, type: 'delimiter.parenthesis.jade' }
]}, {
line: ' }',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 12, type: 'delimiter.curly.jade' }
]}, {
line: ' body',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'tag.jade' }
]}, {
line: ' // Disclaimer: You will need to turn insertSpaces to true in order for the',
tokens: [
{ startIndex: 0, type: 'comment.jade' }
]}, {
line: ' syntax highlighting to kick in properly (especially for comments)',
tokens: [
{ startIndex: 0, type: 'comment.jade' }
]}, {
line: ' Enjoy :)',
tokens: [
{ startIndex: 0, type: 'comment.jade' }
]}, {
line: ' h1 Jade - node template engine if in',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 8, type: 'tag.jade' },
{ startIndex: 10, type: '' }
]}, {
line: ' p.',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 8, type: 'tag.jade' },
{ startIndex: 9, type: 'delimiter.jade' }
]}, {
line: ' text ',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: ' text',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: ' #container',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: ' #container',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: ' #container',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 8, type: 'tag.id.jade' }
]}, {
line: ' if youAreUsingJade',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 10, type: 'keyword.if.jade' },
{ startIndex: 12, type: '' }
]}, {
line: ' p You are amazing',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 12, type: 'tag.jade' },
{ startIndex: 13, type: '' }
]}, {
line: ' else',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 10, type: 'keyword.else.jade' }
]}, {
line: ' p Get on it!',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 12, type: 'tag.jade' },
{ startIndex: 13, type: '' }
]}, {
line: ' p Text can be included in a number of different ways.',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 5, type: 'tag.jade' },
{ startIndex: 6, type: '' }
]}]
]);

605
test/java.test.ts Normal file
View file

@ -0,0 +1,605 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {testTokenization} from './testRunner';
testTokenization('java', [
// Comments - single line
[{
line: '//',
tokens: [
{ startIndex: 0, type: 'comment.java' }
]}],
[{
line: ' // a comment',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'comment.java' }
]}],
// Broken nested tokens due to invalid comment tokenization
[{
line: '/* //*/ a',
tokens: [
{ startIndex: 0, type: 'comment.java' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'identifier.java' }
]}],
[{
line: '// a comment',
tokens: [
{ startIndex: 0, type: 'comment.java' }
]}],
[{
line: '//sticky comment',
tokens: [
{ startIndex: 0, type: 'comment.java' }
]}],
[{
line: '/almost a comment',
tokens: [
{ startIndex: 0, type: 'delimiter.java' },
{ startIndex: 1, type: 'identifier.java' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'identifier.java' },
{ startIndex: 9, type: '' },
{ startIndex: 10, type: 'identifier.java' }
]}],
[{
line: '1 / 2; /* comment',
tokens: [
{ startIndex: 0, type: 'number.java' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.java' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'number.java' },
{ startIndex: 5, type: 'delimiter.java' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'comment.java' }
]}],
[{
line: 'int x = 1; // my comment // is a nice one',
tokens: [
{ startIndex: 0, type: 'keyword.int.java' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.java' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.java' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'number.java' },
{ startIndex: 9, type: 'delimiter.java' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'comment.java' }
]}],
// Comments - range comment, single line
[{
line: '/* a simple comment */',
tokens: [
{ startIndex: 0, type: 'comment.java' }
]}],
[{
line: 'int x = /* a simple comment */ 1;',
tokens: [
{ startIndex: 0, type: 'keyword.int.java' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.java' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.java' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'comment.java' },
{ startIndex: 30, type: '' },
{ startIndex: 31, type: 'number.java' },
{ startIndex: 32, type: 'delimiter.java' }
]}],
[{
line: 'int x = /* comment */ 1; */',
tokens: [
{ startIndex: 0, type: 'keyword.int.java' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.java' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.java' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'comment.java' },
{ startIndex: 21, type: '' },
{ startIndex: 22, type: 'number.java' },
{ startIndex: 23, type: 'delimiter.java' },
{ startIndex: 24, type: '' }
]}],
[{
line: 'x = /**/;',
tokens: [
{ startIndex: 0, type: 'identifier.java' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.java' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'comment.java' },
{ startIndex: 8, type: 'delimiter.java' }
]}],
[{
line: 'x = /*/;',
tokens: [
{ startIndex: 0, type: 'identifier.java' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.java' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'comment.java' }
]}],
// Comments - range comment, multiple lines
[{
line: '/* start of multiline comment',
tokens: [
{ startIndex: 0, type: 'comment.java' }
]}, {
line: 'a comment between without a star',
tokens: [
{ startIndex: 0, type: 'comment.java' }
]}, {
line: 'end of multiline comment*/',
tokens: [
{ startIndex: 0, type: 'comment.java' }
]}],
[{
line: 'int x = /* start a comment',
tokens: [
{ startIndex: 0, type: 'keyword.int.java' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.java' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.java' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'comment.java' }
]}, {
line: ' a ',
tokens: [
{ startIndex: 0, type: 'comment.java' }
]}, {
line: 'and end it */ 2;',
tokens: [
{ startIndex: 0, type: 'comment.java' },
{ startIndex: 13, type: '' },
{ startIndex: 14, type: 'number.java' },
{ startIndex: 15, type: 'delimiter.java' }
]}],
// Java Doc, multiple lines
[{
line: '/** start of Java Doc',
tokens: [
{ startIndex: 0, type: 'comment.doc.java' }
]}, {
line: 'a comment between without a star',
tokens: [
{ startIndex: 0, type: 'comment.doc.java' }
]}, {
line: 'end of multiline comment*/',
tokens: [
{ startIndex: 0, type: 'comment.doc.java' }
]}],
// Keywords
[{
line: 'package test; class Program { static void main(String[] args) {} } }',
tokens: [
{ startIndex: 0, type: 'keyword.package.java' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'identifier.java' },
{ startIndex: 12, type: 'delimiter.java' },
{ startIndex: 13, type: '' },
{ startIndex: 14, type: 'keyword.class.java' },
{ startIndex: 19, type: '' },
{ startIndex: 20, type: 'identifier.java' },
{ startIndex: 27, type: '' },
{ startIndex: 28, type: 'delimiter.curly.java' },
{ startIndex: 29, type: '' },
{ startIndex: 30, type: 'keyword.static.java' },
{ startIndex: 36, type: '' },
{ startIndex: 37, type: 'keyword.void.java' },
{ startIndex: 41, type: '' },
{ startIndex: 42, type: 'identifier.java' },
{ startIndex: 46, type: 'delimiter.parenthesis.java' },
{ startIndex: 47, type: 'identifier.java' },
{ startIndex: 53, type: 'delimiter.square.java' },
{ startIndex: 55, type: '' },
{ startIndex: 56, type: 'identifier.java' },
{ startIndex: 60, type: 'delimiter.parenthesis.java' },
{ startIndex: 61, type: '' },
{ startIndex: 62, type: 'delimiter.curly.java' },
{ startIndex: 64, type: '' },
{ startIndex: 65, type: 'delimiter.curly.java' },
{ startIndex: 66, type: '' },
{ startIndex: 67, type: 'delimiter.curly.java' }
]}],
// Numbers
[{
line: '0',
tokens: [
{ startIndex: 0, type: 'number.java' }
]}],
[{
line: '0.10',
tokens: [
{ startIndex: 0, type: 'number.float.java' }
]}],
[{
line: '0x',
tokens: [
{ startIndex: 0, type: 'number.java' },
{ startIndex: 1, type: 'identifier.java' }
]}],
[{
line: '0x123',
tokens: [
{ startIndex: 0, type: 'number.hex.java' }
]}],
[{
line: '0x5_2',
tokens: [
{ startIndex: 0, type: 'number.hex.java' }
]}],
[{
line: '023L',
tokens: [
{ startIndex: 0, type: 'number.octal.java' }
]}],
[{
line: '0123l',
tokens: [
{ startIndex: 0, type: 'number.octal.java' }
]}],
[{
line: '05_2',
tokens: [
{ startIndex: 0, type: 'number.octal.java' }
]}],
[{
line: '0b1010_0101',
tokens: [
{ startIndex: 0, type: 'number.binary.java' }
]}],
[{
line: '0B001',
tokens: [
{ startIndex: 0, type: 'number.binary.java' }
]}],
[{
line: '10e3',
tokens: [
{ startIndex: 0, type: 'number.float.java' }
]}],
[{
line: '10f',
tokens: [
{ startIndex: 0, type: 'number.float.java' }
]}],
[{
line: '23.5',
tokens: [
{ startIndex: 0, type: 'number.float.java' }
]}],
[{
line: '23.5e3',
tokens: [
{ startIndex: 0, type: 'number.float.java' }
]}],
[{
line: '23.5e-3',
tokens: [
{ startIndex: 0, type: 'number.float.java' }
]}],
[{
line: '23.5E3',
tokens: [
{ startIndex: 0, type: 'number.float.java' }
]}],
[{
line: '23.5E-3',
tokens: [
{ startIndex: 0, type: 'number.float.java' }
]}],
[{
line: '23.5F',
tokens: [
{ startIndex: 0, type: 'number.float.java' }
]}],
[{
line: '23.5f',
tokens: [
{ startIndex: 0, type: 'number.float.java' }
]}],
[{
line: '23.5D',
tokens: [
{ startIndex: 0, type: 'number.float.java' }
]}],
[{
line: '23.5d',
tokens: [
{ startIndex: 0, type: 'number.float.java' }
]}],
[{
line: '1.72E3D',
tokens: [
{ startIndex: 0, type: 'number.float.java' }
]}],
[{
line: '1.72E3d',
tokens: [
{ startIndex: 0, type: 'number.float.java' }
]}],
[{
line: '1.72E-3d',
tokens: [
{ startIndex: 0, type: 'number.float.java' }
]}],
[{
line: '1.72e3D',
tokens: [
{ startIndex: 0, type: 'number.float.java' }
]}],
[{
line: '1.72e3d',
tokens: [
{ startIndex: 0, type: 'number.float.java' }
]}],
[{
line: '1.72e-3d',
tokens: [
{ startIndex: 0, type: 'number.float.java' }
]}],
[{
line: '23L',
tokens: [
{ startIndex: 0, type: 'number.java' }
]}],
[{
line: '23l',
tokens: [
{ startIndex: 0, type: 'number.java' }
]}],
[{
line: '0_52',
tokens: [
{ startIndex: 0, type: 'number.java' }
]}],
[{
line: '5_2',
tokens: [
{ startIndex: 0, type: 'number.java' }
]}],
[{
line: '5_______2',
tokens: [
{ startIndex: 0, type: 'number.java' }
]}],
[{
line: '3_.1415F',
tokens: [
{ startIndex: 0, type: 'number.java' },
{ startIndex: 1, type: 'identifier.java' },
{ startIndex: 2, type: 'delimiter.java' },
{ startIndex: 3, type: 'number.float.java' }
]}],
[{
line: '3._1415F',
tokens: [
{ startIndex: 0, type: 'number.java' },
{ startIndex: 1, type: 'delimiter.java' },
{ startIndex: 2, type: 'identifier.java' }
]}],
[{
line: '999_99_9999_L',
tokens: [
{ startIndex: 0, type: 'number.java' },
{ startIndex: 11, type: 'identifier.java' }
]}],
[{
line: '52_',
tokens: [
{ startIndex: 0, type: 'number.java' },
{ startIndex: 2, type: 'identifier.java' }
]}],
[{
line: '0_x52',
tokens: [
{ startIndex: 0, type: 'number.java' },
{ startIndex: 1, type: 'identifier.java' }
]}],
[{
line: '0x_52',
tokens: [
{ startIndex: 0, type: 'number.java' },
{ startIndex: 1, type: 'identifier.java' }
]}],
[{
line: '0x52_',
tokens: [
{ startIndex: 0, type: 'number.hex.java' },
{ startIndex: 4, type: 'identifier.java' }
]}],
[{
line: '052_',
tokens: [
{ startIndex: 0, type: 'number.octal.java' },
{ startIndex: 3, type: 'identifier.java' }
]}],
[{
line: '23.5L',
tokens: [
{ startIndex: 0, type: 'number.float.java' },
{ startIndex: 4, type: 'identifier.java' }
]}],
[{
line: '0+0',
tokens: [
{ startIndex: 0, type: 'number.java' },
{ startIndex: 1, type: 'delimiter.java' },
{ startIndex: 2, type: 'number.java' }
]}],
[{
line: '100+10',
tokens: [
{ startIndex: 0, type: 'number.java' },
{ startIndex: 3, type: 'delimiter.java' },
{ startIndex: 4, type: 'number.java' }
]}],
[{
line: '0 + 0',
tokens: [
{ startIndex: 0, type: 'number.java' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.java' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'number.java' }
]}],
// single line Strings
[{
line: 'String s = "I\'m a Java String";',
tokens: [
{ startIndex: 0, type: 'identifier.java' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'identifier.java' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'delimiter.java' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'string.java' },
{ startIndex: 30, type: 'delimiter.java' }
]}],
[{
line: 'String s = "concatenated" + " String" ;',
tokens: [
{ startIndex: 0, type: 'identifier.java' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'identifier.java' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'delimiter.java' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'string.java' },
{ startIndex: 25, type: '' },
{ startIndex: 26, type: 'delimiter.java' },
{ startIndex: 27, type: '' },
{ startIndex: 28, type: 'string.java' },
{ startIndex: 37, type: '' },
{ startIndex: 38, type: 'delimiter.java' }
]}],
[{
line: '"quote in a string"',
tokens: [
{ startIndex: 0, type: 'string.java' }
]}],
[{
line: '"escaping \\"quotes\\" is cool"',
tokens: [
{ startIndex: 0, type: 'string.java' },
{ startIndex: 10, type: 'string.escape.java' },
{ startIndex: 12, type: 'string.java' },
{ startIndex: 18, type: 'string.escape.java' },
{ startIndex: 20, type: 'string.java' }
]}],
[{
line: '"\\"',
tokens: [
{ startIndex: 0, type: 'string.invalid.java' }
]}],
// Annotations
[{
line: '@',
tokens: [
{ startIndex: 0, type: '' }
]}],
[{
line: '@Override',
tokens: [
{ startIndex: 0, type: 'annotation.java' }
]}],
[{
line: '@SuppressWarnings(value = "aString")',
tokens: [
{ startIndex: 0, type: 'annotation.java' },
{ startIndex: 17, type: 'delimiter.parenthesis.java' },
{ startIndex: 18, type: 'identifier.java' },
{ startIndex: 23, type: '' },
{ startIndex: 24, type: 'delimiter.java' },
{ startIndex: 25, type: '' },
{ startIndex: 26, type: 'string.java' },
{ startIndex: 35, type: 'delimiter.parenthesis.java' }
]}],
[{
line: '@ AnnotationWithKeywordAfter private',
tokens: [
{ startIndex: 0, type: 'annotation.java' },
{ startIndex: 28, type: '' },
{ startIndex: 29, type: 'keyword.private.java' }
]}]
]);

76
test/lua.test.ts Normal file
View file

@ -0,0 +1,76 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {testTokenization} from './testRunner';
testTokenization('lua', [
// Keywords
[{
line: 'local x, y = 1, 10',
tokens: [
{ startIndex: 0, type: 'keyword.local.lua' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'identifier.lua' },
{ startIndex: 7, type: 'delimiter.lua' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'identifier.lua' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'delimiter.lua' },
{ startIndex: 12, type: '' },
{ startIndex: 13, type: 'number.lua' },
{ startIndex: 14, type: 'delimiter.lua' },
{ startIndex: 15, type: '' },
{ startIndex: 16, type: 'number.lua' }
]}],
[{
line: 'foo = "Hello" .. "World"; local foo = foo',
tokens: [
{ startIndex: 0, type: 'identifier.lua' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'delimiter.lua' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'string.lua' },
{ startIndex: 13, type: '' },
{ startIndex: 14, type: 'delimiter.lua' },
{ startIndex: 16, type: '' },
{ startIndex: 17, type: 'string.lua' },
{ startIndex: 24, type: 'delimiter.lua' },
{ startIndex: 25, type: '' },
{ startIndex: 26, type: 'keyword.local.lua' },
{ startIndex: 31, type: '' },
{ startIndex: 32, type: 'identifier.lua' },
{ startIndex: 35, type: '' },
{ startIndex: 36, type: 'delimiter.lua' },
{ startIndex: 37, type: '' },
{ startIndex: 38, type: 'identifier.lua' }
]}],
// Comments
[{
line: '--[[ text ]] x',
tokens: [
{ startIndex: 0, type: 'comment.lua' },
{ startIndex: 12, type: '' },
{ startIndex: 13, type: 'identifier.lua' }
]}],
[{
line: '--[===[ text ]===] x',
tokens: [
{ startIndex: 0, type: 'comment.lua' },
{ startIndex: 18, type: '' },
{ startIndex: 19, type: 'identifier.lua' }
]}],
[{
line: '--[===[ text ]==] x',
tokens: [
{ startIndex: 0, type: 'comment.lua' }
]}]
]);

13
test/mocha.d.ts vendored Normal file
View file

@ -0,0 +1,13 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare function run(): void;
declare function suite(name: string, fn: (err?)=>void);
declare function test(name: string, fn: (done?: (err?)=>void)=>void);
declare function suiteSetup(fn: (done?: (err?)=>void)=>void);
declare function suiteTeardown(fn: (done?: (err?)=>void)=>void);
declare function setup(fn: (done?: (err?)=>void)=>void);
declare function teardown(fn: (done?: (err?)=>void)=>void);

3
test/mocha.opts Normal file
View file

@ -0,0 +1,3 @@
--delay
--ui tdd
test/all.js

291
test/objective-c.test.ts Normal file
View file

@ -0,0 +1,291 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {testTokenization} from './testRunner';
testTokenization('objective-c', [
// Keywords
[{
line: '-(id) initWithParams:(id<anObject>) aHandler withDeviceStateManager:(id<anotherObject>) deviceStateManager',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.parenthesis.objective-c' },
{ startIndex: 2, type: 'keyword.objective-c' },
{ startIndex: 4, type: 'delimiter.parenthesis.objective-c' },
{ startIndex: 5, type: 'white.objective-c' },
{ startIndex: 6, type: 'identifier.objective-c' },
{ startIndex: 20, type: 'delimiter.objective-c' },
{ startIndex: 21, type: 'delimiter.parenthesis.objective-c' },
{ startIndex: 22, type: 'keyword.objective-c' },
{ startIndex: 24, type: 'delimiter.angle.objective-c' },
{ startIndex: 25, type: 'identifier.objective-c' },
{ startIndex: 33, type: 'delimiter.angle.objective-c' },
{ startIndex: 34, type: 'delimiter.parenthesis.objective-c' },
{ startIndex: 35, type: 'white.objective-c' },
{ startIndex: 36, type: 'identifier.objective-c' },
{ startIndex: 44, type: 'white.objective-c' },
{ startIndex: 45, type: 'identifier.objective-c' },
{ startIndex: 67, type: 'delimiter.objective-c' },
{ startIndex: 68, type: 'delimiter.parenthesis.objective-c' },
{ startIndex: 69, type: 'keyword.objective-c' },
{ startIndex: 71, type: 'delimiter.angle.objective-c' },
{ startIndex: 72, type: 'identifier.objective-c' },
{ startIndex: 85, type: 'delimiter.angle.objective-c' },
{ startIndex: 86, type: 'delimiter.parenthesis.objective-c' },
{ startIndex: 87, type: 'white.objective-c' },
{ startIndex: 88, type: 'identifier.objective-c' }
]}],
// Comments - single line
[{
line: '//',
tokens: [
{ startIndex: 0, type: 'comment.objective-c' }
]}],
[{
line: ' // a comment',
tokens: [
{ startIndex: 0, type: 'white.objective-c' },
{ startIndex: 4, type: 'comment.objective-c' }
]}],
[{
line: '// a comment',
tokens: [
{ startIndex: 0, type: 'comment.objective-c' }
]}],
[{
line: '//sticky comment',
tokens: [
{ startIndex: 0, type: 'comment.objective-c' }
]}],
[{
line: '/almost a comment',
tokens: [
{ startIndex: 0, type: 'operator.objective-c' },
{ startIndex: 1, type: 'identifier.objective-c' },
{ startIndex: 7, type: 'white.objective-c' },
{ startIndex: 8, type: 'identifier.objective-c' },
{ startIndex: 9, type: 'white.objective-c' },
{ startIndex: 10, type: 'identifier.objective-c' }
]}],
[{
line: '1 / 2; /* comment',
tokens: [
{ startIndex: 0, type: 'number.objective-c' },
{ startIndex: 1, type: 'white.objective-c' },
{ startIndex: 2, type: 'operator.objective-c' },
{ startIndex: 3, type: 'white.objective-c' },
{ startIndex: 4, type: 'number.objective-c' },
{ startIndex: 5, type: 'delimiter.objective-c' },
{ startIndex: 6, type: 'white.objective-c' },
{ startIndex: 7, type: 'comment.objective-c' }
]}],
[{
line: 'int x = 1; // my comment // is a nice one',
tokens: [
{ startIndex: 0, type: 'keyword.objective-c' },
{ startIndex: 3, type: 'white.objective-c' },
{ startIndex: 4, type: 'identifier.objective-c' },
{ startIndex: 5, type: 'white.objective-c' },
{ startIndex: 6, type: 'operator.objective-c' },
{ startIndex: 7, type: 'white.objective-c' },
{ startIndex: 8, type: 'number.objective-c' },
{ startIndex: 9, type: 'delimiter.objective-c' },
{ startIndex: 10, type: 'white.objective-c' },
{ startIndex: 11, type: 'comment.objective-c' }
]}],
// Comments - range comment, single line
[{
line: '/* a simple comment */',
tokens: [
{ startIndex: 0, type: 'comment.objective-c' }
]}],
[{
line: 'int x = /* embedded comment */ 1;',
tokens: [
{ startIndex: 0, type: 'keyword.objective-c' },
{ startIndex: 3, type: 'white.objective-c' },
{ startIndex: 4, type: 'identifier.objective-c' },
{ startIndex: 5, type: 'white.objective-c' },
{ startIndex: 6, type: 'operator.objective-c' },
{ startIndex: 7, type: 'white.objective-c' },
{ startIndex: 8, type: 'comment.objective-c' },
{ startIndex: 30, type: 'white.objective-c' },
{ startIndex: 31, type: 'number.objective-c' },
{ startIndex: 32, type: 'delimiter.objective-c' }
]}],
[{
line: 'int x = /* comment and syntax error*/ 1; */',
tokens: [
{ startIndex: 0, type: 'keyword.objective-c' },
{ startIndex: 3, type: 'white.objective-c' },
{ startIndex: 4, type: 'identifier.objective-c' },
{ startIndex: 5, type: 'white.objective-c' },
{ startIndex: 6, type: 'operator.objective-c' },
{ startIndex: 7, type: 'white.objective-c' },
{ startIndex: 8, type: 'comment.objective-c' },
{ startIndex: 37, type: 'white.objective-c' },
{ startIndex: 38, type: 'number.objective-c' },
{ startIndex: 39, type: 'delimiter.objective-c' },
{ startIndex: 40, type: 'white.objective-c' },
{ startIndex: 41, type: 'operator.objective-c' }
]}],
[{
line: 'x = /**/;',
tokens: [
{ startIndex: 0, type: 'identifier.objective-c' },
{ startIndex: 1, type: 'white.objective-c' },
{ startIndex: 2, type: 'operator.objective-c' },
{ startIndex: 3, type: 'white.objective-c' },
{ startIndex: 4, type: 'comment.objective-c' },
{ startIndex: 8, type: 'delimiter.objective-c' }
]}],
[{
line: 'x = /*/;',
tokens: [
{ startIndex: 0, type: 'identifier.objective-c' },
{ startIndex: 1, type: 'white.objective-c' },
{ startIndex: 2, type: 'operator.objective-c' },
{ startIndex: 3, type: 'white.objective-c' },
{ startIndex: 4, type: 'comment.objective-c' }
]}],
// Non-Alpha Keywords
[{
line: '#import <GTLT.h>',
tokens: [
{ startIndex: 0, type: 'keyword.objective-c' },
{ startIndex: 7, type: 'white.objective-c' },
{ startIndex: 8, type: 'delimiter.angle.objective-c' },
{ startIndex: 9, type: 'identifier.objective-c' },
{ startIndex: 13, type: '' },
{ startIndex: 14, type: 'identifier.objective-c' },
{ startIndex: 15, type: 'delimiter.angle.objective-c' }
]}],
// Numbers
[{
line: '0 ',
tokens: [
{ startIndex: 0, type: 'number.objective-c' },
{ startIndex: 1, type: 'white.objective-c' }
]}],
[{
line: '0x ',
tokens: [
{ startIndex: 0, type: 'number.hex.objective-c' },
{ startIndex: 2, type: 'white.objective-c' }
]}],
[{
line: '0x123 ',
tokens: [
{ startIndex: 0, type: 'number.hex.objective-c' },
{ startIndex: 5, type: 'white.objective-c' }
]}],
[{
line: '23.5 ',
tokens: [
{ startIndex: 0, type: 'number.float.objective-c' },
{ startIndex: 4, type: 'white.objective-c' }
]}],
[{
line: '23.5e3 ',
tokens: [
{ startIndex: 0, type: 'number.float.objective-c' },
{ startIndex: 6, type: 'white.objective-c' }
]}],
[{
line: '23.5E3 ',
tokens: [
{ startIndex: 0, type: 'number.float.objective-c' },
{ startIndex: 6, type: 'white.objective-c' }
]}],
[{
line: '23.5F ',
tokens: [
{ startIndex: 0, type: 'number.float.objective-c' },
{ startIndex: 5, type: 'white.objective-c' }
]}],
[{
line: '23.5f ',
tokens: [
{ startIndex: 0, type: 'number.float.objective-c' },
{ startIndex: 5, type: 'white.objective-c' }
]}],
[{
line: '1.72E3F ',
tokens: [
{ startIndex: 0, type: 'number.float.objective-c' },
{ startIndex: 7, type: 'white.objective-c' }
]}],
[{
line: '1.72E3f ',
tokens: [
{ startIndex: 0, type: 'number.float.objective-c' },
{ startIndex: 7, type: 'white.objective-c' }
]}],
[{
line: '1.72e3F ',
tokens: [
{ startIndex: 0, type: 'number.float.objective-c' },
{ startIndex: 7, type: 'white.objective-c' }
]}],
[{
line: '1.72e3f ',
tokens: [
{ startIndex: 0, type: 'number.float.objective-c' },
{ startIndex: 7, type: 'white.objective-c' }
]}],
[{
line: '0+0',
tokens: [
{ startIndex: 0, type: 'number.objective-c' },
{ startIndex: 1, type: 'operator.objective-c' },
{ startIndex: 2, type: 'number.objective-c' }
]}],
[{
line: '100+10',
tokens: [
{ startIndex: 0, type: 'number.objective-c' },
{ startIndex: 3, type: 'operator.objective-c' },
{ startIndex: 4, type: 'number.objective-c' }
]}],
[{
line: '0 + 0',
tokens: [
{ startIndex: 0, type: 'number.objective-c' },
{ startIndex: 1, type: 'white.objective-c' },
{ startIndex: 2, type: 'operator.objective-c' },
{ startIndex: 3, type: 'white.objective-c' },
{ startIndex: 4, type: 'number.objective-c' }
]}]
]);

737
test/powershell.test.ts Normal file
View file

@ -0,0 +1,737 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {testTokenization} from './testRunner';
testTokenization('powershell', [
// Comments - single line
[{
line: '#',
tokens: [
{ startIndex: 0, type: 'comment.ps1' }
]}],
[{
line: ' # a comment',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'comment.ps1' }
]}],
[{
line: '# a comment',
tokens: [
{ startIndex: 0, type: 'comment.ps1' }
]}],
[{
line: '#sticky comment',
tokens: [
{ startIndex: 0, type: 'comment.ps1' }
]}],
[{
line: '##still a comment',
tokens: [
{ startIndex: 0, type: 'comment.ps1' }
]}],
[{
line: '1 / 2 /# comment',
tokens: [
{ startIndex: 0, type: 'number.ps1' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.ps1' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'number.ps1' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.ps1' },
{ startIndex: 7, type: 'comment.ps1' }
]}],
[{
line: '$x = 1 # my comment # is a nice one',
tokens: [
{ startIndex: 0, type: 'variable.ps1' },
{ startIndex: 2, type: '' },
{ startIndex: 3, type: 'delimiter.ps1' },
{ startIndex: 4, type: '' },
{ startIndex: 5, type: 'number.ps1' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'comment.ps1' }
]}],
// Comments - range comment, single line
[{
line: '<# a simple comment #>',
tokens: [
{ startIndex: 0, type: 'comment.ps1' }
]}],
[{
line: '$x = <# a simple comment #> 1',
tokens: [
{ startIndex: 0, type: 'variable.ps1' },
{ startIndex: 2, type: '' },
{ startIndex: 3, type: 'delimiter.ps1' },
{ startIndex: 4, type: '' },
{ startIndex: 5, type: 'comment.ps1' },
{ startIndex: 27, type: '' },
{ startIndex: 28, type: 'number.ps1' }
]}],
[{
line: '$yy = <# comment #> 14',
tokens: [
{ startIndex: 0, type: 'variable.ps1' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'delimiter.ps1' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'comment.ps1' },
{ startIndex: 19, type: '' },
{ startIndex: 20, type: 'number.ps1' }
]}],
[{
line: '$x = <##>7',
tokens: [
{ startIndex: 0, type: 'variable.ps1' },
{ startIndex: 2, type: '' },
{ startIndex: 3, type: 'delimiter.ps1' },
{ startIndex: 4, type: '' },
{ startIndex: 5, type: 'comment.ps1' },
{ startIndex: 9, type: 'number.ps1' }
]}],
[{
line: '$x = <#<85',
tokens: [
{ startIndex: 0, type: 'variable.ps1' },
{ startIndex: 2, type: '' },
{ startIndex: 3, type: 'delimiter.ps1' },
{ startIndex: 4, type: '' },
{ startIndex: 5, type: 'comment.ps1' }
]}],
// Comments - range comment, multiple lines
[{
line: '<# start of multiline comment',
tokens: [
{ startIndex: 0, type: 'comment.ps1' }
]}, {
line: 'a comment between',
tokens: [
{ startIndex: 0, type: 'comment.ps1' }
]}, {
line: 'end of multiline comment#>',
tokens: [
{ startIndex: 0, type: 'comment.ps1' }
]}],
[{
line: '$x = <# start a comment',
tokens: [
{ startIndex: 0, type: 'variable.ps1' },
{ startIndex: 2, type: '' },
{ startIndex: 3, type: 'delimiter.ps1' },
{ startIndex: 4, type: '' },
{ startIndex: 5, type: 'comment.ps1' }
]}, {
line: ' a ',
tokens: [
{ startIndex: 0, type: 'comment.ps1' }
]}, {
line: 'and end it #> 2',
tokens: [
{ startIndex: 0, type: 'comment.ps1' },
{ startIndex: 13, type: '' },
{ startIndex: 14, type: 'number.ps1' }
]}],
// Keywords
[{
line: 'foreach($i in $b) {if (7) continue}',
tokens: [
{ startIndex: 0, type: 'keyword.foreach.ps1' },
{ startIndex: 7, type: 'delimiter.parenthesis.ps1' },
{ startIndex: 8, type: 'variable.ps1' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'keyword.in.ps1' },
{ startIndex: 13, type: '' },
{ startIndex: 14, type: 'variable.ps1' },
{ startIndex: 16, type: 'delimiter.parenthesis.ps1' },
{ startIndex: 17, type: '' },
{ startIndex: 18, type: 'delimiter.curly.ps1' },
{ startIndex: 19, type: 'keyword.if.ps1' },
{ startIndex: 21, type: '' },
{ startIndex: 22, type: 'delimiter.parenthesis.ps1' },
{ startIndex: 23, type: 'number.ps1' },
{ startIndex: 24, type: 'delimiter.parenthesis.ps1' },
{ startIndex: 25, type: '' },
{ startIndex: 26, type: 'keyword.continue.ps1' },
{ startIndex: 34, type: 'delimiter.curly.ps1' }
]}],
// Redirect operand
[{
line: '$i > output1.txt',
tokens: [
{ startIndex: 0, type: 'variable.ps1' },
{ startIndex: 2, type: '' },
{ startIndex: 3, type: 'delimiter.ps1' },
{ startIndex: 4, type: '' },
{ startIndex: 12, type: 'delimiter.ps1' },
{ startIndex: 13, type: '' }
]}],
// Numbers
[{
line: '0',
tokens: [
{ startIndex: 0, type: 'number.ps1' }
]}],
[{
line: '0.10',
tokens: [
{ startIndex: 0, type: 'number.float.ps1' }
]}],
[{
line: '0X123',
tokens: [
{ startIndex: 0, type: 'number.hex.ps1' }
]}],
[{
line: '0x123',
tokens: [
{ startIndex: 0, type: 'number.hex.ps1' }
]}],
[{
line: '23.5e3',
tokens: [
{ startIndex: 0, type: 'number.float.ps1' }
]}],
[{
line: '23.5e-3',
tokens: [
{ startIndex: 0, type: 'number.float.ps1' }
]}],
[{
line: '23.5E3',
tokens: [
{ startIndex: 0, type: 'number.float.ps1' }
]}],
[{
line: '23.5E-3',
tokens: [
{ startIndex: 0, type: 'number.float.ps1' }
]}],
[{
line: '23.5',
tokens: [
{ startIndex: 0, type: 'number.float.ps1' }
]}],
[{
line: '0+0',
tokens: [
{ startIndex: 0, type: 'number.ps1' },
{ startIndex: 1, type: 'delimiter.ps1' },
{ startIndex: 2, type: 'number.ps1' }
]}],
[{
line: '100+10',
tokens: [
{ startIndex: 0, type: 'number.ps1' },
{ startIndex: 3, type: 'delimiter.ps1' },
{ startIndex: 4, type: 'number.ps1' }
]}],
[{
line: '10 + 0',
tokens: [
{ startIndex: 0, type: 'number.ps1' },
{ startIndex: 2, type: '' },
{ startIndex: 3, type: 'delimiter.ps1' },
{ startIndex: 4, type: '' },
{ startIndex: 5, type: 'number.ps1' }
]}],
// Strings
[{
line: '$s = "I am a String"',
tokens: [
{ startIndex: 0, type: 'variable.ps1' },
{ startIndex: 2, type: '' },
{ startIndex: 3, type: 'delimiter.ps1' },
{ startIndex: 4, type: '' },
{ startIndex: 5, type: 'string.ps1' }
]}],
[{
line: '\'I am also a ( String\'',
tokens: [
{ startIndex: 0, type: 'string.ps1' }
]}],
[{
line: '$s = "concatenated" + " String"',
tokens: [
{ startIndex: 0, type: 'variable.ps1' },
{ startIndex: 2, type: '' },
{ startIndex: 3, type: 'delimiter.ps1' },
{ startIndex: 4, type: '' },
{ startIndex: 5, type: 'string.ps1' },
{ startIndex: 19, type: '' },
{ startIndex: 20, type: 'delimiter.ps1' },
{ startIndex: 21, type: '' },
{ startIndex: 22, type: 'string.ps1' }
]}],
[{
line: '"escaping `"quotes`" is cool"',
tokens: [
{ startIndex: 0, type: 'string.ps1' },
{ startIndex: 10, type: 'string.escape.ps1' },
{ startIndex: 12, type: 'string.ps1' },
{ startIndex: 18, type: 'string.escape.ps1' },
{ startIndex: 20, type: 'string.ps1' }
]}],
[{
line: '\'`\'end of the string',
tokens: [
{ startIndex: 0, type: 'string.ps1' },
{ startIndex: 1, type: 'string.escape.ps1' },
{ startIndex: 3, type: 'string.ps1' }
]}],
[{
line: '@"I am an expandable String"@',
tokens: [
{ startIndex: 0, type: 'string.ps1' }
]}],
[{
line: '@\'I am also an expandable String\'@',
tokens: [
{ startIndex: 0, type: 'string.ps1' }
]}],
[{
line: '$s = @\'I am also an expandable String\'@',
tokens: [
{ startIndex: 0, type: 'variable.ps1' },
{ startIndex: 2, type: '' },
{ startIndex: 3, type: 'delimiter.ps1' },
{ startIndex: 4, type: '' },
{ startIndex: 5, type: 'string.ps1' }
]}],
[{
line: '$s = @\'I am also an expandable String\'@+7',
tokens: [
{ startIndex: 0, type: 'variable.ps1' },
{ startIndex: 2, type: '' },
{ startIndex: 3, type: 'delimiter.ps1' },
{ startIndex: 4, type: '' },
{ startIndex: 5, type: 'string.ps1' }
]}],
[{
line: '@\'I am a multiline string,',
tokens: [
{ startIndex: 0, type: 'string.ps1' }
]}, {
line: 'and this is the middle line,',
tokens: [
{ startIndex: 0, type: 'string.ps1' }
]}, {
line: 'and this is NOT the end of the string\'@foreach $i',
tokens: [
{ startIndex: 0, type: 'string.ps1' }
]}, {
line: '\'@',
tokens: [
{ startIndex: 0, type: 'string.ps1' }
]}, {
line: '${script:foo}',
tokens: [
{ startIndex: 0, type: 'variable.ps1' }
]}, {
line: 'foreach $i',
tokens: [
{ startIndex: 0, type: 'keyword.foreach.ps1' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'variable.ps1' }
]}],
// Generated from sample
[{
line: '$SelectedObjectNames=@();',
tokens: [
{ startIndex: 0, type: 'variable.ps1' },
{ startIndex: 20, type: 'delimiter.ps1' },
{ startIndex: 21, type: '' },
{ startIndex: 22, type: 'delimiter.parenthesis.ps1' },
{ startIndex: 24, type: 'delimiter.ps1' }
]}, {
line: '$XenCenterNodeSelected = 0;',
tokens: [
{ startIndex: 0, type: 'variable.ps1' },
{ startIndex: 22, type: '' },
{ startIndex: 23, type: 'delimiter.ps1' },
{ startIndex: 24, type: '' },
{ startIndex: 25, type: 'number.ps1' },
{ startIndex: 26, type: 'delimiter.ps1' }
]}, {
line: '#the object info array contains hashmaps, each of which represent a parameter set and describe a target in the XenCenter resource list',
tokens: [
{ startIndex: 0, type: 'comment.ps1' }
]}, {
line: 'foreach($parameterSet in $ObjInfoArray)',
tokens: [
{ startIndex: 0, type: 'keyword.foreach.ps1' },
{ startIndex: 7, type: 'delimiter.parenthesis.ps1' },
{ startIndex: 8, type: 'variable.ps1' },
{ startIndex: 21, type: '' },
{ startIndex: 22, type: 'keyword.in.ps1' },
{ startIndex: 24, type: '' },
{ startIndex: 25, type: 'variable.ps1' },
{ startIndex: 38, type: 'delimiter.parenthesis.ps1' }
]}, {
line: '{',
tokens: [
{ startIndex: 0, type: 'delimiter.curly.ps1' }
]}, {
line: ' if ($parameterSet["class"] -eq "blank")',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'keyword.if.ps1' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'delimiter.parenthesis.ps1' },
{ startIndex: 5, type: 'variable.ps1' },
{ startIndex: 18, type: 'delimiter.square.ps1' },
{ startIndex: 19, type: 'string.ps1' },
{ startIndex: 26, type: 'delimiter.square.ps1' },
{ startIndex: 27, type: '' },
{ startIndex: 28, type: 'delimiter.ps1' },
{ startIndex: 29, type: '' },
{ startIndex: 32, type: 'string.ps1' },
{ startIndex: 39, type: 'delimiter.parenthesis.ps1' }
]}, {
line: ' {',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.curly.ps1' }
]}, {
line: ' #When the XenCenter node is selected a parameter set is created for each of your connected servers with the class and objUuid keys marked as blank',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'comment.ps1' }
]}, {
line: ' if ($XenCenterNodeSelected)',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'keyword.if.ps1' },
{ startIndex: 4, type: '' },
{ startIndex: 5, type: 'delimiter.parenthesis.ps1' },
{ startIndex: 6, type: 'variable.ps1' },
{ startIndex: 28, type: 'delimiter.parenthesis.ps1' }
]}, {
line: ' {',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'delimiter.curly.ps1' }
]}, {
line: ' continue',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 3, type: 'keyword.continue.ps1' }
]}, {
line: ' }',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'delimiter.curly.ps1' }
]}, {
line: ' $XenCenterNodeSelected = 1;',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'variable.ps1' },
{ startIndex: 24, type: '' },
{ startIndex: 25, type: 'delimiter.ps1' },
{ startIndex: 26, type: '' },
{ startIndex: 27, type: 'number.ps1' },
{ startIndex: 28, type: 'delimiter.ps1' }
]}, {
line: ' $SelectedObjectNames += "XenCenter"',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'variable.ps1' },
{ startIndex: 22, type: '' },
{ startIndex: 23, type: 'delimiter.ps1' },
{ startIndex: 25, type: '' },
{ startIndex: 26, type: 'string.ps1' }
]}, {
line: ' }',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.curly.ps1' }
]}, {
line: ' elseif ($parameterSet["sessionRef"] -eq "null")',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'keyword.elseif.ps1' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'delimiter.parenthesis.ps1' },
{ startIndex: 9, type: 'variable.ps1' },
{ startIndex: 22, type: 'delimiter.square.ps1' },
{ startIndex: 23, type: 'string.ps1' },
{ startIndex: 35, type: 'delimiter.square.ps1' },
{ startIndex: 36, type: '' },
{ startIndex: 37, type: 'delimiter.ps1' },
{ startIndex: 38, type: '' },
{ startIndex: 41, type: 'string.ps1' },
{ startIndex: 47, type: 'delimiter.parenthesis.ps1' }
]}, {
line: ' {',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.curly.ps1' }
]}, {
line: ' #When a disconnected server is selected there is no session information, we get null for everything except class',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'comment.ps1' }
]}, {
line: ' }',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.curly.ps1' }
]}, {
line: ' $SelectedObjectNames += "a disconnected server"',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'variable.ps1' },
{ startIndex: 22, type: '' },
{ startIndex: 23, type: 'delimiter.ps1' },
{ startIndex: 25, type: '' },
{ startIndex: 26, type: 'string.ps1' }
]}, {
line: ' else',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'keyword.else.ps1' }
]}, {
line: ' {',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.curly.ps1' }
]}, {
line: ' Connect-XenServer -url $parameterSet["url"] -opaqueref $parameterSet["sessionRef"]',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 20, type: 'delimiter.ps1' },
{ startIndex: 21, type: '' },
{ startIndex: 25, type: 'variable.ps1' },
{ startIndex: 38, type: 'delimiter.square.ps1' },
{ startIndex: 39, type: 'string.ps1' },
{ startIndex: 44, type: 'delimiter.square.ps1' },
{ startIndex: 45, type: '' },
{ startIndex: 46, type: 'delimiter.ps1' },
{ startIndex: 47, type: '' },
{ startIndex: 57, type: 'variable.ps1' },
{ startIndex: 70, type: 'delimiter.square.ps1' },
{ startIndex: 71, type: 'string.ps1' },
{ startIndex: 83, type: 'delimiter.square.ps1' }
]}, {
line: ' #Use $class to determine which server objects to get',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'comment.ps1' }
]}, {
line: ' #-properties allows us to filter the results to just include the selected object',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'comment.ps1' }
]}, {
line: ' $exp = "Get-XenServer:{0} -properties @{{uuid=\'{1}\'}}" -f $parameterSet["class"], $parameterSet["objUuid"]',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'variable.ps1' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'delimiter.ps1' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'string.ps1' },
{ startIndex: 56, type: '' },
{ startIndex: 57, type: 'delimiter.ps1' },
{ startIndex: 58, type: '' },
{ startIndex: 60, type: 'variable.ps1' },
{ startIndex: 73, type: 'delimiter.square.ps1' },
{ startIndex: 74, type: 'string.ps1' },
{ startIndex: 81, type: 'delimiter.square.ps1' },
{ startIndex: 82, type: 'delimiter.ps1' },
{ startIndex: 83, type: '' },
{ startIndex: 84, type: 'variable.ps1' },
{ startIndex: 97, type: 'delimiter.square.ps1' },
{ startIndex: 98, type: 'string.ps1' },
{ startIndex: 107, type: 'delimiter.square.ps1' }
]}, {
line: ' $obj = Invoke-Expression $exp',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'variable.ps1' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'delimiter.ps1' },
{ startIndex: 8, type: '' },
{ startIndex: 27, type: 'variable.ps1' }
]}, {
line: ' $SelectedObjectNames += $obj.name_label;',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'variable.ps1' },
{ startIndex: 22, type: '' },
{ startIndex: 23, type: 'delimiter.ps1' },
{ startIndex: 25, type: '' },
{ startIndex: 26, type: 'variable.ps1' },
{ startIndex: 30, type: 'delimiter.ps1' },
{ startIndex: 31, type: '' },
{ startIndex: 41, type: 'delimiter.ps1' }
]}, {
line: ' } ',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.curly.ps1' },
{ startIndex: 2, type: '' }
]}, {
line: '}',
tokens: [
{ startIndex: 0, type: 'delimiter.curly.ps1' }
]}, {
line: '',
tokens: [
]}, {
line: '$test = "in string var$test"',
tokens: [
{ startIndex: 0, type: 'variable.ps1' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.ps1' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'string.ps1' },
{ startIndex: 22, type: 'variable.ps1' },
{ startIndex: 27, type: 'string.ps1' }
]}, {
line: '$another = \'not a $var\'',
tokens: [
{ startIndex: 0, type: 'variable.ps1' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'delimiter.ps1' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'string.ps1' }
]}, {
line: '$third = "a $var and not `$var string"',
tokens: [
{ startIndex: 0, type: 'variable.ps1' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'delimiter.ps1' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'string.ps1' },
{ startIndex: 12, type: 'variable.ps1' },
{ startIndex: 16, type: 'string.ps1' },
{ startIndex: 25, type: 'string.escape.ps1' },
{ startIndex: 27, type: 'string.ps1' }
]}, {
line: '',
tokens: [
]}, {
line: ':aLabel',
tokens: [
{ startIndex: 0, type: 'metatag.ps1' }
]}, {
line: '',
tokens: [
]}, {
line: '<#',
tokens: [
{ startIndex: 0, type: 'comment.ps1' }
]}, {
line: '.SYNOPSIS',
tokens: [
{ startIndex: 0, type: 'comment.keyword.synopsis.ps1' }
]}, {
line: ' some text',
tokens: [
{ startIndex: 0, type: 'comment.ps1' }
]}, {
line: ' ',
tokens: [
{ startIndex: 0, type: 'comment.ps1' }
]}, {
line: '.LINK',
tokens: [
{ startIndex: 0, type: 'comment.keyword.link.ps1' }
]}, {
line: ' some more text',
tokens: [
{ startIndex: 0, type: 'comment.ps1' }
]}, {
line: '#>',
tokens: [
{ startIndex: 0, type: 'comment.ps1' }
]}, {
line: '',
tokens: [
]}, {
line: '',
tokens: [
]}, {
line: '$hereString = @"',
tokens: [
{ startIndex: 0, type: 'variable.ps1' },
{ startIndex: 11, type: '' },
{ startIndex: 12, type: 'delimiter.ps1' },
{ startIndex: 13, type: '' },
{ startIndex: 14, type: 'string.ps1' }
]}, {
line: ' a string',
tokens: [
{ startIndex: 0, type: 'string.ps1' }
]}, {
line: ' still "@ a string $withVar',
tokens: [
{ startIndex: 0, type: 'string.ps1' },
{ startIndex: 20, type: 'variable.ps1' }
]}, {
line: ' still a string `$noVar',
tokens: [
{ startIndex: 0, type: 'string.ps1' },
{ startIndex: 17, type: 'string.escape.ps1' },
{ startIndex: 19, type: 'string.ps1' }
]}, {
line: '',
tokens: [
]}, {
line: '"@ still a string',
tokens: [
{ startIndex: 0, type: 'string.ps1' },
{ startIndex: 2, type: '' }
]}]
]);

105
test/python.test.ts Normal file
View file

@ -0,0 +1,105 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {testTokenization} from './testRunner';
testTokenization('python', [
// Keywords
[{
line: 'def func():',
tokens: [
{ startIndex: 0, type: 'keyword.python' },
{ startIndex: 3, type: 'white.python' },
{ startIndex: 4, type: 'identifier.python' },
{ startIndex: 8, type: 'delimiter.parenthesis.python' },
{ startIndex: 10, type: 'delimiter.python' }
]}],
[{
line: 'func(str Y3)',
tokens: [
{ startIndex: 0, type: 'identifier.python' },
{ startIndex: 4, type: 'delimiter.parenthesis.python' },
{ startIndex: 5, type: 'keyword.python' },
{ startIndex: 8, type: 'white.python' },
{ startIndex: 9, type: 'identifier.python' },
{ startIndex: 11, type: 'delimiter.parenthesis.python' }
]}],
[{
line: '@Dec0_rator:',
tokens: [
{ startIndex: 0, type: 'tag.python' },
{ startIndex: 11, type: 'delimiter.python' }
]}],
// Comments
[{
line: ' # Comments! ## "jfkd" ',
tokens: [
{ startIndex: 0, type: 'white.python' },
{ startIndex: 1, type: 'comment.python' }
]}],
// Strings
[{
line: '\'s0\'',
tokens: [
{ startIndex: 0, type: 'string.escape.python' },
{ startIndex: 1, type: 'string.python' },
{ startIndex: 3, type: 'string.escape.python' }
]}],
[{
line: '"\' " "',
tokens: [
{ startIndex: 0, type: 'string.escape.python' },
{ startIndex: 1, type: 'string.python' },
{ startIndex: 3, type: 'string.escape.python' },
{ startIndex: 4, type: 'white.python' },
{ startIndex: 5, type: 'string.escape.python' }
]}],
[{
line: '\'\'\'Lots of string\'\'\'',
tokens: [
{ startIndex: 0, type: 'string.python' }
]}],
[{
line: '"""Lots \'\'\' \'\'\'"""',
tokens: [
{ startIndex: 0, type: 'string.python' }
]}],
[{
line: '\'\'\'Lots \'\'\'0.3e-5',
tokens: [
{ startIndex: 0, type: 'string.python' },
{ startIndex: 11, type: 'number.python' }
]}],
// Numbers
[{
line: '0xAcBFd',
tokens: [
{ startIndex: 0, type: 'number.hex.python' }
]}],
[{
line: '0x0cH',
tokens: [
{ startIndex: 0, type: 'number.hex.python' },
{ startIndex: 4, type: 'identifier.python' }
]}],
[{
line: '456.7e-7j',
tokens: [
{ startIndex: 0, type: 'number.python' }
]}]
]);

471
test/r.test.ts Normal file
View file

@ -0,0 +1,471 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {testTokenization} from './testRunner';
testTokenization('r', [
// Keywords
[{
line: 'function(a) { a }',
tokens: [
{ startIndex: 0, type: 'keyword.r' },
{ startIndex: 8, type: 'delimiter.parenthesis.r' },
{ startIndex: 9, type: 'identifier.r' },
{ startIndex: 10, type: 'delimiter.parenthesis.r' },
{ startIndex: 11, type: 'white.r' },
{ startIndex: 12, type: 'delimiter.curly.r' },
{ startIndex: 13, type: 'white.r' },
{ startIndex: 14, type: 'identifier.r' },
{ startIndex: 15, type: 'white.r' },
{ startIndex: 16, type: 'delimiter.curly.r' }
]}],
[{
line: 'while(FALSE) { break }',
tokens: [
{ startIndex: 0, type: 'keyword.r' },
{ startIndex: 5, type: 'delimiter.parenthesis.r' },
{ startIndex: 6, type: 'constant.r' },
{ startIndex: 11, type: 'delimiter.parenthesis.r' },
{ startIndex: 12, type: 'white.r' },
{ startIndex: 13, type: 'delimiter.curly.r' },
{ startIndex: 14, type: 'white.r' },
{ startIndex: 15, type: 'keyword.r' },
{ startIndex: 20, type: 'white.r' },
{ startIndex: 21, type: 'delimiter.curly.r' }
]}],
[{
line: 'if (a) { b } else { d }',
tokens: [
{ startIndex: 0, type: 'keyword.r' },
{ startIndex: 2, type: 'white.r' },
{ startIndex: 3, type: 'delimiter.parenthesis.r' },
{ startIndex: 4, type: 'identifier.r' },
{ startIndex: 5, type: 'delimiter.parenthesis.r' },
{ startIndex: 6, type: 'white.r' },
{ startIndex: 7, type: 'delimiter.curly.r' },
{ startIndex: 8, type: 'white.r' },
{ startIndex: 9, type: 'identifier.r' },
{ startIndex: 10, type: 'white.r' },
{ startIndex: 11, type: 'delimiter.curly.r' },
{ startIndex: 12, type: 'white.r' },
{ startIndex: 13, type: 'keyword.r' },
{ startIndex: 17, type: 'white.r' },
{ startIndex: 18, type: 'delimiter.curly.r' },
{ startIndex: 19, type: 'white.r' },
{ startIndex: 20, type: 'identifier.r' },
{ startIndex: 21, type: 'white.r' },
{ startIndex: 22, type: 'delimiter.curly.r' }
]}],
// Identifiers
[{
line: 'a',
tokens: [
{ startIndex: 0, type: 'identifier.r' }
]}],
// Comments
[{
line: ' # comment #',
tokens: [
{ startIndex: 0, type: 'white.r' },
{ startIndex: 1, type: 'comment.r' }
]}],
// Roxygen comments
[{
line: ' #\' @author: me ',
tokens: [
{ startIndex: 0, type: 'white.r' },
{ startIndex: 1, type: 'comment.doc.r' },
{ startIndex: 4, type: 'tag.r' },
{ startIndex: 11, type: 'comment.doc.r' }
]}],
// Strings
[{
line: '"a\\n"',
tokens: [
{ startIndex: 0, type: 'string.escape.r' },
{ startIndex: 1, type: 'string.r' },
{ startIndex: 4, type: 'string.escape.r' }
]}],
// '\\s' is not a special character
[{
line: '"a\\s"',
tokens: [
{ startIndex: 0, type: 'string.escape.r' },
{ startIndex: 1, type: 'string.r' },
{ startIndex: 2, type: 'error-token.r' },
{ startIndex: 4, type: 'string.escape.r' }
]}],
// Numbers
[{
line: '0',
tokens: [
{ startIndex: 0, type: 'number.r' }
]}],
[{
line: '1',
tokens: [
{ startIndex: 0, type: 'number.r' }
]}],
[{
line: '-1',
tokens: [
{ startIndex: 0, type: 'number.r' }
]}],
[{
line: '1.1',
tokens: [
{ startIndex: 0, type: 'number.r' }
]}],
[{
line: '-1.1',
tokens: [
{ startIndex: 0, type: 'number.r' }
]}],
[{
line: '.1',
tokens: [
{ startIndex: 0, type: 'number.r' }
]}],
[{
line: '-.1',
tokens: [
{ startIndex: 0, type: 'number.r' }
]}],
[{
line: '1e10',
tokens: [
{ startIndex: 0, type: 'number.r' }
]}],
[{
line: '1e-10',
tokens: [
{ startIndex: 0, type: 'number.r' }
]}],
[{
line: '-1e10',
tokens: [
{ startIndex: 0, type: 'number.r' }
]}],
[{
line: '-1e-10',
tokens: [
{ startIndex: 0, type: 'number.r' }
]}],
[{
line: '1E10',
tokens: [
{ startIndex: 0, type: 'number.r' }
]}],
[{
line: '1E-10',
tokens: [
{ startIndex: 0, type: 'number.r' }
]}],
[{
line: '-1E10',
tokens: [
{ startIndex: 0, type: 'number.r' }
]}],
[{
line: '-1E-10',
tokens: [
{ startIndex: 0, type: 'number.r' }
]}],
// Operators
[{
line: 'a & b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 3, type: 'white.r' },
{ startIndex: 4, type: 'identifier.r' }
]}],
[{
line: 'a - b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 3, type: 'white.r' },
{ startIndex: 4, type: 'identifier.r' }
]}],
[{
line: 'a * b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 3, type: 'white.r' },
{ startIndex: 4, type: 'identifier.r' }
]}],
[{
line: 'a + b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 3, type: 'white.r' },
{ startIndex: 4, type: 'identifier.r' }
]}],
[{
line: 'a = b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 3, type: 'white.r' },
{ startIndex: 4, type: 'identifier.r' }
]}],
[{
line: 'a | b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 3, type: 'white.r' },
{ startIndex: 4, type: 'identifier.r' }
]}],
[{
line: 'a ! b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 3, type: 'white.r' },
{ startIndex: 4, type: 'identifier.r' }
]}],
[{
line: 'a < b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 3, type: 'white.r' },
{ startIndex: 4, type: 'identifier.r' }
]}],
[{
line: 'a > b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 3, type: 'white.r' },
{ startIndex: 4, type: 'identifier.r' }
]}],
[{
line: 'a ^ b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 3, type: 'white.r' },
{ startIndex: 4, type: 'identifier.r' }
]}],
[{
line: 'a ~ b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 3, type: 'white.r' },
{ startIndex: 4, type: 'identifier.r' }
]}],
[{
line: 'a / b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 3, type: 'white.r' },
{ startIndex: 4, type: 'identifier.r' }
]}],
[{
line: 'a : b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 3, type: 'white.r' },
{ startIndex: 4, type: 'identifier.r' }
]}],
[{
line: 'a %in% b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 6, type: 'white.r' },
{ startIndex: 7, type: 'identifier.r' }
]}],
[{
line: 'a %->% b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 6, type: 'white.r' },
{ startIndex: 7, type: 'identifier.r' }
]}],
[{
line: 'a == b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 4, type: 'white.r' },
{ startIndex: 5, type: 'identifier.r' }
]}],
[{
line: 'a != b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 4, type: 'white.r' },
{ startIndex: 5, type: 'identifier.r' }
]}],
[{
line: 'a %% b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 4, type: 'white.r' },
{ startIndex: 5, type: 'identifier.r' }
]}],
[{
line: 'a && b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 4, type: 'white.r' },
{ startIndex: 5, type: 'identifier.r' }
]}],
[{
line: 'a || b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 4, type: 'white.r' },
{ startIndex: 5, type: 'identifier.r' }
]}],
[{
line: 'a <- b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 4, type: 'white.r' },
{ startIndex: 5, type: 'identifier.r' }
]}],
[{
line: 'a <<- b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 5, type: 'white.r' },
{ startIndex: 6, type: 'identifier.r' }
]}],
[{
line: 'a -> b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 4, type: 'white.r' },
{ startIndex: 5, type: 'identifier.r' }
]}],
[{
line: 'a ->> b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 5, type: 'white.r' },
{ startIndex: 6, type: 'identifier.r' }
]}],
[{
line: 'a $ b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 3, type: 'white.r' },
{ startIndex: 4, type: 'identifier.r' }
]}],
[{
line: 'a << b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 4, type: 'white.r' },
{ startIndex: 5, type: 'identifier.r' }
]}],
[{
line: 'a >> b',
tokens: [
{ startIndex: 0, type: 'identifier.r' },
{ startIndex: 1, type: 'white.r' },
{ startIndex: 2, type: 'operator.r' },
{ startIndex: 4, type: 'white.r' },
{ startIndex: 5, type: 'identifier.r' }
]}]
]);

125
test/ruby.test.ts Normal file
View file

@ -0,0 +1,125 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {testTokenization} from './testRunner';
testTokenization('ruby', [
// Keywords
[{
line: 'class Klass def init() end',
tokens: [
{ startIndex: 0, type: 'keyword.class.ruby' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'constructor.identifier.ruby' },
{ startIndex: 11, type: '' },
{ startIndex: 12, type: 'keyword.def.ruby' },
{ startIndex: 15, type: '' },
{ startIndex: 16, type: 'identifier.ruby' },
{ startIndex: 20, type: 'delimiter.parenthesis.ruby' },
{ startIndex: 22, type: '' },
{ startIndex: 23, type: 'keyword.def.ruby' }
]}],
// Single digit
[{
line: 'x == 1 ',
tokens: [
{ startIndex: 0, type: 'identifier.ruby' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'operator.ruby' },
{ startIndex: 4, type: '' },
{ startIndex: 5, type: 'number.ruby' },
{ startIndex: 6, type: '' }
]}],
// Regex
[{
line: 'text =~ /Ruby/',
tokens: [
{ startIndex: 0, type: 'identifier.ruby' },
{ startIndex: 4, type: '' },
{ startIndex: 5, type: 'operator.ruby' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'regexp.delim.ruby' },
{ startIndex: 9, type: 'regexp.ruby' },
{ startIndex: 13, type: 'regexp.delim.ruby' }
]}],
[{
line: 'text.sub!(/Rbuy/, "Ruby")',
tokens: [
{ startIndex: 0, type: 'identifier.ruby' },
{ startIndex: 4, type: '' },
{ startIndex: 5, type: 'identifier.ruby' },
{ startIndex: 9, type: 'delimiter.parenthesis.ruby' },
{ startIndex: 10, type: 'regexp.delim.ruby' },
{ startIndex: 11, type: 'regexp.ruby' },
{ startIndex: 15, type: 'regexp.delim.ruby' },
{ startIndex: 16, type: 'delimiter.ruby' },
{ startIndex: 17, type: '' },
{ startIndex: 18, type: 'string.d.delim.ruby' },
{ startIndex: 19, type: 'string.$S2.ruby' },
{ startIndex: 23, type: 'string.d.delim.ruby' },
{ startIndex: 24, type: 'delimiter.parenthesis.ruby' }
]}],
// make sure that division does not match regex
[{
line: 'a / b',
tokens: [
{ startIndex: 0, type: 'identifier.ruby' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'operator.ruby' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.ruby' }
]}],
// Heredoc
[{
line: '<<HERE',
tokens: [
{ startIndex: 0, type: 'string.heredoc.delimiter.ruby' }
]}, {
line: 'do some string',
tokens: [
{ startIndex: 0, type: 'string.heredoc.ruby' }
]}, {
line: 'HERE',
tokens: [
{ startIndex: 0, type: 'string.heredoc.delimiter.ruby' }
]}],
[{
line: 'x <<HERE',
tokens: [
{ startIndex: 0, type: 'identifier.ruby' },
{ startIndex: 1, type: 'string.heredoc.delimiter.ruby' }
]}, {
line: 'do some string',
tokens: [
{ startIndex: 0, type: 'string.heredoc.ruby' }
]}, {
line: 'HERE',
tokens: [
{ startIndex: 0, type: 'string.heredoc.delimiter.ruby' }
]}],
[{
line: 'x<<HERE',
tokens: [
{ startIndex: 0, type: 'identifier.ruby' },
{ startIndex: 1, type: 'operator.ruby' },
{ startIndex: 3, type: 'constructor.identifier.ruby' }
]}],
[{
line: 'x<<-HERE',
tokens: [
{ startIndex: 0, type: 'identifier.ruby' },
{ startIndex: 1, type: 'string.heredoc.delimiter.ruby' }
]}]
]);

587
test/sql.test.ts Normal file
View file

@ -0,0 +1,587 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {testTokenization} from './testRunner';
testTokenization('sql', [
// Comments
[{
line: '-- a comment',
tokens: [
{ startIndex: 0, type: 'comment.sql' }
]}],
[{
line: '---sticky -- comment',
tokens: [
{ startIndex: 0, type: 'comment.sql' }
]}],
[{
line: '-almost a comment',
tokens: [
{ startIndex: 0, type: 'operator.sql' },
{ startIndex: 1, type: 'identifier.sql' },
{ startIndex: 7, type: 'white.sql' },
{ startIndex: 8, type: 'identifier.sql' },
{ startIndex: 9, type: 'white.sql' },
{ startIndex: 10, type: 'identifier.sql' }
]}],
[{
line: '/* a full line comment */',
tokens: [
{ startIndex: 0, type: 'comment.quote.sql' },
{ startIndex: 2, type: 'comment.sql' },
{ startIndex: 23, type: 'comment.quote.sql' }
]}],
[{
line: '/* /// *** /// */',
tokens: [
{ startIndex: 0, type: 'comment.quote.sql' },
{ startIndex: 2, type: 'comment.sql' },
{ startIndex: 15, type: 'comment.quote.sql' }
]}],
[{
line: 'declare @x int = /* a simple comment */ 1;',
tokens: [
{ startIndex: 0, type: 'keyword.sql' },
{ startIndex: 7, type: 'white.sql' },
{ startIndex: 8, type: 'identifier.sql' },
{ startIndex: 10, type: 'white.sql' },
{ startIndex: 11, type: 'keyword.sql' },
{ startIndex: 14, type: 'white.sql' },
{ startIndex: 15, type: 'operator.sql' },
{ startIndex: 16, type: 'white.sql' },
{ startIndex: 17, type: 'comment.quote.sql' },
{ startIndex: 19, type: 'comment.sql' },
{ startIndex: 37, type: 'comment.quote.sql' },
{ startIndex: 39, type: 'white.sql' },
{ startIndex: 40, type: 'number.sql' },
{ startIndex: 41, type: 'delimiter.sql' }
]}],
// Not supporting nested comments, as nested comments seem to not be standard?
// i.e. http://stackoverflow.com/questions/728172/are-there-multiline-comment-delimiters-in-sql-that-are-vendor-agnostic
[{
line: '@x=/* a /* nested comment 1*/;',
tokens: [
{ startIndex: 0, type: 'identifier.sql' },
{ startIndex: 2, type: 'operator.sql' },
{ startIndex: 3, type: 'comment.quote.sql' },
{ startIndex: 5, type: 'comment.sql' },
{ startIndex: 28, type: 'comment.quote.sql' },
{ startIndex: 30, type: 'delimiter.sql' }
]}],
[{
line: '@x=/* another comment */ 1*/;',
tokens: [
{ startIndex: 0, type: 'identifier.sql' },
{ startIndex: 2, type: 'operator.sql' },
{ startIndex: 3, type: 'comment.quote.sql' },
{ startIndex: 5, type: 'comment.sql' },
{ startIndex: 22, type: 'comment.quote.sql' },
{ startIndex: 24, type: 'white.sql' },
{ startIndex: 25, type: 'number.sql' },
{ startIndex: 26, type: 'operator.sql' },
{ startIndex: 28, type: 'delimiter.sql' }
]}],
[{
line: '@x=/*/;',
tokens: [
{ startIndex: 0, type: 'identifier.sql' },
{ startIndex: 2, type: 'operator.sql' },
{ startIndex: 3, type: 'comment.quote.sql' },
{ startIndex: 5, type: 'comment.sql' }
]}],
// Numbers
[{
line: '123',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '-123',
tokens: [
{ startIndex: 0, type: 'operator.sql' },
{ startIndex: 1, type: 'number.sql' }
]}],
[{
line: '0xaBc123',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '0XaBc123',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '0x',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '0x0',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '0xAB_CD',
tokens: [
{ startIndex: 0, type: 'number.sql' },
{ startIndex: 4, type: 'identifier.sql' }
]}],
[{
line: '$',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '$-123',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '$-+-123',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '$123.5678',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '$0.99',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '$.99',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '$99.',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '$0.',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '$.0',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '.',
tokens: [
{ startIndex: 0, type: 'delimiter.sql' }
]}],
[{
line: '123',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '123.5678',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '0.99',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '.99',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '99.',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '0.',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '.0',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '1E-2',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '1E+2',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '1E2',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '0.1E2',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '1.E2',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
[{
line: '.1E2',
tokens: [
{ startIndex: 0, type: 'number.sql' }
]}],
// Identifiers
[{
line: '_abc$01',
tokens: [
{ startIndex: 0, type: 'identifier.sql' }
]}],
[{
line: '#abc$01',
tokens: [
{ startIndex: 0, type: 'identifier.sql' }
]}],
[{
line: '##abc$01',
tokens: [
{ startIndex: 0, type: 'identifier.sql' }
]}],
[{
line: '@abc$01',
tokens: [
{ startIndex: 0, type: 'identifier.sql' }
]}],
[{
line: '@@abc$01',
tokens: [
{ startIndex: 0, type: 'identifier.sql' }
]}],
[{
line: '$abc',
tokens: [
{ startIndex: 0, type: 'identifier.sql' }
]}],
[{
line: '$action',
tokens: [
{ startIndex: 0, type: 'predefined.sql' }
]}],
[{
line: '$nonexistent',
tokens: [
{ startIndex: 0, type: 'identifier.sql' }
]}],
[{
line: '@@DBTS',
tokens: [
{ startIndex: 0, type: 'predefined.sql' }
]}],
[{
line: '@@nonexistent',
tokens: [
{ startIndex: 0, type: 'identifier.sql' }
]}],
[{
line: 'declare [abc 321];',
tokens: [
{ startIndex: 0, type: 'keyword.sql' },
{ startIndex: 7, type: 'white.sql' },
{ startIndex: 8, type: 'identifier.quote.sql' },
{ startIndex: 9, type: 'identifier.sql' },
{ startIndex: 16, type: 'identifier.quote.sql' },
{ startIndex: 17, type: 'delimiter.sql' }
]}],
[{
line: '[abc[[ 321 ]] xyz]',
tokens: [
{ startIndex: 0, type: 'identifier.quote.sql' },
{ startIndex: 1, type: 'identifier.sql' },
{ startIndex: 17, type: 'identifier.quote.sql' }
]}],
[{
line: '[abc',
tokens: [
{ startIndex: 0, type: 'identifier.quote.sql' },
{ startIndex: 1, type: 'identifier.sql' }
]}],
[{
line: 'declare "abc 321";',
tokens: [
{ startIndex: 0, type: 'keyword.sql' },
{ startIndex: 7, type: 'white.sql' },
{ startIndex: 8, type: 'identifier.quote.sql' },
{ startIndex: 9, type: 'identifier.sql' },
{ startIndex: 16, type: 'identifier.quote.sql' },
{ startIndex: 17, type: 'delimiter.sql' }
]}],
[{
line: '"abc"" 321 "" xyz"',
tokens: [
{ startIndex: 0, type: 'identifier.quote.sql' },
{ startIndex: 1, type: 'identifier.sql' },
{ startIndex: 17, type: 'identifier.quote.sql' }
]}],
[{
line: '"abc',
tokens: [
{ startIndex: 0, type: 'identifier.quote.sql' },
{ startIndex: 1, type: 'identifier.sql' }
]}],
[{
line: 'int',
tokens: [
{ startIndex: 0, type: 'keyword.sql' }
]}],
[{
line: '[int]',
tokens: [
{ startIndex: 0, type: 'identifier.quote.sql' },
{ startIndex: 1, type: 'identifier.sql' },
{ startIndex: 4, type: 'identifier.quote.sql' }
]}],
// Strings
[{
line: 'declare @x=\'a string\';',
tokens: [
{ startIndex: 0, type: 'keyword.sql' },
{ startIndex: 7, type: 'white.sql' },
{ startIndex: 8, type: 'identifier.sql' },
{ startIndex: 10, type: 'operator.sql' },
{ startIndex: 11, type: 'string.quote.sql' },
{ startIndex: 12, type: 'string.sql' },
{ startIndex: 20, type: 'string.quote.sql' },
{ startIndex: 21, type: 'delimiter.sql' }
]}],
[{
line: '\'a \'\' string with quotes\'',
tokens: [
{ startIndex: 0, type: 'string.quote.sql' },
{ startIndex: 1, type: 'string.sql' },
{ startIndex: 24, type: 'string.quote.sql' }
]}],
[{
line: '\'a " string with quotes\'',
tokens: [
{ startIndex: 0, type: 'string.quote.sql' },
{ startIndex: 1, type: 'string.sql' },
{ startIndex: 23, type: 'string.quote.sql' }
]}],
[{
line: '\'a -- string with comment\'',
tokens: [
{ startIndex: 0, type: 'string.quote.sql' },
{ startIndex: 1, type: 'string.sql' },
{ startIndex: 25, type: 'string.quote.sql' }
]}],
[{
line: 'N\'a unicode string\'',
tokens: [
{ startIndex: 0, type: 'string.quote.sql' },
{ startIndex: 2, type: 'string.sql' },
{ startIndex: 18, type: 'string.quote.sql' }
]}],
[{
line: '\'a endless string',
tokens: [
{ startIndex: 0, type: 'string.quote.sql' },
{ startIndex: 1, type: 'string.sql' }
]}],
// Operators
[{
line: 'SET @x=@x+1',
tokens: [
{ startIndex: 0, type: 'keyword.sql' },
{ startIndex: 3, type: 'white.sql' },
{ startIndex: 4, type: 'identifier.sql' },
{ startIndex: 6, type: 'operator.sql' },
{ startIndex: 7, type: 'identifier.sql' },
{ startIndex: 9, type: 'operator.sql' },
{ startIndex: 10, type: 'number.sql' }
]}],
[{
line: '@x^=@x',
tokens: [
{ startIndex: 0, type: 'identifier.sql' },
{ startIndex: 2, type: 'operator.sql' },
{ startIndex: 4, type: 'identifier.sql' }
]}],
[{
line: 'WHERE x IS NOT NULL',
tokens: [
{ startIndex: 0, type: 'keyword.sql' },
{ startIndex: 5, type: 'white.sql' },
{ startIndex: 6, type: 'identifier.sql' },
{ startIndex: 7, type: 'white.sql' },
{ startIndex: 8, type: 'operator.sql' },
{ startIndex: 10, type: 'white.sql' },
{ startIndex: 11, type: 'operator.sql' },
{ startIndex: 14, type: 'white.sql' },
{ startIndex: 15, type: 'operator.sql' }
]}],
[{
line: 'SELECT * FROM dbo.MyTable WHERE MyColumn IN (1,2)',
tokens: [
{ startIndex: 0, type: 'keyword.sql' },
{ startIndex: 6, type: 'white.sql' },
{ startIndex: 7, type: 'operator.sql' },
{ startIndex: 8, type: 'white.sql' },
{ startIndex: 9, type: 'keyword.sql' },
{ startIndex: 13, type: 'white.sql' },
{ startIndex: 14, type: 'identifier.sql' },
{ startIndex: 17, type: 'delimiter.sql' },
{ startIndex: 18, type: 'identifier.sql' },
{ startIndex: 25, type: 'white.sql' },
{ startIndex: 26, type: 'keyword.sql' },
{ startIndex: 31, type: 'white.sql' },
{ startIndex: 32, type: 'identifier.sql' },
{ startIndex: 40, type: 'white.sql' },
{ startIndex: 41, type: 'operator.sql' },
{ startIndex: 43, type: 'white.sql' },
{ startIndex: 44, type: 'delimiter.parenthesis.sql' },
{ startIndex: 45, type: 'number.sql' },
{ startIndex: 46, type: 'delimiter.sql' },
{ startIndex: 47, type: 'number.sql' },
{ startIndex: 48, type: 'delimiter.parenthesis.sql' }
]}],
// Scopes
[{
line: 'WHILE() BEGIN END',
tokens: [
{ startIndex: 0, type: 'keyword.sql' },
{ startIndex: 5, type: 'delimiter.parenthesis.sql' },
{ startIndex: 7, type: 'white.sql' },
{ startIndex: 8, type: 'keyword.block.sql' },
{ startIndex: 13, type: 'white.sql' },
{ startIndex: 14, type: 'keyword.block.sql' }
]}],
[{
line: 'BEGIN TRAN BEGIN TRY SELECT $ COMMIT END TRY BEGIN CATCH ROLLBACK END CATCH',
tokens: [
{ startIndex: 0, type: 'keyword.sql' },
{ startIndex: 10, type: 'white.sql' },
{ startIndex: 11, type: 'keyword.try.sql' },
{ startIndex: 20, type: 'white.sql' },
{ startIndex: 21, type: 'keyword.sql' },
{ startIndex: 27, type: 'white.sql' },
{ startIndex: 28, type: 'number.sql' },
{ startIndex: 29, type: 'white.sql' },
{ startIndex: 30, type: 'keyword.sql' },
{ startIndex: 36, type: 'white.sql' },
{ startIndex: 37, type: 'keyword.try.sql' },
{ startIndex: 44, type: 'white.sql' },
{ startIndex: 45, type: 'keyword.catch.sql' },
{ startIndex: 56, type: 'white.sql' },
{ startIndex: 57, type: 'keyword.sql' },
{ startIndex: 65, type: 'white.sql' },
{ startIndex: 66, type: 'keyword.catch.sql' }
]}],
[{
line: 'SELECT CASE $ WHEN 3 THEN 4 ELSE 5 END',
tokens: [
{ startIndex: 0, type: 'keyword.sql' },
{ startIndex: 6, type: 'white.sql' },
{ startIndex: 7, type: 'keyword.block.sql' },
{ startIndex: 11, type: 'white.sql' },
{ startIndex: 12, type: 'number.sql' },
{ startIndex: 13, type: 'white.sql' },
{ startIndex: 14, type: 'keyword.choice.sql' },
{ startIndex: 18, type: 'white.sql' },
{ startIndex: 19, type: 'number.sql' },
{ startIndex: 20, type: 'white.sql' },
{ startIndex: 21, type: 'keyword.choice.sql' },
{ startIndex: 25, type: 'white.sql' },
{ startIndex: 26, type: 'number.sql' },
{ startIndex: 27, type: 'white.sql' },
{ startIndex: 28, type: 'keyword.sql' },
{ startIndex: 32, type: 'white.sql' },
{ startIndex: 33, type: 'number.sql' },
{ startIndex: 34, type: 'white.sql' },
{ startIndex: 35, type: 'keyword.block.sql' }
]}]
]);

181
test/swift.test.ts Normal file
View file

@ -0,0 +1,181 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {testTokenization} from './testRunner';
testTokenization('swift', [
// Attributes
[{
line: '@noescape',
tokens: [
{ startIndex: 0, type: 'keyword.control.swift' } /* '@noescape' */
]}],
//Keyword and Type Identifier
[{
line: 'class App: UI, UIApp, UIView {',
tokens: [
{ startIndex: 0, type: 'keyword.swift' } /* 'class' */,
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'type.identifier.swift' } /* 'App' */,
{ startIndex: 9, type: 'keyword.operator.swift' } /* ':' */,
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'type.identifier.swift' } /* 'UI' */,
{ startIndex: 13, type: 'keyword.operator.swift' } /* ',' */,
{ startIndex: 14, type: '' },
{ startIndex: 15, type: 'type.identifier.swift' } /* 'UIApp' */,
{ startIndex: 20, type: 'keyword.operator.swift' } /* ',' */,
{ startIndex: 21, type: '' },
{ startIndex: 22, type: 'type.identifier.swift' } /* 'UIView' */,
{ startIndex: 28, type: '' },
{ startIndex: 29, type: 'delimiter.curly.swift' } /* '{' */
]}],
// Keyword, Identifier, and Type Identifier
[{
line: ' var window: UIWindow?',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'keyword.swift' } /* 'var' */,
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'identifier.swift' } /* 'window' */,
{ startIndex: 14, type: 'keyword.operator.swift' } /* ':' */,
{ startIndex: 15, type: '' },
{ startIndex: 16, type: 'type.identifier.swift' } /* 'UIWindow' */,
{ startIndex: 24, type: 'keyword.operator.swift' } /* '?' */
]}],
//Comment
[{
line: ' // Comment',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'comment.swift' } /* '// Comment' */
]}],
//Block Comment with Embedded Comment followed by code
[{
line: ' /* Comment //Embedded */ var y = 0b10',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'comment.swift' }, // /* '/* Comment //Embedded */' */,
{ startIndex: 28, type: '' },
{ startIndex: 29, type: 'keyword.swift' } /* 'var' */,
{ startIndex: 32, type: '' },
{ startIndex: 33, type: 'identifier.swift' } /* 'y' */,
{ startIndex: 34, type: '' },
{ startIndex: 35, type: 'keyword.operator.swift' } /* '=' */,
{ startIndex: 36, type: '' },
{ startIndex: 37, type: 'number.binary.swift' } /* '0b10' */
]}],
// Method signature (broken on two lines)
[{
line: ' public func app(app: App, opts:',
tokens:[
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'keyword.swift' } /* 'public' */,
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'keyword.swift' } /* 'func' */,
{ startIndex: 15, type: '' },
{ startIndex: 16, type: 'identifier.swift' } /* 'app' */,
{ startIndex: 19, type: 'delimiter.parenthesis.swift' } /* '(' */,
{ startIndex: 20, type: 'identifier.swift' }/* 'app' */,
{ startIndex: 23, type: 'keyword.operator.swift' } /* ':' */,
{ startIndex: 24, type: '' },
{ startIndex: 25, type: 'type.identifier.swift' } /* 'App' */,
{ startIndex: 28, type: 'keyword.operator.swift' } /* ',' */,
{ startIndex: 29, type: '' },
{ startIndex: 30, type: 'identifier.swift' } /* 'opts' */,
{ startIndex: 34, type: 'keyword.operator.swift' } /* ':' */,
]}],
// Method signature Continued
[{
line: ' [NSObject: AnyObject]?) -> Bool {',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 8, type: 'delimiter.square.swift' } /* '[' */,
{ startIndex: 9, type: 'type.identifier.swift' } /* 'NSObject' */,
{ startIndex: 17, type: 'keyword.operator.swift' } /* ':' */,
{ startIndex: 18, type: '' },
{ startIndex: 19, type: 'type.identifier.swift' } /* 'AnyObject' */,
{ startIndex: 28, type: 'delimiter.square.swift' } /* ']' */,
{ startIndex: 29, type: 'keyword.operator.swift' } /* '?' */,
{ startIndex: 30, type: 'delimiter.parenthesis.swift' } /* ')' */,
{ startIndex: 31, type: '' },
{ startIndex: 32, type: 'keyword.operator.swift' } /* '->' */,
{ startIndex: 34, type: '' },
{ startIndex: 35, type: 'type.identifier.swift' } /* 'Bool' */,
{ startIndex: 39, type: '' },
{ startIndex: 40, type: 'delimiter.curly.swift' } /* '{' */
]}],
// String with escapes
[{
line: ' var `String` = "String w/ \\"escape\\""',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 8, type: 'keyword.swift' } /* 'var' */,
{ startIndex: 11, type: '' },
{ startIndex: 12, type: 'keyword.operator.swift' } /* '`' */,
{ startIndex: 13, type: 'identifier.swift' } /* 'String' */,
{ startIndex: 19, type: 'keyword.operator.swift' } /* '`' */,
{ startIndex: 20, type: '' },
{ startIndex: 21, type: 'keyword.operator.swift' } /* '=' */,
{ startIndex: 22, type: '' },
{ startIndex: 23, type: 'string.quote.swift' } /* '"' */,
{ startIndex: 24, type: 'string.swift' } /* 'String w/ \\"escape\\""' */,
{ startIndex: 44, type: 'string.quote.swift' } /* '"' */,
]}],
// String with interpolated expression
[{
line: ' let message = "\\(y) times 2.5 is \\(Double(25) * 2.5)"',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 8, type: 'keyword.swift' } /* 'let' */,
{ startIndex: 11, type: '' },
{ startIndex: 12, type: 'identifier.swift' } /* 'message' */,
{ startIndex: 19, type: '' },
{ startIndex: 20, type: 'keyword.operator.swift' } /* '=' */,
{ startIndex: 21, type: '' },
{ startIndex: 22, type: 'string.quote.swift' } /* '"' */,
{ startIndex: 23, type: 'keyword.operator.swift' } /* '\(' */,
{ startIndex: 25, type: 'identifier.swift' },
{ startIndex: 26, type: 'keyword.operator.swift' } /* ')' */,
{ startIndex: 27, type: 'string.swift' } /* ' times 2.5 is ' */,
{ startIndex: 41, type: 'keyword.operator.swift' } /* '\(' */,
{ startIndex: 43, type: 'type.identifier.swift' } /* 'Double' */,
{ startIndex: 49, type: 'keyword.operator.swift' } /* '(' */,
{ startIndex: 50, type: 'number.swift' } /* '25' */,
{ startIndex: 52, type: 'keyword.operator.swift' } /* ')' */,
{ startIndex: 53, type: '' },
{ startIndex: 54, type: 'keyword.operator.swift' } /* '*' */,
{ startIndex: 55, type: '' },
{ startIndex: 56, type: 'number.float.swift' } /* '2.5' */,
{ startIndex: 59, type: 'keyword.operator.swift' } /* ')' */,
{ startIndex: 60, type: 'string.quote.swift' } /* '"' */
]}],
// Method invocation/property accessor.
[{
line: ' let view = self.window!.contr as! UIView',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 8, type: 'keyword.swift' } /* 'let' */,
{ startIndex: 11, type: '' },
{ startIndex: 12, type: 'identifier.swift' } /* 'view' */,
{ startIndex: 16, type: '' },
{ startIndex: 17, type: 'keyword.operator.swift' } /* '=' */,
{ startIndex: 18, type: '' },
{ startIndex: 19, type: 'keyword.swift' } /* 'self' */,
{ startIndex: 23, type: 'delimeter.swift' } /* '.' */,
{ startIndex: 24, type: 'type.identifier.swift' } /* 'window' */,
{ startIndex: 30, type: 'keyword.operator.swift' } /* '!' */,
{ startIndex: 31, type: 'delimeter.swift' } /* '.' */,
{ startIndex: 32, type: 'type.identifier.swift' } /* 'contr' */,
{ startIndex: 37, type: '' },
{ startIndex: 38, type: 'keyword.swift' } /* 'as' */,
{ startIndex: 40, type: 'keyword.operator.swift' } /* '!' */,
{ startIndex: 41, type: '' },
{ startIndex: 42, type: 'type.identifier.swift' } /* 'UIView' */
]}]
]);

58
test/testRunner.ts Normal file
View file

@ -0,0 +1,58 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import {loadLanguage} from '../src/monaco.contribution';
import * as assert from 'assert';
// Allow for running under nodejs/requirejs in tests
var _monaco: typeof monaco = (typeof monaco === 'undefined' ? (<any>self).monaco : monaco);
export interface IRelaxedToken {
startIndex: number;
type: string;
}
export interface ITestItem {
line: string;
tokens: IRelaxedToken[];
}
export function testTokenization(languageId:string, tests:ITestItem[][]): void {
suite(languageId + ' tokenization', () => {
test('', (done) => {
loadLanguage(languageId).then(() => {
runTests(languageId, tests);
done();
}).then(null, done);
});
});
}
function runTests(languageId:string, tests:ITestItem[][]): void {
tests.forEach((test) => runTest(languageId, test));
}
function runTest(languageId:string, test:ITestItem[]): void {
let text = test.map(t => t.line).join('\n');
let model = _monaco.editor.createModel(text, languageId);
for (let lineNumber = 1, lineCount = model.getLineCount(); lineNumber <= lineCount; lineNumber++) {
let actual: IRelaxedToken[] = [];
let lineTokens = (<any>model).getLineTokens(lineNumber);
for (let j = 0; j < lineTokens.getTokenCount(); j++) {
actual.push({
startIndex: lineTokens.getTokenStartIndex(j),
type: lineTokens.getTokenType(j)
});
}
let expected = test[lineNumber - 1].tokens;
// console.log(`actual: ${JSON.stringify(actual)}`);
// console.log(`expected: ${JSON.stringify(expected)}`);
assert.deepEqual(actual, expected, 'TOKENIZING ' + text);
}
model.dispose();
}

395
test/vb.test.ts Normal file
View file

@ -0,0 +1,395 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {testTokenization} from './testRunner';
testTokenization('vb', [
// Comments - single line
[{
line: '\'',
tokens: [
{ startIndex: 0, type: 'comment.vb' }
]}],
[{
line: ' \' a comment',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'comment.vb' }
]}],
[{
line: '\' a comment',
tokens: [
{ startIndex: 0, type: 'comment.vb' }
]}],
[{
line: '\'sticky comment',
tokens: [
{ startIndex: 0, type: 'comment.vb' }
]}],
[{
line: '1 \' 2; \' comment',
tokens: [
{ startIndex: 0, type: 'number.vb' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'comment.vb' }
]}],
[{
line: 'Dim x = 1; \' my comment \'\' is a nice one',
tokens: [
{ startIndex: 0, type: 'keyword.dim.vb' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.vb' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.vb' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'number.vb' },
{ startIndex: 9, type: 'delimiter.vb' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'comment.vb' }
]}],
[{
line: 'REM this is a comment',
tokens: [
{ startIndex: 0, type: 'comment.vb' }
]}],
[{
line: '2 + 5 REM comment starts',
tokens: [
{ startIndex: 0, type: 'number.vb' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.vb' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'number.vb' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'comment.vb' }
]}],
// Numbers
[{
line: '0',
tokens: [
{ startIndex: 0, type: 'number.vb' }
]}],
[{
line: '0.0',
tokens: [
{ startIndex: 0, type: 'number.float.vb' }
]}],
[{
line: '&h123',
tokens: [
{ startIndex: 0, type: 'number.hex.vb' }
]}],
[{
line: '23.5',
tokens: [
{ startIndex: 0, type: 'number.float.vb' }
]}],
[{
line: '23.5e3',
tokens: [
{ startIndex: 0, type: 'number.float.vb' }
]}],
[{
line: '23.5E3',
tokens: [
{ startIndex: 0, type: 'number.float.vb' }
]}],
[{
line: '23.5r',
tokens: [
{ startIndex: 0, type: 'number.float.vb' }
]}],
[{
line: '23.5f',
tokens: [
{ startIndex: 0, type: 'number.float.vb' }
]}],
[{
line: '1.72E3r',
tokens: [
{ startIndex: 0, type: 'number.float.vb' }
]}],
[{
line: '1.72E3r',
tokens: [
{ startIndex: 0, type: 'number.float.vb' }
]}],
[{
line: '1.72e3f',
tokens: [
{ startIndex: 0, type: 'number.float.vb' }
]}],
[{
line: '1.72e3r',
tokens: [
{ startIndex: 0, type: 'number.float.vb' }
]}],
[{
line: '23.5R',
tokens: [
{ startIndex: 0, type: 'number.float.vb' }
]}],
[{
line: '23.5r',
tokens: [
{ startIndex: 0, type: 'number.float.vb' }
]}],
[{
line: '1.72E3#',
tokens: [
{ startIndex: 0, type: 'number.float.vb' }
]}],
[{
line: '1.72E3F',
tokens: [
{ startIndex: 0, type: 'number.float.vb' }
]}],
[{
line: '1.72e3!',
tokens: [
{ startIndex: 0, type: 'number.float.vb' }
]}],
[{
line: '1.72e3f',
tokens: [
{ startIndex: 0, type: 'number.float.vb' }
]}],
[{
line: '1.72e-3',
tokens: [
{ startIndex: 0, type: 'number.float.vb' }
]}],
[{
line: '0+0',
tokens: [
{ startIndex: 0, type: 'number.vb' },
{ startIndex: 1, type: 'delimiter.vb' },
{ startIndex: 2, type: 'number.vb' }
]}],
[{
line: '100+10',
tokens: [
{ startIndex: 0, type: 'number.vb' },
{ startIndex: 3, type: 'delimiter.vb' },
{ startIndex: 4, type: 'number.vb' }
]}],
[{
line: '0 + 0',
tokens: [
{ startIndex: 0, type: 'number.vb' },
{ startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.vb' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'number.vb' }
]}],
// Keywords
[{
line: 'Imports Microsoft.VisualBasic',
tokens: [
{ startIndex: 0, type: 'keyword.imports.vb' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'identifier.vb' },
{ startIndex: 17, type: 'delimiter.vb' },
{ startIndex: 18, type: 'identifier.vb' }
]}],
[{
line: 'Private Sub Foo(ByVal sender As String)',
tokens: [
{ startIndex: 0, type: 'keyword.private.vb' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'keyword.tag-sub.vb' },
{ startIndex: 11, type: '' },
{ startIndex: 12, type: 'identifier.vb' },
{ startIndex: 15, type: 'delimiter.parenthesis.vb' },
{ startIndex: 16, type: 'keyword.byval.vb' },
{ startIndex: 21, type: '' },
{ startIndex: 22, type: 'identifier.vb' },
{ startIndex: 28, type: '' },
{ startIndex: 29, type: 'keyword.as.vb' },
{ startIndex: 31, type: '' },
{ startIndex: 32, type: 'keyword.string.vb' },
{ startIndex: 38, type: 'delimiter.parenthesis.vb' }
]}],
// Strings
[{
line: 'String s = "string"',
tokens: [
{ startIndex: 0, type: 'keyword.string.vb' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'identifier.vb' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'delimiter.vb' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'string.vb' }
]}],
[{
line: '"use strict";',
tokens: [
{ startIndex: 0, type: 'string.vb' },
{ startIndex: 12, type: 'delimiter.vb' }
]}],
// Tags
[{
line: 'Public Sub ToString()',
tokens: [
{ startIndex: 0, type: 'keyword.public.vb' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'keyword.tag-sub.vb' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'identifier.vb' },
{ startIndex: 19, type: 'delimiter.parenthesis.vb' }
]}],
[{
line: 'public sub ToString()',
tokens: [
{ startIndex: 0, type: 'keyword.public.vb' },
{ startIndex: 6, type: '' },
{ startIndex: 7, type: 'keyword.tag-sub.vb' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'identifier.vb' },
{ startIndex: 19, type: 'delimiter.parenthesis.vb' }
]}],
[{
line: 'While Do Continue While End While',
tokens: [
{ startIndex: 0, type: 'keyword.tag-while.vb' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'keyword.tag-do.vb' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'keyword.tag-continue.vb' },
{ startIndex: 17, type: '' },
{ startIndex: 18, type: 'keyword.tag-while.vb' },
{ startIndex: 23, type: '' },
{ startIndex: 24, type: 'keyword.tag-while.vb' }
]}],
[{
line: 'While while WHILE WHile whiLe',
tokens: [
{ startIndex: 0, type: 'keyword.tag-while.vb' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'keyword.tag-while.vb' },
{ startIndex: 11, type: '' },
{ startIndex: 12, type: 'keyword.tag-while.vb' },
{ startIndex: 17, type: '' },
{ startIndex: 18, type: 'keyword.tag-while.vb' },
{ startIndex: 23, type: '' },
{ startIndex: 24, type: 'keyword.tag-while.vb' }
]}],
[{
line: 'If b(i) = col Then',
tokens: [
{ startIndex: 0, type: 'keyword.tag-if.vb' },
{ startIndex: 2, type: '' },
{ startIndex: 3, type: 'identifier.vb' },
{ startIndex: 4, type: 'delimiter.parenthesis.vb' },
{ startIndex: 5, type: 'identifier.vb' },
{ startIndex: 6, type: 'delimiter.parenthesis.vb' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'delimiter.vb' },
{ startIndex: 9, type: '' },
{ startIndex: 10, type: 'identifier.vb' },
{ startIndex: 13, type: '' },
{ startIndex: 14, type: 'keyword.then.vb' }
]}],
[{
line: 'Do stuff While True Loop',
tokens: [
{ startIndex: 0, type: 'keyword.tag-do.vb' },
{ startIndex: 2, type: '' },
{ startIndex: 3, type: 'identifier.vb' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'keyword.tag-while.vb' },
{ startIndex: 14, type: '' },
{ startIndex: 15, type: 'keyword.true.vb' },
{ startIndex: 19, type: '' },
{ startIndex: 20, type: 'keyword.tag-do.vb' }
]}],
[{
line: 'For i = 0 To 10 DoStuff Next',
tokens: [
{ startIndex: 0, type: 'keyword.tag-for.vb' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.vb' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.vb' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'number.vb' },
{ startIndex: 9, type: '' },
{ startIndex: 10, type: 'keyword.to.vb' },
{ startIndex: 12, type: '' },
{ startIndex: 13, type: 'number.vb' },
{ startIndex: 15, type: '' },
{ startIndex: 16, type: 'identifier.vb' },
{ startIndex: 23, type: '' },
{ startIndex: 24, type: 'keyword.tag-for.vb' }
]}],
[{
line: 'For stuff End For',
tokens: [
{ startIndex: 0, type: 'keyword.tag-for.vb' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.vb' },
{ startIndex: 9, type: '' },
{ startIndex: 10, type: 'keyword.end.vb' },
{ startIndex: 13, type: '' },
{ startIndex: 14, type: 'keyword.tag-for.vb' }
]}],
[{
line: 'For stuff end for',
tokens: [
{ startIndex: 0, type: 'keyword.tag-for.vb' },
{ startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.vb' },
{ startIndex: 9, type: '' },
{ startIndex: 10, type: 'keyword.end.vb' },
{ startIndex: 13, type: '' },
{ startIndex: 14, type: 'keyword.tag-for.vb' }
]}]
]);

573
test/xml.test.ts Normal file
View file

@ -0,0 +1,573 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {testTokenization} from './testRunner';
testTokenization('xml', [
// Complete Start Tag with Whitespace
[{
line: '<person>',
tokens: [
{ startIndex: 0, type: 'delimiter.start.xml' },
{ startIndex: 1, type: 'tag.tag-person.xml' },
{ startIndex: 7, type: 'delimiter.start.xml' }
]}],
[{
line: '<person/>',
tokens: [
{ startIndex: 0, type: 'delimiter.start.xml' },
{ startIndex: 1, type: 'tag.tag-person.xml' },
{ startIndex: 8, type: 'delimiter.start.xml' }
]}],
[{
line: '<person >',
tokens: [
{ startIndex: 0, type: 'delimiter.start.xml' },
{ startIndex: 1, type: 'tag.tag-person.xml' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'delimiter.start.xml' }
]}],
[{
line: '<person />',
tokens: [
{ startIndex: 0, type: 'delimiter.start.xml' },
{ startIndex: 1, type: 'tag.tag-person.xml' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'tag.tag-person.xml' },
{ startIndex: 9, type: 'delimiter.start.xml' }
]}],
// Incomplete Start Tag
[{
line: '<',
tokens: [
{ startIndex: 0, type: '' }
]}],
[{
line: '<person',
tokens: [
{ startIndex: 0, type: 'delimiter.start.xml' },
{ startIndex: 1, type: 'tag.tag-person.xml' }
]}],
[{
line: '<input',
tokens: [
{ startIndex: 0, type: 'delimiter.start.xml' },
{ startIndex: 1, type: 'tag.tag-input.xml' }
]}],
// Invalid Open Start Tag
[{
line: '< person',
tokens: [
{ startIndex: 0, type: '' }
]}],
[{
line: '< person>',
tokens: [
{ startIndex: 0, type: '' }
]}],
[{
line: 'i <person;',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'delimiter.start.xml' },
{ startIndex: 3, type: 'tag.tag-person.xml' },
{ startIndex: 9, type: '' }
]}],
// Tag with Attribute
[{
line: '<tool name="">',
tokens: [
{ startIndex: 0, type: 'delimiter.start.xml' },
{ startIndex: 1, type: 'tag.tag-tool.xml' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'attribute.name.xml' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'attribute.value.xml' },
{ startIndex: 13, type: 'delimiter.start.xml' }
]}],
[{
line: '<tool name="Monaco">',
tokens: [
{ startIndex: 0, type: 'delimiter.start.xml' },
{ startIndex: 1, type: 'tag.tag-tool.xml' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'attribute.name.xml' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'attribute.value.xml' },
{ startIndex: 19, type: 'delimiter.start.xml' }
]}],
[{
line: '<tool name=\'Monaco\'>',
tokens: [
{ startIndex: 0, type: 'delimiter.start.xml' },
{ startIndex: 1, type: 'tag.tag-tool.xml' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'attribute.name.xml' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'attribute.value.xml' },
{ startIndex: 19, type: 'delimiter.start.xml' }
]}],
// Tag with Attributes
[{
line: '<tool name="Monaco" version="1.0">',
tokens: [
{ startIndex: 0, type: 'delimiter.start.xml' },
{ startIndex: 1, type: 'tag.tag-tool.xml' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'attribute.name.xml' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'attribute.value.xml' },
{ startIndex: 19, type: '' },
{ startIndex: 20, type: 'attribute.name.xml' },
{ startIndex: 27, type: '' },
{ startIndex: 28, type: 'attribute.value.xml' },
{ startIndex: 33, type: 'delimiter.start.xml' }
]}],
// Tag with Name-Only-Attribute
[{
line: '<tool name>',
tokens: [
{ startIndex: 0, type: 'delimiter.start.xml' },
{ startIndex: 1, type: 'tag.tag-tool.xml' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'attribute.name.xml' },
{ startIndex: 10, type: 'delimiter.start.xml' }
]}],
[{
line: '<tool name version>',
tokens: [
{ startIndex: 0, type: 'delimiter.start.xml' },
{ startIndex: 1, type: 'tag.tag-tool.xml' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'attribute.name.xml' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'attribute.name.xml' },
{ startIndex: 18, type: 'delimiter.start.xml' }
]}],
// Tag with Attribute And Whitespace
[{
line: '<tool name= "monaco">',
tokens: [
{ startIndex: 0, type: 'delimiter.start.xml' },
{ startIndex: 1, type: 'tag.tag-tool.xml' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'attribute.name.xml' },
{ startIndex: 10, type: '' },
{ startIndex: 13, type: 'attribute.value.xml' },
{ startIndex: 21, type: 'delimiter.start.xml' }
]}],
[{
line: '<tool name = "monaco">',
tokens: [
{ startIndex: 0, type: 'delimiter.start.xml' },
{ startIndex: 1, type: 'tag.tag-tool.xml' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'attribute.name.xml' },
{ startIndex: 10, type: '' },
{ startIndex: 13, type: 'attribute.value.xml' },
{ startIndex: 21, type: 'delimiter.start.xml' }
]}],
// Tag with Invalid Attribute Name
[{
line: '<tool name!@#="bar">',
tokens: [
{ startIndex: 0, type: 'delimiter.start.xml' },
{ startIndex: 1, type: 'tag.tag-tool.xml' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'attribute.name.xml' },
{ startIndex: 10, type: '' },
{ startIndex: 15, type: 'attribute.name.xml' },
{ startIndex: 18, type: '' },
{ startIndex: 19, type: 'delimiter.start.xml' }
]}],
// Tag with Invalid Attribute Value
[{
line: '<tool name=">',
tokens: [
{ startIndex: 0, type: 'delimiter.start.xml' },
{ startIndex: 1, type: 'tag.tag-tool.xml' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'attribute.name.xml' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'attribute.value.xml' },
{ startIndex: 12, type: 'delimiter.start.xml' }
]}],
// Complete End Tag
[{
line: '</person>',
tokens: [
{ startIndex: 0, type: 'delimiter.end.xml' },
{ startIndex: 2, type: 'tag.tag-person.xml' },
{ startIndex: 8, type: 'delimiter.end.xml' }
]}],
// Complete End Tag with Whitespace
[{
line: '</person >',
tokens: [
{ startIndex: 0, type: 'delimiter.end.xml' },
{ startIndex: 2, type: 'tag.tag-person.xml' },
{ startIndex: 8, type: '' },
{ startIndex: 10, type: 'delimiter.end.xml' }
]}],
// Incomplete End Tag
[{
line: '</person',
tokens: [
{ startIndex: 0, type: '' }
]}],
// Comments
[{
line: '<!-- -->',
tokens: [
{ startIndex: 0, type: 'comment.xml' },
{ startIndex: 4, type: 'comment.content.xml' },
{ startIndex: 5, type: 'comment.xml' }
]}],
[{
line: '<!--a>monaco</a -->',
tokens: [
{ startIndex: 0, type: 'comment.xml' },
{ startIndex: 4, type: 'comment.content.xml' },
{ startIndex: 16, type: 'comment.xml' }
]}],
[{
line: '<!--a>',
tokens: [
{ startIndex: 0, type: 'comment.xml' },
{ startIndex: 4, type: 'comment.content.xml' }
]},{
line: 'monaco ',
tokens: [
{ startIndex: 0, type: 'comment.content.xml' }
]},{
line: 'tools</a -->',
tokens: [
{ startIndex: 0, type: 'comment.content.xml' },
{ startIndex: 9, type: 'comment.xml' }
]}],
// CDATA
[{
line: '<tools><![CDATA[<person/>]]></tools>',
tokens: [
{ startIndex: 0, type: 'delimiter.start.xml' },
{ startIndex: 1, type: 'tag.tag-tools.xml' },
{ startIndex: 6, type: 'delimiter.start.xml' },
{ startIndex: 7, type: 'delimiter.cdata.xml' },
{ startIndex: 16, type: '' },
{ startIndex: 25, type: 'delimiter.cdata.xml' },
{ startIndex: 28, type: 'delimiter.end.xml' },
{ startIndex: 30, type: 'tag.tag-tools.xml' },
{ startIndex: 35, type: 'delimiter.end.xml' }
]}],
[{
line: '<tools>',
tokens: [
{ startIndex: 0, type: 'delimiter.start.xml' },
{ startIndex: 1, type: 'tag.tag-tools.xml' },
{ startIndex: 6, type: 'delimiter.start.xml' }
]},{
line: '\t<![CDATA[',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.cdata.xml' }
]},{
line: '\t\t<person/>',
tokens: [
{ startIndex: 0, type: '' }
]},{
line: '\t]]>',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.cdata.xml' },
]},{
line: '</tools>',
tokens: [
{ startIndex: 0, type: 'delimiter.end.xml' },
{ startIndex: 2, type: 'tag.tag-tools.xml' },
{ startIndex: 7, type: 'delimiter.end.xml' }
]}],
// Generated from sample
[{
line: '<?xml version="1.0"?>',
tokens: [
{ startIndex: 0, type: 'delimiter.start.xml' },
{ startIndex: 2, type: 'metatag.instruction.xml' },
{ startIndex: 5, type: '' },
{ startIndex: 6, type: 'attribute.name.xml' },
{ startIndex: 13, type: '' },
{ startIndex: 14, type: 'attribute.value.xml' },
{ startIndex: 19, type: 'delimiter.start.xml' }
]}, {
line: '<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">',
tokens: [
{ startIndex: 0, type: 'delimiter.start.xml' },
{ startIndex: 1, type: 'tag.tag-configuration.xml' },
{ startIndex: 14, type: '' },
{ startIndex: 15, type: 'attribute.name.xml' },
{ startIndex: 24, type: '' },
{ startIndex: 25, type: 'attribute.value.xml' },
{ startIndex: 78, type: 'delimiter.start.xml' }
]}, {
line: ' <connectionStrings>',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'delimiter.start.xml' },
{ startIndex: 3, type: 'tag.tag-connectionstrings.xml' },
{ startIndex: 20, type: 'delimiter.start.xml' }
]}, {
line: ' <add name="MyDB" ',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'delimiter.start.xml' },
{ startIndex: 5, type: 'tag.tag-add.xml' },
{ startIndex: 8, type: '' },
{ startIndex: 9, type: 'attribute.name.xml' },
{ startIndex: 13, type: '' },
{ startIndex: 14, type: 'attribute.value.xml' },
{ startIndex: 20, type: '' }
]}, {
line: ' connectionString="value for the deployed Web.config file" ',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 6, type: 'attribute.name.xml' },
{ startIndex: 22, type: '' },
{ startIndex: 23, type: 'attribute.value.xml' },
{ startIndex: 63, type: '' }
]}, {
line: ' xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 6, type: 'attribute.name.xml' },
{ startIndex: 19, type: '' },
{ startIndex: 20, type: 'attribute.value.xml' },
{ startIndex: 35, type: '' },
{ startIndex: 36, type: 'attribute.name.xml' },
{ startIndex: 47, type: '' },
{ startIndex: 48, type: 'attribute.value.xml' },
{ startIndex: 61, type: 'tag.tag-add.xml' },
{ startIndex: 62, type: 'delimiter.start.xml' }
]}, {
line: ' </connectionStrings>',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'delimiter.end.xml' },
{ startIndex: 4, type: 'tag.tag-connectionstrings.xml' },
{ startIndex: 21, type: 'delimiter.end.xml' }
]}, {
line: ' <system.web>',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'delimiter.start.xml' },
{ startIndex: 3, type: 'tag.tag-system.web.xml' },
{ startIndex: 13, type: 'delimiter.start.xml' }
]}, {
line: ' <customErrors defaultRedirect="GenericError.htm"',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'delimiter.start.xml' },
{ startIndex: 5, type: 'tag.tag-customerrors.xml' },
{ startIndex: 17, type: '' },
{ startIndex: 18, type: 'attribute.name.xml' },
{ startIndex: 33, type: '' },
{ startIndex: 34, type: 'attribute.value.xml' }
]}, {
line: ' mode="RemoteOnly" xdt:Transform="Replace">',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 6, type: 'attribute.name.xml' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'attribute.value.xml' },
{ startIndex: 23, type: '' },
{ startIndex: 24, type: 'attribute.name.xml' },
{ startIndex: 37, type: '' },
{ startIndex: 38, type: 'attribute.value.xml' },
{ startIndex: 47, type: 'delimiter.start.xml' }
]}, {
line: ' <error statusCode="500" redirect="InternalError.htm"/>',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 6, type: 'delimiter.start.xml' },
{ startIndex: 7, type: 'tag.tag-error.xml' },
{ startIndex: 12, type: '' },
{ startIndex: 13, type: 'attribute.name.xml' },
{ startIndex: 23, type: '' },
{ startIndex: 24, type: 'attribute.value.xml' },
{ startIndex: 29, type: '' },
{ startIndex: 30, type: 'attribute.name.xml' },
{ startIndex: 38, type: '' },
{ startIndex: 39, type: 'attribute.value.xml' },
{ startIndex: 58, type: 'tag.tag-error.xml' },
{ startIndex: 59, type: 'delimiter.start.xml' }
]}, {
line: ' </customErrors>',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 4, type: 'delimiter.end.xml' },
{ startIndex: 6, type: 'tag.tag-customerrors.xml' },
{ startIndex: 18, type: 'delimiter.end.xml' }
]}, {
line: ' </system.web>',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'delimiter.end.xml' },
{ startIndex: 4, type: 'tag.tag-system.web.xml' },
{ startIndex: 14, type: 'delimiter.end.xml' }
]}, {
line: ' ',
tokens: [
{ startIndex: 0, type: '' }
]}, {
line: ' <!-- The stuff below was added for extra tokenizer testing -->',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'comment.xml' },
{ startIndex: 5, type: 'comment.content.xml' },
{ startIndex: 60, type: 'comment.xml' }
]}, {
line: ' <!-- A multi-line comment <with> </with>',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'comment.xml' },
{ startIndex: 5, type: 'comment.content.xml' }
]}, {
line: ' <tags>',
tokens: [
{ startIndex: 0, type: 'comment.content.xml' }
]}, {
line: ' -->',
tokens: [
{ startIndex: 0, type: 'comment.content.xml' },
{ startIndex: 5, type: 'comment.xml' }
]}, {
line: ' <!DOCTYPE another meta tag>',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.start.xml' },
{ startIndex: 3, type: 'metatag.declaration.xml' },
{ startIndex: 10, type: '' },
{ startIndex: 11, type: 'attribute.name.xml' },
{ startIndex: 18, type: '' },
{ startIndex: 19, type: 'attribute.name.xml' },
{ startIndex: 23, type: '' },
{ startIndex: 24, type: 'attribute.name.xml' },
{ startIndex: 27, type: 'delimiter.start.xml' }
]}, {
line: ' <tools><![CDATA[Some text and tags <person/>]]></tools>',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.start.xml' },
{ startIndex: 2, type: 'tag.tag-tools.xml' },
{ startIndex: 7, type: 'delimiter.start.xml' },
{ startIndex: 8, type: 'delimiter.cdata.xml' },
{ startIndex: 17, type: '' },
{ startIndex: 45, type: 'delimiter.cdata.xml' },
{ startIndex: 48, type: 'delimiter.end.xml' },
{ startIndex: 50, type: 'tag.tag-tools.xml' },
{ startIndex: 55, type: 'delimiter.end.xml' }
]}, {
line: ' <aSelfClosingTag with="attribute" />',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.start.xml' },
{ startIndex: 2, type: 'tag.tag-aselfclosingtag.xml' },
{ startIndex: 17, type: '' },
{ startIndex: 18, type: 'attribute.name.xml' },
{ startIndex: 22, type: '' },
{ startIndex: 23, type: 'attribute.value.xml' },
{ startIndex: 34, type: '' },
{ startIndex: 35, type: 'tag.tag-aselfclosingtag.xml' },
{ startIndex: 36, type: 'delimiter.start.xml' }
]}, {
line: ' <aSelfClosingTag with="attribute"/>',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.start.xml' },
{ startIndex: 2, type: 'tag.tag-aselfclosingtag.xml' },
{ startIndex: 17, type: '' },
{ startIndex: 18, type: 'attribute.name.xml' },
{ startIndex: 22, type: '' },
{ startIndex: 23, type: 'attribute.value.xml' },
{ startIndex: 34, type: 'tag.tag-aselfclosingtag.xml' },
{ startIndex: 35, type: 'delimiter.start.xml' }
]}, {
line: ' <namespace:aSelfClosingTag otherspace:with="attribute"/>',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.start.xml' },
{ startIndex: 2, type: 'tag.tag-namespace:aselfclosingtag.xml' },
{ startIndex: 27, type: '' },
{ startIndex: 28, type: 'attribute.name.xml' },
{ startIndex: 43, type: '' },
{ startIndex: 44, type: 'attribute.value.xml' },
{ startIndex: 55, type: 'tag.tag-namespace:aselfclosingtag.xml' },
{ startIndex: 56, type: 'delimiter.start.xml' }
]}, {
line: ' <valid-name also_valid this.one=\'too is valid\'/>',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.start.xml' },
{ startIndex: 2, type: 'tag.tag-valid-name.xml' },
{ startIndex: 12, type: '' },
{ startIndex: 13, type: 'attribute.name.xml' },
{ startIndex: 23, type: '' },
{ startIndex: 24, type: 'attribute.name.xml' },
{ startIndex: 32, type: '' },
{ startIndex: 33, type: 'attribute.value.xml' },
{ startIndex: 47, type: 'tag.tag-valid-name.xml' },
{ startIndex: 48, type: 'delimiter.start.xml' }
]}, {
line: ' <aSimpleSelfClosingTag />',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.start.xml' },
{ startIndex: 2, type: 'tag.tag-asimpleselfclosingtag.xml' },
{ startIndex: 23, type: '' },
{ startIndex: 24, type: 'tag.tag-asimpleselfclosingtag.xml' },
{ startIndex: 25, type: 'delimiter.start.xml' }
]}, {
line: ' <aSimpleSelfClosingTag/>',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 1, type: 'delimiter.start.xml' },
{ startIndex: 2, type: 'tag.tag-asimpleselfclosingtag.xml' },
{ startIndex: 24, type: 'delimiter.start.xml' }
]}, {
line: '</configuration>',
tokens: [
{ startIndex: 0, type: 'delimiter.end.xml' },
{ startIndex: 2, type: 'tag.tag-configuration.xml' },
{ startIndex: 15, type: 'delimiter.end.xml' }
]}]
]);