提交 d72d0833 编写于 作者: A Alex Dima

Monarch is a tokenizer, and only a tokenizer

上级 1a6d368c
......@@ -20,8 +20,6 @@ import {createDecorator} from 'vs/platform/instantiation/common/instantiation';
import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollection';
import {InstantiationService} from 'vs/platform/instantiation/common/instantiationService';
import {IModel} from 'vs/editor/common/editorCommon';
import {ModesRegistry} from 'vs/editor/common/modes/modesRegistry';
import {ILanguage} from 'vs/editor/common/modes/monarch/monarchTypes';
import {IModelService} from 'vs/editor/common/services/modelService';
import {ICodeEditor, IDiffEditor} from 'vs/editor/browser/editorBrowser';
import {Colorizer, IColorizerElementOptions, IColorizerOptions} from 'vs/editor/browser/standalone/colorizer';
......@@ -208,33 +206,6 @@ export function configureMode(modeId: string, options: any): void {
modeService.configureModeById(modeId, options);
}
/**
* @internal
*/
export function createCustomMode(language:ILanguage): TPromise<modes.IMode> {
startup.initStaticServicesIfNecessary();
let staticPlatformServices = ensureStaticPlatformServices(null);
let modeService = staticPlatformServices.modeService;
let modeId = language.name;
let name = language.name;
ModesRegistry.registerLanguage({
id: modeId,
aliases: [name]
});
let disposable = modeService.onDidCreateMode((mode) => {
if (mode.getId() !== modeId) {
return;
}
modeService.registerMonarchDefinition(modeId, language);
disposable.dispose();
});
return modeService.getOrCreateMode(modeId);
}
interface IMonacoWebWorkerState<T> {
myProxy:StandaloneWorker;
foreignProxy:T;
......@@ -343,8 +314,6 @@ export function createMonacoEditorAPI(): typeof monaco.editor {
onDidChangeModelLanguage: onDidChangeModelLanguage,
// getOrCreateMode: getOrCreateMode,
// createCustomMode: createCustomMode,
createWebWorker: createWebWorker,
colorizeElement: colorizeElement,
colorize: colorize,
......
......@@ -307,7 +307,7 @@ export function registerMonarchStandaloneLanguage(language:ILanguageExtensionPoi
let staticPlatformServices = ensureStaticPlatformServices(null);
let modeService = staticPlatformServices.modeService;
let lexer = compile(value.language);
let lexer = compile(language.id, value.language);
modeService.registerTokenizationSupport(language.id, (mode) => {
return createTokenizationSupport(modeService, mode, lexer);
......
......@@ -33,7 +33,6 @@ import 'vs/editor/common/modes';
import 'vs/editor/common/modes/abstractMode';
import 'vs/editor/common/modes/abstractState';
import 'vs/editor/common/modes/monarch/monarchCommon';
import 'vs/editor/common/modes/monarch/monarchDefinition';
import 'vs/editor/common/modes/monarch/monarchLexer';
import 'vs/editor/common/modes/monarch/monarchCompile';
import 'vs/editor/common/modes/supports/richEditSupport';
......
......@@ -4,8 +4,6 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import {CharacterPair, IAutoClosingPairConditional} from 'vs/editor/common/modes';
/*
* This module exports common types and functionality shared between
* the Monarch compiler that compiles JSON to ILexer, and the Monarch
......@@ -24,10 +22,9 @@ export enum MonarchBracket {
}
export interface ILexerMin {
languageId: string;
noThrow: boolean;
ignoreCase: boolean;
displayName: string;
name: string;
usesEmbedded: boolean;
defaultToken: string;
stateNames: Object;
......@@ -37,30 +34,10 @@ export interface ILexer extends ILexerMin {
maxStack: number;
start: string;
ignoreCase: boolean;
lineComment: string;
blockCommentStart: string;
blockCommentEnd: string;
tokenPostfix: string;
tokenizer: IRule[][];
brackets: IBracket[];
wordDefinition: RegExp;
autoClosingPairs: IAutoClosingPairConditional[];
standardBrackets: CharacterPair[];
// enhancedBrackets: IRegexBracketPair[];
outdentTriggers: string;
}
export interface IAutoIndent {
match: RegExp;
matchAfter: RegExp;
}
export interface IAutoComplete {
triggers: string;
match: RegExp;
complete: string;
}
export interface IBracket {
......@@ -130,7 +107,7 @@ export function sanitize(s: string) {
* Logs a message.
*/
export function log(lexer: ILexerMin, msg: string) {
console.log(`${lexer.name}: ${msg}`);
console.log(`${lexer.languageId}: ${msg}`);
}
// Throwing errors
......@@ -139,7 +116,7 @@ export function log(lexer: ILexerMin, msg: string) {
* Throws error. May actually just log the error and continue.
*/
export function throwError(lexer: ILexerMin, msg: string) {
throw new Error(`${lexer.name}: ${msg}`);
throw new Error(`${lexer.languageId}: ${msg}`);
}
// Helper functions for rule finding and substitution
......
......@@ -10,7 +10,6 @@
*/
import * as objects from 'vs/base/common/objects';
import {IAutoClosingPairConditional, CharacterPair} from 'vs/editor/common/modes';
import * as monarchCommon from 'vs/editor/common/modes/monarch/monarchCommon';
import {ILanguage, ILanguageBracket} from 'vs/editor/common/modes/monarch/monarchTypes';
......@@ -387,20 +386,14 @@ class Rule implements monarchCommon.IRule {
* (Currently we have no samples that need this so perhaps we should always have
* jsonStrict to true).
*/
export function compile(json: ILanguage): monarchCommon.ILexer {
export function compile(languageId:string, json: ILanguage): monarchCommon.ILexer {
if (!json || typeof (json) !== 'object') {
throw new Error('Monarch: expecting a language definition object');
}
// Get names
if (typeof (json.name) !== 'string') {
throw new Error('Monarch: a language definition must include a string \'name\' attribute');
}
// Create our lexer
var lexer: monarchCommon.ILexer = <monarchCommon.ILexer>{};
lexer.name = json.name;
lexer.displayName = string(json.displayName, lexer.name);
lexer.languageId = languageId;
lexer.noThrow = false; // raise exceptions during compilation
lexer.maxStack = 100;
......@@ -408,29 +401,14 @@ export function compile(json: ILanguage): monarchCommon.ILexer {
lexer.start = string(json.start);
lexer.ignoreCase = bool(json.ignoreCase, false);
lexer.lineComment = string(json.lineComment, '//');
lexer.blockCommentStart = string(json.blockCommentStart, '/*');
lexer.blockCommentEnd = string(json.blockCommentEnd, '*/');
lexer.tokenPostfix = string(json.tokenPostfix, '.' + lexer.name);
lexer.tokenPostfix = string(json.tokenPostfix, '.' + lexer.languageId);
lexer.defaultToken = string(json.defaultToken, 'source', function () { monarchCommon.throwError(lexer, 'the \'defaultToken\' must be a string'); });
lexer.usesEmbedded = false; // becomes true if we find a nextEmbedded action
lexer.wordDefinition = json.wordDefinition || undefined;
// COMPAT: with earlier monarch versions
if (!lexer.lineComment && (<any>json).lineComments) {
if (typeof ((<any>json).lineComments) === 'string') {
lexer.lineComment = (<any>json).lineComments;
}
else if (typeof ((<any>json).lineComments[0]) === 'string') {
lexer.lineComment = (<any>json).lineComments[0];
}
}
// For calling compileAction later on
var lexerMin: monarchCommon.ILexerMin = <any>json;
lexerMin.name = lexer.name;
lexerMin.displayName = lexer.displayName;
lexerMin.languageId = languageId;
lexerMin.ignoreCase = lexer.ignoreCase;
lexerMin.noThrow = lexer.noThrow;
lexerMin.usesEmbedded = lexer.usesEmbedded;
......@@ -559,105 +537,6 @@ export function compile(json: ILanguage): monarchCommon.ILexer {
}
lexer.brackets = brackets;
// Set default auto closing pairs
var autoClosingPairs: any/*string[][]*/;
if (json.autoClosingPairs) {
if (!(Array.isArray(<any>json.autoClosingPairs))) {
monarchCommon.throwError(lexer, 'the \'autoClosingPairs\' attribute must be an array of string pairs (as arrays)');
}
autoClosingPairs = json.autoClosingPairs.slice(0);
}
else {
autoClosingPairs = [['"', '"'], ['\'', '\''], ['@brackets']];
}
// set auto closing pairs
lexer.autoClosingPairs = [];
if (autoClosingPairs) {
for (var autoClosingPairIdx in autoClosingPairs) {
if (autoClosingPairs.hasOwnProperty(autoClosingPairIdx)) {
var pair = autoClosingPairs[autoClosingPairIdx];
var openClose: IAutoClosingPairConditional;
if (pair === '@brackets' || pair[0] === '@brackets') {
var bidx: string;
for (bidx in brackets) {
if (brackets.hasOwnProperty(bidx)) {
if (brackets[bidx].open && brackets[bidx].open.length === 1 &&
brackets[bidx].close && brackets[bidx].close.length === 1) {
openClose = { open: brackets[bidx].open, close: brackets[bidx].close, notIn:['string', 'comment'] };
lexer.autoClosingPairs.push(openClose);
}
}
}
}
else if (Array.isArray(pair) && pair.length === 2 &&
typeof (pair[0]) === 'string' && pair[0].length === 1 &&
typeof (pair[1]) === 'string' && pair[1].length === 1) {
openClose = { open: monarchCommon.fixCase(lexer, pair[0]), close: monarchCommon.fixCase(lexer, pair[1]), notIn:['string', 'comment'] };
lexer.autoClosingPairs.push(openClose);
}
else if (typeof (pair.open) === 'string' && pair.open.length === 1 &&
typeof (pair.close) === 'string' && pair.close.length === 1) {
openClose = { open: monarchCommon.fixCase(lexer, pair.open[0]), close: monarchCommon.fixCase(lexer, pair.close[0]), notIn:['string', 'comment'] };
lexer.autoClosingPairs.push(openClose);
}
else {
monarchCommon.throwError(lexer, 'every element in an \'autoClosingPairs\' array must be a pair of 1 character strings, or a \'@brackets\' directive');
}
}
}
}
// Set enhanced brackets
// var enhancedBrackets : IRegexBracketPair[] = [];
// if (json.enhancedBrackets) {
// if (!(Array.isArray(<any>json.enhancedBrackets))) {
// monarchCommon.throwError(lexer, 'the \'enhancedBrackets\' attribute must be defined as an array');
// }
// for (var bracketIdx in json.enhancedBrackets) {
// if (json.enhancedBrackets.hasOwnProperty(bracketIdx)) {
// var desc = <any> json.enhancedBrackets[bracketIdx];
// if (desc.hasOwnProperty('openTrigger') && typeof (desc.openTrigger) !== 'string') {
// monarchCommon.throwError(lexer, 'openTrigger in the \'enhancedBrackets\' array must be a string');
// }
// if (desc.hasOwnProperty('open') && !(desc.open instanceof RegExp)) {
// monarchCommon.throwError(lexer, 'open in the \'enhancedBrackets\' array must be a regex');
// }
// if (desc.hasOwnProperty('closeComplete') && typeof (desc.closeComplete) !== 'string') {
// monarchCommon.throwError(lexer, 'closeComplete in the \'enhancedBrackets\' array must be a string');
// }
// if (desc.hasOwnProperty('matchCase') && typeof (desc.matchCase) !== 'boolean') {
// monarchCommon.throwError(lexer, 'matchCase in the \'enhancedBrackets\' array must be a boolean');
// }
// if (desc.hasOwnProperty('closeTrigger') && typeof (desc.closeTrigger) !== 'string') {
// monarchCommon.throwError(lexer, 'closeTrigger in the \'enhancedBrackets\' array must be a string');
// }
// if (desc.hasOwnProperty('close') && !(desc.close instanceof RegExp)) {
// monarchCommon.throwError(lexer, 'close in the \'enhancedBrackets\' array must be a regex');
// }
// if (desc.hasOwnProperty('tokenType')) {
// if (typeof (desc.tokenType) !== 'string') {
// monarchCommon.throwError(lexer, 'tokenType in the \'enhancedBrackets\' array must be a string');
// }
// else {
// desc.tokenType += lexer.tokenPostfix;
// }
// }
// enhancedBrackets.push(desc);
// }
// }
// }
// lexer.enhancedBrackets = enhancedBrackets;
var standardBrackets: CharacterPair[] = [];
for (var i = 0; i < brackets.length; ++i) {
standardBrackets.push([brackets[i].open, brackets[i].close]);
}
lexer.standardBrackets = standardBrackets;
lexer.outdentTriggers = string(json.outdentTriggers, '');
// Disable throw so the syntax highlighter goes, no matter what
lexer.noThrow = true;
return lexer;
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
/**
* Create a syntax highighter with a fully declarative JSON style lexer description
* using regular expressions.
*/
import {ILexer} from 'vs/editor/common/modes/monarch/monarchCommon';
import {IRichLanguageConfiguration} from 'vs/editor/common/modes/supports/richEditSupport';
export function createRichEditSupport(lexer: ILexer): IRichLanguageConfiguration {
return {
wordPattern: lexer.wordDefinition,
comments: {
lineComment: lexer.lineComment,
blockComment: [lexer.blockCommentStart, lexer.blockCommentEnd]
},
brackets: lexer.standardBrackets,
autoClosingPairs: lexer.autoClosingPairs,
__electricCharacterSupport: {
// regexBrackets: lexer.enhancedBrackets,
caseInsensitive: lexer.ignoreCase,
embeddedElectricCharacters: lexer.outdentTriggers.split('')
}
};
}
......@@ -72,7 +72,7 @@ export class MonarchLexer extends AbstractState {
return false;
}
var otherm: MonarchLexer = <MonarchLexer>other;
if ((this.stack.length !== otherm.stack.length) || (this.lexer.name !== otherm.lexer.name) ||
if ((this.stack.length !== otherm.stack.length) || (this.lexer.languageId !== otherm.lexer.languageId) ||
(this.embeddedMode !== otherm.embeddedMode)) {
return false;
}
......@@ -288,7 +288,7 @@ export class MonarchLexer extends AbstractState {
}
if (action.log && typeof (action.log) === 'string') {
monarchCommon.log(this.lexer, this.lexer.displayName + ': ' + monarchCommon.substituteMatches(this.lexer, action.log, matched, matches, state));
monarchCommon.log(this.lexer, this.lexer.languageId + ': ' + monarchCommon.substituteMatches(this.lexer, action.log, matched, matches, state));
}
}
......
......@@ -14,35 +14,14 @@
* A Monarch language definition
*/
export interface ILanguage {
/**
* unique name to identify the language.
*/
name: string;
/**
* map from string to ILanguageRule[]
*/
tokenizer: Object;
/**
* nice display name
*/
displayName?: string;
/**
* is the language case insensitive?
*/
ignoreCase?: boolean;
/**
* used to insert/delete line comments in the editor
*/
lineComment?: string;
/**
* used to insert/delete block comments in the editor
*/
blockCommentStart?: string;
/**
* used to insert/delete block comments in the editor
*/
blockCommentEnd?: string;
/**
* if no match in the tokenizer assign this token class (default 'source')
*/
......@@ -51,8 +30,6 @@ export interface ILanguage {
* for example [['{','}','delimiter.curly']]
*/
brackets?: ILanguageBracket[];
// advanced
/**
* start symbol in the tokenizer (by default the first entry is used)
*/
......@@ -60,23 +37,7 @@ export interface ILanguage {
/**
* attach this to every token class (by default '.' + name)
*/
tokenPostfix?: string;
/**
* for example [['"','"']]
*/
autoClosingPairs?: string[][];
/**
* word definition regular expression
*/
wordDefinition?: RegExp;
/**
* characters that could potentially cause outdentation
*/
outdentTriggers?: string;
// /**
// * Advanced auto completion, auto indenting, and bracket matching
// */
// enhancedBrackets?: IRegexBracketPair[];
tokenPostfix: string;
}
/**
......
......@@ -9,7 +9,6 @@ import {IDisposable} from 'vs/base/common/lifecycle';
import {TPromise} from 'vs/base/common/winjs.base';
import {ServiceIdentifier, createDecorator} from 'vs/platform/instantiation/common/instantiation';
import * as modes from 'vs/editor/common/modes';
import {ILanguage} from 'vs/editor/common/modes/monarch/monarchTypes';
import {IRichLanguageConfiguration} from 'vs/editor/common/modes/supports/richEditSupport';
export var IModeService = createDecorator<IModeService>('modeService');
......@@ -74,5 +73,4 @@ export interface IModeService {
registerRichEditSupport(modeId: string, support: IRichLanguageConfiguration): IDisposable;
registerTokenizationSupport(modeId: string, callback: (mode: modes.IMode) => modes.ITokenizationSupport): IDisposable;
registerTokenizationSupport2(modeId: string, support: modes.TokensProvider): IDisposable;
registerMonarchDefinition(modeId:string, language:ILanguage): IDisposable;
}
......@@ -7,7 +7,7 @@
import * as nls from 'vs/nls';
import {onUnexpectedError} from 'vs/base/common/errors';
import Event, {Emitter} from 'vs/base/common/event';
import {IDisposable, combinedDisposable, empty as EmptyDisposable} from 'vs/base/common/lifecycle'; // TODO@Alex
import {IDisposable, empty as EmptyDisposable} from 'vs/base/common/lifecycle'; // TODO@Alex
import * as objects from 'vs/base/common/objects';
import * as paths from 'vs/base/common/paths';
import {TPromise} from 'vs/base/common/winjs.base';
......@@ -20,11 +20,6 @@ import {IThreadService, Remotable, ThreadAffinity} from 'vs/platform/thread/comm
import * as modes from 'vs/editor/common/modes';
import {FrankensteinMode} from 'vs/editor/common/modes/abstractMode';
import {ILegacyLanguageDefinition, ModesRegistry} from 'vs/editor/common/modes/modesRegistry';
import {ILexer} from 'vs/editor/common/modes/monarch/monarchCommon';
import {compile} from 'vs/editor/common/modes/monarch/monarchCompile';
import {createRichEditSupport} from 'vs/editor/common/modes/monarch/monarchDefinition';
import {createTokenizationSupport} from 'vs/editor/common/modes/monarch/monarchLexer';
import {ILanguage} from 'vs/editor/common/modes/monarch/monarchTypes';
import {IRichLanguageConfiguration, RichEditSupport} from 'vs/editor/common/modes/supports/richEditSupport';
import {LanguagesRegistry} from 'vs/editor/common/services/languagesRegistry';
import {ILanguageExtensionPoint, IValidLanguageExtensionPoint, IModeLookupResult, IModeService} from 'vs/editor/common/services/modeService';
......@@ -426,21 +421,6 @@ export class ModeServiceImpl implements IModeService {
};
}
protected doRegisterMonarchDefinition(modeId:string, lexer: ILexer): IDisposable {
return combinedDisposable(
this.registerTokenizationSupport(modeId, (mode: modes.IMode) => {
return createTokenizationSupport(this, mode, lexer);
}),
this.registerRichEditSupport(modeId, createRichEditSupport(lexer))
);
}
public registerMonarchDefinition(modeId:string, language:ILanguage): IDisposable {
var lexer = compile(objects.clone(language));
return this.doRegisterMonarchDefinition(modeId, lexer);
}
public registerRichEditSupport(modeId: string, support: IRichLanguageConfiguration): IDisposable {
return this.registerModeSupport(modeId, modes.MutableSupport.RichEditSupport, (mode) => new RichEditSupport(modeId, mode.richEditSupport, support));
}
......@@ -646,12 +626,6 @@ export class MainThreadModeServiceImpl extends ModeServiceImpl {
this._getModeServiceWorkerHelper().instantiateMode(modeId);
return super._createMode(modeId);
}
public registerMonarchDefinition(modeId:string, language:ILanguage): IDisposable {
this._getModeServiceWorkerHelper().registerMonarchDefinition(modeId, language);
var lexer = compile(objects.clone(language));
return super.doRegisterMonarchDefinition(modeId, lexer);
}
}
export interface IWorkerInitData {
......@@ -687,8 +661,4 @@ export class ModeServiceWorkerHelper {
public configureModeById(modeId:string, options:any):void {
this._modeService.configureMode(modeId, options);
}
public registerMonarchDefinition(modeId:string, language:ILanguage): void {
this._modeService.registerMonarchDefinition(modeId, language);
}
}
......@@ -9,7 +9,6 @@ import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
blockComment: ['/*', '*/'],
lineComment: 'REM'
},
brackets: [['{','}'], ['[',']'], ['(',')']],
......@@ -23,24 +22,6 @@ export var conf:IRichLanguageConfiguration = {
caseInsensitive: false,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
displayName: 'Batch',
name: 'bat',
defaultToken: '',
ignoreCase: true,
lineComment: 'REM',
autoClosingPairs: [ ['{','}' ], ['[',']' ], ['(',')' ], ['"','"' ]], // Exclude '
brackets: [
{ token: 'punctuation.bracket', open: '{', close: '}' },
{ token: 'punctuation.parenthesis', open: '(', close: ')' },
{ token: 'punctuation.square', open: '[', close: ']' }
],
// enhancedBrackets: [
// {
// openTrigger: 'l',
......@@ -52,6 +33,18 @@ export var language = <ILanguage> {
// tokenType: 'keyword.tag-setlocal'
// }
// ],
};
export var language = <ILanguage> {
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/,
......
......@@ -25,17 +25,17 @@ export var conf:IRichLanguageConfiguration = {
caseInsensitive: false,
embeddedElectricCharacters: []
}
// 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 = <ILanguage> {
displayName: 'CoffeeScript',
name: 'coffee',
defaultToken: '',
ignoreCase: true,
lineComment: '#',
blockCommentStart: '###',
blockCommentEnd: '###',
tokenPostfix: '.coffee',
brackets: [
{ open:'{', close:'}', token:'delimiter.curly'},
......@@ -43,14 +43,6 @@ export var language = <ILanguage> {
{ open:'(', close:')', token:'delimiter.parenthesis'}
],
// enhancedBrackets: [
// { open: /for$/ }, { open: /while$/ }, { open: /loop$/ }, { open: /if$/ }, { open: /unless$/ },
// { open: /else$/ }, { open: /switch$/ }, { open: /try$/ }, { open: /catch$/ }, { open: /finally$/ },
// { open: /class$/ }, { open: /->$/ }
// ],
// the default separators
wordDefinition: /(-?\d*\.\d\w*)|([^\`\~\!\@\#%\^\&\*\(\)\=\$\-\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
regEx: /\/(?!\/\/)(?:[^\/\\]|\\.)*\/[igm]*/,
keywords: [
......
......@@ -26,13 +26,8 @@ export var conf:IRichLanguageConfiguration = {
};
export var language = <ILanguage> {
displayName: 'C++',
name: 'cpp',
defaultToken: '',
lineComment: '//',
blockCommentStart: '/*',
blockCommentEnd: '*/',
tokenPostfix: '.cpp',
brackets: [
{ token: 'delimiter.curly', open: '{', close: '}' },
......@@ -41,8 +36,6 @@ export var language = <ILanguage> {
{ token: 'delimiter.angle', open: '<', close: '>' }
],
autoClosingPairs: [ ['{', '}'], ['[', ']'], ['(', ')'], ['"', '"']], // Skip < > which would be there by default.
keywords: [
'abstract',
'amp',
......
......@@ -28,25 +28,8 @@ export var conf:IRichLanguageConfiguration = {
};
export var language = <ILanguage> {
displayName: '',
name: 'cs',
defaultToken: '',
// used in the editor to insert comments (ctrl+/ or shift+alt+A)
lineComment: '// ',
blockCommentStart: '/*',
blockCommentEnd: '*/',
// the default separators except `@`
wordDefinition: /(-?\d*\.\d\w*)|([^\`\~\!\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
autoClosingPairs: [
['"', '"'],
['\'', '\''],
['{', '}'],
['[', ']'],
['(', ')'],
],
tokenPostfix: '.cs',
brackets: [
{ open: '{', close: '}', token: 'delimiter.curly' },
......
......@@ -8,10 +8,6 @@
import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
lineComment: '//',
blockComment: ['/*', '*/'],
},
brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']],
autoClosingPairs: [
{ open: '"', close: '"', notIn: ['string', 'comment'] },
......@@ -28,9 +24,8 @@ export var conf:IRichLanguageConfiguration = {
};
export var language = <ILanguage>{
displayName: 'Dockerfile',
name: 'dockerfile',
defaultToken: '',
tokenPostfix: '.dockerfile',
instructions: /FROM|MAINTAINER|RUN|EXPOSE|ENV|ADD|VOLUME|LABEL|USER|WORKDIR|COPY|CMD|ENTRYPOINT/,
......
......@@ -26,15 +26,8 @@ export var conf:IRichLanguageConfiguration = {
};
export var language = <ILanguage> {
displayName: 'F#',
name: 'fs',
defaultToken: '',
lineComment: '//',
blockCommentStart: '(*',
blockCommentEnd: '*)',
autoClosingPairs: [ ['{', '}'], ['[', ']'], ['(', ')'], ['"', '"']], // Skip < > which would be there by default.
tokenPostfix: '.fs',
keywords: [
'abstract', 'and', 'atomic', 'as',
......
......@@ -27,15 +27,8 @@ export var conf:IRichLanguageConfiguration = {
export var language = <ILanguage> {
displayName: 'Go',
name: 'go',
defaultToken: '',
lineComment: '//',
blockCommentStart: '/*',
blockCommentEnd: '*/',
autoClosingPairs: [ ['{', '}'], ['[', ']'], ['(', ')'], ['"', '"']], // Skip < > which would be there by default.
tokenPostfix: '.go',
keywords: [
'break',
......
......@@ -9,8 +9,7 @@ import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
lineComment: '#',
blockComment: ['#', ' '],
lineComment: '#'
},
brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']],
autoClosingPairs: [
......@@ -28,13 +27,8 @@ export var conf:IRichLanguageConfiguration = {
};
export var language = <ILanguage> {
displayName: 'Ini',
name: 'ini',
defaultToken: '',
lineComment: '#',
blockCommentStart: '#',
blockCommentEnd: ' ',
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})/,
......
......@@ -9,8 +9,7 @@ import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
lineComment: '//',
blockComment: ['/*', '*/'],
lineComment: '//'
},
brackets: [['{','}'], ['[',']'], ['(',')']],
autoClosingPairs: [
......@@ -27,14 +26,11 @@ export var conf:IRichLanguageConfiguration = {
};
export var language = <ILanguage> {
displayName: 'Jade',
name: 'jade',
defaultToken: '',
defaultToken: '',
tokenPostfix: '.jade',
ignoreCase: true,
lineComment: '//',
brackets: [
{ token:'delimiter.curly', open: '{', close: '}' },
{ token:'delimiter.array', open: '[', close: ']' },
......
......@@ -30,16 +30,8 @@ export var conf:IRichLanguageConfiguration = {
};
export var language = <ILanguage> {
displayName: 'Java',
name: 'java',
defaultToken: '',
lineComment: '//',
blockCommentStart: '/*',
blockCommentEnd: '*/',
// the default separators except `@$`
wordDefinition: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
tokenPostfix: '.java',
keywords: [
'abstract', 'continue', 'for', 'new', 'switch', 'assert', 'default',
......
......@@ -27,31 +27,26 @@ export var conf:IRichLanguageConfiguration = {
};
export var language = <ILanguage> {
displayName: 'Lua',
name: 'lua',
defaultToken: '',
lineComment: '--',
blockCommentStart: '--[[',
blockCommentEnd: ']]',
tokenPostfix: '.lua',
keywords: [
'and', 'break', 'do', 'else', 'elseif',
'end', 'false', 'for', 'function', 'goto', 'if',
'in', 'local', 'nil', 'not', 'or',
'repeat', 'return', 'then', 'true', 'until',
'while'
'end', 'false', 'for', 'function', 'goto', 'if',
'in', 'local', 'nil', 'not', 'or',
'repeat', 'return', 'then', 'true', 'until',
'while'
],
brackets: [
{ token: 'delimiter.bracket', open: '{', close: '}'},
{ token: 'delimiter.array', open: '[', close: ']'},
{ token: 'delimiter.parenthesis', open: '(', close: ')'}
{ token: 'delimiter.bracket', open: '{', close: '}'},
{ token: 'delimiter.array', open: '[', close: ']'},
{ token: 'delimiter.parenthesis', open: '(', close: ')'}
],
operators: [
'+', '-', '*', '/', '%', '^', '#', '==', '~=', '<=', '>=', '<', '>', '=',
';', ':', ',', '.', '..', '...'
';', ':', ',', '.', '..', '...'
],
// we include these common regular expressions
......@@ -63,7 +58,7 @@ export var language = <ILanguage> {
root: [
// identifiers and keywords
[/[a-zA-Z_]\w*/, { cases: { '@keywords': {token:'keyword.$0'},
'@default': 'identifier' } }],
'@default': 'identifier' } }],
// whitespace
{ include: '@whitespace' },
......@@ -74,7 +69,7 @@ export var language = <ILanguage> {
// delimiters and operators
[/[{}()\[\]]/, '@brackets'],
[/@symbols/, { cases: { '@operators': 'delimiter',
'@default' : '' } } ],
'@default' : '' } } ],
// numbers
[/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
......@@ -108,7 +103,7 @@ export var language = <ILanguage> {
[/@escapes/, 'string.escape'],
[/\\./, 'string.escape.invalid'],
[/["']/, { cases: { '$#==$S2' : { token: 'string', next: '@pop' },
'@default': 'string' }} ]
'@default': 'string' }} ]
],
},
......
......@@ -28,13 +28,8 @@ export var conf:IRichLanguageConfiguration = {
};
export var language = <ILanguage> {
displayName: 'Objective-C',
name: 'objective-c',
defaultToken: '',
lineComment: '//',
blockCommentStart: '/*',
blockCommentEnd: '*/',
tokenPostfix: '.objective-c',
keywords: [
'#import',
......
......@@ -24,36 +24,24 @@ export var conf:IRichLanguageConfiguration = {
caseInsensitive: true,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
displayName: 'PowerShell',
name: 'ps1',
defaultToken: '',
ignoreCase: true,
lineComment: '#',
blockCommentStart: '<#',
blockCommentEnd: '#>',
// the default separators except `$-`
wordDefinition: /(-?\d*\.\d\w*)|([^\`\~\!\@\#%\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
brackets: [
{ token: 'delimiter.curly', open: '{', close: '}' },
{ token: 'delimiter.square', open: '[', close: ']' },
{ token: 'delimiter.parenthesis', open: '(', close: ')' }],
// enhancedBrackets: [
// { tokenType:'string', openTrigger: '"', open: /@"$/, closeComplete: '"@' },
// { tokenType:'string', openTrigger: '\'', open: /@'$/, closeComplete: '\'@' },
// { tokenType:'string', openTrigger: '"', open: /"$/, closeComplete: '"' },
// { tokenType: 'string', openTrigger: '\'', open: /'$/, closeComplete: '\'' }
// ],
};
autoClosingPairs: [['{', '}'], ['[', ']'], ['(', ')']], // Defined explicitly, to suppress the
// default auto-closing of ' and " which is
// override above by enhancedBrackets
export var language = <ILanguage> {
defaultToken: '',
ignoreCase: true,
tokenPostfix: '.ps1',
brackets: [
{ token: 'delimiter.curly', open: '{', close: '}' },
{ token: 'delimiter.square', open: '[', close: ']' },
{ token: 'delimiter.parenthesis', open: '(', close: ')' }
],
keywords: [
'begin', 'break', 'catch', 'class', 'continue', 'data',
......
......@@ -24,16 +24,13 @@ export var conf:IRichLanguageConfiguration = {
caseInsensitive: false,
embeddedElectricCharacters: []
}
// Cause an automatic indent to occur after lines ending in :.
// enhancedBrackets: [ { open: /.*:\s*$/, closeComplete: 'else:' } ],
};
export var language = <ILanguage> {
displayName: '',
name: 'python',
defaultToken: '',
lineComment: '#',
blockCommentStart: '\'\'\'',
blockCommentEnd: '\'\'\'',
tokenPostfix: '.python',
keywords: [
'and',
......@@ -174,9 +171,6 @@ export var language = <ILanguage> {
{ open: '(', close: ')', token: 'delimiter.parenthesis' }
],
// Cause an automatic indent to occur after lines ending in :.
// enhancedBrackets: [ { open: /.*:\s*$/, closeComplete: 'else:' } ],
tokenizer: {
root: [
{ include: '@whitespace' },
......
......@@ -9,8 +9,7 @@ import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
lineComment: '#',
blockComment: ['', ''],
lineComment: '#'
},
brackets: [['{','}'], ['[',']'], ['(',')']],
autoClosingPairs: [
......@@ -27,13 +26,8 @@ export var conf:IRichLanguageConfiguration = {
};
export var language = <ILanguage> {
displayName: 'R',
name: 'r',
defaultToken: '',
lineComment: '#',
blockCommentStart: '',
blockCommentEnd: '',
tokenPostfix: '.r',
roxygen: [
'@param',
......
......@@ -22,6 +22,7 @@ export var conf:IRichLanguageConfiguration = {
],
__electricCharacterSupport: {
caseInsensitive: false,
// trigger outdenting on 'end'
embeddedElectricCharacters: ['d']
}
};
......@@ -76,12 +77,7 @@ export var conf:IRichLanguageConfiguration = {
*/
export var language = <ILanguage> {
displayName: '',
name: 'ruby',
lineComment: '#',
blockCommentStart: '=begin',
blockCommentEnd: '=end',
tokenPostfix: '.ruby',
keywords: [
'__LINE__', '__ENCODING__', '__FILE__', 'BEGIN', 'END', 'alias', 'and', 'begin',
......@@ -121,9 +117,6 @@ export var language = <ILanguage> {
{ open: '[', close: ']', token: 'delimiter.square'}
],
// trigger outdenting on 'end'
outdentTriggers: 'd',
// we include these common regular expressions
symbols: /[=><!~?:&|+\-*\/\^%\.]+/,
......
......@@ -23,26 +23,23 @@ export var conf:IRichLanguageConfiguration = {
caseInsensitive: true,
embeddedElectricCharacters: []
}
// enhancedBrackets:[
// { openTrigger: 'n', open: /begin$/i, closeComplete: 'end', matchCase: true },
// { openTrigger: 'e', open: /case$/i, closeComplete: 'end', matchCase: true },
// { openTrigger: 'n', open: /when$/i, closeComplete: 'then', matchCase: true }
// ],
};
export var language = <ILanguage> {
displayName: 'SQL',
name: 'sql',
defaultToken: '',
tokenPostfix: '.sql',
ignoreCase: true,
brackets: [
{ open: '[', close: ']', token: 'delimiter.square' },
{ open: '(', close: ')', token: 'delimiter.parenthesis' }
],
// enhancedBrackets:[
// { openTrigger: 'n', open: /begin$/i, closeComplete: 'end', matchCase: true },
// { openTrigger: 'e', open: /case$/i, closeComplete: 'end', matchCase: true },
// { openTrigger: 'n', open: /when$/i, closeComplete: 'then', matchCase: true }
// ],
noindentBrackets: '()',
lineComment: '--',
blockCommentStart: '/*',
blockCommentEnd: '*/',
keywords: [
'ABORT_AFTER_WAIT',
'ABSENT',
......
......@@ -27,13 +27,8 @@ export var conf:IRichLanguageConfiguration = {
};
export var language = <ILanguage> {
displayName: 'Swift',
name: 'swift',
defaultToken: '',
lineComment: '//',
blockCommentStart: '/*',
blockCommentEnd: '*/',
tokenPostfix: '.swift',
// TODO(owensd): Support the full range of unicode valid identifiers.
identifier: /[a-zA-Z_][\w$]*/,
......
......@@ -5,7 +5,7 @@
'use strict';
import {language} from 'vs/editor/standalone-languages/bat';
import {language, conf} from 'vs/editor/standalone-languages/bat';
import {testOnEnter, testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
testTokenization('bat', language, [
......@@ -333,7 +333,7 @@ testTokenization('bat', language, [
]}]
]);
testOnEnter('bat', language, (assertOnEnter) => {
testOnEnter('bat', conf, (assertOnEnter) => {
assertOnEnter.nothing('', ' a', '');
assertOnEnter.indents('', ' {', '');
assertOnEnter.indents('', '( ', '');
......
......@@ -5,10 +5,10 @@
'use strict';
import {language} from 'vs/editor/standalone-languages/coffee';
import {language, conf} from 'vs/editor/standalone-languages/coffee';
import {testOnEnter, testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
testOnEnter('coffeescript', language, (assertOnEnter) => {
testOnEnter('coffeescript', conf, (assertOnEnter) => {
assertOnEnter.nothing('', ' a', '');
assertOnEnter.indents('', ' {', '');
assertOnEnter.indents('', '( ', '');
......
......@@ -5,10 +5,10 @@
'use strict';
import {language} from 'vs/editor/standalone-languages/cpp';
import {language, conf} from 'vs/editor/standalone-languages/cpp';
import {testOnEnter, testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
testOnEnter('cpp', language, (assertOnEnter) => {
testOnEnter('cpp', conf, (assertOnEnter) => {
assertOnEnter.nothing('', ' a', '');
assertOnEnter.indents('', ' <', '');
assertOnEnter.indents('', ' {', '');
......
......@@ -6,7 +6,7 @@
'use strict';
import * as assert from 'assert';
import {language} from 'vs/editor/standalone-languages/java';
import {language, conf} from 'vs/editor/standalone-languages/java';
import {testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
testTokenization('java', language, [
......@@ -605,7 +605,7 @@ testTokenization('java', language, [
suite('java', () => {
test('word definition', () => {
var wordDefinition = language.wordDefinition;
var wordDefinition = conf.wordPattern;
assert.deepEqual('a b cde'.match(wordDefinition), ['a', 'b', 'cde']);
assert.deepEqual('public static void main(String[] args) {'.match(wordDefinition),
......
......@@ -6,7 +6,7 @@
'use strict';
import * as assert from 'assert';
import {language} from 'vs/editor/standalone-languages/powershell';
import {language, conf} from 'vs/editor/standalone-languages/powershell';
import {testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
testTokenization('powershell', language, [
......@@ -738,7 +738,7 @@ testTokenization('powershell', language, [
suite('powershell', () => {
test('word definition', () => {
var wordDefinition = language.wordDefinition;
var wordDefinition = conf.wordPattern;
assert.deepEqual('a b cde'.match(wordDefinition), ['a', 'b', 'cde']);
assert.deepEqual('if ($parameterSet["class"] -eq "blank")'.match(wordDefinition), ['if', '$parameterSet', 'class', '-eq', 'blank']);
......
......@@ -5,11 +5,9 @@
'use strict';
import {compile} from 'vs/editor/common/modes/monarch/monarchCompile';
import {createRichEditSupport} from 'vs/editor/common/modes/monarch/monarchDefinition';
import {RichEditSupport} from 'vs/editor/common/modes/supports/richEditSupport';
import {createOnEnterAsserter, executeMonarchTokenizationTests} from 'vs/editor/test/common/modesUtil';
import {ILanguage} from '../types';
import {ILanguage, IRichLanguageConfiguration} from '../types';
export interface IRelaxedToken {
startIndex: number;
......@@ -28,18 +26,17 @@ export interface IOnEnterAsserter {
}
export function testTokenization(name:string, language: ILanguage, tests:ITestItem[][]): void {
suite(language.displayName || name, () => {
suite(name, () => {
test('Tokenization', () => {
executeMonarchTokenizationTests(name, language, <any>tests);
});
});
}
export function testOnEnter(name:string, language: ILanguage, callback:(assertOnEnter: IOnEnterAsserter)=>void): void {
suite(language.displayName || name, () => {
export function testOnEnter(name:string, conf: IRichLanguageConfiguration, callback:(assertOnEnter: IOnEnterAsserter)=>void): void {
suite(name, () => {
test('onEnter', () => {
var lexer = compile(language);
var richEditSupport = new RichEditSupport('test', null, createRichEditSupport(lexer));
var richEditSupport = new RichEditSupport('test', null, conf);
callback(createOnEnterAsserter('test', richEditSupport));
});
});
......
......@@ -17,67 +17,27 @@ export interface ILanguageDef {
export interface ILanguage {
// required
name: string; // unique name to identify the language
tokenizer: Object; // map from string to ILanguageRule[]
tokenPostfix: string; // attach this to every token class (by default '.' + name)
// optional
displayName?: string; // nice display name
ignoreCase?: boolean; // is the language case insensitive?
lineComment?: string; // used to insert/delete line comments in the editor
blockCommentStart?: string; // used to insert/delete block comments in the editor
blockCommentEnd?: string;
defaultToken?: string; // if no match in the tokenizer assign this token class (default 'source')
brackets?: ILanguageBracket[]; // for example [['{','}','delimiter.curly']]
// advanced
start?: string; // start symbol in the tokenizer (by default the first entry is used)
tokenPostfix?: string; // attach this to every token class (by default '.' + name)
autoClosingPairs?: string[][]; // for example [['"','"']]
wordDefinition?: RegExp; // word definition regular expression
outdentTriggers?: string; // characters that could potentially cause outdentation
// enhancedBrackets?: IRegexBracketPair[]; // Advanced auto completion, auto indenting, and bracket matching
}
/**
* This interface can be shortened as an array, ie. ['{','}','delimiter.curly']
*/
* This interface can be shortened as an array, ie. ['{','}','delimiter.curly']
*/
export interface ILanguageBracket {
open: string; // open bracket
close: string; // closeing bracket
token: string; // token class
}
// export interface ILanguageAutoComplete {
// triggers: string; // characters that trigger auto completion rules
// match: string|RegExp; // autocomplete if this matches
// complete: string; // complete with this string
// }
// export interface ILanguageAutoIndent {
// match: string|RegExp; // auto indent if this matches on enter
// matchAfter: string|RegExp; // and auto-outdent if this matches on the next line
// }
// /**
// * Regular expression based brackets. These are always electric.
// */
// export interface IRegexBracketPair {
// // openTrigger?: string; // The character that will trigger the evaluation of 'open'.
// open: RegExp; // The definition of when an opening brace is detected. This regex is matched against the entire line upto, and including the last typed character (the trigger character).
// closeComplete?: string; // How to complete a matching open brace. Matches from 'open' will be expanded, e.g. '</$1>'
// matchCase?: boolean; // If set to true, the case of the string captured in 'open' will be detected an applied also to 'closeComplete'.
// // This is useful for cases like BEGIN/END or begin/end where the opening and closing phrases are unrelated.
// // For identical phrases, use the $1 replacement syntax above directly in closeComplete, as it will
// // include the proper casing from the captured string in 'open'.
// // Upper/Lower/Camel cases are detected. Camel case dection uses only the first two characters and assumes
// // that 'closeComplete' contains wors separated by spaces (e.g. 'End Loop')
// // closeTrigger?: string; // The character that will trigger the evaluation of 'close'.
// close?: RegExp; // The definition of when a closing brace is detected. This regex is matched against the entire line upto, and including the last typed character (the trigger character).
// tokenType?: string; // The type of the token. Matches from 'open' or 'close' will be expanded, e.g. 'keyword.$1'.
// // Only used to auto-(un)indent a closing bracket.
// }
export type CharacterPair = [string, string];
export interface CommentRule {
......
......@@ -54,54 +54,47 @@ export var conf:IRichLanguageConfiguration = {
};
export var language = <ILanguage> {
displayName: 'VB',
name: 'vb',
defaultToken: '',
tokenPostfix: '.vb',
ignoreCase: true,
brackets: [
{ token:'delimiter.bracket', open: '{', close: '}'},
{ token:'delimiter.array', open: '[', close: ']'},
{ token:'delimiter.parenthesis', open: '(', close: ')'},
{ token:'delimiter.angle', open: '<', close: '>'},
// Special bracket statement pairs
// according to https://msdn.microsoft.com/en-us/library/tsw2a11z.aspx
{ token: 'keyword.tag-addhandler', open: 'addhandler', close: 'end addhandler'},
{ token: 'keyword.tag-class', open: 'class', close: 'end class'},
{ token: 'keyword.tag-enum', open: 'enum', close: 'end enum'},
{ token: 'keyword.tag-event', open: 'event', close: 'end event'},
{ token: 'keyword.tag-function', open: 'function', close: 'end function'},
{ token: 'keyword.tag-get', open: 'get', close: 'end get'},
{ token: 'keyword.tag-if', open: 'if', close: 'end if'},
{ token: 'keyword.tag-interface', open: 'interface', close: 'end interface'},
{ token: 'keyword.tag-module', open: 'module', close: 'end module'},
{ token: 'keyword.tag-namespace', open: 'namespace', close: 'end namespace'},
{ token: 'keyword.tag-operator', open: 'operator', close: 'end operator'},
{ token: 'keyword.tag-property', open: 'property', close: 'end property'},
{ token: 'keyword.tag-raiseevent', open: 'raiseevent', close: 'end raiseevent'},
{ token: 'keyword.tag-removehandler', open: 'removehandler', close: 'end removehandler'},
{ token: 'keyword.tag-select', open: 'select', close: 'end select'},
{ token: 'keyword.tag-set', open: 'set', close: 'end set'},
{ token: 'keyword.tag-structure', open: 'structure', close: 'end structure'},
{ token: 'keyword.tag-sub', open: 'sub', close: 'end sub'},
{ token: 'keyword.tag-synclock', open: 'synclock', close: 'end synclock'},
{ token: 'keyword.tag-try', open: 'try', close: 'end try'},
{ token: 'keyword.tag-while', open: 'while', close: 'end while'},
{ token: 'keyword.tag-with', open: 'with', close: 'end with'},
// Other pairs
{ token: 'keyword.tag-using', open: 'using', close: 'end using' },
{ token: 'keyword.tag-do', open: 'do', close: 'loop' },
{ token: 'keyword.tag-for', open: 'for', close: 'next' }
{ token:'delimiter.bracket', open: '{', close: '}'},
{ token:'delimiter.array', open: '[', close: ']'},
{ token:'delimiter.parenthesis', open: '(', close: ')'},
{ token:'delimiter.angle', open: '<', close: '>'},
// Special bracket statement pairs
// according to https://msdn.microsoft.com/en-us/library/tsw2a11z.aspx
{ token: 'keyword.tag-addhandler', open: 'addhandler', close: 'end addhandler'},
{ token: 'keyword.tag-class', open: 'class', close: 'end class'},
{ token: 'keyword.tag-enum', open: 'enum', close: 'end enum'},
{ token: 'keyword.tag-event', open: 'event', close: 'end event'},
{ token: 'keyword.tag-function', open: 'function', close: 'end function'},
{ token: 'keyword.tag-get', open: 'get', close: 'end get'},
{ token: 'keyword.tag-if', open: 'if', close: 'end if'},
{ token: 'keyword.tag-interface', open: 'interface', close: 'end interface'},
{ token: 'keyword.tag-module', open: 'module', close: 'end module'},
{ token: 'keyword.tag-namespace', open: 'namespace', close: 'end namespace'},
{ token: 'keyword.tag-operator', open: 'operator', close: 'end operator'},
{ token: 'keyword.tag-property', open: 'property', close: 'end property'},
{ token: 'keyword.tag-raiseevent', open: 'raiseevent', close: 'end raiseevent'},
{ token: 'keyword.tag-removehandler', open: 'removehandler', close: 'end removehandler'},
{ token: 'keyword.tag-select', open: 'select', close: 'end select'},
{ token: 'keyword.tag-set', open: 'set', close: 'end set'},
{ token: 'keyword.tag-structure', open: 'structure', close: 'end structure'},
{ token: 'keyword.tag-sub', open: 'sub', close: 'end sub'},
{ token: 'keyword.tag-synclock', open: 'synclock', close: 'end synclock'},
{ token: 'keyword.tag-try', open: 'try', close: 'end try'},
{ token: 'keyword.tag-while', open: 'while', close: 'end while'},
{ token: 'keyword.tag-with', open: 'with', close: 'end with'},
// Other pairs
{ token: 'keyword.tag-using', open: 'using', close: 'end using' },
{ token: 'keyword.tag-do', open: 'do', close: 'loop' },
{ token: 'keyword.tag-for', open: 'for', close: 'next' }
],
autoClosingPairs: [ ['{', '}'], ['[', ']'], ['(', ')'], ['"', '"'], ['<', '>'], ],
lineComment: '\'',
blockCommentStart: '/*',
blockCommentEnd: '*/',
keywords: [
'AddHandler', 'AddressOf', 'Alias', 'And', 'AndAlso', 'As', 'Async', 'Boolean', 'ByRef', 'Byte', 'ByVal', 'Call',
'Case', 'Catch', 'CBool', 'CByte', 'CChar', 'CDate', 'CDbl', 'CDec', 'Char', 'CInt', 'Class', 'CLng',
......
......@@ -9,7 +9,6 @@ import {ILanguage, IRichLanguageConfiguration} from './types';
export var conf:IRichLanguageConfiguration = {
comments: {
lineComment: '',
blockComment: ['<!--', '-->'],
},
brackets: [['{','}'],['[',']'],['(',')'],['<','>']],
......@@ -21,22 +20,6 @@ export var conf:IRichLanguageConfiguration = {
caseInsensitive: true,
embeddedElectricCharacters: []
}
};
export var language = <ILanguage> {
displayName: 'XML',
name: 'xml',
defaultToken: '',
ignoreCase: true,
lineComment: '', // no line comment in xml
blockCommentStart: '<!--',
blockCommentEnd: '-->',
// Useful regular expressions
qualifiedName: /(?:[\w\.\-]+:)?[\w\.\-]+/,
// enhancedBrackets: [{
// tokenType: 'tag.tag-$1.xml',
// openTrigger: '>',
......@@ -45,8 +28,16 @@ export var language = <ILanguage> {
// closeTrigger: '>',
// close: /<\/(\w[\w\d]*)\s*>$/i
// }],
};
export var language = <ILanguage> {
defaultToken: '',
tokenPostfix: '.xml',
autoClosingPairs: [['\'', '\''], ['"', '"'] ],
ignoreCase: true,
// Useful regular expressions
qualifiedName: /(?:[\w\.\-]+:)?[\w\.\-]+/,
tokenizer: {
root: [
......
......@@ -9,10 +9,7 @@ import {IDisposable} from 'vs/base/common/lifecycle';
import {TPromise} from 'vs/base/common/winjs.base';
import {ServiceIdentifier} from 'vs/platform/instantiation/common/instantiation';
import * as modes from 'vs/editor/common/modes';
import {ILanguage} from 'vs/editor/common/modes/monarch/monarchTypes';
import {IRichLanguageConfiguration} from 'vs/editor/common/modes/supports/richEditSupport';
import {IEditorWorkerService} from 'vs/editor/common/services/editorWorkerService';
import {IModelService} from 'vs/editor/common/services/modelService';
import {IModeService, IModeLookupResult} from 'vs/editor/common/services/modeService';
export class MockModeService implements IModeService {
......@@ -92,7 +89,4 @@ export class MockModeService implements IModeService {
registerTokenizationSupport2(modeId: string, support: modes.TokensProvider): IDisposable {
throw new Error('Not implemented');
}
registerMonarchDefinition(modeId:string, language:ILanguage): IDisposable {
throw new Error('Not implemented');
}
}
......@@ -92,9 +92,8 @@ export function executeTests2(tokenizationSupport: modes.TokensProvider, tests:I
}
}
export function executeMonarchTokenizationTests(name:string, language:ILanguage, tests:ITestItem[][]): void {
var lexer = compile(language);
var lexer = compile(name, language);
var modeService = createMockModeService();
......
......@@ -24,17 +24,8 @@ import {createTokenizationSupport} from 'vs/editor/common/modes/monarch/monarchL
import {RichEditSupport} from 'vs/editor/common/modes/supports/richEditSupport';
export var language: Types.ILanguage = <Types.ILanguage> {
displayName: 'LESS',
name: 'less',
// TODO@Martin: This definition does not work with umlauts for example
wordDefinition: /(#?-?\d*\.\d\w*%?)|([@#!.:]?[\w-?]+%?)|[@#!.]/g,
defaultToken: '',
lineComment: '//',
blockCommentStart: '/*',
blockCommentEnd: '*/',
tokenPostfix: '.less',
identifier: '-?-?([a-zA-Z]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))([\\w\\-]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))*',
identifierPlus: '-?-?([a-zA-Z:.]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))([\\w\\-:.]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))*',
......@@ -195,7 +186,7 @@ export class LESSMode extends AbstractMode {
@IEditorWorkerService editorWorkerService: IEditorWorkerService
) {
super(descriptor.id);
let lexer = Compile.compile(language);
let lexer = Compile.compile(descriptor.id, language);
this._modeWorkerManager = new ModeWorkerManager<lessWorker.LessWorker>(descriptor, 'vs/languages/less/common/lessWorker', 'LessWorker', 'vs/languages/css/common/cssWorker', instantiationService);
this._threadService = threadService;
......
......@@ -25,14 +25,8 @@ import {wireCancellationToken} from 'vs/base/common/async';
export const language =
<Types.ILanguage>{
displayName: 'Markdown',
name: 'md',
defaultToken: '',
autoClosingPairs: [],
blockCommentStart: '<!--',
blockCommentEnd: '-->',
tokenPostfix: '.md',
// escape codes
control: /[\\`*_\[\]{}()#+\-\.!]/,
......@@ -222,7 +216,7 @@ export class MarkdownMode extends AbstractMode implements Modes.IEmitOutputSuppo
@IConfigurationService configurationService: IConfigurationService
) {
super(descriptor.id);
let lexer = Compile.compile(language);
let lexer = Compile.compile(descriptor.id, language);
this._modeWorkerManager = new ModeWorkerManager<MarkdownWorker.MarkdownWorker>(descriptor, 'vs/languages/markdown/common/markdownWorker', 'MarkdownWorker', null, instantiationService);
this._threadService = threadService;
......
......@@ -24,17 +24,8 @@ import {createTokenizationSupport} from 'vs/editor/common/modes/monarch/monarchL
import {RichEditSupport} from 'vs/editor/common/modes/supports/richEditSupport';
export var language = <Types.ILanguage>{
displayName: 'Sass',
name: 'sass',
// TODO@Martin: This definition does not work with umlauts for example
wordDefinition: /(#?-?\d*\.\d\w*%?)|([$@#!.:]?[\w-?]+%?)|[$@#!.]/g,
defaultToken: '',
lineComment: '//',
blockCommentStart: '/*',
blockCommentEnd: '*/',
tokenPostfix: '.sass',
ws: '[ \t\n\r\f]*', // whitespaces (referenced in several rules)
identifier: '-?-?([a-zA-Z]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))([\\w\\-]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))*',
......@@ -297,7 +288,7 @@ export class SASSMode extends AbstractMode {
@IEditorWorkerService editorWorkerService: IEditorWorkerService
) {
super(descriptor.id);
let lexer = Compile.compile(language);
let lexer = Compile.compile(descriptor.id, language);
this._modeWorkerManager = new ModeWorkerManager<sassWorker.SassWorker>(descriptor, 'vs/languages/sass/common/sassWorker', 'SassWorker', 'vs/languages/css/common/cssWorker', instantiationService);
this._threadService = threadService;
......
......@@ -22,9 +22,8 @@ import {RichEditSupport} from 'vs/editor/common/modes/supports/richEditSupport';
import {wireCancellationToken} from 'vs/base/common/async';
export const language: types.ILanguage = {
displayName: 'Log',
name: 'Log',
defaultToken: '',
tokenPostfix: '.log',
ignoreCase: true,
tokenizer: {
......@@ -60,7 +59,7 @@ export class OutputMode extends AbstractMode {
@IEditorWorkerService editorWorkerService: IEditorWorkerService
) {
super(descriptor.id);
let lexer = compile(language);
let lexer = compile(descriptor.id, language);
this._modeWorkerManager = new ModeWorkerManager<OutputWorker>(descriptor, 'vs/workbench/parts/output/common/outputWorker', 'OutputWorker', null, instantiationService);
this.tokenizationSupport = createTokenizationSupport(modeService, this, lexer);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册