From c4177ec697035fe1c4b264e038010ec862b75c11 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Thu, 9 Jun 2016 19:01:53 +0200 Subject: [PATCH] Initial release --- .gitignore | 3 + .npmignore | 7 + .vscode/settings.json | 9 + LICENSE.md | 21 + README.md | 39 +- ThirdPartyNotices.txt | 34 + gulpfile.js | 148 +++ package.json | 34 + src/bat.ts | 106 ++ src/coffee.ts | 157 +++ src/cpp.ts | 306 ++++++ src/csharp.ts | 175 ++++ src/dockerfile.ts | 97 ++ src/fsharp.ts | 133 +++ src/go.ts | 166 +++ src/ini.ts | 69 ++ src/jade.ts | 179 ++++ src/java.ts | 130 +++ src/lua.ts | 107 ++ src/monaco.contribution.ts | 179 ++++ src/objective-c.ts | 201 ++++ src/powershell.ts | 125 +++ src/python.ts | 232 +++++ src/r.ts | 230 +++++ src/ruby.ts | 395 +++++++ src/sql.ts | 1132 ++++++++++++++++++++ src/swift.ts | 143 +++ src/vb.ts | 179 ++++ src/xml.ts | 104 ++ test/all.js | 48 + test/assert.d.ts | 44 + test/bat.test.ts | 332 ++++++ test/coffee.test.ts | 1983 ++++++++++++++++++++++++++++++++++++ test/cpp.test.ts | 666 ++++++++++++ test/csharp.test.ts | 744 ++++++++++++++ test/dockerfile.test.ts | 189 ++++ test/fsharp.test.ts | 392 +++++++ test/go.test.ts | 1167 +++++++++++++++++++++ test/jade.test.ts | 380 +++++++ test/java.test.ts | 605 +++++++++++ test/lua.test.ts | 76 ++ test/mocha.d.ts | 13 + test/mocha.opts | 3 + test/objective-c.test.ts | 291 ++++++ test/powershell.test.ts | 737 ++++++++++++++ test/python.test.ts | 105 ++ test/r.test.ts | 471 +++++++++ test/ruby.test.ts | 125 +++ test/sql.test.ts | 587 +++++++++++ test/swift.test.ts | 181 ++++ test/testRunner.ts | 58 ++ test/vb.test.ts | 395 +++++++ test/xml.test.ts | 573 +++++++++++ tsconfig.json | 58 ++ 54 files changed, 15061 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 .npmignore create mode 100644 .vscode/settings.json create mode 100644 LICENSE.md create mode 100644 ThirdPartyNotices.txt create mode 100644 gulpfile.js create mode 100644 package.json create mode 100644 src/bat.ts create mode 100644 src/coffee.ts create mode 100644 src/cpp.ts create mode 100644 src/csharp.ts create mode 100644 src/dockerfile.ts create mode 100644 src/fsharp.ts create mode 100644 src/go.ts create mode 100644 src/ini.ts create mode 100644 src/jade.ts create mode 100644 src/java.ts create mode 100644 src/lua.ts create mode 100644 src/monaco.contribution.ts create mode 100644 src/objective-c.ts create mode 100644 src/powershell.ts create mode 100644 src/python.ts create mode 100644 src/r.ts create mode 100644 src/ruby.ts create mode 100644 src/sql.ts create mode 100644 src/swift.ts create mode 100644 src/vb.ts create mode 100644 src/xml.ts create mode 100644 test/all.js create mode 100644 test/assert.d.ts create mode 100644 test/bat.test.ts create mode 100644 test/coffee.test.ts create mode 100644 test/cpp.test.ts create mode 100644 test/csharp.test.ts create mode 100644 test/dockerfile.test.ts create mode 100644 test/fsharp.test.ts create mode 100644 test/go.test.ts create mode 100644 test/jade.test.ts create mode 100644 test/java.test.ts create mode 100644 test/lua.test.ts create mode 100644 test/mocha.d.ts create mode 100644 test/mocha.opts create mode 100644 test/objective-c.test.ts create mode 100644 test/powershell.test.ts create mode 100644 test/python.test.ts create mode 100644 test/r.test.ts create mode 100644 test/ruby.test.ts create mode 100644 test/sql.test.ts create mode 100644 test/swift.test.ts create mode 100644 test/testRunner.ts create mode 100644 test/vb.test.ts create mode 100644 test/xml.test.ts create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..d9ef910d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/node_modules/ +/out/ +/release/ diff --git a/.npmignore b/.npmignore new file mode 100644 index 00000000..9edeecf4 --- /dev/null +++ b/.npmignore @@ -0,0 +1,7 @@ +/.vscode/ +/out/ +/src/ +/test/ +/gulpfile.js +/tsconfig.json +/.npmignore diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..1dc255b6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +// Place your settings in this file to overwrite default and user settings. +{ + "files.trimTrailingWhitespace": true, + "search.exclude": { + "**/node_modules": true, + "**/release": true, + "**/out": true + } +} \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 00000000..f8a94f6e --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Microsoft Corporation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 0a19060c..7b5ab4e4 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,37 @@ -# monaco-languages -Basic colorization support for many Monaco Editor languages. +# Monaco Languages + +Colorization and configuration supports for multiple languages for the Monaco Editor: + +![monaco-languages](https://cloud.githubusercontent.com/assets/5047891/15938606/1fd4bac6-2e74-11e6-8839-d455da8bc8a7.gif) + +* bat +* coffee script +* cpp +* csharp +* fsharp +* go +* ini +* jade +* lua +* objective-c +* powershell +* python +* r +* ruby +* sql +* swift +* vb +* xml + +## Installing + +This npm module is bundled and distributed in the [monaco-editor](https://www.npmjs.com/package/monaco-editor) npm module. + +## Dev: + +* compile with `npm run watch` +* test with `npm run test` +* bundle with `npm run prepublish` + +## License +[MIT](https://github.com/Microsoft/monaco-typescript/blob/master/LICENSE.md) diff --git a/ThirdPartyNotices.txt b/ThirdPartyNotices.txt new file mode 100644 index 00000000..91701413 --- /dev/null +++ b/ThirdPartyNotices.txt @@ -0,0 +1,34 @@ +THIRD-PARTY SOFTWARE NOTICES AND INFORMATION +Do Not Translate or Localize + +This project incorporates components from the projects listed below. The original copyright notices and the licenses +under which Microsoft received such components are set forth below. Microsoft reserves all rights not expressly granted +herein, whether by implication, estoppel or otherwise. + + + + +%% vscode-swift version 0.0.1 (https://github.com/owensd/vscode-swift) +========================================= +The MIT License (MIT) + +Copyright (c) 2015 David Owens II + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +========================================= +END OF vscode-swift NOTICES AND INFORMATION diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..ac4be384 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,148 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +var gulp = require('gulp'); +var tsb = require('gulp-tsb'); +var assign = require('object-assign'); +var fs = require('fs'); +var path = require('path'); +var merge = require('merge-stream'); +var rjs = require('gulp-requirejs'); +var uglify = require('gulp-uglify'); +var rimraf = require('rimraf'); +var es = require('event-stream'); + +gulp.task('clean-release', function(cb) { rimraf('release', { maxBusyTries: 1 }, cb); }); +gulp.task('release', ['clean-release','compile'], function() { + + var sha1 = getGitVersion(__dirname); + var semver = require('./package.json').version; + var headerVersion = semver + '(' + sha1 + ')'; + + var BUNDLED_FILE_HEADER = [ + '/*!-----------------------------------------------------------------------------', + ' * Copyright (c) Microsoft Corporation. All rights reserved.', + ' * monaco-languages version: ' + headerVersion, + ' * Released under the MIT license', + ' * https://github.com/Microsoft/monaco-languages/blob/master/LICENSE.md', + ' *-----------------------------------------------------------------------------*/', + '' + ].join('\n'); + + function bundleOne(moduleId, exclude) { + return rjs({ + baseUrl: '/out/', + name: 'vs/basic-languages/' + moduleId, + out: moduleId + '.js', + exclude: exclude, + paths: { + 'vs/basic-languages': __dirname + '/out' + } + }) + } + + return merge( + bundleOne('src/monaco.contribution'), + bundleOne('src/bat'), + bundleOne('src/coffee'), + bundleOne('src/cpp'), + bundleOne('src/csharp'), + bundleOne('src/dockerfile'), + bundleOne('src/fsharp'), + bundleOne('src/go'), + bundleOne('src/ini'), + bundleOne('src/jade'), + bundleOne('src/java'), + bundleOne('src/lua'), + bundleOne('src/objective-c'), + bundleOne('src/powershell'), + bundleOne('src/python'), + bundleOne('src/r'), + bundleOne('src/ruby'), + bundleOne('src/sql'), + bundleOne('src/swift'), + bundleOne('src/vb'), + bundleOne('src/xml') + ) + .pipe(uglify({ + preserveComments: 'some' + })) + .pipe(es.through(function(data) { + data.contents = new Buffer( + BUNDLED_FILE_HEADER + + data.contents.toString() + ); + this.emit('data', data); + })) + .pipe(gulp.dest('./release/')); +}); + + +var compilation = tsb.create(assign({ verbose: true }, require('./tsconfig.json').compilerOptions)); + +var tsSources = require('./tsconfig.json').filesGlob; + +function compileTask() { + return merge( + gulp.src(tsSources, { base: '.' }).pipe(compilation()) + ) + .pipe(gulp.dest('out')); +} +gulp.task('clean-out', function(cb) { rimraf('out', { maxBusyTries: 1 }, cb); }); +gulp.task('compile', ['clean-out'], compileTask); +gulp.task('compile-without-clean', compileTask); +gulp.task('watch', ['compile'], function() { + gulp.watch(tsSources, ['compile-without-clean']); +}); + +function getGitVersion(repo) { + var git = path.join(repo, '.git'); + var headPath = path.join(git, 'HEAD'); + var head; + + try { + head = fs.readFileSync(headPath, 'utf8').trim(); + } catch (e) { + return void 0; + } + + if (/^[0-9a-f]{40}$/i.test(head)) { + return head; + } + + var refMatch = /^ref: (.*)$/.exec(head); + + if (!refMatch) { + return void 0; + } + + var ref = refMatch[1]; + var refPath = path.join(git, ref); + + try { + return fs.readFileSync(refPath, 'utf8').trim(); + } catch (e) { + // noop + } + + var packedRefsPath = path.join(git, 'packed-refs'); + var refsRaw; + + try { + refsRaw = fs.readFileSync(packedRefsPath, 'utf8').trim(); + } catch (e) { + return void 0; + } + + var refsRegex = /^([0-9a-f]{40})\s+(.+)$/gm; + var refsMatch; + var refs = {}; + + while (refsMatch = refsRegex.exec(refsRaw)) { + refs[refsMatch[2]] = refsMatch[1]; + } + + return refs[ref]; +} diff --git a/package.json b/package.json new file mode 100644 index 00000000..f5ad2605 --- /dev/null +++ b/package.json @@ -0,0 +1,34 @@ +{ + "name": "monaco-languages", + "version": "0.1.0", + "description": "Bundle of many languages for the Monaco Editor.", + "scripts": { + "test": "node_modules/.bin/mocha", + "watch": "node_modules/.bin/gulp watch", + "prepublish": "node_modules/.bin/gulp release" + }, + "author": "Microsoft Corporation", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/Microsoft/monaco-languages" + }, + "bugs": { + "url": "https://github.com/Microsoft/monaco-languages/issues" + }, + "devDependencies": { + "event-stream": "^3.3.2", + "gulp": "^3.9.1", + "gulp-requirejs": "^0.1.3", + "gulp-tsb": "^1.10.4", + "gulp-uglify": "^1.5.3", + "jsdom-no-contextify": "^3.1.0", + "merge-stream": "^1.0.0", + "mocha": "^2.5.3", + "monaco-editor-core": "0.3.1", + "object-assign": "^4.1.0", + "rimraf": "^2.5.2", + "typescript": "^1.8.10", + "typescript-with-globs": "^0.1.4" + } +} diff --git a/src/bat.ts b/src/bat.ts new file mode 100644 index 00000000..4f094401 --- /dev/null +++ b/src/bat.ts @@ -0,0 +1,106 @@ +/*--------------------------------------------------------------------------------------------- + * 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 IRichLanguageConfiguration = monaco.languages.IRichLanguageConfiguration; +import ILanguage = monaco.languages.IMonarchLanguage; + +export var conf:IRichLanguageConfiguration = { + comments: { + lineComment: 'REM' + }, + brackets: [['{','}'], ['[',']'], ['(',')']], + autoClosingPairs: [ + { open: '"', close: '"', notIn: ['string', 'comment'] }, + { open: '{', close: '}', notIn: ['string', 'comment'] }, + { open: '[', close: ']', notIn: ['string', 'comment'] }, + { open: '(', close: ')', notIn: ['string', 'comment'] }, + ] + // enhancedBrackets: [ + // { + // openTrigger: 'l', + // open: /setlocal$/i, + // closeComplete: 'endlocal', + // matchCase: true, + // closeTrigger: 'l', + // close: /endlocal$/i, + // tokenType: 'keyword.tag-setlocal' + // } + // ], +}; + +export var language = { + defaultToken: '', + ignoreCase: true, + tokenPostfix: '.bat', + + brackets: [ + { token: 'punctuation.bracket', open: '{', close: '}' }, + { token: 'punctuation.parenthesis', open: '(', close: ')' }, + { token: 'punctuation.square', open: '[', close: ']' } + ], + + keywords: /call|defined|echo|errorlevel|exist|for|goto|if|pause|set|shift|start|title|not|pushd|popd/, + + // we include these common regular expressions + symbols: /[=>\/\?\s]+)/g, + comments: { + blockComment: ['###', '###'], + lineComment: '#' + }, + brackets: [['{','}'], ['[',']'], ['(',')']], + autoClosingPairs: [ + { open: '"', close: '"', notIn: ['string', 'comment'] }, + { open: '\'', close: '\'', notIn: ['string', 'comment'] }, + { open: '{', close: '}', notIn: ['string', 'comment'] }, + { open: '[', close: ']', notIn: ['string', 'comment'] }, + { open: '(', close: ')', notIn: ['string', 'comment'] }, + ] + // enhancedBrackets: [ + // { open: /for$/ }, { open: /while$/ }, { open: /loop$/ }, { open: /if$/ }, { open: /unless$/ }, + // { open: /else$/ }, { open: /switch$/ }, { open: /try$/ }, { open: /catch$/ }, { open: /finally$/ }, + // { open: /class$/ }, { open: /->$/ } + // ], +}; + +export var language = { + defaultToken: '', + ignoreCase: true, + tokenPostfix: '.coffee', + + brackets: [ + { open:'{', close:'}', token:'delimiter.curly'}, + { open:'[', close:']', token:'delimiter.square'}, + { open:'(', close:')', token:'delimiter.parenthesis'} + ], + + regEx: /\/(?!\/\/)(?:[^\/\\]|\\.)*\/[igm]*/, + + keywords: [ + 'and', 'or', 'is', 'isnt', 'not', 'on', 'yes', '@', 'no', 'off', + 'true', 'false', 'null', 'this', + 'new', 'delete', 'typeof', 'in', 'instanceof', + 'return', 'throw', 'break', 'continue', 'debugger', + 'if', 'else', 'switch', 'for', 'while', 'do', 'try', 'catch', 'finally', + 'class', 'extends', 'super', + 'undefined', 'then', 'unless', 'until', 'loop', 'of', 'by', 'when' + ], + + // we include these common regular expressions + symbols: /[=>']], + autoClosingPairs: [ + { open: '"', close: '"', notIn: ['string', 'comment'] }, + { open: '{', close: '}', notIn: ['string', 'comment'] }, + { open: '[', close: ']', notIn: ['string', 'comment'] }, + { open: '(', close: ')', notIn: ['string', 'comment'] }, + ] +}; + +export var language = { + defaultToken: '', + tokenPostfix: '.cpp', + + brackets: [ + { token: 'delimiter.curly', open: '{', close: '}' }, + { token: 'delimiter.parenthesis', open: '(', close: ')' }, + { token: 'delimiter.square', open: '[', close: ']' }, + { token: 'delimiter.angle', open: '<', close: '>' } + ], + + keywords: [ + 'abstract', + 'amp', + 'array', + 'auto', + 'bool', + 'break', + 'case', + 'catch', + 'char', + 'class', + 'const', + 'constexpr', + 'const_cast', + 'continue', + 'cpu', + 'decltype', + 'default', + 'delegate', + 'delete', + 'do', + 'double', + 'dynamic_cast', + 'each', + 'else', + 'enum', + 'event', + 'explicit', + 'export', + 'extern', + 'false', + 'final', + 'finally', + 'float', + 'for', + 'friend', + 'gcnew', + 'generic', + 'goto', + 'if', + 'in', + 'initonly', + 'inline', + 'int', + 'interface', + 'interior_ptr', + 'internal', + 'literal', + 'long', + 'mutable', + 'namespace', + 'new', + 'noexcept', + 'nullptr', + '__nullptr', + 'operator', + 'override', + 'partial', + 'pascal', + 'pin_ptr', + 'private', + 'property', + 'protected', + 'public', + 'ref', + 'register', + 'reinterpret_cast', + 'restrict', + 'return', + 'safe_cast', + 'sealed', + 'short', + 'signed', + 'sizeof', + 'static', + 'static_assert', + 'static_cast', + 'struct', + 'switch', + 'template', + 'this', + 'thread_local', + 'throw', + 'tile_static', + 'true', + 'try', + 'typedef', + 'typeid', + 'typename', + 'union', + 'unsigned', + 'using', + 'virtual', + 'void', + 'volatile', + 'wchar_t', + 'where', + 'while', + + '_asm', // reserved word with one underscores + '_based', + '_cdecl', + '_declspec', + '_fastcall', + '_if_exists', + '_if_not_exists', + '_inline', + '_multiple_inheritance', + '_pascal', + '_single_inheritance', + '_stdcall', + '_virtual_inheritance', + '_w64', + + '__abstract', // reserved word with two underscores + '__alignof', + '__asm', + '__assume', + '__based', + '__box', + '__builtin_alignof', + '__cdecl', + '__clrcall', + '__declspec', + '__delegate', + '__event', + '__except', + '__fastcall', + '__finally', + '__forceinline', + '__gc', + '__hook', + '__identifier', + '__if_exists', + '__if_not_exists', + '__inline', + '__int128', + '__int16', + '__int32', + '__int64', + '__int8', + '__interface', + '__leave', + '__m128', + '__m128d', + '__m128i', + '__m256', + '__m256d', + '__m256i', + '__m64', + '__multiple_inheritance', + '__newslot', + '__nogc', + '__noop', + '__nounwind', + '__novtordisp', + '__pascal', + '__pin', + '__pragma', + '__property', + '__ptr32', + '__ptr64', + '__raise', + '__restrict', + '__resume', + '__sealed', + '__single_inheritance', + '__stdcall', + '__super', + '__thiscall', + '__try', + '__try_cast', + '__typeof', + '__unaligned', + '__unhook', + '__uuidof', + '__value', + '__virtual_inheritance', + '__w64', + '__wchar_t' + ], + + operators: [ + '=', '>', '<', '!', '~', '?', ':', + '==', '<=', '>=', '!=', '&&', '||', '++', '--', + '+', '-', '*', '/', '&', '|', '^', '%', '<<', + '>>', '>>>', '+=', '-=', '*=', '/=', '&=', '|=', + '^=', '%=', '<<=', '>>=', '>>>=' + ], + + // we include these common regular expressions + symbols: /[=>](?!@symbols)/, '@brackets'], + [/@symbols/, { cases: { '@operators': 'delimiter', + '@default' : '' } } ], + + // numbers + [/\d*\d+[eE]([\-+]?\d+)?(@floatsuffix)/, 'number.float'], + [/\d*\.\d+([eE][\-+]?\d+)?(@floatsuffix)/, 'number.float'], + [/0[xX][0-9a-fA-F']*[0-9a-fA-F](@integersuffix)/, 'number.hex'], + [/0[0-7']*[0-7](@integersuffix)/, 'number.octal'], + [/0[bB][0-1']*[0-1](@integersuffix)/, 'number.binary'], + [/\d[\d']*\d(@integersuffix)/, 'number'], + [/\d(@integersuffix)/, 'number'], + + // delimiter: after number because of .\d floats + [/[;,.]/, 'delimiter'], + + // strings + [/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string + [/"/, 'string', '@string' ], + + // characters + [/'[^\\']'/, 'string'], + [/(')(@escapes)(')/, ['string','string.escape','string']], + [/'/, 'string.invalid'] + ], + + whitespace: [ + [/[ \t\r\n]+/, ''], + [/\/\*\*(?!\/)/, 'comment.doc', '@doccomment' ], + [/\/\*/, 'comment', '@comment' ], + [/\/\/.*$/, 'comment'], + ], + + comment: [ + [/[^\/*]+/, 'comment' ], + // [/\/\*/, 'comment', '@push' ], // nested comment not allowed :-( + // [/\/\*/, 'comment.invalid' ], // this breaks block comments in the shape of /* //*/ + [/\*\//, 'comment', '@pop' ], + [/[\/*]/, 'comment' ] + ], + //Identical copy of comment above, except for the addition of .doc + doccomment: [ + [/[^\/*]+/, 'comment.doc' ], + // [/\/\*/, 'comment.doc', '@push' ], // nested comment not allowed :-( + [/\/\*/, 'comment.doc.invalid' ], + [/\*\//, 'comment.doc', '@pop' ], + [/[\/*]/, 'comment.doc' ] + ], + + string: [ + [/[^\\"]+/, 'string'], + [/@escapes/, 'string.escape'], + [/\\./, 'string.escape.invalid'], + [/"/, 'string', '@pop' ] + ], + }, +}; \ No newline at end of file diff --git a/src/csharp.ts b/src/csharp.ts new file mode 100644 index 00000000..038d88c4 --- /dev/null +++ b/src/csharp.ts @@ -0,0 +1,175 @@ +/*--------------------------------------------------------------------------------------------- + * 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 IRichLanguageConfiguration = monaco.languages.IRichLanguageConfiguration; +import ILanguage = monaco.languages.IMonarchLanguage; + +export var conf:IRichLanguageConfiguration = { + wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g, + comments: { + lineComment: '//', + blockComment: ['/*', '*/'], + }, + brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']], + autoClosingPairs: [ + { open: '"', close: '"', notIn: ['string', 'comment'] }, + { open: '\'', close: '\'', notIn: ['string', 'comment'] }, + { open: '{', close: '}', notIn: ['string', 'comment'] }, + { open: '[', close: ']', notIn: ['string', 'comment'] }, + { open: '(', close: ')', notIn: ['string', 'comment'] }, + ] +}; + +export var language = { + defaultToken: '', + tokenPostfix: '.cs', + + brackets: [ + { open: '{', close: '}', token: 'delimiter.curly' }, + { open: '[', close: ']', token: 'delimiter.square' }, + { open: '(', close: ')', token: 'delimiter.parenthesis' }, + { open: '<', close: '>', token: 'delimiter.angle' } + ], + + keywords: [ + 'extern', 'alias', 'using', 'bool', 'decimal', 'sbyte', 'byte', 'short', + 'ushort', 'int', 'uint', 'long', 'ulong', 'char', 'float', 'double', + 'object', 'dynamic', 'string', 'assembly', 'is', 'as', 'ref', + 'out', 'this', 'base', 'new', 'typeof', 'void', 'checked', 'unchecked', + 'default', 'delegate', 'var', 'const', 'if', 'else', 'switch', 'case', + 'while', 'do', 'for', 'foreach', 'in', 'break', 'continue', 'goto', + 'return', 'throw', 'try', 'catch', 'finally', 'lock', 'yield', 'from', + 'let', 'where', 'join', 'on', 'equals', 'into', 'orderby', 'ascending', + 'descending', 'select', 'group', 'by', 'namespace', 'partial', 'class', + 'field', 'event', 'method', 'param', 'property', 'public', 'protected', + 'internal', 'private', 'abstract', 'sealed', 'static', 'struct', 'readonly', + 'volatile', 'virtual', 'override', 'params', 'get', 'set', 'add', 'remove', + 'operator', 'true', 'false', 'implicit', 'explicit', 'interface', 'enum', + 'null', 'async', 'await','fixed','sizeof','stackalloc','unsafe', 'nameof', + 'when' + ], + + namespaceFollows: [ + 'namespace', 'using', + ], + + parenFollows: [ + 'if', 'for', 'while', 'switch', 'foreach', 'using', 'catch', 'when' + ], + + operators: [ + '=', '??', '||', '&&', '|', '^', '&', '==', '!=', '<=', '>=', '<<', + '+', '-', '*', '/', '%', '!', '~', '++', '--','+=', + '-=', '*=', '/=', '%=', '&=', '|=', '^=', '<<=', '>>=', '>>', '=>' + ], + + symbols: /[=>](?!@symbols)/, '@brackets'], + [/@symbols/, { cases: { '@operators': 'delimiter', '@default' : '' } } ], + + // literal string + [/\@"/, { token: 'string.quote', bracket: '@open', next: '@litstring' } ], + + // interpolated string + [/\$"/, { token: 'string.quote', bracket: '@open', next: '@interpolatedstring' } ], + + // numbers + [/\d*\.\d+([eE][\-+]?\d+)?[fFdD]?/, 'number.float'], + [/0[xX][0-9a-fA-F]+/, 'number.hex'], + [/\d+/, 'number'], + + // delimiter: after number because of .\d floats + [/[;,.]/, 'delimiter'], + + // strings + [/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string + [/"/, { token: 'string.quote', bracket: '@open', next: '@string' } ], + + // characters + [/'[^\\']'/, 'string'], + [/(')(@escapes)(')/, ['string','string.escape','string']], + [/'/, 'string.invalid'] + ], + + qualified: [ + [/[a-zA-Z_][\w]*/, { cases: + { '@keywords': {token:'keyword.$0'}, + '@default': 'identifier' } + }], + [/\./, 'delimiter'], + ['','','@pop'], + ], + + namespace: [ + { include: '@whitespace' }, + [/[A-Z]\w*/, 'namespace'], + [/[\.=]/, 'delimiter'], + ['','','@pop'], + ], + + comment: [ + [/[^\/*]+/, 'comment' ], + // [/\/\*/, 'comment', '@push' ], // no nested comments :-( + ['\\*/', 'comment', '@pop' ], + [/[\/*]/, 'comment' ] + ], + + string: [ + [/[^\\"]+/, 'string'], + [/@escapes/, 'string.escape'], + [/\\./, 'string.escape.invalid'], + [/"/, { token: 'string.quote', bracket: '@close', next: '@pop' } ] + ], + + litstring: [ + [/[^"]+/, 'string'], + [/""/, 'string.escape'], + [/"/, { token: 'string.quote', bracket: '@close', next: '@pop' } ] + ], + + interpolatedstring: [ + [/[^\\"{]+/, 'string'], + [/@escapes/, 'string.escape'], + [/\\./, 'string.escape.invalid'], + [/{{/, 'string.escape'], + [/}}/, 'string.escape'], + [/{/, { token: 'string.quote', bracket: '@open', next: 'root.interpolatedstring' } ], + [/"/, { token: 'string.quote', bracket: '@close', next: '@pop' } ] + ], + + whitespace: [ + [/^[ \t\v\f]*#\w.*$/, 'namespace.cpp' ], + [/[ \t\v\f\r\n]+/, ''], + [/\/\*/, 'comment', '@comment' ], + [/\/\/.*$/, 'comment'], + ], + }, +}; \ No newline at end of file diff --git a/src/dockerfile.ts b/src/dockerfile.ts new file mode 100644 index 00000000..df722774 --- /dev/null +++ b/src/dockerfile.ts @@ -0,0 +1,97 @@ +/*--------------------------------------------------------------------------------------------- + * 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 IRichLanguageConfiguration = monaco.languages.IRichLanguageConfiguration; +import ILanguage = monaco.languages.IMonarchLanguage; + +export var conf:IRichLanguageConfiguration = { + brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']], + autoClosingPairs: [ + { open: '"', close: '"', notIn: ['string', 'comment'] }, + { open: '\'', close: '\'', notIn: ['string', 'comment'] }, + { open: '{', close: '}', notIn: ['string', 'comment'] }, + { open: '[', close: ']', notIn: ['string', 'comment'] }, + { open: '(', close: ')', notIn: ['string', 'comment'] }, + { open: '<', close: '>', notIn: ['string', 'comment'] }, + ] +}; + +export var language = { + defaultToken: '', + tokenPostfix: '.dockerfile', + + instructions: /FROM|MAINTAINER|RUN|EXPOSE|ENV|ADD|VOLUME|LABEL|USER|WORKDIR|COPY|CMD|ENTRYPOINT/, + + instructionAfter: /ONBUILD/, + + variableAfter: /ENV/, + + variable:/\${?[\w]+}?/, + + tokenizer: { + root: [ + { include: '@whitespace' }, + { include: '@comment' }, + + [/(@instructionAfter)(\s+)/, ['keyword', { token: '', next: '@instructions' }]], + ['', 'keyword', '@instructions'] + ], + + instructions: [ + [/(@variableAfter)(\s+)([\w]+)/, ['keyword', '',{token:'variable', next:'@arguments'}]], + [/(@instructions)/, 'keyword', '@arguments'] + ], + + arguments: [ + { include: '@whitespace' }, + { include: '@strings' }, + + [/(@variable)/, { cases: { '@eos': {token:'variable', next:'@popall'}, '@default': 'variable' }} ], + [/\\/, { cases: { '@eos': '', '@default': '' }}], + [/./, { cases: { '@eos': {token:'', next:'@popall'}, '@default': '' } }], + ], + + // Deal with white space, including comments + whitespace: [ + [/\s+/, { cases: { '@eos': {token:'', next:'@popall'}, '@default': '' }}], + ], + + comment: [ + [/(^#.*$)/, 'comment', '@popall'] + ], + + // Recognize strings, including those broken across lines with \ (but not without) + strings: [ + [/'$/, 'string', '@popall'], + [/'/, 'string', '@stringBody'], + [/"$/, 'string', '@popall'], + [/"/, 'string', '@dblStringBody'] + ], + stringBody: [ + [/[^\\\$']/, { cases: { '@eos': {token:'string', next:'@popall'}, '@default': 'string' }}], + + [/\\./, 'string.escape'], + [/'$/, 'string', '@popall'], + [/'/, 'string', '@pop'], + [/(@variable)/, 'variable' ], + + [/\\$/, 'string'], + [/$/, 'string', '@popall'] + ], + dblStringBody: [ + [/[^\\\$"]/, { cases: { '@eos': {token:'string', next:'@popall'}, '@default': 'string' }}], + + [/\\./, 'string.escape'], + [/"$/, 'string', '@popall'], + [/"/, 'string', '@pop'], + [/(@variable)/, 'variable' ], + + [/\\$/, 'string'], + [/$/, 'string', '@popall'] + ] + } +}; \ No newline at end of file diff --git a/src/fsharp.ts b/src/fsharp.ts new file mode 100644 index 00000000..d8b0ee03 --- /dev/null +++ b/src/fsharp.ts @@ -0,0 +1,133 @@ +/*--------------------------------------------------------------------------------------------- + * 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 IRichLanguageConfiguration = monaco.languages.IRichLanguageConfiguration; +import ILanguage = monaco.languages.IMonarchLanguage; + +export var conf:IRichLanguageConfiguration = { + comments: { + lineComment: '//', + blockComment: ['(*', '*)'], + }, + brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']], + autoClosingPairs: [ + { open: '{', close: '}', notIn: ['string', 'comment'] }, + { open: '[', close: ']', notIn: ['string', 'comment'] }, + { open: '(', close: ')', notIn: ['string', 'comment'] }, + { open: '"', close: '"', notIn: ['string', 'comment'] } + ] +}; + +export var language = { + defaultToken: '', + tokenPostfix: '.fs', + + keywords: [ + 'abstract', 'and', 'atomic', 'as', + 'assert', 'asr', 'base', 'begin', + 'break', 'checked', 'component', + 'const', 'constraint', 'constructor', + 'continue', 'class', 'default', + 'delegate','do', 'done', 'downcast', + 'downto', 'elif', 'else', 'end', + 'exception', 'eager', 'event', 'external', + 'extern', 'false', 'finally', 'for', + 'fun', 'function', 'fixed', 'functor', + 'global', 'if', 'in', 'include', 'inherit', + 'inline', 'interface', 'internal', 'land', + 'lor', 'lsl','lsr', 'lxor', 'lazy', 'let', + 'match', 'member','mod','module', 'mutable', + 'namespace', 'method', 'mixin', 'new', 'not', + 'null', 'of', 'open', 'or', 'object', + 'override', 'private', 'parallel', 'process', + 'protected', 'pure', 'public', 'rec', 'return', + 'static', 'sealed', 'struct', 'sig', 'then', + 'to', 'true', 'tailcall', 'trait', + 'try', 'type', 'upcast', 'use', + 'val', 'void', 'virtual', 'volatile', + 'when', 'while','with', 'yield' + ], + + // we include these common regular expressions + symbols: /[=>]. + [/\[<.*>\]/, 'annotation'], + + // Preprocessor directive + [/^#(if|else|endif)/, 'keyword'], + + // delimiters and operators + [/[{}()\[\]]/, '@brackets'], + [/[<>](?!@symbols)/, '@brackets'], + [/@symbols/, 'delimiter' ], + + // numbers + [/\d*\d+[eE]([\-+]?\d+)?(@floatsuffix)/, 'number.float'], + [/\d*\.\d+([eE][\-+]?\d+)?(@floatsuffix)/, 'number.float'], + [/0x[0-9a-fA-F]+LF/, 'number.float'], + [/0x[0-9a-fA-F]+(@integersuffix)/, 'number.hex'], + [/0b[0-1]+(@integersuffix)/, 'number.bin'], + [/\d+(@integersuffix)/, 'number'], + + // delimiter: after number because of .\d floats + [/[;,.]/, 'delimiter'], + + // strings + [/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string + [/"""/, 'string', '@string."""'], + [/"/, 'string', '@string."' ], + + // literal string + [/\@"/, { token: 'string.quote', bracket: '@open', next: '@litstring' }], + + // characters + [/'[^\\']'B?/, 'string'], + [/(')(@escapes)(')/, ['string','string.escape','string']], + [/'/, 'string.invalid'] + ], + + whitespace: [ + [/[ \t\r\n]+/, ''], + [/\(\*/, 'comment', '@comment' ], + [/\/\/.*$/, 'comment'], + ], + + comment: [ + [/[^\*]+/, 'comment' ], + [/\*\)/, 'comment', '@pop' ], + [/\*/, 'comment' ] + ], + + string: [ + [/[^\\"]+/, 'string'], + [/@escapes/, 'string.escape'], + [/\\./, 'string.escape.invalid'], + [/("""|"B?)/, { cases: { '$#==$S2' : { token: 'string', next: '@pop' }, + '@default': 'string' }} ] + ], + + litstring: [ + [/[^"]+/, 'string'], + [/""/, 'string.escape'], + [/"/, { token: 'string.quote', bracket: '@close', next: '@pop' } ] + ], + }, +}; \ No newline at end of file diff --git a/src/go.ts b/src/go.ts new file mode 100644 index 00000000..ea9138fc --- /dev/null +++ b/src/go.ts @@ -0,0 +1,166 @@ +/*--------------------------------------------------------------------------------------------- + * 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 IRichLanguageConfiguration = monaco.languages.IRichLanguageConfiguration; +import ILanguage = monaco.languages.IMonarchLanguage; + +export var conf:IRichLanguageConfiguration = { + comments: { + lineComment: '//', + blockComment: ['/*', '*/'], + }, + brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']], + autoClosingPairs: [ + { open: '{', close: '}', notIn: ['string', 'comment'] }, + { open: '[', close: ']', notIn: ['string', 'comment'] }, + { open: '(', close: ')', notIn: ['string', 'comment'] }, + { open: '"', close: '"', notIn: ['string', 'comment'] } + ] +}; + +export var language = { + + defaultToken: '', + tokenPostfix: '.go', + + keywords: [ + 'break', + 'case', + 'chan', + 'const', + 'continue', + 'default', + 'defer', + 'else', + 'fallthrough', + 'for', + 'func', + 'go', + 'goto', + 'if', + 'import', + 'interface', + 'map', + 'package', + 'range', + 'return', + 'select', + 'struct', + 'switch', + 'type', + 'var', + 'bool', + 'true', + 'false', + 'uint8', + 'uint16', + 'uint32', + 'uint64', + 'int8', + 'int16', + 'int32', + 'int64', + 'float32', + 'float64', + 'complex64', + 'complex128', + 'byte', + 'rune', + 'uint', + 'int', + 'uintptr', + 'string', + 'nil', + ], + + operators: [ + '+', '-', '*', '/', '%', '&', '|', '^', '<<', '>>', '&^', + '+=', '-=', '*=', '/=', '%=', '&=', '|=', '^=', '<<=', '>>=', '&^=', + '&&', '||', '<-', '++', '--', '==', '<', '>', '=', '!', '!=', '<=', '>=', ':=', '...', + '(', ')', '', ']', '{', '}', ',', ';', '.', ':' + ], + + // we include these common regular expressions + symbols: /[=>](?!@symbols)/, '@brackets'], + [/@symbols/, { cases: { '@operators': 'delimiter', + '@default' : '' } } ], + + // numbers + [/\d*\d+[eE]([\-+]?\d+)?/, 'number.float'], + [/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'], + [/0[xX][0-9a-fA-F']*[0-9a-fA-F]/, 'number.hex'], + [/0[0-7']*[0-7]/, 'number.octal'], + [/0[bB][0-1']*[0-1]/, 'number.binary'], + [/\d[\d']*/, 'number'], + [/\d/, 'number'], + + // delimiter: after number because of .\d floats + [/[;,.]/, 'delimiter'], + + // strings + [/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string + [/"/, 'string', '@string' ], + + // characters + [/'[^\\']'/, 'string'], + [/(')(@escapes)(')/, ['string','string.escape','string']], + [/'/, 'string.invalid'] + ], + + whitespace: [ + [/[ \t\r\n]+/, ''], + [/\/\*\*(?!\/)/, 'comment.doc', '@doccomment' ], + [/\/\*/, 'comment', '@comment' ], + [/\/\/.*$/, 'comment'], + ], + + comment: [ + [/[^\/*]+/, 'comment' ], + // [/\/\*/, 'comment', '@push' ], // nested comment not allowed :-( + // [/\/\*/, 'comment.invalid' ], // this breaks block comments in the shape of /* //*/ + [/\*\//, 'comment', '@pop' ], + [/[\/*]/, 'comment' ] + ], + //Identical copy of comment above, except for the addition of .doc + doccomment: [ + [/[^\/*]+/, 'comment.doc' ], + // [/\/\*/, 'comment.doc', '@push' ], // nested comment not allowed :-( + [/\/\*/, 'comment.doc.invalid' ], + [/\*\//, 'comment.doc', '@pop' ], + [/[\/*]/, 'comment.doc' ] + ], + + string: [ + [/[^\\"]+/, 'string'], + [/@escapes/, 'string.escape'], + [/\\./, 'string.escape.invalid'], + [/"/, 'string', '@pop' ] + ], + }, +}; \ No newline at end of file diff --git a/src/ini.ts b/src/ini.ts new file mode 100644 index 00000000..30f1fbb1 --- /dev/null +++ b/src/ini.ts @@ -0,0 +1,69 @@ +/*--------------------------------------------------------------------------------------------- + * 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 IRichLanguageConfiguration = monaco.languages.IRichLanguageConfiguration; +import ILanguage = monaco.languages.IMonarchLanguage; + +export var conf:IRichLanguageConfiguration = { + comments: { + lineComment: '#' + }, + brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']], + autoClosingPairs: [ + { open: '"', close: '"', notIn: ['string', 'comment'] }, + { open: '\'', close: '\'', notIn: ['string', 'comment'] }, + { open: '{', close: '}', notIn: ['string', 'comment'] }, + { open: '[', close: ']', notIn: ['string', 'comment'] }, + { open: '(', close: ')', notIn: ['string', 'comment'] }, + { open: '<', close: '>', notIn: ['string', 'comment'] }, + ] +}; + +export var language = { + defaultToken: '', + tokenPostfix: '.ini', + + // we include these common regular expressions + escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, + + // The main tokenizer for our languages + tokenizer: { + root: [ + + // sections + [/^\[[^\]]*\]/, 'metatag'], + + // keys + [/(^\w+)(\s*)(\=)/, ['key', '', 'delimiter']], + + // whitespace + { include: '@whitespace' }, + + // numbers + [/\d+/, 'number'], + + // strings: recover on non-terminated strings + [/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string + [/'([^'\\]|\\.)*$/, 'string.invalid' ], // non-teminated string + [/"/, 'string', '@string."' ], + [/'/, 'string', '@string.\''], + ], + + whitespace: [ + [/[ \t\r\n]+/, ''], + [/^\s*[#;].*$/, 'comment'], + ], + + string: [ + [/[^\\"']+/, 'string'], + [/@escapes/, 'string.escape'], + [/\\./, 'string.escape.invalid'], + [/["']/, { cases: { '$#==$S2' : { token: 'string', next: '@pop' }, + '@default': 'string' }} ] + ], + }, +}; \ No newline at end of file diff --git a/src/jade.ts b/src/jade.ts new file mode 100644 index 00000000..2ba856a3 --- /dev/null +++ b/src/jade.ts @@ -0,0 +1,179 @@ +/*--------------------------------------------------------------------------------------------- + * 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 IRichLanguageConfiguration = monaco.languages.IRichLanguageConfiguration; +import ILanguage = monaco.languages.IMonarchLanguage; + +export var conf:IRichLanguageConfiguration = { + comments: { + lineComment: '//' + }, + brackets: [['{','}'], ['[',']'], ['(',')']], + autoClosingPairs: [ + { open: '"', close: '"', notIn: ['string', 'comment'] }, + { open: '\'', close: '\'', notIn: ['string', 'comment'] }, + { open: '{', close: '}', notIn: ['string', 'comment'] }, + { open: '[', close: ']', notIn: ['string', 'comment'] }, + { open: '(', close: ')', notIn: ['string', 'comment'] }, + ] +}; + +export var language = { + defaultToken: '', + tokenPostfix: '.jade', + + ignoreCase: true, + + brackets: [ + { token:'delimiter.curly', open: '{', close: '}' }, + { token:'delimiter.array', open: '[', close: ']' }, + { token:'delimiter.parenthesis', open: '(', close: ')' } + ], + + keywords: [ 'append', 'block', 'case', 'default', 'doctype', 'each', 'else', 'extends', + 'for', 'if', 'in', 'include', 'mixin', 'typeof', 'unless', 'var', 'when'], + + tags: [ + 'a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', + 'b', 'base', 'basefont', 'bdi', 'bdo', 'blockquote', 'body', 'br', 'button', + 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'command', + 'datalist', 'dd', 'del', 'details', 'dfn', 'div', 'dl', 'dt', + 'em', 'embed', + 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'frame', 'frameset', + 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', + 'i', 'iframe', 'img', 'input', 'ins', + 'keygen', 'kbd', + 'label', 'li', 'link', + 'map', 'mark', 'menu', 'meta', 'meter', + 'nav', 'noframes', 'noscript', + 'object', 'ol', 'optgroup', 'option', 'output', + 'p', 'param', 'pre', 'progress', + 'q', + 'rp', 'rt', 'ruby', + 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', + 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'tracks', 'tt', + 'u', 'ul', + 'video', + 'wbr' + ], + + // we include these common regular expressions + symbols: /[\+\-\*\%\&\|\!\=\/\.\,\:]+/, + escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, + + tokenizer: { + root: [ + + // Tag or a keyword at start + [/^(\s*)([a-zA-Z_-][\w-]*)/, + { cases: { + '$2@tags': { cases: { '@eos': ['', 'tag'], '@default': ['', { token: 'tag', next: '@tag.$1' }, ] } }, + '$2@keywords': [ '', { token: 'keyword.$2'}, ], + '@default': [ '', '', ]}} + ], + + // id + [/^(\s*)(#[a-zA-Z_-][\w-]*)/, { cases: { '@eos': ['', 'tag.id'], '@default': ['', { token: 'tag.id', next: '@tag.$1' }] }}], + + // class + [/^(\s*)(\.[a-zA-Z_-][\w-]*)/, { cases: { '@eos': ['', 'tag.class'], '@default': ['', { token: 'tag.class', next: '@tag.$1' }] } }], + + // plain text with pipe + [/^(\s*)(\|.*)$/, '' ], + + { include: '@whitespace' }, + + // keywords + [/[a-zA-Z_$][\w$]*/, { cases: { '@keywords': {token:'keyword.$0'}, + '@default': '' } }], + + // delimiters and operators + [/[{}()\[\]]/, '@brackets'], + [/@symbols/, 'delimiter'], + + // numbers + [/\d+\.\d+([eE][\-+]?\d+)?/, 'number.float'], + [/\d+/, 'number'], + + // strings: + [/"/, 'string', '@string."' ], + [/'/, 'string', '@string.\''], + ], + + tag: [ + [/(\.)(\s*$)/, [ {token: 'delimiter', next:'@blockText.$S2.'}, '']], + [/\s+/, { token: '', next: '@simpleText' }], + + // id + [/#[a-zA-Z_-][\w-]*/, { cases: { '@eos': { token: 'tag.id', next: '@pop' }, '@default': 'tag.id' } }], + // class + [/\.[a-zA-Z_-][\w-]*/, { cases: { '@eos': { token: 'tag.class', next: '@pop' }, '@default': 'tag.class' } }], + // attributes + [/\(/, { token: 'delimiter.parenthesis', bracket: '@open', next: '@attributeList' }], + ], + + simpleText: [ + [/[^#]+$/, {token: '', next: '@popall'}], + [/[^#]+/, {token: ''}], + + // interpolation + [/(#{)([^}]*)(})/, { cases: { + '@eos': ['interpolation.delimiter', 'interpolation', { token: 'interpolation.delimiter', next: '@popall' }], + '@default': ['interpolation.delimiter', 'interpolation', 'interpolation.delimiter'] }}], + + [/#$/, { token: '', next: '@popall' }], + [/#/, ''] + ], + + attributeList: [ + [/\s+/, '' ], + [/(\w+)(\s*=\s*)("|')/, ['attribute.name', 'delimiter', { token: 'attribute.value', next:'@value.$3'}]], + [/\w+/, 'attribute.name'], + + + [/,/, { cases: { '@eos': { token: 'attribute.delimiter', next: '@popall' }, '@default': 'attribute.delimiter' } }], + + [/\)$/, { token: 'delimiter.parenthesis', bracket: '@close', next: '@popall' }], + [/\)/, { token: 'delimiter.parenthesis', bracket: '@close', next: '@pop' }], + ], + + whitespace: [ + [/^(\s*)(\/\/.*)$/, { token: 'comment', next: '@blockText.$1.comment' } ], + [/[ \t\r\n]+/, ''], + [//, { token: 'comment', bracket: '@close', next: '@pop' } ], + [/'], + }, + brackets: [['{','}'],['[',']'],['(',')'],['<','>']], + autoClosingPairs: [ + { open: '\'', close: '\'', notIn: ['string', 'comment'] }, + { open: '"', close: '"', notIn: ['string', 'comment'] }, + ] + // enhancedBrackets: [{ + // tokenType: 'tag.tag-$1.xml', + // openTrigger: '>', + // open: /<(\w[\w\d]*)([^\/>]*(?!\/)>)[^<>]*$/i, + // closeComplete: '', + // closeTrigger: '>', + // close: /<\/(\w[\w\d]*)\s*>$/i + // }], +}; + +export var language = { + defaultToken: '', + tokenPostfix: '.xml', + + ignoreCase: true, + + // Useful regular expressions + qualifiedName: /(?:[\w\.\-]+:)?[\w\.\-]+/, + + tokenizer: { + root: [ + [/[^<&]+/, ''], + + { include: '@whitespace' }, + + // Standard opening tag + [/(<)(@qualifiedName)/, [ + { token: 'delimiter.start', bracket: '@open' }, + { token: 'tag.tag-$2', bracket: '@open', next: '@tag.$2' }]], + + // Standard closing tag + [/(<\/)(@qualifiedName)(\s*)(>)/, [ + { token: 'delimiter.end', bracket: '@open' }, + { token: 'tag.tag-$2', bracket: '@close' }, + '', + { token: 'delimiter.end', bracket: '@close' }]], + + // Meta tags - instruction + [/(<\?)(@qualifiedName)/, [ + { token: 'delimiter.start', bracket: '@open' }, + { token: 'metatag.instruction', next: '@tag' }]], + + // Meta tags - declaration + [/(<\!)(@qualifiedName)/, [ + { token: 'delimiter.start', bracket: '@open' }, + { token: 'metatag.declaration', next: '@tag' }]], + + // CDATA + [/<\!\[CDATA\[/, { token: 'delimiter.cdata', bracket: '@open', next: '@cdata' }], + + [/&\w+;/, 'string.escape'], + ], + + cdata: [ + [/[^\]]+/, ''], + [/\]\]>/, { token: 'delimiter.cdata', bracket: '@close', next: '@pop' }], + [/\]/, ''] + ], + + tag: [ + [/[ \t\r\n]+/, '' ], + [/(@qualifiedName)(\s*=\s*)("[^"]*"|'[^']*')/, ['attribute.name', '', 'attribute.value']], + [/(@qualifiedName)(\s*=\s*)("[^">?\/]*|'[^'>?\/]*)(?=[\?\/]\>)/, ['attribute.name', '', 'attribute.value']], + [/(@qualifiedName)(\s*=\s*)("[^">]*|'[^'>]*)/, ['attribute.name', '', 'attribute.value']], + [/@qualifiedName/, 'attribute.name'], + [/\?>/, { token: 'delimiter.start', bracket: '@close', next: '@pop' }], + [/(\/)(>)/, [ + { token: 'tag.tag-$S2', bracket: '@close' }, + { token: 'delimiter.start', bracket: '@close', next: '@pop' }]], + [/>/, { token: 'delimiter.start', bracket: '@close', next: '@pop' }], + ], + + whitespace: [ + [/[ \t\r\n]+/, ''], + [//, { token: 'comment', bracket: '@close', next: '@pop' } ], + [/', + tokens: [ + { startIndex: 0, type: 'comment.xml' }, + { startIndex: 4, type: 'comment.content.xml' }, + { startIndex: 5, type: 'comment.xml' } + ]}], + + [{ + line: '', + tokens: [ + { startIndex: 0, type: 'comment.xml' }, + { startIndex: 4, type: 'comment.content.xml' }, + { startIndex: 16, type: 'comment.xml' } + ]}], + + [{ + line: '', + tokens: [ + { startIndex: 0, type: 'comment.content.xml' }, + { startIndex: 9, type: 'comment.xml' } + ]}], + + // CDATA + [{ + line: ']]>', + 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: '', + tokens: [ + { startIndex: 0, type: 'delimiter.start.xml' }, + { startIndex: 1, type: 'tag.tag-tools.xml' }, + { startIndex: 6, type: 'delimiter.start.xml' } + ]},{ + line: '\t', + tokens: [ + { startIndex: 0, type: '' } + ]},{ + line: '\t]]>', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'delimiter.cdata.xml' }, + ]},{ + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.end.xml' }, + { startIndex: 2, type: 'tag.tag-tools.xml' }, + { startIndex: 7, type: 'delimiter.end.xml' } + ]}], + + // Generated from sample + [{ + line: '', + 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: '', + 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: ' ', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.start.xml' }, + { startIndex: 3, type: 'tag.tag-connectionstrings.xml' }, + { startIndex: 20, type: 'delimiter.start.xml' } + ]}, { + line: ' ', + 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: ' ', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.end.xml' }, + { startIndex: 4, type: 'tag.tag-connectionstrings.xml' }, + { startIndex: 21, type: 'delimiter.end.xml' } + ]}, { + line: ' ', + 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: ' ', + 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: ' ', + 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: ' ', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'delimiter.end.xml' }, + { startIndex: 6, type: 'tag.tag-customerrors.xml' }, + { startIndex: 18, type: 'delimiter.end.xml' } + ]}, { + line: ' ', + 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: ' ', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'comment.xml' }, + { startIndex: 5, type: 'comment.content.xml' }, + { startIndex: 60, type: 'comment.xml' } + ]}, { + line: ' ', + tokens: [ + { startIndex: 0, type: 'comment.content.xml' }, + { startIndex: 5, type: 'comment.xml' } + ]}, { + line: ' ', + 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: ' ]]>', + 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: ' ', + 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: ' ', + 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: ' ', + 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: ' ', + 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: ' ', + 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: ' ', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'delimiter.start.xml' }, + { startIndex: 2, type: 'tag.tag-asimpleselfclosingtag.xml' }, + { startIndex: 24, type: 'delimiter.start.xml' } + ]}, { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.end.xml' }, + { startIndex: 2, type: 'tag.tag-configuration.xml' }, + { startIndex: 15, type: 'delimiter.end.xml' } + ]}] +]); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..69b3885c --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,58 @@ +{ + "compilerOptions": { + "module": "amd", + "outDir": "out", + "target": "es5" + }, + "filesGlob": [ + "src/*.ts", + "test/*.ts", + "node_modules/monaco-editor-core/monaco.d.ts" + ], + "files": [ + "src/bat.ts", + "src/coffee.ts", + "src/cpp.ts", + "src/csharp.ts", + "src/dockerfile.ts", + "src/fsharp.ts", + "src/go.ts", + "src/ini.ts", + "src/jade.ts", + "src/java.ts", + "src/lua.ts", + "src/monaco.contribution.ts", + "src/objective-c.ts", + "src/powershell.ts", + "src/python.ts", + "src/r.ts", + "src/ruby.ts", + "src/sql.ts", + "src/swift.ts", + "src/vb.ts", + "src/xml.ts", + "test/assert.d.ts", + "test/bat.test.ts", + "test/coffee.test.ts", + "test/cpp.test.ts", + "test/csharp.test.ts", + "test/dockerfile.test.ts", + "test/fsharp.test.ts", + "test/go.test.ts", + "test/jade.test.ts", + "test/java.test.ts", + "test/lua.test.ts", + "test/mocha.d.ts", + "test/objective-c.test.ts", + "test/powershell.test.ts", + "test/python.test.ts", + "test/r.test.ts", + "test/ruby.test.ts", + "test/sql.test.ts", + "test/swift.test.ts", + "test/testRunner.ts", + "test/vb.test.ts", + "test/xml.test.ts", + "node_modules/monaco-editor-core/monaco.d.ts" + ] +} \ No newline at end of file