Format sources

This commit is contained in:
Alex Dima 2017-06-08 18:54:55 +02:00
parent da162968ac
commit f661c5f826
65 changed files with 19255 additions and 17150 deletions

View file

@ -1,12 +1,13 @@
// Place your settings in this file to overwrite default and user settings. // Place your settings in this file to overwrite default and user settings.
{ {
"files.trimTrailingWhitespace": true,
"search.exclude": { "search.exclude": {
"**/node_modules": true, "**/node_modules": true,
"**/release": true, "**/release": true,
"**/out": true "**/out": true
}, },
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"editor.tabSize": 4, "editor.tabSize": 4,
"editor.insertSpaces": false, "editor.insertSpaces": false,
"typescript.tsdk": "./node_modules/typescript/lib" "typescript.tsdk": "./node_modules/typescript/lib"
} }

View file

@ -8,14 +8,14 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
comments: { comments: {
lineComment: 'REM' lineComment: 'REM'
}, },
brackets: [ brackets: [
['{','}'], ['{', '}'],
['[',']'], ['[', ']'],
['(',')'] ['(', ')']
], ],
autoClosingPairs: [ autoClosingPairs: [
{ open: '{', close: '}' }, { open: '{', close: '}' },
@ -30,7 +30,7 @@ export var conf:IRichLanguageConfiguration = {
] ]
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
ignoreCase: true, ignoreCase: true,
tokenPostfix: '.bat', tokenPostfix: '.bat',
@ -44,23 +44,23 @@ export var language = <ILanguage> {
keywords: /call|defined|echo|errorlevel|exist|for|goto|if|pause|set|shift|start|title|not|pushd|popd/, keywords: /call|defined|echo|errorlevel|exist|for|goto|if|pause|set|shift|start|title|not|pushd|popd/,
// we include these common regular expressions // we include these common regular expressions
symbols: /[=><!~?&|+\-*\/\^;\.,]+/, symbols: /[=><!~?&|+\-*\/\^;\.,]+/,
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, 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 // The main tokenizer for our languages
tokenizer: { tokenizer: {
root: [ root: [
[/^(\s*)(rem(?:\s.*|))$/, ['','comment']], [/^(\s*)(rem(?:\s.*|))$/, ['', 'comment']],
[/(\@?)(@keywords)(?!\w)/, [{token:'keyword'}, {token:'keyword.$2'}]], [/(\@?)(@keywords)(?!\w)/, [{ token: 'keyword' }, { token: 'keyword.$2' }]],
// whitespace // whitespace
[/[ \t\r\n]+/, ''], [/[ \t\r\n]+/, ''],
// blocks // blocks
[/setlocal(?!\w)/, 'keyword.tag-setlocal' ], [/setlocal(?!\w)/, 'keyword.tag-setlocal'],
[/endlocal(?!\w)/, 'keyword.tag-setlocal' ], [/endlocal(?!\w)/, 'keyword.tag-setlocal'],
// words // words
[/[a-zA-Z_]\w*/, ''], [/[a-zA-Z_]\w*/, ''],
@ -85,18 +85,27 @@ export var language = <ILanguage> {
[/[;,.]/, 'delimiter'], [/[;,.]/, 'delimiter'],
// strings: // strings:
[/"/, 'string', '@string."' ], [/"/, 'string', '@string."'],
[/'/, 'string', '@string.\''], [/'/, 'string', '@string.\''],
], ],
string: [ string: [
[/[^\\"'%]+/, { cases: { '@eos': {token:'string', next:'@popall'}, '@default': 'string' }}], [/[^\\"'%]+/, {
cases: {
'@eos': { token: 'string', next: '@popall' },
'@default': 'string'
}
}],
[/@escapes/, 'string.escape'], [/@escapes/, 'string.escape'],
[/\\./, 'string.escape.invalid'], [/\\./, 'string.escape.invalid'],
[/%[\w ]+%/, 'variable'], [/%[\w ]+%/, 'variable'],
[/%%[\w]+(?!\w)/, 'variable'], [/%%[\w]+(?!\w)/, 'variable'],
[/["']/, { cases: { '$#==$S2' : { token: 'string', next: '@pop' }, [/["']/, {
'@default': 'string' }} ], cases: {
'$#==$S2': { token: 'string', next: '@pop' },
'@default': 'string'
}
}],
[/$/, 'string', '@popall'] [/$/, 'string', '@popall']
], ],

View file

@ -8,16 +8,16 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#%\^\&\*\(\)\=\$\-\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g, wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#%\^\&\*\(\)\=\$\-\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
comments: { comments: {
blockComment: ['###', '###'], blockComment: ['###', '###'],
lineComment: '#' lineComment: '#'
}, },
brackets: [ brackets: [
['{','}'], ['{', '}'],
['[',']'], ['[', ']'],
['(',')'] ['(', ')']
], ],
autoClosingPairs: [ autoClosingPairs: [
{ open: '{', close: '}' }, { open: '{', close: '}' },
@ -33,22 +33,17 @@ export var conf:IRichLanguageConfiguration = {
{ open: '"', close: '"' }, { open: '"', close: '"' },
{ open: '\'', close: '\'' }, { open: '\'', close: '\'' },
] ]
// 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> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
ignoreCase: true, ignoreCase: true,
tokenPostfix: '.coffee', tokenPostfix: '.coffee',
brackets: [ brackets: [
{ open:'{', close:'}', token:'delimiter.curly'}, { open: '{', close: '}', token: 'delimiter.curly' },
{ open:'[', close:']', token:'delimiter.square'}, { open: '[', close: ']', token: 'delimiter.square' },
{ open:'(', close:')', token:'delimiter.parenthesis'} { open: '(', close: ')', token: 'delimiter.parenthesis' }
], ],
regEx: /\/(?!\/\/)(?:[^\/\\]|\\.)*\/[igm]*/, regEx: /\/(?!\/\/)(?:[^\/\\]|\\.)*\/[igm]*/,
@ -61,11 +56,11 @@ export var language = <ILanguage> {
'if', 'else', 'switch', 'for', 'while', 'do', 'try', 'catch', 'finally', 'if', 'else', 'switch', 'for', 'while', 'do', 'try', 'catch', 'finally',
'class', 'extends', 'super', 'class', 'extends', 'super',
'undefined', 'then', 'unless', 'until', 'loop', 'of', 'by', 'when' 'undefined', 'then', 'unless', 'until', 'loop', 'of', 'by', 'when'
], ],
// we include these common regular expressions // we include these common regular expressions
symbols: /[=><!~?&%|+\-*\/\^\.,\:]+/, symbols: /[=><!~?&%|+\-*\/\^\.,\:]+/,
escapes: /\\(?:[abfnrtv\\"'$]|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, 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 // The main tokenizer for our languages
tokenizer: { tokenizer: {
@ -73,10 +68,11 @@ export var language = <ILanguage> {
// identifiers and keywords // identifiers and keywords
[/\@[a-zA-Z_]\w*/, 'variable.predefined'], [/\@[a-zA-Z_]\w*/, 'variable.predefined'],
[/[a-zA-Z_]\w*/, { cases: { [/[a-zA-Z_]\w*/, {
'this': 'variable.predefined', cases: {
'@keywords': { token: 'keyword.$0' }, 'this': 'variable.predefined',
'@default': '' '@keywords': { token: 'keyword.$0' },
'@default': ''
} }
}], }],
@ -105,9 +101,12 @@ export var language = <ILanguage> {
// delimiters // delimiters
[/}/, { cases: { [/}/, {
'$S2==interpolatedstring' : { token: 'string', next: '@pop' } cases: {
, '@default' : '@brackets' } }], '$S2==interpolatedstring': { token: 'string', next: '@pop' },
'@default': '@brackets'
}
}],
[/[{}()\[\]]/, '@brackets'], [/[{}()\[\]]/, '@brackets'],
[/@symbols/, 'delimiter'], [/@symbols/, 'delimiter'],
@ -123,9 +122,19 @@ export var language = <ILanguage> {
// strings: // strings:
[/"""/, 'string', '@herestring."""'], [/"""/, 'string', '@herestring."""'],
[/'''/, 'string', '@herestring.\'\'\''], [/'''/, 'string', '@herestring.\'\'\''],
[/"/, { cases: { '@eos': 'string', '@default': {token:'string', next:'@string."'} }} ], [/"/, {
[/'/, { cases: { '@eos': 'string', '@default': {token:'string', next:'@string.\''} }} ], cases: {
'@eos': 'string',
'@default': { token: 'string', next: '@string."' }
}
}],
[/'/, {
cases: {
'@eos': 'string',
'@default': { token: 'string', next: '@string.\'' }
}
}],
], ],
string: [ string: [
@ -134,27 +143,42 @@ export var language = <ILanguage> {
[/\./, 'string.escape.invalid'], [/\./, 'string.escape.invalid'],
[/\./, 'string.escape.invalid'], [/\./, 'string.escape.invalid'],
[/#{/, { cases: { '$S2=="': { token: 'string', next: 'root.interpolatedstring' }, '@default': 'string' }}], [/#{/, {
cases: {
'$S2=="': { token: 'string', next: 'root.interpolatedstring' },
'@default': 'string'
}
}],
[/["']/, { cases: { '$#==$S2' : { token: 'string', next: '@pop' }, '@default': 'string' }} ], [/["']/, {
cases: {
'$#==$S2': { token: 'string', next: '@pop' },
'@default': 'string'
}
}],
[/#/, 'string'] [/#/, 'string']
], ],
herestring: [ herestring: [
[/("""|''')/, { cases: { '$1==$S2': { token: 'string', next: '@pop' }, '@default': 'string' } }], [/("""|''')/, {
[/[^#\\'"]+/,'string' ], cases: {
[/['"]+/,'string' ], '$1==$S2': { token: 'string', next: '@pop' },
'@default': 'string'
}
}],
[/[^#\\'"]+/, 'string'],
[/['"]+/, 'string'],
[/@escapes/, 'string.escape'], [/@escapes/, 'string.escape'],
[/\./, 'string.escape.invalid'], [/\./, 'string.escape.invalid'],
[/#{/, { token: 'string.quote', next: 'root.interpolatedstring' } ], [/#{/, { token: 'string.quote', next: 'root.interpolatedstring' }],
[/#/, 'string'] [/#/, 'string']
], ],
comment: [ comment: [
[/[^#]+/, 'comment', ], [/[^#]+/, 'comment',],
[/###/, 'comment', '@pop'], [/###/, 'comment', '@pop'],
[/#/, 'comment' ], [/#/, 'comment'],
], ],
hereregexp: [ hereregexp: [
@ -165,4 +189,4 @@ export var language = <ILanguage> {
[/\//, 'regexp'], [/\//, 'regexp'],
], ],
}, },
}; };

View file

@ -8,15 +8,15 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
comments: { comments: {
lineComment: '//', lineComment: '//',
blockComment: ['/*', '*/'], blockComment: ['/*', '*/'],
}, },
brackets: [ brackets: [
['{','}'], ['{', '}'],
['[',']'], ['[', ']'],
['(',')'] ['(', ')']
], ],
autoClosingPairs: [ autoClosingPairs: [
{ open: '[', close: ']' }, { open: '[', close: ']' },
@ -34,7 +34,7 @@ export var conf:IRichLanguageConfiguration = {
] ]
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.cpp', tokenPostfix: '.cpp',
@ -236,8 +236,8 @@ export var language = <ILanguage> {
], ],
// we include these common regular expressions // we include these common regular expressions
symbols: /[=><!~?:&|+\-*\/\^%]+/, symbols: /[=><!~?:&|+\-*\/\^%]+/,
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
integersuffix: /(ll|LL|u|U|l|L)?(ll|LL|u|U|l|L)?/, integersuffix: /(ll|LL|u|U|l|L)?(ll|LL|u|U|l|L)?/,
floatsuffix: /[fFlL]?/, floatsuffix: /[fFlL]?/,
@ -245,8 +245,12 @@ export var language = <ILanguage> {
tokenizer: { tokenizer: {
root: [ root: [
// identifiers and keywords // identifiers and keywords
[/[a-zA-Z_]\w*/, { cases: { '@keywords': {token:'keyword.$0'}, [/[a-zA-Z_]\w*/, {
'@default': 'identifier' } }], cases: {
'@keywords': { token: 'keyword.$0' },
'@default': 'identifier'
}
}],
// whitespace // whitespace
{ include: '@whitespace' }, { include: '@whitespace' },
@ -260,8 +264,12 @@ export var language = <ILanguage> {
// delimiters and operators // delimiters and operators
[/[{}()\[\]]/, '@brackets'], [/[{}()\[\]]/, '@brackets'],
[/[<>](?!@symbols)/, '@brackets'], [/[<>](?!@symbols)/, '@brackets'],
[/@symbols/, { cases: { '@operators': 'delimiter', [/@symbols/, {
'@default' : '' } } ], cases: {
'@operators': 'delimiter',
'@default': ''
}
}],
// numbers // numbers
[/\d*\d+[eE]([\-+]?\d+)?(@floatsuffix)/, 'number.float'], [/\d*\d+[eE]([\-+]?\d+)?(@floatsuffix)/, 'number.float'],
@ -276,39 +284,39 @@ export var language = <ILanguage> {
[/[;,.]/, 'delimiter'], [/[;,.]/, 'delimiter'],
// strings // strings
[/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
[/"/, 'string', '@string' ], [/"/, 'string', '@string'],
// characters // characters
[/'[^\\']'/, 'string'], [/'[^\\']'/, 'string'],
[/(')(@escapes)(')/, ['string','string.escape','string']], [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
[/'/, 'string.invalid'] [/'/, 'string.invalid']
], ],
whitespace: [ whitespace: [
[/[ \t\r\n]+/, ''], [/[ \t\r\n]+/, ''],
[/\/\*\*(?!\/)/, 'comment.doc', '@doccomment' ], [/\/\*\*(?!\/)/, 'comment.doc', '@doccomment'],
[/\/\*/, 'comment', '@comment' ], [/\/\*/, 'comment', '@comment'],
[/\/\/.*$/, 'comment'], [/\/\/.*$/, 'comment'],
], ],
comment: [ comment: [
[/[^\/*]+/, 'comment' ], [/[^\/*]+/, 'comment'],
[/\*\//, 'comment', '@pop' ], [/\*\//, 'comment', '@pop'],
[/[\/*]/, 'comment' ] [/[\/*]/, 'comment']
], ],
//Identical copy of comment above, except for the addition of .doc //Identical copy of comment above, except for the addition of .doc
doccomment: [ doccomment: [
[/[^\/*]+/, 'comment.doc' ], [/[^\/*]+/, 'comment.doc'],
[/\*\//, 'comment.doc', '@pop' ], [/\*\//, 'comment.doc', '@pop'],
[/[\/*]/, 'comment.doc' ] [/[\/*]/, 'comment.doc']
], ],
string: [ string: [
[/[^\\"]+/, 'string'], [/[^\\"]+/, 'string'],
[/@escapes/, 'string.escape'], [/@escapes/, 'string.escape'],
[/\\./, 'string.escape.invalid'], [/\\./, 'string.escape.invalid'],
[/"/, 'string', '@pop' ] [/"/, 'string', '@pop']
], ],
}, },
}; };

View file

@ -8,16 +8,16 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g, wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
comments: { comments: {
lineComment: '//', lineComment: '//',
blockComment: ['/*', '*/'], blockComment: ['/*', '*/'],
}, },
brackets: [ brackets: [
['{','}'], ['{', '}'],
['[',']'], ['[', ']'],
['(',')'], ['(', ')'],
], ],
autoClosingPairs: [ autoClosingPairs: [
{ open: '{', close: '}' }, { open: '{', close: '}' },
@ -36,7 +36,7 @@ export var conf:IRichLanguageConfiguration = {
] ]
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.cs', tokenPostfix: '.cs',
@ -61,9 +61,9 @@ export var language = <ILanguage> {
'internal', 'private', 'abstract', 'sealed', 'static', 'struct', 'readonly', 'internal', 'private', 'abstract', 'sealed', 'static', 'struct', 'readonly',
'volatile', 'virtual', 'override', 'params', 'get', 'set', 'add', 'remove', 'volatile', 'virtual', 'override', 'params', 'get', 'set', 'add', 'remove',
'operator', 'true', 'false', 'implicit', 'explicit', 'interface', 'enum', 'operator', 'true', 'false', 'implicit', 'explicit', 'interface', 'enum',
'null', 'async', 'await','fixed','sizeof','stackalloc','unsafe', 'nameof', 'null', 'async', 'await', 'fixed', 'sizeof', 'stackalloc', 'unsafe', 'nameof',
'when' 'when'
], ],
namespaceFollows: [ namespaceFollows: [
'namespace', 'using', 'namespace', 'using',
@ -75,11 +75,11 @@ export var language = <ILanguage> {
operators: [ operators: [
'=', '??', '||', '&&', '|', '^', '&', '==', '!=', '<=', '>=', '<<', '=', '??', '||', '&&', '|', '^', '&', '==', '!=', '<=', '>=', '<<',
'+', '-', '*', '/', '%', '!', '~', '++', '--','+=', '+', '-', '*', '/', '%', '!', '~', '++', '--', '+=',
'-=', '*=', '/=', '%=', '&=', '|=', '^=', '<<=', '>>=', '>>', '=>' '-=', '*=', '/=', '%=', '&=', '|=', '^=', '<<=', '>>=', '>>', '=>'
], ],
symbols: /[=><!~?:&|+\-*\/\^%]+/, symbols: /[=><!~?:&|+\-*\/\^%]+/,
// escape sequences // escape sequences
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
@ -89,10 +89,11 @@ export var language = <ILanguage> {
root: [ root: [
// identifiers and keywords // identifiers and keywords
[/\@?[a-zA-Z_]\w*/, { cases: { [/\@?[a-zA-Z_]\w*/, {
'@namespaceFollows': { token: 'keyword.$0', next: '@namespace' }, cases: {
'@keywords': { token: 'keyword.$0', next: '@qualified' }, '@namespaceFollows': { token: 'keyword.$0', next: '@namespace' },
'@default': { token: 'identifier', next: '@qualified' } '@keywords': { token: 'keyword.$0', next: '@qualified' },
'@default': { token: 'identifier', next: '@qualified' }
} }
}], }],
@ -100,13 +101,21 @@ export var language = <ILanguage> {
{ include: '@whitespace' }, { include: '@whitespace' },
// delimiters and operators // delimiters and operators
[/}/, { cases: { [/}/, {
'$S2==interpolatedstring' : { token: 'string.quote', next: '@pop' } cases: {
, '$S2==litinterpstring' : { token: 'string.quote', next: '@pop' } '$S2==interpolatedstring': { token: 'string.quote', next: '@pop' },
, '@default' : '@brackets' } }], '$S2==litinterpstring': { token: 'string.quote', next: '@pop' },
'@default': '@brackets'
}
}],
[/[{}()\[\]]/, '@brackets'], [/[{}()\[\]]/, '@brackets'],
[/[<>](?!@symbols)/, '@brackets'], [/[<>](?!@symbols)/, '@brackets'],
[/@symbols/, { cases: { '@operators': 'delimiter', '@default' : '' } } ], [/@symbols/, {
cases: {
'@operators': 'delimiter',
'@default': ''
}
}],
// numbers // numbers
@ -119,79 +128,81 @@ export var language = <ILanguage> {
[/[;,.]/, 'delimiter'], [/[;,.]/, 'delimiter'],
// strings // strings
[/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
[/"/, { token: 'string.quote', next: '@string' } ], [/"/, { token: 'string.quote', next: '@string' }],
[/\$\@"/, { token: 'string.quote', next: '@litinterpstring' } ], [/\$\@"/, { token: 'string.quote', next: '@litinterpstring' }],
[/\@"/, { token: 'string.quote', next: '@litstring' } ], [/\@"/, { token: 'string.quote', next: '@litstring' }],
[/\$"/, { token: 'string.quote', next: '@interpolatedstring' } ], [/\$"/, { token: 'string.quote', next: '@interpolatedstring' }],
// characters // characters
[/'[^\\']'/, 'string'], [/'[^\\']'/, 'string'],
[/(')(@escapes)(')/, ['string','string.escape','string']], [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
[/'/, 'string.invalid'] [/'/, 'string.invalid']
], ],
qualified: [ qualified: [
[/[a-zA-Z_][\w]*/, { cases: [/[a-zA-Z_][\w]*/, {
{ '@keywords': {token:'keyword.$0'}, cases: {
'@default': 'identifier' } '@keywords': { token: 'keyword.$0' },
'@default': 'identifier'
}
}], }],
[/\./, 'delimiter'], [/\./, 'delimiter'],
['','','@pop'], ['', '', '@pop'],
], ],
namespace: [ namespace: [
{ include: '@whitespace' }, { include: '@whitespace' },
[/[A-Z]\w*/, 'namespace'], [/[A-Z]\w*/, 'namespace'],
[/[\.=]/, 'delimiter'], [/[\.=]/, 'delimiter'],
['','','@pop'], ['', '', '@pop'],
], ],
comment: [ comment: [
[/[^\/*]+/, 'comment' ], [/[^\/*]+/, 'comment'],
// [/\/\*/, 'comment', '@push' ], // no nested comments :-( // [/\/\*/, 'comment', '@push' ], // no nested comments :-(
['\\*/', 'comment', '@pop' ], ['\\*/', 'comment', '@pop'],
[/[\/*]/, 'comment' ] [/[\/*]/, 'comment']
], ],
string: [ string: [
[/[^\\"]+/, 'string'], [/[^\\"]+/, 'string'],
[/@escapes/, 'string.escape'], [/@escapes/, 'string.escape'],
[/\\./, 'string.escape.invalid'], [/\\./, 'string.escape.invalid'],
[/"/, { token: 'string.quote', next: '@pop' } ] [/"/, { token: 'string.quote', next: '@pop' }]
], ],
litstring: [ litstring: [
[/[^"]+/, 'string'], [/[^"]+/, 'string'],
[/""/, 'string.escape'], [/""/, 'string.escape'],
[/"/, { token: 'string.quote', next: '@pop' } ] [/"/, { token: 'string.quote', next: '@pop' }]
], ],
litinterpstring: [ litinterpstring: [
[/[^"{]+/, 'string'], [/[^"{]+/, 'string'],
[/""/, 'string.escape'], [/""/, 'string.escape'],
[/{{/, 'string.escape'], [/{{/, 'string.escape'],
[/}}/, 'string.escape'], [/}}/, 'string.escape'],
[/{/, { token: 'string.quote', next: 'root.litinterpstring' } ], [/{/, { token: 'string.quote', next: 'root.litinterpstring' }],
[/"/, { token: 'string.quote', next: '@pop' } ] [/"/, { token: 'string.quote', next: '@pop' }]
], ],
interpolatedstring: [ interpolatedstring: [
[/[^\\"{]+/, 'string'], [/[^\\"{]+/, 'string'],
[/@escapes/, 'string.escape'], [/@escapes/, 'string.escape'],
[/\\./, 'string.escape.invalid'], [/\\./, 'string.escape.invalid'],
[/{{/, 'string.escape'], [/{{/, 'string.escape'],
[/}}/, 'string.escape'], [/}}/, 'string.escape'],
[/{/, { token: 'string.quote', next: 'root.interpolatedstring' } ], [/{/, { token: 'string.quote', next: 'root.interpolatedstring' }],
[/"/, { token: 'string.quote', next: '@pop' } ] [/"/, { token: 'string.quote', next: '@pop' }]
], ],
whitespace: [ whitespace: [
[/^[ \t\v\f]*#((r)|(load))(?=\s)/, 'directive.csx' ], [/^[ \t\v\f]*#((r)|(load))(?=\s)/, 'directive.csx'],
[/^[ \t\v\f]*#\w.*$/, 'namespace.cpp' ], [/^[ \t\v\f]*#\w.*$/, 'namespace.cpp'],
[/[ \t\v\f\r\n]+/, ''], [/[ \t\v\f\r\n]+/, ''],
[/\/\*/, 'comment', '@comment' ], [/\/\*/, 'comment', '@comment'],
[/\/\/.*$/, 'comment'], [/\/\/.*$/, 'comment'],
], ],
}, },
}; };

View file

@ -8,7 +8,7 @@
import LanguageConfiguration = monaco.languages.LanguageConfiguration; import LanguageConfiguration = monaco.languages.LanguageConfiguration;
import IMonarchLanguage = monaco.languages.IMonarchLanguage; import IMonarchLanguage = monaco.languages.IMonarchLanguage;
export var conf:LanguageConfiguration = { export var conf: LanguageConfiguration = {
wordPattern: /(#?-?\d*\.\d\w*%?)|((::|[@#.!:])?[\w-?]+%?)|::|[@#.!:]/g, wordPattern: /(#?-?\d*\.\d\w*%?)|((::|[@#.!:])?[\w-?]+%?)|::|[@#.!:]/g,
comments: { comments: {
@ -44,7 +44,7 @@ const TOKEN_PROPERTY = 'attribute.name';
const TOKEN_VALUE = 'attribute.value'; const TOKEN_VALUE = 'attribute.value';
const TOKEN_AT_KEYWORD = 'keyword'; const TOKEN_AT_KEYWORD = 'keyword';
export var language = <IMonarchLanguage> { export var language = <IMonarchLanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.css', tokenPostfix: '.css',
@ -70,8 +70,8 @@ export var language = <IMonarchLanguage> {
['[@](keyframes|-webkit-keyframes|-moz-keyframes|-o-keyframes)', { token: TOKEN_AT_KEYWORD, next: '@keyframedeclaration' }], ['[@](keyframes|-webkit-keyframes|-moz-keyframes|-o-keyframes)', { token: TOKEN_AT_KEYWORD, next: '@keyframedeclaration' }],
['[@](page|content|font-face|-moz-document)', { token: TOKEN_AT_KEYWORD }], ['[@](page|content|font-face|-moz-document)', { token: TOKEN_AT_KEYWORD }],
['[@](charset|namespace)', { token: TOKEN_AT_KEYWORD, next: '@declarationbody' }], ['[@](charset|namespace)', { token: TOKEN_AT_KEYWORD, next: '@declarationbody' }],
['(url-prefix)(\\()', ['attribute.value', { token: 'delimiter.parenthesis', next: '@urldeclaration' }] ], ['(url-prefix)(\\()', ['attribute.value', { token: 'delimiter.parenthesis', next: '@urldeclaration' }]],
['(url)(\\()', ['attribute.value', { token: 'delimiter.parenthesis', next: '@urldeclaration' }] ], ['(url)(\\()', ['attribute.value', { token: 'delimiter.parenthesis', next: '@urldeclaration' }]],
{ include: '@selectorname' }, { include: '@selectorname' },
['[\\*]', TOKEN_SELECTOR_TAG], // selector symbols ['[\\*]', TOKEN_SELECTOR_TAG], // selector symbols
['[>\\+,]', 'delimiter'], // selector operators ['[>\\+,]', 'delimiter'], // selector operators
@ -96,8 +96,8 @@ export var language = <IMonarchLanguage> {
term: [ term: [
{ include: '@comments' }, { include: '@comments' },
['(url-prefix)(\\()', ['attribute.value', { token: 'delimiter.parenthesis', next: '@urldeclaration' }] ], ['(url-prefix)(\\()', ['attribute.value', { token: 'delimiter.parenthesis', next: '@urldeclaration' }]],
['(url)(\\()', ['attribute.value', { token: 'delimiter.parenthesis', next: '@urldeclaration' }] ], ['(url)(\\()', ['attribute.value', { token: 'delimiter.parenthesis', next: '@urldeclaration' }]],
{ include: '@functioninvocation' }, { include: '@functioninvocation' },
{ include: '@numbers' }, { include: '@numbers' },
{ include: '@name' }, { include: '@name' },
@ -204,4 +204,4 @@ export var language = <IMonarchLanguage> {
['.', 'string'] ['.', 'string']
] ]
} }
}; };

View file

@ -8,11 +8,11 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
brackets: [ brackets: [
['{','}'], ['{', '}'],
['[',']'], ['[', ']'],
['(',')'] ['(', ')']
], ],
autoClosingPairs: [ autoClosingPairs: [
{ open: '{', close: '}' }, { open: '{', close: '}' },
@ -40,68 +40,98 @@ export var language = <ILanguage>{
variableAfter: /ENV/, variableAfter: /ENV/,
variable:/\${?[\w]+}?/, variable: /\${?[\w]+}?/,
tokenizer: { tokenizer: {
root: [ root: [
{ include: '@whitespace' }, { include: '@whitespace' },
{ include: '@comment' }, { include: '@comment' },
[/(@instructionAfter)(\s+)/, ['keyword', { token: '', next: '@instructions' }]], [/(@instructionAfter)(\s+)/, ['keyword', { token: '', next: '@instructions' }]],
['', 'keyword', '@instructions'] ['', 'keyword', '@instructions']
], ],
instructions: [ instructions: [
[/(@variableAfter)(\s+)([\w]+)/, ['keyword', '',{token:'variable', next:'@arguments'}]], [/(@variableAfter)(\s+)([\w]+)/, ['keyword', '', { token: 'variable', next: '@arguments' }]],
[/(@instructions)/, 'keyword', '@arguments'] [/(@instructions)/, 'keyword', '@arguments']
], ],
arguments: [ arguments: [
{ include: '@whitespace' }, { include: '@whitespace' },
{ include: '@strings' }, { include: '@strings' },
[/(@variable)/, { cases: { '@eos': {token:'variable', next:'@popall'}, '@default': 'variable' }} ], [/(@variable)/, {
[/\\/, { cases: { '@eos': '', '@default': '' }}], cases: {
[/./, { cases: { '@eos': {token:'', next:'@popall'}, '@default': '' } }], '@eos': { token: 'variable', next: '@popall' },
], '@default': 'variable'
}
}],
[/\\/, {
cases: {
'@eos': '',
'@default': ''
}
}],
[/./, {
cases: {
'@eos': { token: '', next: '@popall' },
'@default': ''
}
}],
],
// Deal with white space, including comments // Deal with white space, including comments
whitespace: [ whitespace: [
[/\s+/, { cases: { '@eos': {token:'', next:'@popall'}, '@default': '' }}], [/\s+/, {
], cases: {
'@eos': { token: '', next: '@popall' },
'@default': ''
}
}],
],
comment: [ comment: [
[/(^#.*$)/, 'comment', '@popall'] [/(^#.*$)/, 'comment', '@popall']
], ],
// Recognize strings, including those broken across lines with \ (but not without) // Recognize strings, including those broken across lines with \ (but not without)
strings: [ strings: [
[/'$/, 'string', '@popall'], [/'$/, 'string', '@popall'],
[/'/, 'string', '@stringBody'], [/'/, 'string', '@stringBody'],
[/"$/, 'string', '@popall'], [/"$/, 'string', '@popall'],
[/"/, 'string', '@dblStringBody'] [/"/, 'string', '@dblStringBody']
], ],
stringBody: [ stringBody: [
[/[^\\\$']/, { cases: { '@eos': {token:'string', next:'@popall'}, '@default': 'string' }}], [/[^\\\$']/, {
cases: {
'@eos': { token: 'string', next: '@popall' },
'@default': 'string'
}
}],
[/\\./, 'string.escape'], [/\\./, 'string.escape'],
[/'$/, 'string', '@popall'], [/'$/, 'string', '@popall'],
[/'/, 'string', '@pop'], [/'/, 'string', '@pop'],
[/(@variable)/, 'variable' ], [/(@variable)/, 'variable'],
[/\\$/, 'string'], [/\\$/, 'string'],
[/$/, 'string', '@popall'] [/$/, 'string', '@popall']
], ],
dblStringBody: [ dblStringBody: [
[/[^\\\$"]/, { cases: { '@eos': {token:'string', next:'@popall'}, '@default': 'string' }}], [/[^\\\$"]/, {
cases: {
'@eos': { token: 'string', next: '@popall' },
'@default': 'string'
}
}],
[/\\./, 'string.escape'], [/\\./, 'string.escape'],
[/"$/, 'string', '@popall'], [/"$/, 'string', '@popall'],
[/"/, 'string', '@pop'], [/"/, 'string', '@pop'],
[/(@variable)/, 'variable' ], [/(@variable)/, 'variable'],
[/\\$/, 'string'], [/\\$/, 'string'],
[/$/, 'string', '@popall'] [/$/, 'string', '@popall']
] ]
} }
}; };

View file

@ -8,15 +8,15 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
comments: { comments: {
lineComment: '//', lineComment: '//',
blockComment: ['(*', '*)'], blockComment: ['(*', '*)'],
}, },
brackets: [ brackets: [
['{','}'], ['{', '}'],
['[',']'], ['[', ']'],
['(',')'] ['(', ')']
], ],
autoClosingPairs: [ autoClosingPairs: [
{ open: '{', close: '}' }, { open: '{', close: '}' },
@ -33,7 +33,7 @@ export var conf:IRichLanguageConfiguration = {
] ]
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.fs', tokenPostfix: '.fs',
@ -43,15 +43,15 @@ export var language = <ILanguage> {
'break', 'checked', 'component', 'break', 'checked', 'component',
'const', 'constraint', 'constructor', 'const', 'constraint', 'constructor',
'continue', 'class', 'default', 'continue', 'class', 'default',
'delegate','do', 'done', 'downcast', 'delegate', 'do', 'done', 'downcast',
'downto', 'elif', 'else', 'end', 'downto', 'elif', 'else', 'end',
'exception', 'eager', 'event', 'external', 'exception', 'eager', 'event', 'external',
'extern', 'false', 'finally', 'for', 'extern', 'false', 'finally', 'for',
'fun', 'function', 'fixed', 'functor', 'fun', 'function', 'fixed', 'functor',
'global', 'if', 'in', 'include', 'inherit', 'global', 'if', 'in', 'include', 'inherit',
'inline', 'interface', 'internal', 'land', 'inline', 'interface', 'internal', 'land',
'lor', 'lsl','lsr', 'lxor', 'lazy', 'let', 'lor', 'lsl', 'lsr', 'lxor', 'lazy', 'let',
'match', 'member','mod','module', 'mutable', 'match', 'member', 'mod', 'module', 'mutable',
'namespace', 'method', 'mixin', 'new', 'not', 'namespace', 'method', 'mixin', 'new', 'not',
'null', 'of', 'open', 'or', 'object', 'null', 'of', 'open', 'or', 'object',
'override', 'private', 'parallel', 'process', 'override', 'private', 'parallel', 'process',
@ -60,12 +60,12 @@ export var language = <ILanguage> {
'to', 'true', 'tailcall', 'trait', 'to', 'true', 'tailcall', 'trait',
'try', 'type', 'upcast', 'use', 'try', 'type', 'upcast', 'use',
'val', 'void', 'virtual', 'volatile', 'val', 'void', 'virtual', 'volatile',
'when', 'while','with', 'yield' 'when', 'while', 'with', 'yield'
], ],
// we include these common regular expressions // we include these common regular expressions
symbols: /[=><!~?:&|+\-*\^%;\.,\/]+/, symbols: /[=><!~?:&|+\-*\^%;\.,\/]+/,
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
integersuffix: /[uU]?[yslnLI]?/, integersuffix: /[uU]?[yslnLI]?/,
floatsuffix: /[fFmM]?/, floatsuffix: /[fFmM]?/,
@ -73,8 +73,12 @@ export var language = <ILanguage> {
tokenizer: { tokenizer: {
root: [ root: [
// identifiers and keywords // identifiers and keywords
[/[a-zA-Z_]\w*/, { cases: { '@keywords': {token:'keyword.$0'}, [/[a-zA-Z_]\w*/, {
'@default': 'identifier' } }], cases: {
'@keywords': { token: 'keyword.$0' },
'@default': 'identifier'
}
}],
// whitespace // whitespace
{ include: '@whitespace' }, { include: '@whitespace' },
@ -88,7 +92,7 @@ export var language = <ILanguage> {
// delimiters and operators // delimiters and operators
[/[{}()\[\]]/, '@brackets'], [/[{}()\[\]]/, '@brackets'],
[/[<>](?!@symbols)/, '@brackets'], [/[<>](?!@symbols)/, '@brackets'],
[/@symbols/, 'delimiter' ], [/@symbols/, 'delimiter'],
// numbers // numbers
[/\d*\d+[eE]([\-+]?\d+)?(@floatsuffix)/, 'number.float'], [/\d*\d+[eE]([\-+]?\d+)?(@floatsuffix)/, 'number.float'],
@ -102,43 +106,47 @@ export var language = <ILanguage> {
[/[;,.]/, 'delimiter'], [/[;,.]/, 'delimiter'],
// strings // strings
[/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
[/"""/, 'string', '@string."""'], [/"""/, 'string', '@string."""'],
[/"/, 'string', '@string."' ], [/"/, 'string', '@string."'],
// literal string // literal string
[/\@"/, { token: 'string.quote', next: '@litstring' }], [/\@"/, { token: 'string.quote', next: '@litstring' }],
// characters // characters
[/'[^\\']'B?/, 'string'], [/'[^\\']'B?/, 'string'],
[/(')(@escapes)(')/, ['string','string.escape','string']], [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
[/'/, 'string.invalid'] [/'/, 'string.invalid']
], ],
whitespace: [ whitespace: [
[/[ \t\r\n]+/, ''], [/[ \t\r\n]+/, ''],
[/\(\*/, 'comment', '@comment' ], [/\(\*/, 'comment', '@comment'],
[/\/\/.*$/, 'comment'], [/\/\/.*$/, 'comment'],
], ],
comment: [ comment: [
[/[^\*]+/, 'comment' ], [/[^\*]+/, 'comment'],
[/\*\)/, 'comment', '@pop' ], [/\*\)/, 'comment', '@pop'],
[/\*/, 'comment' ] [/\*/, 'comment']
], ],
string: [ string: [
[/[^\\"]+/, 'string'], [/[^\\"]+/, 'string'],
[/@escapes/, 'string.escape'], [/@escapes/, 'string.escape'],
[/\\./, 'string.escape.invalid'], [/\\./, 'string.escape.invalid'],
[/("""|"B?)/, { cases: { '$#==$S2' : { token: 'string', next: '@pop' }, [/("""|"B?)/, {
'@default': 'string' }} ] cases: {
'$#==$S2': { token: 'string', next: '@pop' },
'@default': 'string'
}
}]
], ],
litstring: [ litstring: [
[/[^"]+/, 'string'], [/[^"]+/, 'string'],
[/""/, 'string.escape'], [/""/, 'string.escape'],
[/"/, { token: 'string.quote', next: '@pop' } ] [/"/, { token: 'string.quote', next: '@pop' }]
], ],
}, },
}; };

View file

@ -8,15 +8,15 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
comments: { comments: {
lineComment: '//', lineComment: '//',
blockComment: ['/*', '*/'], blockComment: ['/*', '*/'],
}, },
brackets: [ brackets: [
['{','}'], ['{', '}'],
['[',']'], ['[', ']'],
['(',')'] ['(', ')']
], ],
autoClosingPairs: [ autoClosingPairs: [
{ open: '{', close: '}' }, { open: '{', close: '}' },
@ -36,7 +36,7 @@ export var conf:IRichLanguageConfiguration = {
] ]
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.go', tokenPostfix: '.go',
@ -99,16 +99,20 @@ export var language = <ILanguage> {
], ],
// we include these common regular expressions // we include these common regular expressions
symbols: /[=><!~?:&|+\-*\/\^%]+/, symbols: /[=><!~?:&|+\-*\/\^%]+/,
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, 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 // The main tokenizer for our languages
tokenizer: { tokenizer: {
root: [ root: [
// identifiers and keywords // identifiers and keywords
[/[a-zA-Z_]\w*/, { cases: { '@keywords': {token:'keyword.$0'}, [/[a-zA-Z_]\w*/, {
'@default': 'identifier' } }], cases: {
'@keywords': { token: 'keyword.$0' },
'@default': 'identifier'
}
}],
// whitespace // whitespace
{ include: '@whitespace' }, { include: '@whitespace' },
@ -122,8 +126,12 @@ export var language = <ILanguage> {
// delimiters and operators // delimiters and operators
[/[{}()\[\]]/, '@brackets'], [/[{}()\[\]]/, '@brackets'],
[/[<>](?!@symbols)/, '@brackets'], [/[<>](?!@symbols)/, '@brackets'],
[/@symbols/, { cases: { '@operators': 'delimiter', [/@symbols/, {
'@default' : '' } } ], cases: {
'@operators': 'delimiter',
'@default': ''
}
}],
// numbers // numbers
[/\d*\d+[eE]([\-+]?\d+)?/, 'number.float'], [/\d*\d+[eE]([\-+]?\d+)?/, 'number.float'],
@ -138,44 +146,44 @@ export var language = <ILanguage> {
[/[;,.]/, 'delimiter'], [/[;,.]/, 'delimiter'],
// strings // strings
[/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
[/"/, 'string', '@string' ], [/"/, 'string', '@string'],
[/`/, "string", "@rawstring"], [/`/, "string", "@rawstring"],
// characters // characters
[/'[^\\']'/, 'string'], [/'[^\\']'/, 'string'],
[/(')(@escapes)(')/, ['string','string.escape','string']], [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
[/'/, 'string.invalid'] [/'/, 'string.invalid']
], ],
whitespace: [ whitespace: [
[/[ \t\r\n]+/, ''], [/[ \t\r\n]+/, ''],
[/\/\*\*(?!\/)/, 'comment.doc', '@doccomment' ], [/\/\*\*(?!\/)/, 'comment.doc', '@doccomment'],
[/\/\*/, 'comment', '@comment' ], [/\/\*/, 'comment', '@comment'],
[/\/\/.*$/, 'comment'], [/\/\/.*$/, 'comment'],
], ],
comment: [ comment: [
[/[^\/*]+/, 'comment' ], [/[^\/*]+/, 'comment'],
// [/\/\*/, 'comment', '@push' ], // nested comment not allowed :-( // [/\/\*/, 'comment', '@push' ], // nested comment not allowed :-(
// [/\/\*/, 'comment.invalid' ], // this breaks block comments in the shape of /* //*/ // [/\/\*/, 'comment.invalid' ], // this breaks block comments in the shape of /* //*/
[/\*\//, 'comment', '@pop' ], [/\*\//, 'comment', '@pop'],
[/[\/*]/, 'comment' ] [/[\/*]/, 'comment']
], ],
//Identical copy of comment above, except for the addition of .doc //Identical copy of comment above, except for the addition of .doc
doccomment: [ doccomment: [
[/[^\/*]+/, 'comment.doc' ], [/[^\/*]+/, 'comment.doc'],
// [/\/\*/, 'comment.doc', '@push' ], // nested comment not allowed :-( // [/\/\*/, 'comment.doc', '@push' ], // nested comment not allowed :-(
[/\/\*/, 'comment.doc.invalid' ], [/\/\*/, 'comment.doc.invalid'],
[/\*\//, 'comment.doc', '@pop' ], [/\*\//, 'comment.doc', '@pop'],
[/[\/*]/, 'comment.doc' ] [/[\/*]/, 'comment.doc']
], ],
string: [ string: [
[/[^\\"]+/, 'string'], [/[^\\"]+/, 'string'],
[/@escapes/, 'string.escape'], [/@escapes/, 'string.escape'],
[/\\./, 'string.escape.invalid'], [/\\./, 'string.escape.invalid'],
[/"/, 'string', '@pop' ] [/"/, 'string', '@pop']
], ],
rawstring: [ rawstring: [
@ -183,4 +191,4 @@ export var language = <ILanguage> {
[/`/, "string", "@pop"] [/`/, "string", "@pop"]
], ],
}, },
}; };

View file

@ -11,9 +11,9 @@ import ILanguage = monaco.languages.IMonarchLanguage;
// Allow for running under nodejs/requirejs in tests // Allow for running under nodejs/requirejs in tests
var _monaco: typeof monaco = (typeof monaco === 'undefined' ? (<any>self).monaco : monaco); var _monaco: typeof monaco = (typeof monaco === 'undefined' ? (<any>self).monaco : monaco);
const EMPTY_ELEMENTS:string[] = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']; const EMPTY_ELEMENTS: string[] = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr'];
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\s]+)/g, wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\s]+)/g,
comments: { comments: {
@ -65,7 +65,7 @@ export const htmlTokenTypes = {
} }
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '', tokenPostfix: '',
// ignoreCase: true, // ignoreCase: true,
@ -77,9 +77,9 @@ export var language = <ILanguage> {
[/<!DOCTYPE/, 'metatag.html', '@doctype'], [/<!DOCTYPE/, 'metatag.html', '@doctype'],
[/<!--/, 'comment.html', '@comment'], [/<!--/, 'comment.html', '@comment'],
[/(<)(\w+)(\/>)/, [htmlTokenTypes.DELIM_START, 'tag.html', htmlTokenTypes.DELIM_END]], [/(<)(\w+)(\/>)/, [htmlTokenTypes.DELIM_START, 'tag.html', htmlTokenTypes.DELIM_END]],
[/(<)(script)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@script'} ]], [/(<)(script)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@script' }]],
[/(<)(style)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@style'} ]], [/(<)(style)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@style' }]],
[/(<)([:\w]+)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@otherTag'} ]], [/(<)([:\w]+)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@otherTag' }]],
[/(<\/)(\w+)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@otherTag' }]], [/(<\/)(\w+)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@otherTag' }]],
[/</, htmlTokenTypes.DELIM_START], [/</, htmlTokenTypes.DELIM_START],
[/\{/, htmlTokenTypes.DELIM_START], [/\{/, htmlTokenTypes.DELIM_START],
@ -88,8 +88,8 @@ export var language = <ILanguage> {
doctype: [ doctype: [
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.comment' }], [/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.comment' }],
[/[^>]+/, 'metatag.content.html' ], [/[^>]+/, 'metatag.content.html'],
[/>/, 'metatag.html', '@pop' ], [/>/, 'metatag.html', '@pop'],
], ],
comment: [ comment: [
@ -119,15 +119,15 @@ export var language = <ILanguage> {
[/'([^']*)'/, 'attribute.value'], [/'([^']*)'/, 'attribute.value'],
[/[\w\-]+/, 'attribute.name'], [/[\w\-]+/, 'attribute.name'],
[/=/, 'delimiter'], [/=/, 'delimiter'],
[/>/, { token: htmlTokenTypes.DELIM_END, next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript'} ], [/>/, { token: htmlTokenTypes.DELIM_END, next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript' }],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/(<\/)(script\s*)(>)/, [ htmlTokenTypes.DELIM_START, 'tag.html', { token: htmlTokenTypes.DELIM_END, next: '@pop' } ]] [/(<\/)(script\s*)(>)/, [htmlTokenTypes.DELIM_START, 'tag.html', { token: htmlTokenTypes.DELIM_END, next: '@pop' }]]
], ],
// After <script ... type // After <script ... type
scriptAfterType: [ scriptAfterType: [
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.scriptAfterType' }], [/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.scriptAfterType' }],
[/=/,'delimiter', '@scriptAfterTypeEquals'], [/=/, 'delimiter', '@scriptAfterTypeEquals'],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }] [/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
], ],
@ -135,8 +135,8 @@ export var language = <ILanguage> {
// After <script ... type = // After <script ... type =
scriptAfterTypeEquals: [ scriptAfterTypeEquals: [
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.scriptAfterTypeEquals' }], [/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.scriptAfterTypeEquals' }],
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' } ], [/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' } ], [/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }] [/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
], ],
@ -144,7 +144,7 @@ export var language = <ILanguage> {
// After <script ... type = $S2 // After <script ... type = $S2
scriptWithCustomType: [ scriptWithCustomType: [
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.scriptWithCustomType.$S2' }], [/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.scriptWithCustomType.$S2' }],
[/>/, { token: htmlTokenTypes.DELIM_END, next: '@scriptEmbedded.$S2', nextEmbedded: '$S2'}], [/>/, { token: htmlTokenTypes.DELIM_END, next: '@scriptEmbedded.$S2', nextEmbedded: '$S2' }],
[/"([^"]*)"/, 'attribute.value'], [/"([^"]*)"/, 'attribute.value'],
[/'([^']*)'/, 'attribute.value'], [/'([^']*)'/, 'attribute.value'],
[/[\w\-]+/, 'attribute.name'], [/[\w\-]+/, 'attribute.name'],
@ -171,15 +171,15 @@ export var language = <ILanguage> {
[/'([^']*)'/, 'attribute.value'], [/'([^']*)'/, 'attribute.value'],
[/[\w\-]+/, 'attribute.name'], [/[\w\-]+/, 'attribute.name'],
[/=/, 'delimiter'], [/=/, 'delimiter'],
[/>/, { token: htmlTokenTypes.DELIM_END, next: '@styleEmbedded.text/css', nextEmbedded: 'text/css'} ], [/>/, { token: htmlTokenTypes.DELIM_END, next: '@styleEmbedded.text/css', nextEmbedded: 'text/css' }],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/(<\/)(style\s*)(>)/, [htmlTokenTypes.DELIM_START, 'tag.html', { token: htmlTokenTypes.DELIM_END, next: '@pop' } ]] [/(<\/)(style\s*)(>)/, [htmlTokenTypes.DELIM_START, 'tag.html', { token: htmlTokenTypes.DELIM_END, next: '@pop' }]]
], ],
// After <style ... type // After <style ... type
styleAfterType: [ styleAfterType: [
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.styleAfterType' }], [/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.styleAfterType' }],
[/=/,'delimiter', '@styleAfterTypeEquals'], [/=/, 'delimiter', '@styleAfterTypeEquals'],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }] [/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
], ],
@ -187,8 +187,8 @@ export var language = <ILanguage> {
// After <style ... type = // After <style ... type =
styleAfterTypeEquals: [ styleAfterTypeEquals: [
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.styleAfterTypeEquals' }], [/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.styleAfterTypeEquals' }],
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' } ], [/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' } ], [/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }] [/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
], ],
@ -196,7 +196,7 @@ export var language = <ILanguage> {
// After <style ... type = $S2 // After <style ... type = $S2
styleWithCustomType: [ styleWithCustomType: [
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.styleWithCustomType.$S2' }], [/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.styleWithCustomType.$S2' }],
[/>/, { token: htmlTokenTypes.DELIM_END, next: '@styleEmbedded.$S2', nextEmbedded: '$S2'}], [/>/, { token: htmlTokenTypes.DELIM_END, next: '@styleEmbedded.$S2', nextEmbedded: '$S2' }],
[/"([^"]*)"/, 'attribute.value'], [/"([^"]*)"/, 'attribute.value'],
[/'([^']*)'/, 'attribute.value'], [/'([^']*)'/, 'attribute.value'],
[/[\w\-]+/, 'attribute.name'], [/[\w\-]+/, 'attribute.name'],
@ -232,4 +232,4 @@ export var language = <ILanguage> {
[/[^}]/, 'variable.parameter.handlebars'], [/[^}]/, 'variable.parameter.handlebars'],
], ],
}, },
}; };

View file

@ -11,9 +11,9 @@ import ILanguage = monaco.languages.IMonarchLanguage;
// Allow for running under nodejs/requirejs in tests // Allow for running under nodejs/requirejs in tests
var _monaco: typeof monaco = (typeof monaco === 'undefined' ? (<any>self).monaco : monaco); var _monaco: typeof monaco = (typeof monaco === 'undefined' ? (<any>self).monaco : monaco);
const EMPTY_ELEMENTS:string[] = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']; const EMPTY_ELEMENTS: string[] = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr'];
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\s]+)/g, wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\s]+)/g,
comments: { comments: {
@ -66,7 +66,7 @@ export const htmlTokenTypes = {
} }
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.html', tokenPostfix: '.html',
ignoreCase: true, ignoreCase: true,
@ -77,8 +77,8 @@ export var language = <ILanguage> {
[/<!DOCTYPE/, 'metatag', '@doctype'], [/<!DOCTYPE/, 'metatag', '@doctype'],
[/<!--/, 'comment', '@comment'], [/<!--/, 'comment', '@comment'],
[/(<)((?:[\w\-]+:)?[\w\-]+)(\s*)(\/>)/, [htmlTokenTypes.DELIM_START, 'tag', '', htmlTokenTypes.DELIM_END]], [/(<)((?:[\w\-]+:)?[\w\-]+)(\s*)(\/>)/, [htmlTokenTypes.DELIM_START, 'tag', '', htmlTokenTypes.DELIM_END]],
[/(<)(script)/, [htmlTokenTypes.DELIM_START, { token: 'tag', next: '@script'} ]], [/(<)(script)/, [htmlTokenTypes.DELIM_START, { token: 'tag', next: '@script' }]],
[/(<)(style)/, [htmlTokenTypes.DELIM_START, { token: 'tag', next: '@style'} ]], [/(<)(style)/, [htmlTokenTypes.DELIM_START, { token: 'tag', next: '@style' }]],
[/(<)((?:[\w\-]+:)?[\w\-]+)/, [htmlTokenTypes.DELIM_START, { token: 'tag', next: '@otherTag' }]], [/(<)((?:[\w\-]+:)?[\w\-]+)/, [htmlTokenTypes.DELIM_START, { token: 'tag', next: '@otherTag' }]],
[/(<\/)((?:[\w\-]+:)?[\w\-]+)/, [htmlTokenTypes.DELIM_START, { token: 'tag', next: '@otherTag' }]], [/(<\/)((?:[\w\-]+:)?[\w\-]+)/, [htmlTokenTypes.DELIM_START, { token: 'tag', next: '@otherTag' }]],
[/</, htmlTokenTypes.DELIM_START], [/</, htmlTokenTypes.DELIM_START],
@ -86,8 +86,8 @@ export var language = <ILanguage> {
], ],
doctype: [ doctype: [
[/[^>]+/, 'metatag.content' ], [/[^>]+/, 'metatag.content'],
[/>/, 'metatag', '@pop' ], [/>/, 'metatag', '@pop'],
], ],
comment: [ comment: [
@ -114,29 +114,29 @@ export var language = <ILanguage> {
[/'([^']*)'/, 'attribute.value'], [/'([^']*)'/, 'attribute.value'],
[/[\w\-]+/, 'attribute.name'], [/[\w\-]+/, 'attribute.name'],
[/=/, 'delimiter'], [/=/, 'delimiter'],
[/>/, { token: htmlTokenTypes.DELIM_END, next: '@scriptEmbedded', nextEmbedded: 'text/javascript'} ], [/>/, { token: htmlTokenTypes.DELIM_END, next: '@scriptEmbedded', nextEmbedded: 'text/javascript' }],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/(<\/)(script\s*)(>)/, [ htmlTokenTypes.DELIM_START, 'tag', { token: htmlTokenTypes.DELIM_END, next: '@pop' } ]] [/(<\/)(script\s*)(>)/, [htmlTokenTypes.DELIM_START, 'tag', { token: htmlTokenTypes.DELIM_END, next: '@pop' }]]
], ],
// After <script ... type // After <script ... type
scriptAfterType: [ scriptAfterType: [
[/=/,'delimiter', '@scriptAfterTypeEquals'], [/=/, 'delimiter', '@scriptAfterTypeEquals'],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }] [/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
], ],
// After <script ... type = // After <script ... type =
scriptAfterTypeEquals: [ scriptAfterTypeEquals: [
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' } ], [/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' } ], [/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }] [/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
], ],
// After <script ... type = $S2 // After <script ... type = $S2
scriptWithCustomType: [ scriptWithCustomType: [
[/>/, { token: htmlTokenTypes.DELIM_END, next: '@scriptEmbedded.$S2', nextEmbedded: '$S2'}], [/>/, { token: htmlTokenTypes.DELIM_END, next: '@scriptEmbedded.$S2', nextEmbedded: '$S2' }],
[/"([^"]*)"/, 'attribute.value'], [/"([^"]*)"/, 'attribute.value'],
[/'([^']*)'/, 'attribute.value'], [/'([^']*)'/, 'attribute.value'],
[/[\w\-]+/, 'attribute.name'], [/[\w\-]+/, 'attribute.name'],
@ -162,29 +162,29 @@ export var language = <ILanguage> {
[/'([^']*)'/, 'attribute.value'], [/'([^']*)'/, 'attribute.value'],
[/[\w\-]+/, 'attribute.name'], [/[\w\-]+/, 'attribute.name'],
[/=/, 'delimiter'], [/=/, 'delimiter'],
[/>/, { token: htmlTokenTypes.DELIM_END, next: '@styleEmbedded', nextEmbedded: 'text/css'} ], [/>/, { token: htmlTokenTypes.DELIM_END, next: '@styleEmbedded', nextEmbedded: 'text/css' }],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/(<\/)(style\s*)(>)/, [htmlTokenTypes.DELIM_START, 'tag', { token: htmlTokenTypes.DELIM_END, next: '@pop' } ]] [/(<\/)(style\s*)(>)/, [htmlTokenTypes.DELIM_START, 'tag', { token: htmlTokenTypes.DELIM_END, next: '@pop' }]]
], ],
// After <style ... type // After <style ... type
styleAfterType: [ styleAfterType: [
[/=/,'delimiter', '@styleAfterTypeEquals'], [/=/, 'delimiter', '@styleAfterTypeEquals'],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }] [/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
], ],
// After <style ... type = // After <style ... type =
styleAfterTypeEquals: [ styleAfterTypeEquals: [
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' } ], [/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' } ], [/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }] [/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
], ],
// After <style ... type = $S2 // After <style ... type = $S2
styleWithCustomType: [ styleWithCustomType: [
[/>/, { token: htmlTokenTypes.DELIM_END, next: '@styleEmbedded.$S2', nextEmbedded: '$S2'}], [/>/, { token: htmlTokenTypes.DELIM_END, next: '@styleEmbedded.$S2', nextEmbedded: '$S2' }],
[/"([^"]*)"/, 'attribute.value'], [/"([^"]*)"/, 'attribute.value'],
[/'([^']*)'/, 'attribute.value'], [/'([^']*)'/, 'attribute.value'],
[/[\w\-]+/, 'attribute.name'], [/[\w\-]+/, 'attribute.name'],
@ -198,7 +198,7 @@ export var language = <ILanguage> {
[/[^<]+/, ''] [/[^<]+/, '']
], ],
// -- END <style> tags handling // -- END <style> tags handling
}, },
}; };

View file

@ -8,14 +8,14 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
comments: { comments: {
lineComment: '#' lineComment: '#'
}, },
brackets: [ brackets: [
['{','}'], ['{', '}'],
['[',']'], ['[', ']'],
['(',')'], ['(', ')'],
], ],
autoClosingPairs: [ autoClosingPairs: [
{ open: '{', close: '}' }, { open: '{', close: '}' },
@ -33,12 +33,12 @@ export var conf:IRichLanguageConfiguration = {
] ]
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.ini', tokenPostfix: '.ini',
// we include these common regular expressions // 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})/, 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 // The main tokenizer for our languages
tokenizer: { tokenizer: {
@ -57,23 +57,27 @@ export var language = <ILanguage> {
[/\d+/, 'number'], [/\d+/, 'number'],
// strings: recover on non-terminated strings // strings: recover on non-terminated strings
[/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
[/'([^'\\]|\\.)*$/, 'string.invalid' ], // non-teminated string [/'([^'\\]|\\.)*$/, 'string.invalid'], // non-teminated string
[/"/, 'string', '@string."' ], [/"/, 'string', '@string."'],
[/'/, 'string', '@string.\''], [/'/, 'string', '@string.\''],
], ],
whitespace: [ whitespace: [
[/[ \t\r\n]+/, ''], [/[ \t\r\n]+/, ''],
[/^\s*[#;].*$/, 'comment'], [/^\s*[#;].*$/, 'comment'],
], ],
string: [ string: [
[/[^\\"']+/, 'string'], [/[^\\"']+/, 'string'],
[/@escapes/, 'string.escape'], [/@escapes/, 'string.escape'],
[/\\./, 'string.escape.invalid'], [/\\./, 'string.escape.invalid'],
[/["']/, { cases: { '$#==$S2' : { token: 'string', next: '@pop' }, [/["']/, {
'@default': 'string' }} ] cases: {
'$#==$S2': { token: 'string', next: '@pop' },
'@default': 'string'
}
}]
], ],
}, },
}; };

View file

@ -8,11 +8,11 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
comments: { comments: {
lineComment: '//' lineComment: '//'
}, },
brackets: [['{','}'], ['[',']'], ['(',')']], brackets: [['{', '}'], ['[', ']'], ['(', ')']],
autoClosingPairs: [ autoClosingPairs: [
{ open: '"', close: '"', notIn: ['string', 'comment'] }, { open: '"', close: '"', notIn: ['string', 'comment'] },
{ open: '\'', close: '\'', notIn: ['string', 'comment'] }, { open: '\'', close: '\'', notIn: ['string', 'comment'] },
@ -22,19 +22,19 @@ export var conf:IRichLanguageConfiguration = {
] ]
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.jade', tokenPostfix: '.jade',
ignoreCase: true, ignoreCase: true,
brackets: [ brackets: [
{ token:'delimiter.curly', open: '{', close: '}' }, { token: 'delimiter.curly', open: '{', close: '}' },
{ token:'delimiter.array', open: '[', close: ']' }, { token: 'delimiter.array', open: '[', close: ']' },
{ token:'delimiter.parenthesis', open: '(', close: ')' } { token: 'delimiter.parenthesis', open: '(', close: ')' }
], ],
keywords: [ 'append', 'block', 'case', 'default', 'doctype', 'each', 'else', 'extends', keywords: ['append', 'block', 'case', 'default', 'doctype', 'each', 'else', 'extends',
'for', 'if', 'in', 'include', 'mixin', 'typeof', 'unless', 'var', 'when'], 'for', 'if', 'in', 'include', 'mixin', 'typeof', 'unless', 'var', 'when'],
tags: [ tags: [
@ -70,26 +70,48 @@ export var language = <ILanguage> {
// Tag or a keyword at start // Tag or a keyword at start
[/^(\s*)([a-zA-Z_-][\w-]*)/, [/^(\s*)([a-zA-Z_-][\w-]*)/,
{ cases: { {
'$2@tags': { cases: { '@eos': ['', 'tag'], '@default': ['', { token: 'tag', next: '@tag.$1' }, ] } }, cases: {
'$2@keywords': [ '', { token: 'keyword.$2'}, ], '$2@tags': {
'@default': [ '', '', ]}} cases: {
'@eos': ['', 'tag'],
'@default': ['', { token: 'tag', next: '@tag.$1' },]
}
},
'$2@keywords': ['', { token: 'keyword.$2' },],
'@default': ['', '',]
}
}
], ],
// id // id
[/^(\s*)(#[a-zA-Z_-][\w-]*)/, { cases: { '@eos': ['', 'tag.id'], '@default': ['', { token: 'tag.id', next: '@tag.$1' }] }}], [/^(\s*)(#[a-zA-Z_-][\w-]*)/, {
cases: {
'@eos': ['', 'tag.id'],
'@default': ['', { token: 'tag.id', next: '@tag.$1' }]
}
}],
// class // class
[/^(\s*)(\.[a-zA-Z_-][\w-]*)/, { cases: { '@eos': ['', 'tag.class'], '@default': ['', { token: 'tag.class', next: '@tag.$1' }] } }], [/^(\s*)(\.[a-zA-Z_-][\w-]*)/, {
cases: {
'@eos': ['', 'tag.class'],
'@default': ['', { token: 'tag.class', next: '@tag.$1' }]
}
}],
// plain text with pipe // plain text with pipe
[/^(\s*)(\|.*)$/, '' ], [/^(\s*)(\|.*)$/, ''],
{ include: '@whitespace' }, { include: '@whitespace' },
// keywords // keywords
[/[a-zA-Z_$][\w$]*/, { cases: { '@keywords': {token:'keyword.$0'}, [/[a-zA-Z_$][\w$]*/, {
'@default': '' } }], cases: {
'@keywords': { token: 'keyword.$0' },
'@default': ''
}
}],
// delimiters and operators // delimiters and operators
[/[{}()\[\]]/, '@brackets'], [/[{}()\[\]]/, '@brackets'],
@ -100,80 +122,138 @@ export var language = <ILanguage> {
[/\d+/, 'number'], [/\d+/, 'number'],
// strings: // strings:
[/"/, 'string', '@string."' ], [/"/, 'string', '@string."'],
[/'/, 'string', '@string.\''], [/'/, 'string', '@string.\''],
], ],
tag: [ tag: [
[/(\.)(\s*$)/, [ {token: 'delimiter', next:'@blockText.$S2.'}, '']], [/(\.)(\s*$)/, [{ token: 'delimiter', next: '@blockText.$S2.' }, '']],
[/\s+/, { token: '', next: '@simpleText' }], [/\s+/, { token: '', next: '@simpleText' }],
// id // id
[/#[a-zA-Z_-][\w-]*/, { cases: { '@eos': { token: 'tag.id', next: '@pop' }, '@default': 'tag.id' } }], [/#[a-zA-Z_-][\w-]*/, {
cases: {
'@eos': { token: 'tag.id', next: '@pop' },
'@default': 'tag.id'
}
}],
// class // class
[/\.[a-zA-Z_-][\w-]*/, { cases: { '@eos': { token: 'tag.class', next: '@pop' }, '@default': 'tag.class' } }], [/\.[a-zA-Z_-][\w-]*/, {
cases: {
'@eos': { token: 'tag.class', next: '@pop' },
'@default': 'tag.class'
}
}],
// attributes // attributes
[/\(/, { token: 'delimiter.parenthesis', next: '@attributeList' }], [/\(/, { token: 'delimiter.parenthesis', next: '@attributeList' }],
], ],
simpleText: [ simpleText: [
[/[^#]+$/, {token: '', next: '@popall'}], [/[^#]+$/, { token: '', next: '@popall' }],
[/[^#]+/, {token: ''}], [/[^#]+/, { token: '' }],
// interpolation // interpolation
[/(#{)([^}]*)(})/, { cases: { [/(#{)([^}]*)(})/, {
'@eos': ['interpolation.delimiter', 'interpolation', { token: 'interpolation.delimiter', next: '@popall' }], cases: {
'@default': ['interpolation.delimiter', 'interpolation', 'interpolation.delimiter'] }}], '@eos': ['interpolation.delimiter', 'interpolation', { token: 'interpolation.delimiter', next: '@popall' }],
'@default': ['interpolation.delimiter', 'interpolation', 'interpolation.delimiter']
}
}],
[/#$/, { token: '', next: '@popall' }], [/#$/, { token: '', next: '@popall' }],
[/#/, ''] [/#/, '']
], ],
attributeList: [ attributeList: [
[/\s+/, '' ], [/\s+/, ''],
[/(\w+)(\s*=\s*)("|')/, ['attribute.name', 'delimiter', { token: 'attribute.value', next:'@value.$3'}]], [/(\w+)(\s*=\s*)("|')/, ['attribute.name', 'delimiter', { token: 'attribute.value', next: '@value.$3' }]],
[/\w+/, 'attribute.name'], [/\w+/, 'attribute.name'],
[/,/, { cases: { '@eos': { token: 'attribute.delimiter', next: '@popall' }, '@default': 'attribute.delimiter' } }], [/,/, {
cases: {
'@eos': { token: 'attribute.delimiter', next: '@popall' },
'@default': 'attribute.delimiter'
}
}],
[/\)$/, { token: 'delimiter.parenthesis', next: '@popall' }], [/\)$/, { token: 'delimiter.parenthesis', next: '@popall' }],
[/\)/, { token: 'delimiter.parenthesis', next: '@pop' }], [/\)/, { token: 'delimiter.parenthesis', next: '@pop' }],
], ],
whitespace: [ whitespace: [
[/^(\s*)(\/\/.*)$/, { token: 'comment', next: '@blockText.$1.comment' } ], [/^(\s*)(\/\/.*)$/, { token: 'comment', next: '@blockText.$1.comment' }],
[/[ \t\r\n]+/, ''], [/[ \t\r\n]+/, ''],
[/<!--/, { token: 'comment', next: '@comment' }], [/<!--/, { token: 'comment', next: '@comment' }],
], ],
blockText: [ blockText: [
[/^\s+.*$/, { cases: { '($S2\\s+.*$)': { token: '$S3' }, '@default': { token: '@rematch', next: '@popall' } } }], [/^\s+.*$/, {
[/./, { token: '@rematch', next: '@popall' }] cases: {
'($S2\\s+.*$)': { token: '$S3' },
'@default': { token: '@rematch', next: '@popall' }
}
}],
[/./, { token: '@rematch', next: '@popall' }]
], ],
comment: [ comment: [
[/[^<\-]+/, 'comment.content' ], [/[^<\-]+/, 'comment.content'],
[/-->/, { token: 'comment', next: '@pop' } ], [/-->/, { token: 'comment', next: '@pop' }],
[/<!--/, 'comment.content.invalid'], [/<!--/, 'comment.content.invalid'],
[/[<\-]/, 'comment.content' ] [/[<\-]/, 'comment.content']
], ],
string: [ string: [
[/[^\\"'#]+/, { cases: { '@eos': { token: 'string', next: '@popall' }, '@default': 'string' } }], [/[^\\"'#]+/, {
[/@escapes/, { cases: { '@eos': { token: 'string.escape', next: '@popall' }, '@default': 'string.escape' }}], cases: {
[/\\./, { cases: { '@eos': { token: 'string.escape.invalid', next: '@popall' }, '@default': 'string.escape.invalid' }}], '@eos': { token: 'string', next: '@popall' },
'@default': 'string'
}
}],
[/@escapes/, {
cases: {
'@eos': { token: 'string.escape', next: '@popall' },
'@default': 'string.escape'
}
}],
[/\\./, {
cases: {
'@eos': { token: 'string.escape.invalid', next: '@popall' },
'@default': 'string.escape.invalid'
}
}],
// interpolation // interpolation
[/(#{)([^}]*)(})/, ['interpolation.delimiter', 'interpolation', 'interpolation.delimiter']], [/(#{)([^}]*)(})/, ['interpolation.delimiter', 'interpolation', 'interpolation.delimiter']],
[/#/, 'string'], [/#/, 'string'],
[/["']/, { cases: { '$#==$S2': { token: 'string', next: '@pop' }, '@default': { token: 'string' } } }], [/["']/, {
cases: {
'$#==$S2': { token: 'string', next: '@pop' },
'@default': { token: 'string' }
}
}],
], ],
// Almost identical to above, except for escapes and the output token // Almost identical to above, except for escapes and the output token
value: [ value: [
[/[^\\"']+/, { cases: { '@eos': { token: 'attribute.value', next: '@popall' }, '@default': 'attribute.value' }}], [/[^\\"']+/, {
[/\\./, { cases: { '@eos': { token: 'attribute.value', next: '@popall' }, '@default': 'attribute.value' }}], cases: {
[/["']/, { cases: { '$#==$S2': { token: 'attribute.value', next: '@pop' }, '@default': { token: 'attribute.value' } } }], '@eos': { token: 'attribute.value', next: '@popall' },
'@default': 'attribute.value'
}
}],
[/\\./, {
cases: {
'@eos': { token: 'attribute.value', next: '@popall' },
'@default': 'attribute.value'
}
}],
[/["']/, {
cases: {
'$#==$S2': { token: 'attribute.value', next: '@pop' },
'@default': { token: 'attribute.value' }
}
}],
], ],
}, },
}; };

View file

@ -8,7 +8,7 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
// the default separators except `@$` // the default separators except `@$`
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g, wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
comments: { comments: {
@ -16,9 +16,9 @@ export var conf:IRichLanguageConfiguration = {
blockComment: ['/*', '*/'], blockComment: ['/*', '*/'],
}, },
brackets: [ brackets: [
['{','}'], ['{', '}'],
['[',']'], ['[', ']'],
['(',')'], ['(', ')'],
], ],
autoClosingPairs: [ autoClosingPairs: [
{ open: '{', close: '}' }, { open: '{', close: '}' },
@ -37,7 +37,7 @@ export var conf:IRichLanguageConfiguration = {
] ]
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.java', tokenPostfix: '.java',
@ -60,7 +60,7 @@ export var language = <ILanguage> {
], ],
// we include these common regular expressions // we include these common regular expressions
symbols: /[=><!~?:&|+\-*\/\^%]+/, symbols: /[=><!~?:&|+\-*\/\^%]+/,
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
digits: /\d+(_+\d+)*/, digits: /\d+(_+\d+)*/,
octaldigits: /[0-7]+(_+[0-7]+)*/, octaldigits: /[0-7]+(_+[0-7]+)*/,
@ -71,8 +71,12 @@ export var language = <ILanguage> {
tokenizer: { tokenizer: {
root: [ root: [
// identifiers and keywords // identifiers and keywords
[/[a-zA-Z_$][\w$]*/, { cases: { '@keywords': {token:'keyword.$0'}, [/[a-zA-Z_$][\w$]*/, {
'@default': 'identifier' } }], cases: {
'@keywords': { token: 'keyword.$0' },
'@default': 'identifier'
}
}],
// whitespace // whitespace
{ include: '@whitespace' }, { include: '@whitespace' },
@ -80,8 +84,12 @@ export var language = <ILanguage> {
// delimiters and operators // delimiters and operators
[/[{}()\[\]]/, '@brackets'], [/[{}()\[\]]/, '@brackets'],
[/[<>](?!@symbols)/, '@brackets'], [/[<>](?!@symbols)/, '@brackets'],
[/@symbols/, { cases: { '@operators': 'delimiter', [/@symbols/, {
'@default' : '' } } ], cases: {
'@operators': 'delimiter',
'@default': ''
}
}],
// @ annotations. // @ annotations.
[/@\s*[a-zA-Z_\$][\w\$]*/, 'annotation'], [/@\s*[a-zA-Z_\$][\w\$]*/, 'annotation'],
@ -99,43 +107,43 @@ export var language = <ILanguage> {
[/[;,.]/, 'delimiter'], [/[;,.]/, 'delimiter'],
// strings // strings
[/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
[/"/, 'string', '@string' ], [/"/, 'string', '@string'],
// characters // characters
[/'[^\\']'/, 'string'], [/'[^\\']'/, 'string'],
[/(')(@escapes)(')/, ['string','string.escape','string']], [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
[/'/, 'string.invalid'] [/'/, 'string.invalid']
], ],
whitespace: [ whitespace: [
[/[ \t\r\n]+/, ''], [/[ \t\r\n]+/, ''],
[/\/\*\*(?!\/)/, 'comment.doc', '@javadoc' ], [/\/\*\*(?!\/)/, 'comment.doc', '@javadoc'],
[/\/\*/, 'comment', '@comment' ], [/\/\*/, 'comment', '@comment'],
[/\/\/.*$/, 'comment'], [/\/\/.*$/, 'comment'],
], ],
comment: [ comment: [
[/[^\/*]+/, 'comment' ], [/[^\/*]+/, 'comment'],
// [/\/\*/, 'comment', '@push' ], // nested comment not allowed :-( // [/\/\*/, 'comment', '@push' ], // nested comment not allowed :-(
// [/\/\*/, 'comment.invalid' ], // this breaks block comments in the shape of /* //*/ // [/\/\*/, 'comment.invalid' ], // this breaks block comments in the shape of /* //*/
[/\*\//, 'comment', '@pop' ], [/\*\//, 'comment', '@pop'],
[/[\/*]/, 'comment' ] [/[\/*]/, 'comment']
], ],
//Identical copy of comment above, except for the addition of .doc //Identical copy of comment above, except for the addition of .doc
javadoc: [ javadoc: [
[/[^\/*]+/, 'comment.doc' ], [/[^\/*]+/, 'comment.doc'],
// [/\/\*/, 'comment.doc', '@push' ], // nested comment not allowed :-( // [/\/\*/, 'comment.doc', '@push' ], // nested comment not allowed :-(
[/\/\*/, 'comment.doc.invalid' ], [/\/\*/, 'comment.doc.invalid'],
[/\*\//, 'comment.doc', '@pop' ], [/\*\//, 'comment.doc', '@pop'],
[/[\/*]/, 'comment.doc' ] [/[\/*]/, 'comment.doc']
], ],
string: [ string: [
[/[^\\"]+/, 'string'], [/[^\\"]+/, 'string'],
[/@escapes/, 'string.escape'], [/@escapes/, 'string.escape'],
[/\\./, 'string.escape.invalid'], [/\\./, 'string.escape.invalid'],
[/"/, 'string', '@pop' ] [/"/, 'string', '@pop']
], ],
}, },
}; };

View file

@ -41,7 +41,7 @@ const TOKEN_PROPERTY = 'attribute.name';
const TOKEN_VALUE = 'attribute.value'; const TOKEN_VALUE = 'attribute.value';
const TOKEN_AT_KEYWORD = 'keyword.control.at-rule'; const TOKEN_AT_KEYWORD = 'keyword.control.at-rule';
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.less', tokenPostfix: '.less',
@ -67,7 +67,7 @@ export var language = <ILanguage> {
{ include: '@numbers' }, { include: '@numbers' },
['[*_]?[a-zA-Z\\-\\s]+(?=:.*(;|(\\\\$)))', TOKEN_PROPERTY, '@attribute'], ['[*_]?[a-zA-Z\\-\\s]+(?=:.*(;|(\\\\$)))', TOKEN_PROPERTY, '@attribute'],
['url(\\-prefix)?\\(', { token: 'tag', next: '@urldeclaration'}], ['url(\\-prefix)?\\(', { token: 'tag', next: '@urldeclaration' }],
['[{}()\\[\\]]', '@brackets'], ['[{}()\\[\\]]', '@brackets'],
['[,:;]', 'delimiter'], ['[,:;]', 'delimiter'],
@ -104,9 +104,9 @@ export var language = <ILanguage> {
], ],
urldeclaration: [ urldeclaration: [
{ include: '@strings'}, { include: '@strings' },
[ '[^)\r\n]+', 'string' ], ['[^)\r\n]+', 'string'],
['\\)', { token: 'tag', next: '@pop'}], ['\\)', { token: 'tag', next: '@pop' }],
], ],
attribute: <any[]>[ attribute: <any[]>[
@ -177,4 +177,4 @@ export var language = <ILanguage> {
['.', 'key'] ['.', 'key']
] ]
} }
}; };

View file

@ -8,15 +8,15 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
comments: { comments: {
lineComment: '--', lineComment: '--',
blockComment: ['--[[', ']]'], blockComment: ['--[[', ']]'],
}, },
brackets: [ brackets: [
['{','}'], ['{', '}'],
['[',']'], ['[', ']'],
['(',')'] ['(', ')']
], ],
autoClosingPairs: [ autoClosingPairs: [
{ open: '{', close: '}' }, { open: '{', close: '}' },
@ -34,7 +34,7 @@ export var conf:IRichLanguageConfiguration = {
] ]
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.lua', tokenPostfix: '.lua',
@ -47,9 +47,9 @@ export var language = <ILanguage> {
], ],
brackets: [ brackets: [
{ token: 'delimiter.bracket', open: '{', close: '}'}, { token: 'delimiter.bracket', open: '{', close: '}' },
{ token: 'delimiter.array', open: '[', close: ']'}, { token: 'delimiter.array', open: '[', close: ']' },
{ token: 'delimiter.parenthesis', open: '(', close: ')'} { token: 'delimiter.parenthesis', open: '(', close: ')' }
], ],
operators: [ operators: [
@ -58,26 +58,34 @@ export var language = <ILanguage> {
], ],
// we include these common regular expressions // we include these common regular expressions
symbols: /[=><!~?:&|+\-*\/\^%]+/, symbols: /[=><!~?:&|+\-*\/\^%]+/,
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, 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 // The main tokenizer for our languages
tokenizer: { tokenizer: {
root: [ root: [
// identifiers and keywords // identifiers and keywords
[/[a-zA-Z_]\w*/, { cases: { '@keywords': {token:'keyword.$0'}, [/[a-zA-Z_]\w*/, {
'@default': 'identifier' } }], cases: {
'@keywords': { token: 'keyword.$0' },
'@default': 'identifier'
}
}],
// whitespace // whitespace
{ include: '@whitespace' }, { include: '@whitespace' },
// keys // keys
[/(,)(\s*)([a-zA-Z_]\w*)(\s*)(:)(?!:)/, ['delimiter', '', 'key', '', 'delimiter']], [/(,)(\s*)([a-zA-Z_]\w*)(\s*)(:)(?!:)/, ['delimiter', '', 'key', '', 'delimiter']],
[/({)(\s*)([a-zA-Z_]\w*)(\s*)(:)(?!:)/, ['@brackets', '', 'key', '', 'delimiter']], [/({)(\s*)([a-zA-Z_]\w*)(\s*)(:)(?!:)/, ['@brackets', '', 'key', '', 'delimiter']],
// delimiters and operators // delimiters and operators
[/[{}()\[\]]/, '@brackets'], [/[{}()\[\]]/, '@brackets'],
[/@symbols/, { cases: { '@operators': 'delimiter', [/@symbols/, {
'@default' : '' } } ], cases: {
'@operators': 'delimiter',
'@default': ''
}
}],
// numbers // numbers
[/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'], [/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
@ -88,31 +96,40 @@ export var language = <ILanguage> {
[/[;,.]/, 'delimiter'], [/[;,.]/, 'delimiter'],
// strings: recover on non-terminated strings // strings: recover on non-terminated strings
[/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
[/'([^'\\]|\\.)*$/, 'string.invalid' ], // non-teminated string [/'([^'\\]|\\.)*$/, 'string.invalid'], // non-teminated string
[/"/, 'string', '@string."' ], [/"/, 'string', '@string."'],
[/'/, 'string', '@string.\''], [/'/, 'string', '@string.\''],
], ],
whitespace: [ whitespace: [
[/[ \t\r\n]+/, ''], [/[ \t\r\n]+/, ''],
[/--\[([=]*)\[/, 'comment', '@comment.$1' ], [/--\[([=]*)\[/, 'comment', '@comment.$1'],
[/--.*$/, 'comment'], [/--.*$/, 'comment'],
], ],
comment: [ comment: [
[/[^\]]+/, 'comment'], [/[^\]]+/, 'comment'],
[/\]([=]*)\]/, { cases: { '$1==$S2': { token: 'comment', next: '@pop' }, '@default' : 'comment' } } ], [/\]([=]*)\]/, {
[/./, 'comment' ] cases: {
'$1==$S2': { token: 'comment', next: '@pop' },
'@default': 'comment'
}
}],
[/./, 'comment']
], ],
string: [ string: [
[/[^\\"']+/, 'string'], [/[^\\"']+/, 'string'],
[/@escapes/, 'string.escape'], [/@escapes/, 'string.escape'],
[/\\./, 'string.escape.invalid'], [/\\./, 'string.escape.invalid'],
[/["']/, { cases: { '$#==$S2' : { token: 'string', next: '@pop' }, [/["']/, {
'@default': 'string' }} ] cases: {
'$#==$S2': { token: 'string', next: '@pop' },
'@default': 'string'
}
}]
], ],
}, },
}; };

View file

@ -22,179 +22,179 @@ const ATTRIB_NAME = 'attribute.name.html';
const ATTRIB_VALUE = 'string.html'; const ATTRIB_VALUE = 'string.html';
function getTag(name: string) { function getTag(name: string) {
return 'tag'; return 'tag';
} }
export var conf: IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
comments: { comments: {
blockComment: ['<!--', '-->',] blockComment: ['<!--', '-->',]
}, },
brackets: [ brackets: [
['{', '}'], ['{', '}'],
['[', ']'], ['[', ']'],
['(', ')'] ['(', ')']
], ],
autoClosingPairs: [ autoClosingPairs: [
{ open: '{', close: '}' }, { open: '{', close: '}' },
{ open: '[', close: ']' }, { open: '[', close: ']' },
{ open: '(', close: ')' }, { open: '(', close: ')' },
{ open: '<', close: '>', notIn: [ 'string' ] } { open: '<', close: '>', notIn: ['string'] }
], ],
surroundingPairs: [ surroundingPairs: [
{ open: '(', close: ')' }, { open: '(', close: ')' },
{ open: '[', close: ']' }, { open: '[', close: ']' },
{ open: '`', close: '`' }, { open: '`', close: '`' },
] ]
}; };
export var language = <ILanguage>{ export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.md', tokenPostfix: '.md',
// escape codes // escape codes
control: /[\\`*_\[\]{}()#+\-\.!]/, control: /[\\`*_\[\]{}()#+\-\.!]/,
noncontrol: /[^\\`*_\[\]{}()#+\-\.!]/, noncontrol: /[^\\`*_\[\]{}()#+\-\.!]/,
escapes: /\\(?:@control)/, escapes: /\\(?:@control)/,
// escape codes for javascript/CSS strings // escape codes for javascript/CSS strings
jsescapes: /\\(?:[btnfr\\"']|[0-7][0-7]?|[0-3][0-7]{2})/, jsescapes: /\\(?:[btnfr\\"']|[0-7][0-7]?|[0-3][0-7]{2})/,
// non matched elements // non matched elements
empty: [ empty: [
'area', 'base', 'basefont', 'br', 'col', 'frame', 'area', 'base', 'basefont', 'br', 'col', 'frame',
'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param' 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param'
], ],
tokenizer: { tokenizer: {
root: [ root: [
// headers (with #) // headers (with #)
[/^(\s{0,3})(#+)((?:[^\\#]|@escapes)+)((?:#+)?)/, ['white', TOKEN_HEADER_LEAD, TOKEN_HEADER, TOKEN_HEADER]], [/^(\s{0,3})(#+)((?:[^\\#]|@escapes)+)((?:#+)?)/, ['white', TOKEN_HEADER_LEAD, TOKEN_HEADER, TOKEN_HEADER]],
// headers (with =) // headers (with =)
[/^\s*(=+|\-+)\s*$/, TOKEN_EXT_HEADER], [/^\s*(=+|\-+)\s*$/, TOKEN_EXT_HEADER],
// headers (with ***) // headers (with ***)
[/^\s*((\*[ ]?)+)\s*$/, TOKEN_SEPARATOR], [/^\s*((\*[ ]?)+)\s*$/, TOKEN_SEPARATOR],
// quote // quote
[/^\s*>+/, TOKEN_QUOTE], [/^\s*>+/, TOKEN_QUOTE],
// list (starting with * or number) // list (starting with * or number)
[/^\s*([\*\-+:]|\d+\.)\s/, TOKEN_LIST], [/^\s*([\*\-+:]|\d+\.)\s/, TOKEN_LIST],
// code block (4 spaces indent) // code block (4 spaces indent)
[/^(\t|[ ]{4})[^ ].*$/, TOKEN_BLOCK], [/^(\t|[ ]{4})[^ ].*$/, TOKEN_BLOCK],
// code block (3 tilde) // code block (3 tilde)
[/^\s*~~~\s*((?:\w|[\/\-#])+)?\s*$/, { token: TOKEN_BLOCK, next: '@codeblock' }], [/^\s*~~~\s*((?:\w|[\/\-#])+)?\s*$/, { token: TOKEN_BLOCK, next: '@codeblock' }],
// github style code blocks (with backticks and language) // github style code blocks (with backticks and language)
[/^\s*```\s*((?:\w|[\/\-#])+)\s*$/, { token: TOKEN_BLOCK, next: '@codeblockgh', nextEmbedded: '$1' }], [/^\s*```\s*((?:\w|[\/\-#])+)\s*$/, { token: TOKEN_BLOCK, next: '@codeblockgh', nextEmbedded: '$1' }],
// github style code blocks (with backticks but no language) // github style code blocks (with backticks but no language)
[/^\s*```\s*$/, { token: TOKEN_BLOCK, next: '@codeblock' }], [/^\s*```\s*$/, { token: TOKEN_BLOCK, next: '@codeblock' }],
// markup within lines // markup within lines
{ include: '@linecontent' }, { include: '@linecontent' },
], ],
codeblock: [ codeblock: [
[/^\s*~~~\s*$/, { token: TOKEN_BLOCK, next: '@pop' }], [/^\s*~~~\s*$/, { token: TOKEN_BLOCK, next: '@pop' }],
[/^\s*```\s*$/, { token: TOKEN_BLOCK, next: '@pop' }], [/^\s*```\s*$/, { token: TOKEN_BLOCK, next: '@pop' }],
[/.*$/, TOKEN_BLOCK_CODE], [/.*$/, TOKEN_BLOCK_CODE],
], ],
// github style code blocks // github style code blocks
codeblockgh: [ codeblockgh: [
[/```\s*$/, { token: TOKEN_BLOCK_CODE, next: '@pop', nextEmbedded: '@pop' }], [/```\s*$/, { token: TOKEN_BLOCK_CODE, next: '@pop', nextEmbedded: '@pop' }],
[/[^`]+/, TOKEN_BLOCK_CODE], [/[^`]+/, TOKEN_BLOCK_CODE],
], ],
linecontent: [ linecontent: [
// escapes // escapes
[/&\w+;/, 'string.escape'], [/&\w+;/, 'string.escape'],
[/@escapes/, 'escape'], [/@escapes/, 'escape'],
// various markup // various markup
[/\b__([^\\_]|@escapes|_(?!_))+__\b/, 'strong'], [/\b__([^\\_]|@escapes|_(?!_))+__\b/, 'strong'],
[/\*\*([^\\*]|@escapes|\*(?!\*))+\*\*/, 'strong'], [/\*\*([^\\*]|@escapes|\*(?!\*))+\*\*/, 'strong'],
[/\b_[^_]+_\b/, 'emphasis'], [/\b_[^_]+_\b/, 'emphasis'],
[/\*([^\\*]|@escapes)+\*/, 'emphasis'], [/\*([^\\*]|@escapes)+\*/, 'emphasis'],
[/`([^\\`]|@escapes)+`/, 'variable'], [/`([^\\`]|@escapes)+`/, 'variable'],
// links // links
[/\{[^}]+\}/, 'string.target'], [/\{[^}]+\}/, 'string.target'],
[/(!?\[)((?:[^\]\\]|@escapes)*)(\]\([^\)]+\))/, ['string.link', '', 'string.link']], [/(!?\[)((?:[^\]\\]|@escapes)*)(\]\([^\)]+\))/, ['string.link', '', 'string.link']],
[/(!?\[)((?:[^\]\\]|@escapes)*)(\])/, 'string.link'], [/(!?\[)((?:[^\]\\]|@escapes)*)(\])/, 'string.link'],
// or html // or html
{ include: 'html' }, { include: 'html' },
], ],
// Note: it is tempting to rather switch to the real HTML mode instead of building our own here // Note: it is tempting to rather switch to the real HTML mode instead of building our own here
// but currently there is a limitation in Monarch that prevents us from doing it: The opening // but currently there is a limitation in Monarch that prevents us from doing it: The opening
// '<' would start the HTML mode, however there is no way to jump 1 character back to let the // '<' would start the HTML mode, however there is no way to jump 1 character back to let the
// HTML mode also tokenize the opening angle bracket. Thus, even though we could jump to HTML, // HTML mode also tokenize the opening angle bracket. Thus, even though we could jump to HTML,
// we cannot correctly tokenize it in that mode yet. // we cannot correctly tokenize it in that mode yet.
html: [ html: [
// html tags // html tags
[/<(\w+)\/>/, getTag('$1')], [/<(\w+)\/>/, getTag('$1')],
[/<(\w+)/, { [/<(\w+)/, {
cases: { cases: {
'@empty': { token: getTag('$1'), next: '@tag.$1' }, '@empty': { token: getTag('$1'), next: '@tag.$1' },
'@default': { token: getTag('$1'), next: '@tag.$1' } '@default': { token: getTag('$1'), next: '@tag.$1' }
} }
}], }],
[/<\/(\w+)\s*>/, { token: getTag('$1') }], [/<\/(\w+)\s*>/, { token: getTag('$1') }],
[/<!--/, 'comment', '@comment'] [/<!--/, 'comment', '@comment']
], ],
comment: [ comment: [
[/[^<\-]+/, 'comment.content'], [/[^<\-]+/, 'comment.content'],
[/-->/, 'comment', '@pop'], [/-->/, 'comment', '@pop'],
[/<!--/, 'comment.content.invalid'], [/<!--/, 'comment.content.invalid'],
[/[<\-]/, 'comment.content'] [/[<\-]/, 'comment.content']
], ],
// Almost full HTML tag matching, complete with embedded scripts & styles // Almost full HTML tag matching, complete with embedded scripts & styles
tag: [ tag: [
[/[ \t\r\n]+/, 'white'], [/[ \t\r\n]+/, 'white'],
[/(type)(\s*=\s*)(")([^"]+)(")/, [ATTRIB_NAME, DELIM_ASSIGN, ATTRIB_VALUE, [/(type)(\s*=\s*)(")([^"]+)(")/, [ATTRIB_NAME, DELIM_ASSIGN, ATTRIB_VALUE,
{ token: ATTRIB_VALUE, switchTo: '@tag.$S2.$4' }, { token: ATTRIB_VALUE, switchTo: '@tag.$S2.$4' },
ATTRIB_VALUE]], ATTRIB_VALUE]],
[/(type)(\s*=\s*)(')([^']+)(')/, [ATTRIB_NAME, DELIM_ASSIGN, ATTRIB_VALUE, [/(type)(\s*=\s*)(')([^']+)(')/, [ATTRIB_NAME, DELIM_ASSIGN, ATTRIB_VALUE,
{ token: ATTRIB_VALUE, switchTo: '@tag.$S2.$4' }, { token: ATTRIB_VALUE, switchTo: '@tag.$S2.$4' },
ATTRIB_VALUE]], ATTRIB_VALUE]],
[/(\w+)(\s*=\s*)("[^"]*"|'[^']*')/, [ATTRIB_NAME, DELIM_ASSIGN, ATTRIB_VALUE]], [/(\w+)(\s*=\s*)("[^"]*"|'[^']*')/, [ATTRIB_NAME, DELIM_ASSIGN, ATTRIB_VALUE]],
[/\w+/, ATTRIB_NAME], [/\w+/, ATTRIB_NAME],
[/\/>/, getTag('$S2'), '@pop'], [/\/>/, getTag('$S2'), '@pop'],
[/>/, { [/>/, {
cases: { cases: {
'$S2==style': { token: getTag('$S2'), switchTo: 'embeddedStyle', nextEmbedded: 'text/css' }, '$S2==style': { token: getTag('$S2'), switchTo: 'embeddedStyle', nextEmbedded: 'text/css' },
'$S2==script': { '$S2==script': {
cases: { cases: {
'$S3': { token: getTag('$S2'), switchTo: 'embeddedScript', nextEmbedded: '$S3' }, '$S3': { token: getTag('$S2'), switchTo: 'embeddedScript', nextEmbedded: '$S3' },
'@default': { token: getTag('$S2'), switchTo: 'embeddedScript', nextEmbedded: 'text/javascript' } '@default': { token: getTag('$S2'), switchTo: 'embeddedScript', nextEmbedded: 'text/javascript' }
} }
}, },
'@default': { token: getTag('$S2'), next: '@pop' } '@default': { token: getTag('$S2'), next: '@pop' }
} }
}], }],
], ],
embeddedStyle: [ embeddedStyle: [
[/[^<]+/, ''], [/[^<]+/, ''],
[/<\/style\s*>/, { token: '@rematch', next: '@pop', nextEmbedded: '@pop' }], [/<\/style\s*>/, { token: '@rematch', next: '@pop', nextEmbedded: '@pop' }],
[/</, ''] [/</, '']
], ],
embeddedScript: [ embeddedScript: [
[/[^<]+/, ''], [/[^<]+/, ''],
[/<\/script\s*>/, { token: '@rematch', next: '@pop', nextEmbedded: '@pop' }], [/<\/script\s*>/, { token: '@rematch', next: '@pop', nextEmbedded: '@pop' }],
[/</, ''] [/</, '']
], ],
} }
}; };

View file

@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
'use strict'; 'use strict';
declare var require:<T>(moduleId:[string], callback:(module:T)=>void, error:(err:any)=>void)=>void; declare var require: <T>(moduleId: [string], callback: (module: T) => void, error: (err: any) => void) => void;
// Allow for running under nodejs/requirejs in tests // Allow for running under nodejs/requirejs in tests
var _monaco: typeof monaco = (typeof monaco === 'undefined' ? (<any>self).monaco : monaco); var _monaco: typeof monaco = (typeof monaco === 'undefined' ? (<any>self).monaco : monaco);
@ -18,9 +18,9 @@ interface ILangImpl {
language: monaco.languages.IMonarchLanguage; language: monaco.languages.IMonarchLanguage;
} }
let languageDefinitions:{[languageId:string]:ILang} = {}; let languageDefinitions: { [languageId: string]: ILang } = {};
function _loadLanguage(languageId:string): monaco.Promise<void> { function _loadLanguage(languageId: string): monaco.Promise<void> {
let module = languageDefinitions[languageId].module; let module = languageDefinitions[languageId].module;
return new _monaco.Promise<void>((c, e, p) => { return new _monaco.Promise<void>((c, e, p) => {
require<ILangImpl>([module], (mod) => { require<ILangImpl>([module], (mod) => {
@ -31,16 +31,16 @@ function _loadLanguage(languageId:string): monaco.Promise<void> {
}); });
} }
let languagePromises:{[languageId:string]: monaco.Promise<void>} = {}; let languagePromises: { [languageId: string]: monaco.Promise<void> } = {};
export function loadLanguage(languageId:string): monaco.Promise<void> { export function loadLanguage(languageId: string): monaco.Promise<void> {
if (!languagePromises[languageId]) { if (!languagePromises[languageId]) {
languagePromises[languageId] = _loadLanguage(languageId); languagePromises[languageId] = _loadLanguage(languageId);
} }
return languagePromises[languageId]; return languagePromises[languageId];
} }
function registerLanguage(def:ILang): void { function registerLanguage(def: ILang): void {
let languageId = def.id; let languageId = def.id;
languageDefinitions[languageId] = def; languageDefinitions[languageId] = def;
@ -53,52 +53,52 @@ function registerLanguage(def:ILang): void {
registerLanguage({ registerLanguage({
id: 'bat', id: 'bat',
extensions: [ '.bat', '.cmd'], extensions: ['.bat', '.cmd'],
aliases: [ 'Batch', 'bat' ], aliases: ['Batch', 'bat'],
module: './bat' module: './bat'
}); });
registerLanguage({ registerLanguage({
id: 'coffeescript', id: 'coffeescript',
extensions: [ '.coffee' ], extensions: ['.coffee'],
aliases: [ 'CoffeeScript', 'coffeescript', 'coffee' ], aliases: ['CoffeeScript', 'coffeescript', 'coffee'],
mimetypes: ['text/x-coffeescript', 'text/coffeescript'], mimetypes: ['text/x-coffeescript', 'text/coffeescript'],
module: './coffee' module: './coffee'
}); });
registerLanguage({ registerLanguage({
id: 'c', id: 'c',
extensions: [ '.c', '.h' ], extensions: ['.c', '.h'],
aliases: [ 'C', 'c' ], aliases: ['C', 'c'],
module: './cpp' module: './cpp'
}); });
registerLanguage({ registerLanguage({
id: 'cpp', id: 'cpp',
extensions: [ '.cpp', '.cc', '.cxx', '.hpp', '.hh', '.hxx' ], extensions: ['.cpp', '.cc', '.cxx', '.hpp', '.hh', '.hxx'],
aliases: [ 'C++', 'Cpp', 'cpp'], aliases: ['C++', 'Cpp', 'cpp'],
module: './cpp' module: './cpp'
}); });
registerLanguage({ registerLanguage({
id: 'csharp', id: 'csharp',
extensions: [ '.cs', '.csx' ], extensions: ['.cs', '.csx'],
aliases: [ 'C#', 'csharp' ], aliases: ['C#', 'csharp'],
module: './csharp' module: './csharp'
}); });
registerLanguage({ registerLanguage({
id: 'dockerfile', id: 'dockerfile',
extensions: [ '.dockerfile' ], extensions: ['.dockerfile'],
filenames: [ 'Dockerfile' ], filenames: ['Dockerfile'],
aliases: [ 'Dockerfile' ], aliases: ['Dockerfile'],
module: './dockerfile' module: './dockerfile'
}); });
registerLanguage({ registerLanguage({
id: 'fsharp', id: 'fsharp',
extensions: [ '.fs', '.fsi', '.ml', '.mli', '.fsx', '.fsscript' ], extensions: ['.fs', '.fsi', '.ml', '.mli', '.fsx', '.fsscript'],
aliases: [ 'F#', 'FSharp', 'fsharp' ], aliases: ['F#', 'FSharp', 'fsharp'],
module: './fsharp' module: './fsharp'
}); });
registerLanguage({ registerLanguage({
id: 'go', id: 'go',
extensions: [ '.go' ], extensions: ['.go'],
aliases: [ 'Go' ], aliases: ['Go'],
module: './go' module: './go'
}); });
registerLanguage({ registerLanguage({
@ -117,28 +117,28 @@ registerLanguage({
}); });
registerLanguage({ registerLanguage({
id: 'ini', id: 'ini',
extensions: [ '.ini', '.properties', '.gitconfig' ], extensions: ['.ini', '.properties', '.gitconfig'],
filenames: ['config', '.gitattributes', '.gitconfig', '.editorconfig'], filenames: ['config', '.gitattributes', '.gitconfig', '.editorconfig'],
aliases: [ 'Ini', 'ini' ], aliases: ['Ini', 'ini'],
module: './ini' module: './ini'
}); });
registerLanguage({ registerLanguage({
id: 'jade', id: 'jade',
extensions: [ '.jade', '.pug' ], extensions: ['.jade', '.pug'],
aliases: [ 'Jade', 'jade' ], aliases: ['Jade', 'jade'],
module: './jade' module: './jade'
}); });
registerLanguage({ registerLanguage({
id: 'java', id: 'java',
extensions: [ '.java', '.jav' ], extensions: ['.java', '.jav'],
aliases: [ 'Java', 'java' ], aliases: ['Java', 'java'],
mimetypes: ['text/x-java-source', 'text/x-java'], mimetypes: ['text/x-java-source', 'text/x-java'],
module: './java' module: './java'
}); });
registerLanguage({ registerLanguage({
id: 'lua', id: 'lua',
extensions: [ '.lua' ], extensions: ['.lua'],
aliases: [ 'Lua', 'lua' ], aliases: ['Lua', 'lua'],
module: './lua' module: './lua'
}); });
registerLanguage({ registerLanguage({
@ -155,14 +155,14 @@ registerLanguage({
}); });
registerLanguage({ registerLanguage({
id: 'objective-c', id: 'objective-c',
extensions: [ '.m' ], extensions: ['.m'],
aliases: [ 'Objective-C'], aliases: ['Objective-C'],
module: './objective-c' module: './objective-c'
}); });
registerLanguage({ registerLanguage({
id: 'postiats', id: 'postiats',
extensions: [ '.dats', '.sats', '.hats' ], extensions: ['.dats', '.sats', '.hats'],
aliases: [ 'ATS', 'ATS/Postiats' ], aliases: ['ATS', 'ATS/Postiats'],
module: './postiats' module: './postiats'
}); });
registerLanguage({ registerLanguage({
@ -174,21 +174,21 @@ registerLanguage({
}); });
registerLanguage({ registerLanguage({
id: 'powershell', id: 'powershell',
extensions: [ '.ps1', '.psm1', '.psd1' ], extensions: ['.ps1', '.psm1', '.psd1'],
aliases: [ 'PowerShell', 'powershell', 'ps', 'ps1' ], aliases: ['PowerShell', 'powershell', 'ps', 'ps1'],
module: './powershell' module: './powershell'
}); });
registerLanguage({ registerLanguage({
id: 'python', id: 'python',
extensions: [ '.py', '.rpy', '.pyw', '.cpy', '.gyp', '.gypi' ], extensions: ['.py', '.rpy', '.pyw', '.cpy', '.gyp', '.gypi'],
aliases: [ 'Python', 'py' ], aliases: ['Python', 'py'],
firstLine: '^#!/.*\\bpython[0-9.-]*\\b', firstLine: '^#!/.*\\bpython[0-9.-]*\\b',
module: './python' module: './python'
}); });
registerLanguage({ registerLanguage({
id: 'r', id: 'r',
extensions: [ '.r', '.rhistory', '.rprofile', '.rt' ], extensions: ['.r', '.rhistory', '.rprofile', '.rt'],
aliases: [ 'R', 'r' ], aliases: ['R', 'r'],
module: './r' module: './r'
}); });
registerLanguage({ registerLanguage({
@ -200,35 +200,35 @@ registerLanguage({
}); });
registerLanguage({ registerLanguage({
id: 'ruby', id: 'ruby',
extensions: [ '.rb', '.rbx', '.rjs', '.gemspec', '.pp' ], extensions: ['.rb', '.rbx', '.rjs', '.gemspec', '.pp'],
filenames: [ 'rakefile' ], filenames: ['rakefile'],
aliases: [ 'Ruby', 'rb' ], aliases: ['Ruby', 'rb'],
module: './ruby' module: './ruby'
}); });
registerLanguage({ registerLanguage({
id: 'swift', id: 'swift',
aliases: ['Swift','swift'], aliases: ['Swift', 'swift'],
extensions: ['.swift'], extensions: ['.swift'],
mimetypes: ['text/swift'], mimetypes: ['text/swift'],
module: './swift' module: './swift'
}); });
registerLanguage({ registerLanguage({
id: 'sql', id: 'sql',
extensions: [ '.sql' ], extensions: ['.sql'],
aliases: [ 'SQL' ], aliases: ['SQL'],
module: './sql' module: './sql'
}); });
registerLanguage({ registerLanguage({
id: 'vb', id: 'vb',
extensions: [ '.vb' ], extensions: ['.vb'],
aliases: [ 'Visual Basic', 'vb' ], aliases: ['Visual Basic', 'vb'],
module: './vb' module: './vb'
}); });
registerLanguage({ registerLanguage({
id: 'xml', id: 'xml',
extensions: [ '.xml', '.dtd', '.ascx', '.csproj', '.config', '.wxi', '.wxl', '.wxs', '.xaml', '.svg', '.svgz' ], extensions: ['.xml', '.dtd', '.ascx', '.csproj', '.config', '.wxi', '.wxl', '.wxs', '.xaml', '.svg', '.svgz'],
firstLine : '(\\<\\?xml.*)|(\\<svg)|(\\<\\!doctype\\s+svg)', firstLine: '(\\<\\?xml.*)|(\\<svg)|(\\<\\!doctype\\s+svg)',
aliases: [ 'XML', 'xml' ], aliases: ['XML', 'xml'],
mimetypes: ['text/xml', 'application/xml', 'application/xaml+xml', 'application/xml-dtd'], mimetypes: ['text/xml', 'application/xml', 'application/xaml+xml', 'application/xml-dtd'],
module: './xml' module: './xml'
}); });
@ -261,8 +261,8 @@ registerLanguage({
module: './yaml' module: './yaml'
}); });
registerLanguage({ registerLanguage({
id: 'sol', id: 'sol',
extensions: [ '.sol' ], extensions: ['.sol'],
aliases: [ 'sol','solidity','Solidity' ], aliases: ['sol', 'solidity', 'Solidity'],
module: './solidity' module: './solidity'
}); });

View file

@ -8,48 +8,48 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
comments: { comments: {
lineComment: '//', lineComment: '//',
blockComment: ['/*', '*/'], blockComment: ['/*', '*/'],
}, },
brackets: [['[',']'],['(',')'],['{','}']], brackets: [['[', ']'], ['(', ')'], ['{', '}']],
autoClosingPairs: [ 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'] },
{ open: '(', close: ')', notIn: ['string', 'comment'] }, { open: '(', close: ')', notIn: ['string', 'comment'] },
{ open: '{', close: '}', notIn: ['string', 'comment'] }, { open: '{', close: '}', notIn: ['string', 'comment'] },
] ]
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.msdax', tokenPostfix: '.msdax',
ignoreCase: true, ignoreCase: true,
brackets: [ brackets: [
{ open: '[', close: ']', token: 'delimiter.square' }, { open: '[', close: ']', token: 'delimiter.square' },
{ open: '{', close: '}', token: 'delimiter.brackets' }, { open: '{', close: '}', token: 'delimiter.brackets' },
{ open: '(', close: ')', token: 'delimiter.parenthesis' } { open: '(', close: ')', token: 'delimiter.parenthesis' }
], ],
keywords: [ keywords: [
// Query keywords // Query keywords
'VAR', 'VAR',
'RETURN', 'RETURN',
'NOT', 'NOT',
'EVALUATE', 'EVALUATE',
'DATATABLE', 'DATATABLE',
'ORDER', 'ORDER',
'BY', 'BY',
'START', 'START',
'AT', 'AT',
'DEFINE', 'DEFINE',
'MEASURE', 'MEASURE',
'ASC', 'ASC',
'DESC', 'DESC',
'IN', 'IN',
// Datatable types // Datatable types
'BOOLEAN', 'BOOLEAN',
'DOUBLE', 'DOUBLE',
@ -57,119 +57,120 @@ export var language = <ILanguage> {
'DATETIME', 'DATETIME',
'CURRENCY', 'CURRENCY',
'STRING' 'STRING'
], ],
functions: [ functions: [
// Relational // Relational
'CLOSINGBALANCEMONTH', 'CLOSINGBALANCEQUARTER', 'CLOSINGBALANCEYEAR', 'DATEADD', 'DATESBETWEEN', 'CLOSINGBALANCEMONTH', 'CLOSINGBALANCEQUARTER', 'CLOSINGBALANCEYEAR', 'DATEADD', 'DATESBETWEEN',
'DATESINPERIOD', 'DATESMTD', 'DATESQTD', 'DATESYTD', 'ENDOFMONTH', 'DATESINPERIOD', 'DATESMTD', 'DATESQTD', 'DATESYTD', 'ENDOFMONTH',
'ENDOFQUARTER', 'ENDOFYEAR', 'FIRSTDATE', 'FIRSTNONBLANK', 'LASTDATE', 'ENDOFQUARTER', 'ENDOFYEAR', 'FIRSTDATE', 'FIRSTNONBLANK', 'LASTDATE',
'LASTNONBLANK', 'NEXTDAY', 'NEXTMONTH', 'NEXTQUARTER', 'NEXTYEAR', 'LASTNONBLANK', 'NEXTDAY', 'NEXTMONTH', 'NEXTQUARTER', 'NEXTYEAR',
'OPENINGBALANCEMONTH', 'OPENINGBALANCEQUARTER', 'OPENINGBALANCEYEAR', 'PARALLELPERIOD', 'PREVIOUSDAY', 'OPENINGBALANCEMONTH', 'OPENINGBALANCEQUARTER', 'OPENINGBALANCEYEAR', 'PARALLELPERIOD', 'PREVIOUSDAY',
'PREVIOUSMONTH', 'PREVIOUSQUARTER', 'PREVIOUSYEAR', 'SAMEPERIODLASTYEAR', 'STARTOFMONTH', 'PREVIOUSMONTH', 'PREVIOUSQUARTER', 'PREVIOUSYEAR', 'SAMEPERIODLASTYEAR', 'STARTOFMONTH',
'STARTOFQUARTER', 'STARTOFYEAR', 'TOTALMTD', 'TOTALQTD', 'TOTALYTD', 'STARTOFQUARTER', 'STARTOFYEAR', 'TOTALMTD', 'TOTALQTD', 'TOTALYTD',
'ADDCOLUMNS', 'ADDMISSINGITEMS', 'ALL', 'ALLEXCEPT', 'ALLNOBLANKROW', 'ADDCOLUMNS', 'ADDMISSINGITEMS', 'ALL', 'ALLEXCEPT', 'ALLNOBLANKROW',
'ALLSELECTED', 'CALCULATE', 'CALCULATETABLE', 'CALENDAR', 'CALENDARAUTO', 'ALLSELECTED', 'CALCULATE', 'CALCULATETABLE', 'CALENDAR', 'CALENDARAUTO',
'CROSSFILTER', 'CROSSJOIN', 'CURRENTGROUP', 'DATATABLE', 'DETAILROWS', 'CROSSFILTER', 'CROSSJOIN', 'CURRENTGROUP', 'DATATABLE', 'DETAILROWS',
'DISTINCT', 'EARLIER', 'EARLIEST', 'EXCEPT', 'FILTER', 'DISTINCT', 'EARLIER', 'EARLIEST', 'EXCEPT', 'FILTER',
'FILTERS', 'GENERATE', 'GENERATEALL', 'GROUPBY', 'IGNORE', 'FILTERS', 'GENERATE', 'GENERATEALL', 'GROUPBY', 'IGNORE',
'INTERSECT', 'ISONORAFTER', 'KEEPFILTERS', 'LOOKUPVALUE', 'NATURALINNERJOIN', 'INTERSECT', 'ISONORAFTER', 'KEEPFILTERS', 'LOOKUPVALUE', 'NATURALINNERJOIN',
'NATURALLEFTOUTERJOIN', 'RELATED', 'RELATEDTABLE', 'ROLLUP', 'ROLLUPADDISSUBTOTAL', 'NATURALLEFTOUTERJOIN', 'RELATED', 'RELATEDTABLE', 'ROLLUP', 'ROLLUPADDISSUBTOTAL',
'ROLLUPGROUP', 'ROLLUPISSUBTOTAL', 'ROW', 'SAMPLE', 'SELECTCOLUMNS', 'ROLLUPGROUP', 'ROLLUPISSUBTOTAL', 'ROW', 'SAMPLE', 'SELECTCOLUMNS',
'SUBSTITUTEWITHINDEX', 'SUMMARIZE', 'SUMMARIZECOLUMNS', 'TOPN', 'TREATAS', 'SUBSTITUTEWITHINDEX', 'SUMMARIZE', 'SUMMARIZECOLUMNS', 'TOPN', 'TREATAS',
'UNION', 'USERELATIONSHIP', 'VALUES', 'SUM', 'SUMX', 'UNION', 'USERELATIONSHIP', 'VALUES', 'SUM', 'SUMX',
'PATH', 'PATHCONTAINS', 'PATHITEM', 'PATHITEMREVERSE', 'PATHLENGTH', 'PATH', 'PATHCONTAINS', 'PATHITEM', 'PATHITEMREVERSE', 'PATHLENGTH',
'AVERAGE', 'AVERAGEA', 'AVERAGEX', 'COUNT', 'COUNTA', 'AVERAGE', 'AVERAGEA', 'AVERAGEX', 'COUNT', 'COUNTA',
'COUNTAX', 'COUNTBLANK', 'COUNTROWS', 'COUNTX', 'DISTINCTCOUNT', 'COUNTAX', 'COUNTBLANK', 'COUNTROWS', 'COUNTX', 'DISTINCTCOUNT',
'DIVIDE', 'GEOMEAN', 'GEOMEANX', 'MAX', 'MAXA', 'DIVIDE', 'GEOMEAN', 'GEOMEANX', 'MAX', 'MAXA',
'MAXX', 'MEDIAN', 'MEDIANX', 'MIN', 'MINA', 'MAXX', 'MEDIAN', 'MEDIANX', 'MIN', 'MINA',
'MINX', 'PERCENTILE.EXC', 'PERCENTILE.INC', 'PERCENTILEX.EXC', 'PERCENTILEX.INC', 'MINX', 'PERCENTILE.EXC', 'PERCENTILE.INC', 'PERCENTILEX.EXC', 'PERCENTILEX.INC',
'PRODUCT', 'PRODUCTX', 'RANK.EQ', 'RANKX', 'STDEV.P', 'PRODUCT', 'PRODUCTX', 'RANK.EQ', 'RANKX', 'STDEV.P',
'STDEV.S', 'STDEVX.P', 'STDEVX.S', 'VAR.P', 'VAR.S', 'STDEV.S', 'STDEVX.P', 'STDEVX.S', 'VAR.P', 'VAR.S',
'VARX.P', 'VARX.S', 'XIRR', 'XNPV', 'VARX.P', 'VARX.S', 'XIRR', 'XNPV',
// Scalar // Scalar
'DATE', 'DATEDIFF', 'DATEVALUE', 'DAY', 'EDATE', 'DATE', 'DATEDIFF', 'DATEVALUE', 'DAY', 'EDATE',
'EOMONTH', 'HOUR', 'MINUTE', 'MONTH', 'NOW', 'EOMONTH', 'HOUR', 'MINUTE', 'MONTH', 'NOW',
'SECOND', 'TIME', 'TIMEVALUE', 'TODAY', 'WEEKDAY', 'SECOND', 'TIME', 'TIMEVALUE', 'TODAY', 'WEEKDAY',
'WEEKNUM', 'YEAR', 'YEARFRAC', 'CONTAINS', 'CONTAINSROW', 'WEEKNUM', 'YEAR', 'YEARFRAC', 'CONTAINS', 'CONTAINSROW',
'CUSTOMDATA', 'ERROR', 'HASONEFILTER', 'HASONEVALUE', 'ISBLANK', 'CUSTOMDATA', 'ERROR', 'HASONEFILTER', 'HASONEVALUE', 'ISBLANK',
'ISCROSSFILTERED', 'ISEMPTY', 'ISERROR', 'ISEVEN', 'ISFILTERED', 'ISCROSSFILTERED', 'ISEMPTY', 'ISERROR', 'ISEVEN', 'ISFILTERED',
'ISLOGICAL', 'ISNONTEXT', 'ISNUMBER', 'ISODD', 'ISSUBTOTAL', 'ISLOGICAL', 'ISNONTEXT', 'ISNUMBER', 'ISODD', 'ISSUBTOTAL',
'ISTEXT', 'USERNAME', 'USERPRINCIPALNAME', 'AND', 'FALSE', 'ISTEXT', 'USERNAME', 'USERPRINCIPALNAME', 'AND', 'FALSE',
'IF', 'IFERROR', 'NOT', 'OR', 'SWITCH', 'IF', 'IFERROR', 'NOT', 'OR', 'SWITCH',
'TRUE', 'ABS', 'ACOS', 'ACOSH', 'ACOT', 'TRUE', 'ABS', 'ACOS', 'ACOSH', 'ACOT',
'ACOTH', 'ASIN', 'ASINH', 'ATAN', 'ATANH', 'ACOTH', 'ASIN', 'ASINH', 'ATAN', 'ATANH',
'BETA.DIST', 'BETA.INV', 'CEILING', 'CHISQ.DIST', 'CHISQ.DIST.RT', 'BETA.DIST', 'BETA.INV', 'CEILING', 'CHISQ.DIST', 'CHISQ.DIST.RT',
'CHISQ.INV', 'CHISQ.INV.RT', 'COMBIN', 'COMBINA', 'CONFIDENCE.NORM', 'CHISQ.INV', 'CHISQ.INV.RT', 'COMBIN', 'COMBINA', 'CONFIDENCE.NORM',
'CONFIDENCE.T', 'COS', 'COSH', 'COT', 'COTH', 'CONFIDENCE.T', 'COS', 'COSH', 'COT', 'COTH',
'CURRENCY', 'DEGREES', 'EVEN', 'EXP', 'EXPON.DIST', 'CURRENCY', 'DEGREES', 'EVEN', 'EXP', 'EXPON.DIST',
'FACT', 'FLOOR', 'GCD', 'INT', 'ISO.CEILING', 'FACT', 'FLOOR', 'GCD', 'INT', 'ISO.CEILING',
'LCM', 'LN', 'LOG', 'LOG10', 'MOD', 'LCM', 'LN', 'LOG', 'LOG10', 'MOD',
'MROUND', 'ODD', 'PERMUT', 'PI', 'POISSON.DIST', 'MROUND', 'ODD', 'PERMUT', 'PI', 'POISSON.DIST',
'POWER', 'QUOTIENT', 'RADIANS', 'RAND', 'RANDBETWEEN', 'POWER', 'QUOTIENT', 'RADIANS', 'RAND', 'RANDBETWEEN',
'ROUND', 'ROUNDDOWN', 'ROUNDUP', 'SIGN', 'SIN', 'ROUND', 'ROUNDDOWN', 'ROUNDUP', 'SIGN', 'SIN',
'SINH', 'SQRT', 'SQRTPI', 'TAN', 'TANH', 'SINH', 'SQRT', 'SQRTPI', 'TAN', 'TANH',
'TRUNC', 'BLANK', 'CONCATENATE', 'CONCATENATEX', 'EXACT', 'TRUNC', 'BLANK', 'CONCATENATE', 'CONCATENATEX', 'EXACT',
'FIND', 'FIXED', 'FORMAT', 'LEFT', 'LEN', 'FIND', 'FIXED', 'FORMAT', 'LEFT', 'LEN',
'LOWER', 'MID', 'REPLACE', 'REPT', 'RIGHT', 'LOWER', 'MID', 'REPLACE', 'REPT', 'RIGHT',
'SEARCH', 'SUBSTITUTE', 'TRIM', 'UNICHAR', 'UNICODE', 'SEARCH', 'SUBSTITUTE', 'TRIM', 'UNICHAR', 'UNICODE',
'UPPER', 'VALUE' 'UPPER', 'VALUE'
], ],
tokenizer: { tokenizer: {
root: [ root: [
{ include: '@comments' }, { include: '@comments' },
{ include: '@whitespace' }, { include: '@whitespace' },
{ include: '@numbers' }, { include: '@numbers' },
{ include: '@strings' }, { include: '@strings' },
{ include: '@complexIdentifiers' }, { include: '@complexIdentifiers' },
[/[;,.]/, 'delimiter'], [/[;,.]/, 'delimiter'],
[/[({})]/, '@brackets'], [/[({})]/, '@brackets'],
[/[a-z_][a-zA-Z0-9_]*/, [/[a-z_][a-zA-Z0-9_]*/, {
{ cases: { '@keywords': 'keyword' cases: {
, '@functions': 'keyword' '@keywords': 'keyword',
, '@default': 'identifier' } '@functions': 'keyword',
} '@default': 'identifier'
], }
[/[<>=!%&+\-*/|~^]/, 'operator'], }],
], [/[<>=!%&+\-*/|~^]/, 'operator'],
whitespace: [ ],
[/\s+/, 'white'] whitespace: [
], [/\s+/, 'white']
comments: [ ],
[/\/\/+.*/, 'comment'], comments: [
[/\/\*/, { token: 'comment.quote', next: '@comment' }] [/\/\/+.*/, 'comment'],
], [/\/\*/, { token: 'comment.quote', next: '@comment' }]
comment: [ ],
[/[^*/]+/, 'comment'], comment: [
[/\*\//, { token: 'comment.quote', next: '@pop' }], [/[^*/]+/, 'comment'],
[/./, 'comment'] [/\*\//, { token: 'comment.quote', next: '@pop' }],
], [/./, 'comment']
numbers: [ ],
[/0[xX][0-9a-fA-F]*/, 'number'], numbers: [
[/[$][+-]*\d*(\.\d*)?/, 'number'], [/0[xX][0-9a-fA-F]*/, 'number'],
[/((\d+(\.\d*)?)|(\.\d+))([eE][\-+]?\d+)?/, 'number'] [/[$][+-]*\d*(\.\d*)?/, 'number'],
], [/((\d+(\.\d*)?)|(\.\d+))([eE][\-+]?\d+)?/, 'number']
strings: [ ],
[/N"/, { token: 'string', next: '@string' }], strings: [
[/"/, { token: 'string', next: '@string' }] [/N"/, { token: 'string', next: '@string' }],
], [/"/, { token: 'string', next: '@string' }]
string: [ ],
[/[^"]+/, 'string'], string: [
[/""/, 'string'], [/[^"]+/, 'string'],
[/"/, { token: 'string', next: '@pop' }] [/""/, 'string'],
], [/"/, { token: 'string', next: '@pop' }]
complexIdentifiers: [ ],
[/\[/, { token: 'identifier.quote', next: '@bracketedIdentifier' }], complexIdentifiers: [
[/'/, { token: 'identifier.quote', next: '@quotedIdentifier' }] [/\[/, { token: 'identifier.quote', next: '@bracketedIdentifier' }],
], [/'/, { token: 'identifier.quote', next: '@quotedIdentifier' }]
bracketedIdentifier: [ ],
[/[^\]]+/, 'identifier'], bracketedIdentifier: [
[/]]/, 'identifier'], [/[^\]]+/, 'identifier'],
[/]/, { token: 'identifier.quote', next: '@pop' }] [/]]/, 'identifier'],
], [/]/, { token: 'identifier.quote', next: '@pop' }]
quotedIdentifier: [ ],
[/[^']+/, 'identifier'], quotedIdentifier: [
[/''/, 'identifier'], [/[^']+/, 'identifier'],
[/'/, { token: 'identifier.quote', next: '@pop' }] [/''/, 'identifier'],
] [/'/, { token: 'identifier.quote', next: '@pop' }]
} ]
}
}; };

View file

@ -8,15 +8,15 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
comments: { comments: {
lineComment: '//', lineComment: '//',
blockComment: ['/*', '*/'], blockComment: ['/*', '*/'],
}, },
brackets: [ brackets: [
['{','}'], ['{', '}'],
['[',']'], ['[', ']'],
['(',')'] ['(', ')']
], ],
autoClosingPairs: [ autoClosingPairs: [
{ open: '{', close: '}' }, { open: '{', close: '}' },
@ -34,7 +34,7 @@ export var conf:IRichLanguageConfiguration = {
] ]
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.objective-c', tokenPostfix: '.objective-c',
@ -150,7 +150,7 @@ export var language = <ILanguage> {
decimal: /0|@decpart/, decimal: /0|@decpart/,
tokenizer: { tokenizer: {
root: [ root: [
{ include: '@comments' }, { include: '@comments' },
{ include: '@whitespace' }, { include: '@whitespace' },
{ include: '@numbers' }, { include: '@numbers' },
@ -159,53 +159,60 @@ export var language = <ILanguage> {
[/[,:;]/, 'delimiter'], [/[,:;]/, 'delimiter'],
[/[{}\[\]()<>]/, '@brackets'], [/[{}\[\]()<>]/, '@brackets'],
[/[a-zA-Z@#]\w*/, { cases: { '@keywords': 'keyword', [/[a-zA-Z@#]\w*/, {
'@default': 'identifier' } }], cases: {
'@keywords': 'keyword',
'@default': 'identifier'
}
}],
[/[<>=\\+\\-\\*\\/\\^\\|\\~,]|and\\b|or\\b|not\\b]/, 'operator'], [/[<>=\\+\\-\\*\\/\\^\\|\\~,]|and\\b|or\\b|not\\b]/, 'operator'],
],
whitespace: [
[/\s+/, 'white'],
],
comments: [
['\\/\\*','comment','@comment' ],
['\\/\\/+.*','comment' ],
], ],
comment: [ whitespace: [
['\\*\\/','comment','@pop' ], [/\s+/, 'white'],
['.', 'comment', ],
], ],
numbers: [ comments: [
['\\/\\*', 'comment', '@comment'],
['\\/\\/+.*', 'comment'],
],
comment: [
['\\*\\/', 'comment', '@pop'],
['.', 'comment',],
],
numbers: [
[/0[xX][0-9a-fA-F]*(_?[0-9a-fA-F])*/, 'number.hex'], [/0[xX][0-9a-fA-F]*(_?[0-9a-fA-F])*/, 'number.hex'],
[/@decimal((\.@decpart)?([eE][\-+]?@decpart)?)[fF]*/, { [/@decimal((\.@decpart)?([eE][\-+]?@decpart)?)[fF]*/, {
cases: { '(\\d)*': 'number', cases: {
'$0':'number.float' }} ] '(\\d)*': 'number',
'$0': 'number.float'
}
}]
], ],
// Recognize strings, including those broken across lines with \ (but not without) // Recognize strings, including those broken across lines with \ (but not without)
strings: [ strings: [
[/'$/, 'string.escape', '@popall'], [/'$/, 'string.escape', '@popall'],
[/'/, 'string.escape', '@stringBody'], [/'/, 'string.escape', '@stringBody'],
[/"$/, 'string.escape', '@popall'], [/"$/, 'string.escape', '@popall'],
[/"/, 'string.escape', '@dblStringBody'] [/"/, 'string.escape', '@dblStringBody']
], ],
stringBody: [ stringBody: [
[/\\./, 'string'], [/\\./, 'string'],
[/'/, 'string.escape', '@popall'], [/'/, 'string.escape', '@popall'],
[/.(?=.*')/, 'string'], [/.(?=.*')/, 'string'],
[/.*\\$/, 'string'], [/.*\\$/, 'string'],
[/.*$/, 'string', '@popall'] [/.*$/, 'string', '@popall']
], ],
dblStringBody: [ dblStringBody: [
[/\\./, 'string'], [/\\./, 'string'],
[/"/, 'string.escape', '@popall'], [/"/, 'string.escape', '@popall'],
[/.(?=.*")/, 'string'], [/.(?=.*")/, 'string'],
[/.*\\$/, 'string'], [/.*\\$/, 'string'],
[/.*$/, 'string', '@popall'] [/.*$/, 'string', '@popall']
] ]
} }
}; };

View file

@ -8,7 +8,7 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g, wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
comments: { comments: {
@ -41,7 +41,7 @@ export const htmlTokenTypes = {
} }
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '', tokenPostfix: '',
// ignoreCase: true, // ignoreCase: true,
@ -53,9 +53,9 @@ export var language = <ILanguage> {
[/<!DOCTYPE/, 'metatag.html', '@doctype'], [/<!DOCTYPE/, 'metatag.html', '@doctype'],
[/<!--/, 'comment.html', '@comment'], [/<!--/, 'comment.html', '@comment'],
[/(<)(\w+)(\/>)/, [htmlTokenTypes.DELIM_START, 'tag.html', htmlTokenTypes.DELIM_END]], [/(<)(\w+)(\/>)/, [htmlTokenTypes.DELIM_START, 'tag.html', htmlTokenTypes.DELIM_END]],
[/(<)(script)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@script'} ]], [/(<)(script)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@script' }]],
[/(<)(style)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@style'} ]], [/(<)(style)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@style' }]],
[/(<)([:\w]+)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@otherTag'} ]], [/(<)([:\w]+)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@otherTag' }]],
[/(<\/)(\w+)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@otherTag' }]], [/(<\/)(\w+)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@otherTag' }]],
[/</, htmlTokenTypes.DELIM_START], [/</, htmlTokenTypes.DELIM_START],
[/[^<]+/] // text [/[^<]+/] // text
@ -63,8 +63,8 @@ export var language = <ILanguage> {
doctype: [ doctype: [
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.comment' }], [/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.comment' }],
[/[^>]+/, 'metatag.content.html' ], [/[^>]+/, 'metatag.content.html'],
[/>/, 'metatag.html', '@pop' ], [/>/, 'metatag.html', '@pop'],
], ],
comment: [ comment: [
@ -94,15 +94,15 @@ export var language = <ILanguage> {
[/'([^']*)'/, 'attribute.value'], [/'([^']*)'/, 'attribute.value'],
[/[\w\-]+/, 'attribute.name'], [/[\w\-]+/, 'attribute.name'],
[/=/, 'delimiter'], [/=/, 'delimiter'],
[/>/, { token: htmlTokenTypes.DELIM_END, next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript'} ], [/>/, { token: htmlTokenTypes.DELIM_END, next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript' }],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/(<\/)(script\s*)(>)/, [ htmlTokenTypes.DELIM_START, 'tag.html', { token: htmlTokenTypes.DELIM_END, next: '@pop' } ]] [/(<\/)(script\s*)(>)/, [htmlTokenTypes.DELIM_START, 'tag.html', { token: htmlTokenTypes.DELIM_END, next: '@pop' }]]
], ],
// After <script ... type // After <script ... type
scriptAfterType: [ scriptAfterType: [
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.scriptAfterType' }], [/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.scriptAfterType' }],
[/=/,'delimiter', '@scriptAfterTypeEquals'], [/=/, 'delimiter', '@scriptAfterTypeEquals'],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }] [/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
], ],
@ -110,8 +110,8 @@ export var language = <ILanguage> {
// After <script ... type = // After <script ... type =
scriptAfterTypeEquals: [ scriptAfterTypeEquals: [
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.scriptAfterTypeEquals' }], [/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.scriptAfterTypeEquals' }],
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' } ], [/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' } ], [/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }] [/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
], ],
@ -119,7 +119,7 @@ export var language = <ILanguage> {
// After <script ... type = $S2 // After <script ... type = $S2
scriptWithCustomType: [ scriptWithCustomType: [
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.scriptWithCustomType.$S2' }], [/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.scriptWithCustomType.$S2' }],
[/>/, { token: htmlTokenTypes.DELIM_END, next: '@scriptEmbedded.$S2', nextEmbedded: '$S2'}], [/>/, { token: htmlTokenTypes.DELIM_END, next: '@scriptEmbedded.$S2', nextEmbedded: '$S2' }],
[/"([^"]*)"/, 'attribute.value'], [/"([^"]*)"/, 'attribute.value'],
[/'([^']*)'/, 'attribute.value'], [/'([^']*)'/, 'attribute.value'],
[/[\w\-]+/, 'attribute.name'], [/[\w\-]+/, 'attribute.name'],
@ -146,15 +146,15 @@ export var language = <ILanguage> {
[/'([^']*)'/, 'attribute.value'], [/'([^']*)'/, 'attribute.value'],
[/[\w\-]+/, 'attribute.name'], [/[\w\-]+/, 'attribute.name'],
[/=/, 'delimiter'], [/=/, 'delimiter'],
[/>/, { token: htmlTokenTypes.DELIM_END, next: '@styleEmbedded.text/css', nextEmbedded: 'text/css'} ], [/>/, { token: htmlTokenTypes.DELIM_END, next: '@styleEmbedded.text/css', nextEmbedded: 'text/css' }],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/(<\/)(style\s*)(>)/, [htmlTokenTypes.DELIM_START, 'tag.html', { token: htmlTokenTypes.DELIM_END, next: '@pop' } ]] [/(<\/)(style\s*)(>)/, [htmlTokenTypes.DELIM_START, 'tag.html', { token: htmlTokenTypes.DELIM_END, next: '@pop' }]]
], ],
// After <style ... type // After <style ... type
styleAfterType: [ styleAfterType: [
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.styleAfterType' }], [/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.styleAfterType' }],
[/=/,'delimiter', '@styleAfterTypeEquals'], [/=/, 'delimiter', '@styleAfterTypeEquals'],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }] [/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
], ],
@ -162,8 +162,8 @@ export var language = <ILanguage> {
// After <style ... type = // After <style ... type =
styleAfterTypeEquals: [ styleAfterTypeEquals: [
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.styleAfterTypeEquals' }], [/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.styleAfterTypeEquals' }],
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' } ], [/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' } ], [/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }] [/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
], ],
@ -171,7 +171,7 @@ export var language = <ILanguage> {
// After <style ... type = $S2 // After <style ... type = $S2
styleWithCustomType: [ styleWithCustomType: [
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.styleWithCustomType.$S2' }], [/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.styleWithCustomType.$S2' }],
[/>/, { token: htmlTokenTypes.DELIM_END, next: '@styleEmbedded.$S2', nextEmbedded: '$S2'}], [/>/, { token: htmlTokenTypes.DELIM_END, next: '@styleEmbedded.$S2', nextEmbedded: '$S2' }],
[/"([^"]*)"/, 'attribute.value'], [/"([^"]*)"/, 'attribute.value'],
[/'([^']*)'/, 'attribute.value'], [/'([^']*)'/, 'attribute.value'],
[/[\w\-]+/, 'attribute.name'], [/[\w\-]+/, 'attribute.name'],
@ -203,22 +203,22 @@ export var language = <ILanguage> {
phpRoot: [ phpRoot: [
[/[a-zA-Z_]\w*/, { [/[a-zA-Z_]\w*/, {
cases: { cases: {
'@phpKeywords': { token:'keyword.php' }, '@phpKeywords': { token: 'keyword.php' },
'@phpCompileTimeConstants': { token: 'constant.php'}, '@phpCompileTimeConstants': { token: 'constant.php' },
'@default': 'identifier.php' '@default': 'identifier.php'
} }
}], }],
[/[$a-zA-Z_]\w*/, { [/[$a-zA-Z_]\w*/, {
cases: { cases: {
'@phpPreDefinedVariables': { token:'variable.predefined.php' }, '@phpPreDefinedVariables': { token: 'variable.predefined.php' },
'@default': 'variable.php' '@default': 'variable.php'
} }
}], }],
// brackets // brackets
[/[{}]/, 'delimiter.bracket.php' ], [/[{}]/, 'delimiter.bracket.php'],
[/[\[\]]/, 'delimiter.array.php' ], [/[\[\]]/, 'delimiter.array.php'],
[/[()]/, 'delimiter.parenthesis.php' ], [/[()]/, 'delimiter.parenthesis.php'],
// whitespace // whitespace
[/[ \t\r\n]+/], [/[ \t\r\n]+/],
@ -228,14 +228,14 @@ export var language = <ILanguage> {
[/\/\//, 'comment.php', '@phpLineComment'], [/\/\//, 'comment.php', '@phpLineComment'],
// block comments // block comments
[/\/\*/, 'comment.php', '@phpComment' ], [/\/\*/, 'comment.php', '@phpComment'],
// strings // strings
[/"/, 'string.php', '@phpDoubleQuoteString' ], [/"/, 'string.php', '@phpDoubleQuoteString'],
[/'/, 'string.php', '@phpSingleQuoteString' ], [/'/, 'string.php', '@phpSingleQuoteString'],
// delimiters // delimiters
[/[\+\-\*\%\&\|\^\~\!\=\<\>\/\?\;\:\.\,\@]/, 'delimiter.php' ], [/[\+\-\*\%\&\|\^\~\!\=\<\>\/\?\;\:\.\,\@]/, 'delimiter.php'],
// numbers // numbers
[/\d*\d+[eE]([\-+]?\d+)?/, 'number.float.php'], [/\d*\d+[eE]([\-+]?\d+)?/, 'number.float.php'],
@ -262,17 +262,17 @@ export var language = <ILanguage> {
], ],
phpDoubleQuoteString: [ phpDoubleQuoteString: [
[/[^\\"]+/, 'string.php'], [/[^\\"]+/, 'string.php'],
[/@escapes/, 'string.escape.php'], [/@escapes/, 'string.escape.php'],
[/\\./, 'string.escape.invalid.php'], [/\\./, 'string.escape.invalid.php'],
[/"/, 'string.php', '@pop' ] [/"/, 'string.php', '@pop']
], ],
phpSingleQuoteString: [ phpSingleQuoteString: [
[/[^\\']+/, 'string.php'], [/[^\\']+/, 'string.php'],
[/@escapes/, 'string.escape.php'], [/@escapes/, 'string.escape.php'],
[/\\./, 'string.escape.invalid.php'], [/\\./, 'string.escape.invalid.php'],
[/'/, 'string.php', '@pop' ] [/'/, 'string.php', '@pop']
], ],
}, },
@ -321,7 +321,7 @@ export var language = <ILanguage> {
'$argv' '$argv'
], ],
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
}; };
// TESTED WITH // TESTED WITH
@ -426,4 +426,4 @@ export var language = <ILanguage> {
// ?> // ?>
// </body> // </body>
// </html> // </html>

File diff suppressed because it is too large Load diff

View file

@ -8,7 +8,7 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
// the default separators except `$-` // the default separators except `$-`
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#%\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g, wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#%\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
comments: { comments: {
@ -16,9 +16,9 @@ export var conf:IRichLanguageConfiguration = {
blockComment: ['<#', '#>'], blockComment: ['<#', '#>'],
}, },
brackets: [ brackets: [
['{','}'], ['{', '}'],
['[',']'], ['[', ']'],
['(',')'] ['(', ')']
], ],
autoClosingPairs: [ autoClosingPairs: [
{ open: '{', close: '}' }, { open: '{', close: '}' },
@ -36,7 +36,7 @@ export var conf:IRichLanguageConfiguration = {
] ]
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
ignoreCase: true, ignoreCase: true,
tokenPostfix: '.ps1', tokenPostfix: '.ps1',
@ -67,8 +67,12 @@ export var language = <ILanguage> {
root: [ root: [
// commands and keywords // commands and keywords
[/[a-zA-Z_][\w-]*/, { cases: { '@keywords': {token:'keyword.$0'}, [/[a-zA-Z_][\w-]*/, {
'@default': '' } }], cases: {
'@keywords': { token: 'keyword.$0' },
'@default': ''
}
}],
// whitespace // whitespace
[/[ \t\r\n]+/, ''], [/[ \t\r\n]+/, ''],
@ -97,36 +101,90 @@ export var language = <ILanguage> {
// strings: // strings:
[/\@"/, 'string', '@herestring."'], [/\@"/, 'string', '@herestring."'],
[/\@'/, 'string', '@herestring.\''], [/\@'/, 'string', '@herestring.\''],
[/"/, { cases: { '@eos': 'string', '@default': {token:'string', next:'@string."'} }} ], [/"/, {
[/'/, { cases: { '@eos': 'string', '@default': {token:'string', next:'@string.\''} }} ], cases: {
'@eos': 'string',
'@default': { token: 'string', next: '@string."' }
}
}],
[/'/, {
cases: {
'@eos': 'string',
'@default': { token: 'string', next: '@string.\'' }
}
}],
], ],
string: [ string: [
[/[^"'\$`]+/, { cases: { '@eos': {token:'string', next:'@popall'}, '@default': 'string' }}], [/[^"'\$`]+/, {
[/@escapes/, { cases: { '@eos': {token:'string.escape', next:'@popall'}, '@default': 'string.escape' }}], cases: {
[/`./, { cases: { '@eos': {token:'string.escape.invalid', next:'@popall'}, '@default': 'string.escape.invalid' }}], '@eos': { token: 'string', next: '@popall' },
'@default': 'string'
}
}],
[/@escapes/, {
cases: {
'@eos': { token: 'string.escape', next: '@popall' },
'@default': 'string.escape'
}
}],
[/`./, {
cases: {
'@eos': { token: 'string.escape.invalid', next: '@popall' },
'@default': 'string.escape.invalid'
}
}],
[/\$[\w]+$/, { cases: { '$S2=="': { token: 'variable', next: '@popall' }, '@default': { token: 'string', next: '@popall' } } }], [/\$[\w]+$/, {
[/\$[\w]+/, { cases: { '$S2=="': 'variable', '@default': 'string' }}], cases: {
'$S2=="': { token: 'variable', next: '@popall' },
'@default': { token: 'string', next: '@popall' }
}
}],
[/\$[\w]+/, {
cases: {
'$S2=="': 'variable',
'@default': 'string'
}
}],
[/["']/, { cases: { '$#==$S2' : { token: 'string', next: '@pop' }, [/["']/, {
'@default': { cases: { '@eos': {token:'string', next:'@popall'}, '@default': 'string' }} }} ], cases: {
'$#==$S2': { token: 'string', next: '@pop' },
'@default': {
cases: {
'@eos': { token: 'string', next: '@popall' },
'@default': 'string'
}
}
}
}],
], ],
herestring: [ herestring: [
[/^\s*(["'])@/, { cases: { '$1==$S2': { token: 'string', next: '@pop' }, '@default': 'string' } }], [/^\s*(["'])@/, {
[/[^\$`]+/,'string' ], cases: {
'$1==$S2': { token: 'string', next: '@pop' },
'@default': 'string'
}
}],
[/[^\$`]+/, 'string'],
[/@escapes/, 'string.escape'], [/@escapes/, 'string.escape'],
[/`./, 'string.escape.invalid'], [/`./, 'string.escape.invalid'],
[/\$[\w]+/, { cases: { '$S2=="': 'variable', '@default': 'string' } }], [/\$[\w]+/, {
cases: {
'$S2=="': 'variable',
'@default': 'string'
}
}],
], ],
comment: [ comment: [
[/[^#\.]+/, 'comment' ], [/[^#\.]+/, 'comment'],
[/#>/, 'comment', '@pop'], [/#>/, 'comment', '@pop'],
[/(\.)(@helpKeywords)(?!\w)/, { token: 'comment.keyword.$2' } ], [/(\.)(@helpKeywords)(?!\w)/, { token: 'comment.keyword.$2' }],
[/[\.#]/, 'comment' ] [/[\.#]/, 'comment']
], ],
}, },
}; };

View file

@ -8,15 +8,15 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
comments: { comments: {
lineComment: '#', lineComment: '#',
blockComment: ['\'\'\'', '\'\'\''], blockComment: ['\'\'\'', '\'\'\''],
}, },
brackets: [ brackets: [
['{','}'], ['{', '}'],
['[',']'], ['[', ']'],
['(',')'] ['(', ')']
], ],
autoClosingPairs: [ autoClosingPairs: [
{ open: '{', close: '}' }, { open: '{', close: '}' },
@ -34,7 +34,7 @@ export var conf:IRichLanguageConfiguration = {
] ]
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.python', tokenPostfix: '.python',
@ -178,7 +178,7 @@ export var language = <ILanguage> {
], ],
tokenizer: { tokenizer: {
root: [ root: [
{ include: '@whitespace' }, { include: '@whitespace' },
{ include: '@numbers' }, { include: '@numbers' },
{ include: '@strings' }, { include: '@strings' },
@ -187,55 +187,59 @@ export var language = <ILanguage> {
[/[{}\[\]()]/, '@brackets'], [/[{}\[\]()]/, '@brackets'],
[/@[a-zA-Z]\w*/, 'tag'], [/@[a-zA-Z]\w*/, 'tag'],
[/[a-zA-Z]\w*/, { cases: { '@keywords': 'keyword', [/[a-zA-Z]\w*/, {
'@default': 'identifier' } }] cases: {
], '@keywords': 'keyword',
'@default': 'identifier'
}
}]
],
// Deal with white space, including single and multi-line comments // Deal with white space, including single and multi-line comments
whitespace: [ whitespace: [
[/\s+/, 'white'], [/\s+/, 'white'],
[/(^#.*$)/, 'comment'], [/(^#.*$)/, 'comment'],
[/('''.*''')|(""".*""")/, 'string'], [/('''.*''')|(""".*""")/, 'string'],
[/'''.*$/, 'string', '@endDocString'], [/'''.*$/, 'string', '@endDocString'],
[/""".*$/, 'string', '@endDblDocString'] [/""".*$/, 'string', '@endDblDocString']
], ],
endDocString: [ endDocString: [
[/\\'/, 'string'], [/\\'/, 'string'],
[/.*'''/, 'string', '@popall'], [/.*'''/, 'string', '@popall'],
[/.*$/, 'string'] [/.*$/, 'string']
], ],
endDblDocString: [ endDblDocString: [
[/\\"/, 'string'], [/\\"/, 'string'],
[/.*"""/, 'string', '@popall'], [/.*"""/, 'string', '@popall'],
[/.*$/, 'string'] [/.*$/, 'string']
], ],
// Recognize hex, negatives, decimals, imaginaries, longs, and scientific notation // Recognize hex, negatives, decimals, imaginaries, longs, and scientific notation
numbers: [ numbers: [
[/-?0x([abcdef]|[ABCDEF]|\d)+[lL]?/, 'number.hex'], [/-?0x([abcdef]|[ABCDEF]|\d)+[lL]?/, 'number.hex'],
[/-?(\d*\.)?\d+([eE][+\-]?\d+)?[jJ]?[lL]?/, 'number'] [/-?(\d*\.)?\d+([eE][+\-]?\d+)?[jJ]?[lL]?/, 'number']
], ],
// Recognize strings, including those broken across lines with \ (but not without) // Recognize strings, including those broken across lines with \ (but not without)
strings: [ strings: [
[/'$/, 'string.escape', '@popall'], [/'$/, 'string.escape', '@popall'],
[/'/, 'string.escape', '@stringBody'], [/'/, 'string.escape', '@stringBody'],
[/"$/, 'string.escape', '@popall'], [/"$/, 'string.escape', '@popall'],
[/"/, 'string.escape', '@dblStringBody'] [/"/, 'string.escape', '@dblStringBody']
], ],
stringBody: [ stringBody: [
[/\\./, 'string'], [/\\./, 'string'],
[/'/, 'string.escape', '@popall'], [/'/, 'string.escape', '@popall'],
[/.(?=.*')/, 'string'], [/.(?=.*')/, 'string'],
[/.*\\$/, 'string'], [/.*\\$/, 'string'],
[/.*$/, 'string', '@popall'] [/.*$/, 'string', '@popall']
], ],
dblStringBody: [ dblStringBody: [
[/\\./, 'string'], [/\\./, 'string'],
[/"/, 'string.escape', '@popall'], [/"/, 'string.escape', '@popall'],
[/.(?=.*")/, 'string'], [/.(?=.*")/, 'string'],
[/.*\\$/, 'string'], [/.*\\$/, 'string'],
[/.*$/, 'string', '@popall'] [/.*$/, 'string', '@popall']
] ]
} }
}; };

View file

@ -8,14 +8,14 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
comments: { comments: {
lineComment: '#' lineComment: '#'
}, },
brackets: [ brackets: [
['{','}'], ['{', '}'],
['[',']'], ['[', ']'],
['(',')'] ['(', ')']
], ],
autoClosingPairs: [ autoClosingPairs: [
{ open: '{', close: '}' }, { open: '{', close: '}' },
@ -31,7 +31,7 @@ export var conf:IRichLanguageConfiguration = {
] ]
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.r', tokenPostfix: '.r',
@ -236,4 +236,4 @@ export var language = <ILanguage> {
[/./, 'string'], [/./, 'string'],
] ]
} }
}; };

View file

@ -11,9 +11,9 @@ import ILanguage = monaco.languages.IMonarchLanguage;
// Allow for running under nodejs/requirejs in tests // Allow for running under nodejs/requirejs in tests
var _monaco: typeof monaco = (typeof monaco === 'undefined' ? (<any>self).monaco : monaco); var _monaco: typeof monaco = (typeof monaco === 'undefined' ? (<any>self).monaco : monaco);
const EMPTY_ELEMENTS:string[] = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']; const EMPTY_ELEMENTS: string[] = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr'];
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\s]+)/g, wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\s]+)/g,
comments: { comments: {
@ -64,7 +64,7 @@ export const htmlTokenTypes = {
} }
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '', tokenPostfix: '',
// ignoreCase: true, // ignoreCase: true,
@ -77,9 +77,9 @@ export var language = <ILanguage> {
[/<!DOCTYPE/, 'metatag.html', '@doctype'], [/<!DOCTYPE/, 'metatag.html', '@doctype'],
[/<!--/, 'comment.html', '@comment'], [/<!--/, 'comment.html', '@comment'],
[/(<)(\w+)(\/>)/, [htmlTokenTypes.DELIM_START, 'tag.html', htmlTokenTypes.DELIM_END]], [/(<)(\w+)(\/>)/, [htmlTokenTypes.DELIM_START, 'tag.html', htmlTokenTypes.DELIM_END]],
[/(<)(script)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@script'} ]], [/(<)(script)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@script' }]],
[/(<)(style)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@style'} ]], [/(<)(style)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@style' }]],
[/(<)([:\w]+)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@otherTag'} ]], [/(<)([:\w]+)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@otherTag' }]],
[/(<\/)(\w+)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@otherTag' }]], [/(<\/)(\w+)/, [htmlTokenTypes.DELIM_START, { token: 'tag.html', next: '@otherTag' }]],
[/</, htmlTokenTypes.DELIM_START], [/</, htmlTokenTypes.DELIM_START],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
@ -88,8 +88,8 @@ export var language = <ILanguage> {
doctype: [ doctype: [
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.comment' }], [/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.comment' }],
[/[^>]+/, 'metatag.content.html' ], [/[^>]+/, 'metatag.content.html'],
[/>/, 'metatag.html', '@pop' ], [/>/, 'metatag.html', '@pop'],
], ],
comment: [ comment: [
@ -119,15 +119,15 @@ export var language = <ILanguage> {
[/'([^']*)'/, 'attribute.value'], [/'([^']*)'/, 'attribute.value'],
[/[\w\-]+/, 'attribute.name'], [/[\w\-]+/, 'attribute.name'],
[/=/, 'delimiter'], [/=/, 'delimiter'],
[/>/, { token: htmlTokenTypes.DELIM_END, next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript'} ], [/>/, { token: htmlTokenTypes.DELIM_END, next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript' }],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/(<\/)(script\s*)(>)/, [ htmlTokenTypes.DELIM_START, 'tag.html', { token: htmlTokenTypes.DELIM_END, next: '@pop' } ]] [/(<\/)(script\s*)(>)/, [htmlTokenTypes.DELIM_START, 'tag.html', { token: htmlTokenTypes.DELIM_END, next: '@pop' }]]
], ],
// After <script ... type // After <script ... type
scriptAfterType: [ scriptAfterType: [
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.scriptAfterType' }], [/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.scriptAfterType' }],
[/=/,'delimiter', '@scriptAfterTypeEquals'], [/=/, 'delimiter', '@scriptAfterTypeEquals'],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }] [/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
], ],
@ -135,8 +135,8 @@ export var language = <ILanguage> {
// After <script ... type = // After <script ... type =
scriptAfterTypeEquals: [ scriptAfterTypeEquals: [
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.scriptAfterTypeEquals' }], [/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.scriptAfterTypeEquals' }],
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' } ], [/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' } ], [/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }] [/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
], ],
@ -144,7 +144,7 @@ export var language = <ILanguage> {
// After <script ... type = $S2 // After <script ... type = $S2
scriptWithCustomType: [ scriptWithCustomType: [
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.scriptWithCustomType.$S2' }], [/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.scriptWithCustomType.$S2' }],
[/>/, { token: htmlTokenTypes.DELIM_END, next: '@scriptEmbedded.$S2', nextEmbedded: '$S2'}], [/>/, { token: htmlTokenTypes.DELIM_END, next: '@scriptEmbedded.$S2', nextEmbedded: '$S2' }],
[/"([^"]*)"/, 'attribute.value'], [/"([^"]*)"/, 'attribute.value'],
[/'([^']*)'/, 'attribute.value'], [/'([^']*)'/, 'attribute.value'],
[/[\w\-]+/, 'attribute.name'], [/[\w\-]+/, 'attribute.name'],
@ -171,15 +171,15 @@ export var language = <ILanguage> {
[/'([^']*)'/, 'attribute.value'], [/'([^']*)'/, 'attribute.value'],
[/[\w\-]+/, 'attribute.name'], [/[\w\-]+/, 'attribute.name'],
[/=/, 'delimiter'], [/=/, 'delimiter'],
[/>/, { token: htmlTokenTypes.DELIM_END, next: '@styleEmbedded.text/css', nextEmbedded: 'text/css'} ], [/>/, { token: htmlTokenTypes.DELIM_END, next: '@styleEmbedded.text/css', nextEmbedded: 'text/css' }],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/(<\/)(style\s*)(>)/, [htmlTokenTypes.DELIM_START, 'tag.html', { token: htmlTokenTypes.DELIM_END, next: '@pop' } ]] [/(<\/)(style\s*)(>)/, [htmlTokenTypes.DELIM_START, 'tag.html', { token: htmlTokenTypes.DELIM_END, next: '@pop' }]]
], ],
// After <style ... type // After <style ... type
styleAfterType: [ styleAfterType: [
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.styleAfterType' }], [/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.styleAfterType' }],
[/=/,'delimiter', '@styleAfterTypeEquals'], [/=/, 'delimiter', '@styleAfterTypeEquals'],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }] [/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
], ],
@ -187,8 +187,8 @@ export var language = <ILanguage> {
// After <style ... type = // After <style ... type =
styleAfterTypeEquals: [ styleAfterTypeEquals: [
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.styleAfterTypeEquals' }], [/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.styleAfterTypeEquals' }],
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' } ], [/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' } ], [/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
[/[ \t\r\n]+/], // whitespace [/[ \t\r\n]+/], // whitespace
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }] [/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
], ],
@ -196,7 +196,7 @@ export var language = <ILanguage> {
// After <style ... type = $S2 // After <style ... type = $S2
styleWithCustomType: [ styleWithCustomType: [
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.styleWithCustomType.$S2' }], [/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.styleWithCustomType.$S2' }],
[/>/, { token: htmlTokenTypes.DELIM_END, next: '@styleEmbedded.$S2', nextEmbedded: '$S2'}], [/>/, { token: htmlTokenTypes.DELIM_END, next: '@styleEmbedded.$S2', nextEmbedded: '$S2' }],
[/"([^"]*)"/, 'attribute.value'], [/"([^"]*)"/, 'attribute.value'],
[/'([^']*)'/, 'attribute.value'], [/'([^']*)'/, 'attribute.value'],
[/[\w\-]+/, 'attribute.name'], [/[\w\-]+/, 'attribute.name'],
@ -216,7 +216,7 @@ export var language = <ILanguage> {
razorInSimpleState: [ razorInSimpleState: [
[/@\*/, 'comment.cs', '@razorBlockCommentTopLevel'], [/@\*/, 'comment.cs', '@razorBlockCommentTopLevel'],
[/@[{(]/, 'metatag.cs', '@razorRootTopLevel'], [/@[{(]/, 'metatag.cs', '@razorRootTopLevel'],
[/(@)(\s*[\w]+)/, ['metatag.cs', { token: 'identifier.cs', switchTo: '@$S2.$S3'} ]], [/(@)(\s*[\w]+)/, ['metatag.cs', { token: 'identifier.cs', switchTo: '@$S2.$S3' }]],
[/[})]/, { token: 'metatag.cs', switchTo: '@$S2.$S3' }], [/[})]/, { token: 'metatag.cs', switchTo: '@$S2.$S3' }],
[/\*@/, { token: 'comment.cs', switchTo: '@$S2.$S3' }], [/\*@/, { token: 'comment.cs', switchTo: '@$S2.$S3' }],
], ],
@ -224,7 +224,7 @@ export var language = <ILanguage> {
razorInEmbeddedState: [ razorInEmbeddedState: [
[/@\*/, 'comment.cs', '@razorBlockCommentTopLevel'], [/@\*/, 'comment.cs', '@razorBlockCommentTopLevel'],
[/@[{(]/, 'metatag.cs', '@razorRootTopLevel'], [/@[{(]/, 'metatag.cs', '@razorRootTopLevel'],
[/(@)(\s*[\w]+)/, ['metatag.cs', { token: 'identifier.cs', switchTo: '@$S2.$S3', nextEmbedded: '$S3'} ]], [/(@)(\s*[\w]+)/, ['metatag.cs', { token: 'identifier.cs', switchTo: '@$S2.$S3', nextEmbedded: '$S3' }]],
[/[})]/, { token: 'metatag.cs', switchTo: '@$S2.$S3', nextEmbedded: '$S3' }], [/[})]/, { token: 'metatag.cs', switchTo: '@$S2.$S3', nextEmbedded: '$S3' }],
[/\*@/, { token: 'comment.cs', switchTo: '@$S2.$S3', nextEmbedded: '$S3' }], [/\*@/, { token: 'comment.cs', switchTo: '@$S2.$S3', nextEmbedded: '$S3' }],
], ],
@ -242,30 +242,30 @@ export var language = <ILanguage> {
], ],
razorRootTopLevel: [ razorRootTopLevel: [
[/\{/, 'delimiter.bracket.cs', '@razorRoot'] , [/\{/, 'delimiter.bracket.cs', '@razorRoot'],
[/\(/, 'delimiter.parenthesis.cs', '@razorRoot'] , [/\(/, 'delimiter.parenthesis.cs', '@razorRoot'],
[/[})]/, '@rematch', '@pop'], [/[})]/, '@rematch', '@pop'],
{ include: 'razorCommon' } { include: 'razorCommon' }
], ],
razorRoot: [ razorRoot: [
[/\{/, 'delimiter.bracket.cs', '@razorRoot'] , [/\{/, 'delimiter.bracket.cs', '@razorRoot'],
[/\(/, 'delimiter.parenthesis.cs', '@razorRoot'] , [/\(/, 'delimiter.parenthesis.cs', '@razorRoot'],
[/\}/, 'delimiter.bracket.cs', '@pop'], [/\}/, 'delimiter.bracket.cs', '@pop'],
[/\)/, 'delimiter.parenthesis.cs', '@pop'], [/\)/, 'delimiter.parenthesis.cs', '@pop'],
{ include: 'razorCommon' } { include: 'razorCommon' }
], ],
razorCommon: [ razorCommon: [
[/[a-zA-Z_]\w*/, { [/[a-zA-Z_]\w*/, {
cases: { cases: {
'@razorKeywords': { token:'keyword.cs' }, '@razorKeywords': { token: 'keyword.cs' },
'@default': 'identifier.cs' '@default': 'identifier.cs'
} }
}], }],
// brackets // brackets
[/[\[\]]/, 'delimiter.array.cs' ], [/[\[\]]/, 'delimiter.array.cs'],
// whitespace // whitespace
[/[ \t\r\n]+/], [/[ \t\r\n]+/],
@ -275,7 +275,7 @@ export var language = <ILanguage> {
[/@\*/, 'comment.cs', '@razorBlockComment'], [/@\*/, 'comment.cs', '@razorBlockComment'],
// strings // strings
[/"([^"]*)"/, 'string.cs'], [/"([^"]*)"/, 'string.cs'],
[/'([^']*)'/, 'string.cs'], [/'([^']*)'/, 'string.cs'],
// simple html // simple html
@ -284,7 +284,7 @@ export var language = <ILanguage> {
[/(<\/)(\w+)(>)/, [htmlTokenTypes.DELIM_START, 'tag.html', htmlTokenTypes.DELIM_END]], [/(<\/)(\w+)(>)/, [htmlTokenTypes.DELIM_START, 'tag.html', htmlTokenTypes.DELIM_END]],
// delimiters // delimiters
[/[\+\-\*\%\&\|\^\~\!\=\<\>\/\?\;\:\.\,]/, 'delimiter.cs' ], [/[\+\-\*\%\&\|\^\~\!\=\<\>\/\?\;\:\.\,]/, 'delimiter.cs'],
// numbers // numbers
[/\d*\d+[eE]([\-+]?\d+)?/, 'number.float.cs'], [/\d*\d+[eE]([\-+]?\d+)?/, 'number.float.cs'],

View file

@ -8,15 +8,15 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
comments: { comments: {
lineComment: '#', lineComment: '#',
blockComment: ['=begin', '=end'], blockComment: ['=begin', '=end'],
}, },
brackets: [ brackets: [
['(',')'], ['(', ')'],
['{','}'], ['{', '}'],
['[',']'] ['[', ']']
], ],
autoClosingPairs: [ autoClosingPairs: [
{ open: '{', close: '}' }, { open: '{', close: '}' },
@ -83,7 +83,7 @@ export var conf:IRichLanguageConfiguration = {
* regular expression can also contain comments. * regular expression can also contain comments.
*/ */
export var language = <ILanguage> { export var language = <ILanguage>{
tokenPostfix: '.ruby', tokenPostfix: '.ruby',
keywords: [ keywords: [
@ -105,11 +105,11 @@ export var language = <ILanguage> {
// these are closed by 'end' (if, while and until are handled separately) // these are closed by 'end' (if, while and until are handled separately)
declarations: [ declarations: [
'module','class','def','case','do','begin','for','if','while','until','unless' 'module', 'class', 'def', 'case', 'do', 'begin', 'for', 'if', 'while', 'until', 'unless'
], ],
linedecls: [ linedecls: [
'def','case','do','begin','for','if','while','until','unless' 'def', 'case', 'do', 'begin', 'for', 'if', 'while', 'until', 'unless'
], ],
operators: [ operators: [
@ -119,22 +119,22 @@ export var language = <ILanguage> {
], ],
brackets: [ brackets: [
{ open: '(', close: ')', token: 'delimiter.parenthesis'}, { open: '(', close: ')', token: 'delimiter.parenthesis' },
{ open: '{', close: '}', token: 'delimiter.curly'}, { open: '{', close: '}', token: 'delimiter.curly' },
{ open: '[', close: ']', token: 'delimiter.square'} { open: '[', close: ']', token: 'delimiter.square' }
], ],
// we include these common regular expressions // we include these common regular expressions
symbols: /[=><!~?:&|+\-*\/\^%\.]+/, symbols: /[=><!~?:&|+\-*\/\^%\.]+/,
// escape sequences // escape sequences
escape: /(?:[abefnrstv\\"'\n\r]|[0-7]{1,3}|x[0-9A-Fa-f]{1,2}|u[0-9A-Fa-f]{4})/, escape: /(?:[abefnrstv\\"'\n\r]|[0-7]{1,3}|x[0-9A-Fa-f]{1,2}|u[0-9A-Fa-f]{4})/,
escapes: /\\(?:C\-(@escape|.)|c(@escape|.)|@escape)/, escapes: /\\(?:C\-(@escape|.)|c(@escape|.)|@escape)/,
decpart: /\d(_?\d)*/, decpart: /\d(_?\d)*/,
decimal: /0|@decpart/, decimal: /0|@decpart/,
delim: /[^a-zA-Z0-9\s\n\r]/, delim: /[^a-zA-Z0-9\s\n\r]/,
heredelim: /(?:\w+|'[^']*'|"[^"]*"|`[^`]*`)/, heredelim: /(?:\w+|'[^']*'|"[^"]*"|`[^`]*`)/,
regexpctl: /[(){}\[\]\$\^|\-*+?\.]/, regexpctl: /[(){}\[\]\$\^|\-*+?\.]/,
@ -150,56 +150,68 @@ export var language = <ILanguage> {
// most complexity here is due to matching 'end' correctly with declarations. // most complexity here is due to matching 'end' correctly with declarations.
// We distinguish a declaration that comes first on a line, versus declarations further on a line (which are most likey modifiers) // We distinguish a declaration that comes first on a line, versus declarations further on a line (which are most likey modifiers)
[/^(\s*)([a-z_]\w*[!?=]?)/, ['white', [/^(\s*)([a-z_]\w*[!?=]?)/, ['white',
{ cases: { 'for|until|while': { token: 'keyword.$2', next: '@dodecl.$2' }, {
'@declarations': { token: 'keyword.$2', next: '@root.$2' }, cases: {
'end': { token: 'keyword.$S2', next: '@pop' }, 'for|until|while': { token: 'keyword.$2', next: '@dodecl.$2' },
'@keywords': 'keyword', '@declarations': { token: 'keyword.$2', next: '@root.$2' },
'@builtins': 'predefined', 'end': { token: 'keyword.$S2', next: '@pop' },
'@default': 'identifier' } }]], '@keywords': 'keyword',
'@builtins': 'predefined',
'@default': 'identifier'
}
}]],
[/[a-z_]\w*[!?=]?/, [/[a-z_]\w*[!?=]?/,
{ cases: { 'if|unless|while|until': { token: 'keyword.$0x', next: '@modifier.$0x' }, {
'for': { token: 'keyword.$2', next: '@dodecl.$2' }, cases: {
'@linedecls': { token: 'keyword.$0', next: '@root.$0' }, 'if|unless|while|until': { token: 'keyword.$0x', next: '@modifier.$0x' },
'end': { token: 'keyword.$S2', next: '@pop' }, 'for': { token: 'keyword.$2', next: '@dodecl.$2' },
'@keywords': 'keyword', '@linedecls': { token: 'keyword.$0', next: '@root.$0' },
'@builtins': 'predefined', 'end': { token: 'keyword.$S2', next: '@pop' },
'@default': 'identifier' } }], '@keywords': 'keyword',
'@builtins': 'predefined',
'@default': 'identifier'
}
}],
[/[A-Z][\w]*[!?=]?/, 'constructor.identifier' ], // constant [/[A-Z][\w]*[!?=]?/, 'constructor.identifier'], // constant
[/\$[\w]*/, 'global.constant' ], // global [/\$[\w]*/, 'global.constant'], // global
[/@[\w]*/, 'namespace.instance.identifier' ], // instance [/@[\w]*/, 'namespace.instance.identifier'], // instance
[/@@[\w]*/, 'namespace.class.identifier' ], // class [/@@[\w]*/, 'namespace.class.identifier'], // class
// here document // here document
[/<<-(@heredelim).*/, { token: 'string.heredoc.delimiter', next: '@heredoc.$1' } ], [/<<-(@heredelim).*/, { token: 'string.heredoc.delimiter', next: '@heredoc.$1' }],
[/[ \t\r\n]+<<(@heredelim).*/, { token: 'string.heredoc.delimiter', next: '@heredoc.$1' } ], [/[ \t\r\n]+<<(@heredelim).*/, { token: 'string.heredoc.delimiter', next: '@heredoc.$1' }],
[/^<<(@heredelim).*/, { token: 'string.heredoc.delimiter', next: '@heredoc.$1' } ], [/^<<(@heredelim).*/, { token: 'string.heredoc.delimiter', next: '@heredoc.$1' }],
// whitespace // whitespace
{ include: '@whitespace' }, { include: '@whitespace' },
// strings // strings
[/"/, { token: 'string.d.delim', next: '@dstring.d."'} ], [/"/, { token: 'string.d.delim', next: '@dstring.d."' }],
[/'/, { token: 'string.sq.delim', next: '@sstring.sq' } ], [/'/, { token: 'string.sq.delim', next: '@sstring.sq' }],
// % literals. For efficiency, rematch in the 'pstring' state // % literals. For efficiency, rematch in the 'pstring' state
[/%([rsqxwW]|Q?)/, { token: '@rematch', next: 'pstring' } ], [/%([rsqxwW]|Q?)/, { token: '@rematch', next: 'pstring' }],
// commands and symbols // commands and symbols
[/`/, { token: 'string.x.delim', next: '@dstring.x.`' } ], [/`/, { token: 'string.x.delim', next: '@dstring.x.`' }],
[/:(\w|[$@])\w*[!?=]?/, 'string.s'], [/:(\w|[$@])\w*[!?=]?/, 'string.s'],
[/:"/, { token: 'string.s.delim', next: '@dstring.s."' } ], [/:"/, { token: 'string.s.delim', next: '@dstring.s."' }],
[/:'/, { token: 'string.s.delim', next: '@sstring.s' } ], [/:'/, { token: 'string.s.delim', next: '@sstring.s' }],
// regular expressions. Lookahead for a (not escaped) closing forwardslash on the same line // regular expressions. Lookahead for a (not escaped) closing forwardslash on the same line
[/\/(?=(\\\/|[^\/\n])+\/)/, { token: 'regexp.delim', next: '@regexp' } ], [/\/(?=(\\\/|[^\/\n])+\/)/, { token: 'regexp.delim', next: '@regexp' }],
// delimiters and operators // delimiters and operators
[/[{}()\[\]]/, '@brackets'], [/[{}()\[\]]/, '@brackets'],
[/@symbols/, { cases: { '@keywordops': 'keyword', [/@symbols/, {
'@operators' : 'operator', cases: {
'@default' : '' } } ], '@keywordops': 'keyword',
'@operators': 'operator',
'@default': ''
}
}],
[/[;,]/, 'delimiter'], [/[;,]/, 'delimiter'],
@ -208,8 +220,12 @@ export var language = <ILanguage> {
[/0[_oO][0-7](_?[0-7])*/, 'number.octal'], [/0[_oO][0-7](_?[0-7])*/, 'number.octal'],
[/0[bB][01](_?[01])*/, 'number.binary'], [/0[bB][01](_?[01])*/, 'number.binary'],
[/0[dD]@decpart/, 'number'], [/0[dD]@decpart/, 'number'],
[/@decimal((\.@decpart)?([eE][\-+]?@decpart)?)/, { cases: { '$1': 'number.float', [/@decimal((\.@decpart)?([eE][\-+]?@decpart)?)/, {
'@default': 'number' }}], cases: {
'$1': 'number.float',
'@default': 'number'
}
}],
], ],
@ -218,12 +234,16 @@ export var language = <ILanguage> {
// dodecl.<decl> where decl is the declarations started, like 'while' // dodecl.<decl> where decl is the declarations started, like 'while'
dodecl: [ dodecl: [
[/^/, { token: '', switchTo: '@root.$S2' }], // get out of do-skipping mode on a new line [/^/, { token: '', switchTo: '@root.$S2' }], // get out of do-skipping mode on a new line
[/[a-z_]\w*[!?=]?/, { cases: { 'end': { token: 'keyword.$S2', next: '@pop' }, // end on same line [/[a-z_]\w*[!?=]?/, {
'do' : { token: 'keyword', switchTo: '@root.$S2' }, // do on same line: not an open bracket here cases: {
'@linedecls': { token: '@rematch', switchTo: '@root.$S2' }, // other declaration on same line: rematch 'end': { token: 'keyword.$S2', next: '@pop' }, // end on same line
'@keywords': 'keyword', 'do': { token: 'keyword', switchTo: '@root.$S2' }, // do on same line: not an open bracket here
'@builtins': 'predefined', '@linedecls': { token: '@rematch', switchTo: '@root.$S2' }, // other declaration on same line: rematch
'@default': 'identifier' } }], '@keywords': 'keyword',
'@builtins': 'predefined',
'@default': 'identifier'
}
}],
{ include: '@root' } { include: '@root' }
], ],
@ -232,22 +252,26 @@ export var language = <ILanguage> {
// modifier.<decl>x where decl is the declaration starter, like 'if' // modifier.<decl>x where decl is the declaration starter, like 'if'
modifier: [ modifier: [
[/^/, '', '@pop'], // it was a modifier: get out of modifier mode on a new line [/^/, '', '@pop'], // it was a modifier: get out of modifier mode on a new line
[/[a-z_]\w*[!?=]?/, { cases: { 'end': { token: 'keyword.$S2', next: '@pop' }, // end on same line [/[a-z_]\w*[!?=]?/, {
'then|else|elsif|do': { token: 'keyword', switchTo: '@root.$S2' }, // real declaration and not a modifier cases: {
'@linedecls': { token: '@rematch', switchTo: '@root.$S2' }, // other declaration => not a modifier 'end': { token: 'keyword.$S2', next: '@pop' }, // end on same line
'@keywords': 'keyword', 'then|else|elsif|do': { token: 'keyword', switchTo: '@root.$S2' }, // real declaration and not a modifier
'@builtins': 'predefined', '@linedecls': { token: '@rematch', switchTo: '@root.$S2' }, // other declaration => not a modifier
'@default': 'identifier' } }], '@keywords': 'keyword',
'@builtins': 'predefined',
'@default': 'identifier'
}
}],
{ include: '@root' } { include: '@root' }
], ],
// single quote strings (also used for symbols) // single quote strings (also used for symbols)
// sstring.<kind> where kind is 'sq' (single quote) or 's' (symbol) // sstring.<kind> where kind is 'sq' (single quote) or 's' (symbol)
sstring: [ sstring: [
[/[^\\']+/, 'string.$S2' ], [/[^\\']+/, 'string.$S2'],
[/\\\\|\\'|\\$/, 'string.$S2.escape'], [/\\\\|\\'|\\$/, 'string.$S2.escape'],
[/\\./, 'string.$S2.invalid'], [/\\./, 'string.$S2.invalid'],
[/'/, { token: 'string.$S2.delim', next: '@pop'} ] [/'/, { token: 'string.$S2.delim', next: '@pop' }]
], ],
// double quoted "string". // double quoted "string".
@ -255,34 +279,42 @@ export var language = <ILanguage> {
// and delim is the ending delimiter (" or `) // and delim is the ending delimiter (" or `)
dstring: [ dstring: [
[/[^\\`"#]+/, 'string.$S2'], [/[^\\`"#]+/, 'string.$S2'],
[/#/, 'string.$S2.escape', '@interpolated' ], [/#/, 'string.$S2.escape', '@interpolated'],
[/\\$/, 'string.$S2.escape' ], [/\\$/, 'string.$S2.escape'],
[/@escapes/, 'string.$S2.escape'], [/@escapes/, 'string.$S2.escape'],
[/\\./, 'string.$S2.escape.invalid'], [/\\./, 'string.$S2.escape.invalid'],
[/[`"]/, { cases: { '$#==$S3': { token: 'string.$S2.delim', next: '@pop'}, [/[`"]/, {
'@default': 'string.$S2' } } ] cases: {
'$#==$S3': { token: 'string.$S2.delim', next: '@pop' },
'@default': 'string.$S2'
}
}]
], ],
// literal documents // literal documents
// heredoc.<close> where close is the closing delimiter // heredoc.<close> where close is the closing delimiter
heredoc: [ heredoc: [
[/^(\s*)(@heredelim)$/, { cases: { '$2==$S2': ['string.heredoc', { token: 'string.heredoc.delimiter', next: '@pop' }], [/^(\s*)(@heredelim)$/, {
'@default': ['string.heredoc','string.heredoc'] }}], cases: {
[/.*/, 'string.heredoc' ], '$2==$S2': ['string.heredoc', { token: 'string.heredoc.delimiter', next: '@pop' }],
'@default': ['string.heredoc', 'string.heredoc']
}
}],
[/.*/, 'string.heredoc'],
], ],
// interpolated sequence // interpolated sequence
interpolated: [ interpolated: [
[/\$\w*/, 'global.constant', '@pop' ], [/\$\w*/, 'global.constant', '@pop'],
[/@\w*/, 'namespace.class.identifier', '@pop' ], [/@\w*/, 'namespace.class.identifier', '@pop'],
[/@@\w*/, 'namespace.instance.identifier', '@pop' ], [/@@\w*/, 'namespace.instance.identifier', '@pop'],
[/[{]/, { token: 'string.escape.curly', switchTo: '@interpolated_compound' }], [/[{]/, { token: 'string.escape.curly', switchTo: '@interpolated_compound' }],
['', '', '@pop' ], // just a # is interpreted as a # ['', '', '@pop'], // just a # is interpreted as a #
], ],
// any code // any code
interpolated_compound: [ interpolated_compound: [
[/[}]/, { token: 'string.escape.curly', next: '@pop'} ], [/[}]/, { token: 'string.escape.curly', next: '@pop' }],
{ include: '@root' }, { include: '@root' },
], ],
@ -293,72 +325,76 @@ export var language = <ILanguage> {
// turns out that you can quote using regex control characters, aargh! // turns out that you can quote using regex control characters, aargh!
// for example; %r|kgjgaj| is ok (even though | is used for alternation) // for example; %r|kgjgaj| is ok (even though | is used for alternation)
// so, we need to match those first // so, we need to match those first
[/[^\(\{\[\\]/, { cases: { '$#==$S3' : { token: 'regexp.delim', next: '@pop' }, [/[^\(\{\[\\]/, {
'$#==$S2' : { token: 'regexp.delim', next: '@push' }, // nested delimiters are allowed.. cases: {
'~[)}\\]]' : '@brackets.regexp.escape.control', '$#==$S3': { token: 'regexp.delim', next: '@pop' },
'~@regexpctl': 'regexp.escape.control', '$#==$S2': { token: 'regexp.delim', next: '@push' }, // nested delimiters are allowed..
'@default': 'regexp' }}], '~[)}\\]]': '@brackets.regexp.escape.control',
'~@regexpctl': 'regexp.escape.control',
'@default': 'regexp'
}
}],
{ include: '@regexcontrol' }, { include: '@regexcontrol' },
], ],
// We match regular expression quite precisely // We match regular expression quite precisely
regexp: [ regexp: [
{ include: '@regexcontrol' }, { include: '@regexcontrol' },
[/[^\\\/]/, 'regexp' ], [/[^\\\/]/, 'regexp'],
['/[ixmp]*', { token: 'regexp.delim'}, '@pop' ], ['/[ixmp]*', { token: 'regexp.delim' }, '@pop'],
], ],
regexcontrol: [ regexcontrol: [
[/(\{)(\d+(?:,\d*)?)(\})/, ['@brackets.regexp.escape.control', 'regexp.escape.control', '@brackets.regexp.escape.control'] ], [/(\{)(\d+(?:,\d*)?)(\})/, ['@brackets.regexp.escape.control', 'regexp.escape.control', '@brackets.regexp.escape.control']],
[/(\[)(\^?)/, ['@brackets.regexp.escape.control',{ token: 'regexp.escape.control', next: '@regexrange'}]], [/(\[)(\^?)/, ['@brackets.regexp.escape.control', { token: 'regexp.escape.control', next: '@regexrange' }]],
[/(\()(\?[:=!])/, ['@brackets.regexp.escape.control', 'regexp.escape.control'] ], [/(\()(\?[:=!])/, ['@brackets.regexp.escape.control', 'regexp.escape.control']],
[/\(\?#/, { token: 'regexp.escape.control', next: '@regexpcomment' }], [/\(\?#/, { token: 'regexp.escape.control', next: '@regexpcomment' }],
[/[()]/, '@brackets.regexp.escape.control'], [/[()]/, '@brackets.regexp.escape.control'],
[/@regexpctl/, 'regexp.escape.control'], [/@regexpctl/, 'regexp.escape.control'],
[/\\$/, 'regexp.escape' ], [/\\$/, 'regexp.escape'],
[/@regexpesc/, 'regexp.escape' ], [/@regexpesc/, 'regexp.escape'],
[/\\\./, 'regexp.invalid' ], [/\\\./, 'regexp.invalid'],
[/#/, 'regexp.escape', '@interpolated' ], [/#/, 'regexp.escape', '@interpolated'],
], ],
regexrange: [ regexrange: [
[/-/, 'regexp.escape.control'], [/-/, 'regexp.escape.control'],
[/\^/, 'regexp.invalid'], [/\^/, 'regexp.invalid'],
[/\\$/, 'regexp.escape' ], [/\\$/, 'regexp.escape'],
[/@regexpesc/, 'regexp.escape'], [/@regexpesc/, 'regexp.escape'],
[/[^\]]/, 'regexp'], [/[^\]]/, 'regexp'],
[/\]/, '@brackets.regexp.escape.control', '@pop'], [/\]/, '@brackets.regexp.escape.control', '@pop'],
], ],
regexpcomment: [ regexpcomment: [
[ /[^)]+/, 'comment' ], [/[^)]+/, 'comment'],
[ /\)/, { token: 'regexp.escape.control', next: '@pop' } ] [/\)/, { token: 'regexp.escape.control', next: '@pop' }]
], ],
// % quoted strings // % quoted strings
// A bit repetitive since we need to often special case the kind of ending delimiter // A bit repetitive since we need to often special case the kind of ending delimiter
pstring: [ pstring: [
[/%([qws])\(/, { token: 'string.$1.delim', switchTo: '@qstring.$1.(.)' } ], [/%([qws])\(/, { token: 'string.$1.delim', switchTo: '@qstring.$1.(.)' }],
[/%([qws])\[/, { token: 'string.$1.delim', switchTo: '@qstring.$1.[.]' } ], [/%([qws])\[/, { token: 'string.$1.delim', switchTo: '@qstring.$1.[.]' }],
[/%([qws])\{/, { token: 'string.$1.delim', switchTo: '@qstring.$1.{.}' } ], [/%([qws])\{/, { token: 'string.$1.delim', switchTo: '@qstring.$1.{.}' }],
[/%([qws])</, { token: 'string.$1.delim', switchTo: '@qstring.$1.<.>' } ], [/%([qws])</, { token: 'string.$1.delim', switchTo: '@qstring.$1.<.>' }],
[/%([qws])(@delim)/, { token: 'string.$1.delim', switchTo: '@qstring.$1.$2.$2' } ], [/%([qws])(@delim)/, { token: 'string.$1.delim', switchTo: '@qstring.$1.$2.$2' }],
[/%r\(/, { token: 'regexp.delim', switchTo: '@pregexp.(.)' } ], [/%r\(/, { token: 'regexp.delim', switchTo: '@pregexp.(.)' }],
[/%r\[/, { token: 'regexp.delim', switchTo: '@pregexp.[.]' } ], [/%r\[/, { token: 'regexp.delim', switchTo: '@pregexp.[.]' }],
[/%r\{/, { token: 'regexp.delim', switchTo: '@pregexp.{.}' } ], [/%r\{/, { token: 'regexp.delim', switchTo: '@pregexp.{.}' }],
[/%r</, { token: 'regexp.delim', switchTo: '@pregexp.<.>' } ], [/%r</, { token: 'regexp.delim', switchTo: '@pregexp.<.>' }],
[/%r(@delim)/, { token: 'regexp.delim', switchTo: '@pregexp.$1.$1' } ], [/%r(@delim)/, { token: 'regexp.delim', switchTo: '@pregexp.$1.$1' }],
[/%(x|W|Q?)\(/, { token: 'string.$1.delim', switchTo: '@qqstring.$1.(.)' } ], [/%(x|W|Q?)\(/, { token: 'string.$1.delim', switchTo: '@qqstring.$1.(.)' }],
[/%(x|W|Q?)\[/, { token: 'string.$1.delim', switchTo: '@qqstring.$1.[.]' } ], [/%(x|W|Q?)\[/, { token: 'string.$1.delim', switchTo: '@qqstring.$1.[.]' }],
[/%(x|W|Q?)\{/, { token: 'string.$1.delim', switchTo: '@qqstring.$1.{.}' } ], [/%(x|W|Q?)\{/, { token: 'string.$1.delim', switchTo: '@qqstring.$1.{.}' }],
[/%(x|W|Q?)</, { token: 'string.$1.delim', switchTo: '@qqstring.$1.<.>' } ], [/%(x|W|Q?)</, { token: 'string.$1.delim', switchTo: '@qqstring.$1.<.>' }],
[/%(x|W|Q?)(@delim)/, { token: 'string.$1.delim', switchTo: '@qqstring.$1.$2.$2' } ], [/%(x|W|Q?)(@delim)/, { token: 'string.$1.delim', switchTo: '@qqstring.$1.$2.$2' }],
[/%([rqwsxW]|Q?)./, { token: 'invalid', next: '@pop' } ], // recover [/%([rqwsxW]|Q?)./, { token: 'invalid', next: '@pop' }], // recover
[/./, { token: 'invalid', next: '@pop' } ], // recover [/./, { token: 'invalid', next: '@pop' }], // recover
], ],
// non-expanded quoted string. // non-expanded quoted string.
@ -367,11 +403,15 @@ export var language = <ILanguage> {
// open = open delimiter // open = open delimiter
// close = close delimiter // close = close delimiter
qstring: [ qstring: [
[/\\$/, 'string.$S2.escape' ], [/\\$/, 'string.$S2.escape'],
[/\\./, 'string.$S2.escape' ], [/\\./, 'string.$S2.escape'],
[/./, { cases: { '$#==$S4' : { token: 'string.$S2.delim', next: '@pop' }, [/./, {
'$#==$S3' : { token: 'string.$S2.delim', next: '@push' }, // nested delimiters are allowed.. cases: {
'@default': 'string.$S2' }}], '$#==$S4': { token: 'string.$S2.delim', next: '@pop' },
'$#==$S3': { token: 'string.$S2.delim', next: '@push' }, // nested delimiters are allowed..
'@default': 'string.$S2'
}
}],
], ],
// expanded quoted string. // expanded quoted string.
@ -380,7 +420,7 @@ export var language = <ILanguage> {
// open = open delimiter // open = open delimiter
// close = close delimiter // close = close delimiter
qqstring: [ qqstring: [
[/#/, 'string.$S2.escape', '@interpolated' ], [/#/, 'string.$S2.escape', '@interpolated'],
{ include: '@qstring' } { include: '@qstring' }
], ],
@ -388,15 +428,15 @@ export var language = <ILanguage> {
// whitespace & comments // whitespace & comments
whitespace: [ whitespace: [
[/[ \t\r\n]+/, ''], [/[ \t\r\n]+/, ''],
[/^\s*=begin\b/, 'comment', '@comment' ], [/^\s*=begin\b/, 'comment', '@comment'],
[/#.*$/, 'comment'], [/#.*$/, 'comment'],
], ],
comment: [ comment: [
[/[^=]+/, 'comment' ], [/[^=]+/, 'comment'],
[/^\s*=begin\b/, 'comment.invalid' ], // nested comment [/^\s*=begin\b/, 'comment.invalid'], // nested comment
[/^\s*=end\b.*/, 'comment', '@pop' ], [/^\s*=end\b.*/, 'comment', '@pop'],
[/[=]/, 'comment' ] [/[=]/, 'comment']
], ],
} }
}; };

View file

@ -9,30 +9,30 @@ import LanguageConfiguration = monaco.languages.LanguageConfiguration;
import IMonarchLanguage = monaco.languages.IMonarchLanguage; import IMonarchLanguage = monaco.languages.IMonarchLanguage;
export var conf: LanguageConfiguration = { export var conf: LanguageConfiguration = {
wordPattern: /(#?-?\d*\.\d\w*%?)|([@$#!.:]?[\w-?]+%?)|[@#!.]/g, wordPattern: /(#?-?\d*\.\d\w*%?)|([@$#!.:]?[\w-?]+%?)|[@#!.]/g,
comments: { comments: {
blockComment: ['/*', '*/'], blockComment: ['/*', '*/'],
lineComment: '//' lineComment: '//'
}, },
brackets: [ brackets: [
['{', '}'], ['{', '}'],
['[', ']'], ['[', ']'],
['(', ')'] ['(', ')']
], ],
autoClosingPairs: [ 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'] },
{ open: '"', close: '"', notIn: ['string', 'comment'] }, { open: '"', close: '"', notIn: ['string', 'comment'] },
{ open: '\'', close: '\'', notIn: ['string', 'comment'] }, { open: '\'', close: '\'', notIn: ['string', 'comment'] },
], ],
surroundingPairs: [ surroundingPairs: [
{ open: '{', close: '}' }, { open: '{', close: '}' },
{ open: '[', close: ']' }, { open: '[', close: ']' },
{ open: '(', close: ')' }, { open: '(', close: ')' },
{ open: '"', close: '"' }, { open: '"', close: '"' },
{ open: '\'', close: '\'' }, { open: '\'', close: '\'' },
] ]
}; };
const TOKEN_SELECTOR = 'tag'; const TOKEN_SELECTOR = 'tag';
@ -41,247 +41,247 @@ const TOKEN_PROPERTY = 'attribute.name';
const TOKEN_VALUE = 'attribute.value'; const TOKEN_VALUE = 'attribute.value';
const TOKEN_AT_KEYWORD = 'keyword'; const TOKEN_AT_KEYWORD = 'keyword';
export var language = <IMonarchLanguage> { export var language = <IMonarchLanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.scss', tokenPostfix: '.scss',
ws: '[ \t\n\r\f]*', // whitespaces (referenced in several rules) 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])))*', 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])))*',
brackets: [ brackets: [
{ open: '{', close: '}', token: 'delimiter.curly' }, { open: '{', close: '}', token: 'delimiter.curly' },
{ open: '[', close: ']', token: 'delimiter.bracket' }, { open: '[', close: ']', token: 'delimiter.bracket' },
{ open: '(', close: ')', token: 'delimiter.parenthesis' }, { open: '(', close: ')', token: 'delimiter.parenthesis' },
{ open: '<', close: '>', token: 'delimiter.angle' } { open: '<', close: '>', token: 'delimiter.angle' }
], ],
tokenizer: { tokenizer: {
root: [ root: [
{ include: '@selector' }, { include: '@selector' },
], ],
selector: [ selector: [
{ include: '@comments' }, { include: '@comments' },
{ include: '@import' }, { include: '@import' },
{ include: '@variabledeclaration' }, { include: '@variabledeclaration' },
{ include: '@warndebug' }, // sass: log statements { include: '@warndebug' }, // sass: log statements
['[@](include)', { token: TOKEN_AT_KEYWORD, next: '@includedeclaration' }], // sass: include statement ['[@](include)', { token: TOKEN_AT_KEYWORD, next: '@includedeclaration' }], // sass: include statement
['[@](keyframes|-webkit-keyframes|-moz-keyframes|-o-keyframes)', { token: TOKEN_AT_KEYWORD, next: '@keyframedeclaration' }], ['[@](keyframes|-webkit-keyframes|-moz-keyframes|-o-keyframes)', { token: TOKEN_AT_KEYWORD, next: '@keyframedeclaration' }],
['[@](page|content|font-face|-moz-document)', { token: TOKEN_AT_KEYWORD }], // sass: placeholder for includes ['[@](page|content|font-face|-moz-document)', { token: TOKEN_AT_KEYWORD }], // sass: placeholder for includes
['[@](charset|namespace)', { token: TOKEN_AT_KEYWORD, next: '@declarationbody' }], ['[@](charset|namespace)', { token: TOKEN_AT_KEYWORD, next: '@declarationbody' }],
['[@](function)', { token: TOKEN_AT_KEYWORD, next: '@functiondeclaration' }], ['[@](function)', { token: TOKEN_AT_KEYWORD, next: '@functiondeclaration' }],
['[@](mixin)', { token: TOKEN_AT_KEYWORD, next: '@mixindeclaration' }], ['[@](mixin)', { token: TOKEN_AT_KEYWORD, next: '@mixindeclaration' }],
['url(\\-prefix)?\\(', { token: 'meta', next: '@urldeclaration' }], ['url(\\-prefix)?\\(', { token: 'meta', next: '@urldeclaration' }],
{ include: '@controlstatement' }, // sass control statements { include: '@controlstatement' }, // sass control statements
{ include: '@selectorname' }, { include: '@selectorname' },
['[&\\*]', TOKEN_SELECTOR_TAG], // selector symbols ['[&\\*]', TOKEN_SELECTOR_TAG], // selector symbols
['[>\\+,]', 'delimiter'], // selector operators ['[>\\+,]', 'delimiter'], // selector operators
['\\[', { token: 'delimiter.bracket', next: '@selectorattribute' }], ['\\[', { token: 'delimiter.bracket', next: '@selectorattribute' }],
['{', { token: 'delimiter.curly', next: '@selectorbody' }], ['{', { token: 'delimiter.curly', next: '@selectorbody' }],
], ],
selectorbody: [ selectorbody: [
['[*_]?@identifier@ws:(?=(\\s|\\d|[^{;}]*[;}]))', TOKEN_PROPERTY, '@rulevalue'], // rule definition: to distinguish from a nested selector check for whitespace, number or a semicolon ['[*_]?@identifier@ws:(?=(\\s|\\d|[^{;}]*[;}]))', TOKEN_PROPERTY, '@rulevalue'], // rule definition: to distinguish from a nested selector check for whitespace, number or a semicolon
{ include: '@selector' }, // sass: nested selectors { include: '@selector' }, // sass: nested selectors
['[@](extend)', { token: TOKEN_AT_KEYWORD, next: '@extendbody' }], // sass: extend other selectors ['[@](extend)', { token: TOKEN_AT_KEYWORD, next: '@extendbody' }], // sass: extend other selectors
['[@](return)', { token: TOKEN_AT_KEYWORD, next: '@declarationbody' }], ['[@](return)', { token: TOKEN_AT_KEYWORD, next: '@declarationbody' }],
['}', { token: 'delimiter.curly', next: '@pop' }], ['}', { token: 'delimiter.curly', next: '@pop' }],
], ],
selectorname: [ selectorname: [
['#{', { token: 'meta', next: '@variableinterpolation' }], // sass: interpolation ['#{', { token: 'meta', next: '@variableinterpolation' }], // sass: interpolation
['(\\.|#(?=[^{])|%|(@identifier)|:)+', TOKEN_SELECTOR], // selector (.foo, div, ...) ['(\\.|#(?=[^{])|%|(@identifier)|:)+', TOKEN_SELECTOR], // selector (.foo, div, ...)
], ],
selectorattribute: [ selectorattribute: [
{ include: '@term' }, { include: '@term' },
[']', { token: 'delimiter.bracket', next: '@pop' }], [']', { token: 'delimiter.bracket', next: '@pop' }],
], ],
term: [ term: [
{ include: '@comments' }, { include: '@comments' },
['url(\\-prefix)?\\(', { token: 'meta', next: '@urldeclaration' }], ['url(\\-prefix)?\\(', { token: 'meta', next: '@urldeclaration' }],
{ include: '@functioninvocation' }, { include: '@functioninvocation' },
{ include: '@numbers' }, { include: '@numbers' },
{ include: '@strings' }, { include: '@strings' },
{ include: '@variablereference' }, { include: '@variablereference' },
['(and\\b|or\\b|not\\b)', 'operator'], ['(and\\b|or\\b|not\\b)', 'operator'],
{ include: '@name' }, { include: '@name' },
['([<>=\\+\\-\\*\\/\\^\\|\\~,])', 'operator'], ['([<>=\\+\\-\\*\\/\\^\\|\\~,])', 'operator'],
[',', 'delimiter'], [',', 'delimiter'],
['!default', 'literal'], ['!default', 'literal'],
['\\(', { token: 'delimiter.parenthesis', next: '@parenthizedterm' }], ['\\(', { token: 'delimiter.parenthesis', next: '@parenthizedterm' }],
], ],
rulevalue: [ rulevalue: [
{ include: '@term' }, { include: '@term' },
['!important', 'literal'], ['!important', 'literal'],
[';', 'delimiter', '@pop'], [';', 'delimiter', '@pop'],
['{', { token: 'delimiter.curly', switchTo: '@nestedproperty' }], // sass: nested properties ['{', { token: 'delimiter.curly', switchTo: '@nestedproperty' }], // sass: nested properties
['(?=})', { token: '', next: '@pop' }], // missing semicolon ['(?=})', { token: '', next: '@pop' }], // missing semicolon
], ],
nestedproperty: [ nestedproperty: [
['[*_]?@identifier@ws:', TOKEN_PROPERTY, '@rulevalue'], ['[*_]?@identifier@ws:', TOKEN_PROPERTY, '@rulevalue'],
{ include: '@comments' }, { include: '@comments' },
['}', { token: 'delimiter.curly', next: '@pop' }], ['}', { token: 'delimiter.curly', next: '@pop' }],
], ],
warndebug: [ warndebug: [
['[@](warn|debug)', { token: TOKEN_AT_KEYWORD, next: '@declarationbody' }], ['[@](warn|debug)', { token: TOKEN_AT_KEYWORD, next: '@declarationbody' }],
], ],
import: [ import: [
['[@](import)', { token: TOKEN_AT_KEYWORD, next: '@declarationbody' }], ['[@](import)', { token: TOKEN_AT_KEYWORD, next: '@declarationbody' }],
], ],
variabledeclaration: [ // sass variables variabledeclaration: [ // sass variables
['\\$@identifier@ws:', 'variable.decl', '@declarationbody'], ['\\$@identifier@ws:', 'variable.decl', '@declarationbody'],
], ],
urldeclaration: [ urldeclaration: [
{ include: '@strings' }, { include: '@strings' },
['[^)\r\n]+', 'string'], ['[^)\r\n]+', 'string'],
['\\)', { token: 'meta', next: '@pop' }], ['\\)', { token: 'meta', next: '@pop' }],
], ],
parenthizedterm: [ parenthizedterm: [
{ include: '@term' }, { include: '@term' },
['\\)', { token: 'delimiter.parenthesis', next: '@pop' }], ['\\)', { token: 'delimiter.parenthesis', next: '@pop' }],
], ],
declarationbody: [ declarationbody: [
{ include: '@term' }, { include: '@term' },
[';', 'delimiter', '@pop'], [';', 'delimiter', '@pop'],
['(?=})', { token: '', next: '@pop' }], // missing semicolon ['(?=})', { token: '', next: '@pop' }], // missing semicolon
], ],
extendbody: [ extendbody: [
{ include: '@selectorname' }, { include: '@selectorname' },
['!optional', 'literal'], ['!optional', 'literal'],
[';', 'delimiter', '@pop'], [';', 'delimiter', '@pop'],
['(?=})', { token: '', next: '@pop' }], // missing semicolon ['(?=})', { token: '', next: '@pop' }], // missing semicolon
], ],
variablereference: [ // sass variable reference variablereference: [ // sass variable reference
['\\$@identifier', 'variable.ref'], ['\\$@identifier', 'variable.ref'],
['\\.\\.\\.', 'operator'], // var args in reference ['\\.\\.\\.', 'operator'], // var args in reference
['#{', { token: 'meta', next: '@variableinterpolation' }], // sass var resolve ['#{', { token: 'meta', next: '@variableinterpolation' }], // sass var resolve
], ],
variableinterpolation: [ variableinterpolation: [
{ include: '@variablereference' }, { include: '@variablereference' },
['}', { token: 'meta', next: '@pop' }], ['}', { token: 'meta', next: '@pop' }],
], ],
comments: [ comments: [
['\\/\\*', 'comment', '@comment'], ['\\/\\*', 'comment', '@comment'],
['\\/\\/+.*', 'comment'], ['\\/\\/+.*', 'comment'],
], ],
comment: [ comment: [
['\\*\\/', 'comment', '@pop'], ['\\*\\/', 'comment', '@pop'],
['.', 'comment'], ['.', 'comment'],
], ],
name: [ name: [
['@identifier', TOKEN_VALUE], ['@identifier', TOKEN_VALUE],
], ],
numbers: [ numbers: [
['(\\d*\\.)?\\d+([eE][\\-+]?\\d+)?', { token: 'number', next: '@units' }], ['(\\d*\\.)?\\d+([eE][\\-+]?\\d+)?', { token: 'number', next: '@units' }],
['#[0-9a-fA-F_]+(?!\\w)', 'number.hex'], ['#[0-9a-fA-F_]+(?!\\w)', 'number.hex'],
], ],
units: [ units: [
['(em|ex|ch|rem|vmin|vmax|vw|vh|vm|cm|mm|in|px|pt|pc|deg|grad|rad|turn|s|ms|Hz|kHz|%)?', 'number', '@pop'] ['(em|ex|ch|rem|vmin|vmax|vw|vh|vm|cm|mm|in|px|pt|pc|deg|grad|rad|turn|s|ms|Hz|kHz|%)?', 'number', '@pop']
], ],
functiondeclaration: [ functiondeclaration: [
['@identifier@ws\\(', { token: 'meta', next: '@parameterdeclaration' }], ['@identifier@ws\\(', { token: 'meta', next: '@parameterdeclaration' }],
['{', { token: 'delimiter.curly', switchTo: '@functionbody' }], ['{', { token: 'delimiter.curly', switchTo: '@functionbody' }],
], ],
mixindeclaration: [ mixindeclaration: [
// mixin with parameters // mixin with parameters
['@identifier@ws\\(', { token: 'meta', next: '@parameterdeclaration' }], ['@identifier@ws\\(', { token: 'meta', next: '@parameterdeclaration' }],
// mixin without parameters // mixin without parameters
['@identifier', 'meta'], ['@identifier', 'meta'],
['{', { token: 'delimiter.curly', switchTo: '@selectorbody' }], ['{', { token: 'delimiter.curly', switchTo: '@selectorbody' }],
], ],
parameterdeclaration: [ parameterdeclaration: [
['\\$@identifier@ws:', 'variable.decl'], ['\\$@identifier@ws:', 'variable.decl'],
['\\.\\.\\.', 'operator'], // var args in declaration ['\\.\\.\\.', 'operator'], // var args in declaration
[',', 'delimiter'], [',', 'delimiter'],
{ include: '@term' }, { include: '@term' },
['\\)', { token: 'meta', next: '@pop' }], ['\\)', { token: 'meta', next: '@pop' }],
], ],
includedeclaration: [ includedeclaration: [
{ include: '@functioninvocation' }, { include: '@functioninvocation' },
['@identifier', 'meta'], ['@identifier', 'meta'],
[';', 'delimiter', '@pop'], [';', 'delimiter', '@pop'],
['(?=})', { token: '', next: '@pop' }], // missing semicolon ['(?=})', { token: '', next: '@pop' }], // missing semicolon
['{', { token: 'delimiter.curly', switchTo: '@selectorbody' }], ['{', { token: 'delimiter.curly', switchTo: '@selectorbody' }],
], ],
keyframedeclaration: [ keyframedeclaration: [
['@identifier', 'meta'], ['@identifier', 'meta'],
['{', { token: 'delimiter.curly', switchTo: '@keyframebody' }], ['{', { token: 'delimiter.curly', switchTo: '@keyframebody' }],
], ],
keyframebody: [ keyframebody: [
{ include: '@term' }, { include: '@term' },
['{', { token: 'delimiter.curly', next: '@selectorbody' }], ['{', { token: 'delimiter.curly', next: '@selectorbody' }],
['}', { token: 'delimiter.curly', next: '@pop' }], ['}', { token: 'delimiter.curly', next: '@pop' }],
], ],
controlstatement: [ controlstatement: [
['[@](if|else|for|while|each|media)', { token: 'keyword.flow', next: '@controlstatementdeclaration' }], ['[@](if|else|for|while|each|media)', { token: 'keyword.flow', next: '@controlstatementdeclaration' }],
], ],
controlstatementdeclaration: [ controlstatementdeclaration: [
['(in|from|through|if|to)\\b', { token: 'keyword.flow' }], ['(in|from|through|if|to)\\b', { token: 'keyword.flow' }],
{ include: '@term' }, { include: '@term' },
['{', { token: 'delimiter.curly', switchTo: '@selectorbody' }], ['{', { token: 'delimiter.curly', switchTo: '@selectorbody' }],
], ],
functionbody: [ functionbody: [
['[@](return)', { token: TOKEN_AT_KEYWORD }], ['[@](return)', { token: TOKEN_AT_KEYWORD }],
{ include: '@variabledeclaration' }, { include: '@variabledeclaration' },
{ include: '@term' }, { include: '@term' },
{ include: '@controlstatement' }, { include: '@controlstatement' },
[';', 'delimiter'], [';', 'delimiter'],
['}', { token: 'delimiter.curly', next: '@pop' }], ['}', { token: 'delimiter.curly', next: '@pop' }],
], ],
functioninvocation: [ functioninvocation: [
['@identifier\\(', { token: 'meta', next: '@functionarguments' }], ['@identifier\\(', { token: 'meta', next: '@functionarguments' }],
], ],
functionarguments: [ functionarguments: [
['\\$@identifier@ws:', TOKEN_PROPERTY], ['\\$@identifier@ws:', TOKEN_PROPERTY],
['[,]', 'delimiter'], ['[,]', 'delimiter'],
{ include: '@term' }, { include: '@term' },
['\\)', { token: 'meta', next: '@pop' }], ['\\)', { token: 'meta', next: '@pop' }],
], ],
strings: [ strings: [
['~?"', { token: 'string.delimiter', next: '@stringenddoublequote' }], ['~?"', { token: 'string.delimiter', next: '@stringenddoublequote' }],
['~?\'', { token: 'string.delimiter', next: '@stringendquote' }] ['~?\'', { token: 'string.delimiter', next: '@stringendquote' }]
], ],
stringenddoublequote: [ stringenddoublequote: [
['\\\\.', 'string'], ['\\\\.', 'string'],
['"', { token: 'string.delimiter', next: '@pop' }], ['"', { token: 'string.delimiter', next: '@pop' }],
['.', 'string'] ['.', 'string']
], ],
stringendquote: [ stringendquote: [
['\\\\.', 'string'], ['\\\\.', 'string'],
['\'', { token: 'string.delimiter', next: '@pop' }], ['\'', { token: 'string.delimiter', next: '@pop' }],
['.', 'string'] ['.', 'string']
] ]
} }
}; };

File diff suppressed because one or more lines are too long

View file

@ -8,15 +8,15 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
comments: { comments: {
lineComment: '--', lineComment: '--',
blockComment: ['/*', '*/'], blockComment: ['/*', '*/'],
}, },
brackets: [ brackets: [
['{','}'], ['{', '}'],
['[',']'], ['[', ']'],
['(',')'] ['(', ')']
], ],
autoClosingPairs: [ autoClosingPairs: [
{ open: '{', close: '}' }, { open: '{', close: '}' },
@ -34,7 +34,7 @@ export var conf:IRichLanguageConfiguration = {
] ]
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.sql', tokenPostfix: '.sql',
ignoreCase: true, ignoreCase: true,
@ -956,101 +956,101 @@ export var language = <ILanguage> {
], ],
operators: [ operators: [
// Logical // Logical
'ALL','AND','ANY','BETWEEN','EXISTS','IN','LIKE','NOT','OR','SOME', 'ALL', 'AND', 'ANY', 'BETWEEN', 'EXISTS', 'IN', 'LIKE', 'NOT', 'OR', 'SOME',
// Set // Set
'EXCEPT','INTERSECT','UNION', 'EXCEPT', 'INTERSECT', 'UNION',
// Join // Join
'APPLY','CROSS','FULL','INNER','JOIN','LEFT','OUTER','RIGHT', 'APPLY', 'CROSS', 'FULL', 'INNER', 'JOIN', 'LEFT', 'OUTER', 'RIGHT',
// Predicates // Predicates
'CONTAINS','FREETEXT','IS','NULL', 'CONTAINS', 'FREETEXT', 'IS', 'NULL',
// Pivoting // Pivoting
'PIVOT','UNPIVOT', 'PIVOT', 'UNPIVOT',
// Merging // Merging
'MATCHED' 'MATCHED'
], ],
builtinFunctions: [ builtinFunctions: [
// Aggregate // Aggregate
'AVG','CHECKSUM_AGG','COUNT','COUNT_BIG','GROUPING','GROUPING_ID','MAX','MIN','SUM','STDEV','STDEVP','VAR','VARP', 'AVG', 'CHECKSUM_AGG', 'COUNT', 'COUNT_BIG', 'GROUPING', 'GROUPING_ID', 'MAX', 'MIN', 'SUM', 'STDEV', 'STDEVP', 'VAR', 'VARP',
// Analytic // Analytic
'CUME_DIST','FIRST_VALUE','LAG','LAST_VALUE','LEAD','PERCENTILE_CONT','PERCENTILE_DISC','PERCENT_RANK', 'CUME_DIST', 'FIRST_VALUE', 'LAG', 'LAST_VALUE', 'LEAD', 'PERCENTILE_CONT', 'PERCENTILE_DISC', 'PERCENT_RANK',
// Collation // Collation
'COLLATE','COLLATIONPROPERTY','TERTIARY_WEIGHTS', 'COLLATE', 'COLLATIONPROPERTY', 'TERTIARY_WEIGHTS',
// Azure // Azure
'FEDERATION_FILTERING_VALUE', 'FEDERATION_FILTERING_VALUE',
// Conversion // Conversion
'CAST','CONVERT','PARSE','TRY_CAST','TRY_CONVERT','TRY_PARSE', 'CAST', 'CONVERT', 'PARSE', 'TRY_CAST', 'TRY_CONVERT', 'TRY_PARSE',
// Cryptographic // Cryptographic
'ASYMKEY_ID','ASYMKEYPROPERTY','CERTPROPERTY','CERT_ID','CRYPT_GEN_RANDOM', 'ASYMKEY_ID', 'ASYMKEYPROPERTY', 'CERTPROPERTY', 'CERT_ID', 'CRYPT_GEN_RANDOM',
'DECRYPTBYASYMKEY','DECRYPTBYCERT','DECRYPTBYKEY','DECRYPTBYKEYAUTOASYMKEY','DECRYPTBYKEYAUTOCERT','DECRYPTBYPASSPHRASE', 'DECRYPTBYASYMKEY', 'DECRYPTBYCERT', 'DECRYPTBYKEY', 'DECRYPTBYKEYAUTOASYMKEY', 'DECRYPTBYKEYAUTOCERT', 'DECRYPTBYPASSPHRASE',
'ENCRYPTBYASYMKEY','ENCRYPTBYCERT','ENCRYPTBYKEY','ENCRYPTBYPASSPHRASE','HASHBYTES','IS_OBJECTSIGNED', 'ENCRYPTBYASYMKEY', 'ENCRYPTBYCERT', 'ENCRYPTBYKEY', 'ENCRYPTBYPASSPHRASE', 'HASHBYTES', 'IS_OBJECTSIGNED',
'KEY_GUID','KEY_ID','KEY_NAME','SIGNBYASYMKEY','SIGNBYCERT','SYMKEYPROPERTY','VERIFYSIGNEDBYCERT','VERIFYSIGNEDBYASYMKEY', 'KEY_GUID', 'KEY_ID', 'KEY_NAME', 'SIGNBYASYMKEY', 'SIGNBYCERT', 'SYMKEYPROPERTY', 'VERIFYSIGNEDBYCERT', 'VERIFYSIGNEDBYASYMKEY',
// Cursor // Cursor
'CURSOR_STATUS', 'CURSOR_STATUS',
// Datatype // Datatype
'DATALENGTH','IDENT_CURRENT','IDENT_INCR','IDENT_SEED','IDENTITY','SQL_VARIANT_PROPERTY', 'DATALENGTH', 'IDENT_CURRENT', 'IDENT_INCR', 'IDENT_SEED', 'IDENTITY', 'SQL_VARIANT_PROPERTY',
// Datetime // Datetime
'CURRENT_TIMESTAMP','DATEADD','DATEDIFF','DATEFROMPARTS','DATENAME','DATEPART','DATETIME2FROMPARTS','DATETIMEFROMPARTS', 'CURRENT_TIMESTAMP', 'DATEADD', 'DATEDIFF', 'DATEFROMPARTS', 'DATENAME', 'DATEPART', 'DATETIME2FROMPARTS', 'DATETIMEFROMPARTS',
'DATETIMEOFFSETFROMPARTS','DAY','EOMONTH','GETDATE','GETUTCDATE','ISDATE','MONTH','SMALLDATETIMEFROMPARTS','SWITCHOFFSET', 'DATETIMEOFFSETFROMPARTS', 'DAY', 'EOMONTH', 'GETDATE', 'GETUTCDATE', 'ISDATE', 'MONTH', 'SMALLDATETIMEFROMPARTS', 'SWITCHOFFSET',
'SYSDATETIME','SYSDATETIMEOFFSET','SYSUTCDATETIME','TIMEFROMPARTS','TODATETIMEOFFSET','YEAR', 'SYSDATETIME', 'SYSDATETIMEOFFSET', 'SYSUTCDATETIME', 'TIMEFROMPARTS', 'TODATETIMEOFFSET', 'YEAR',
// Logical // Logical
'CHOOSE','COALESCE','IIF','NULLIF', 'CHOOSE', 'COALESCE', 'IIF', 'NULLIF',
// Mathematical // Mathematical
'ABS','ACOS','ASIN','ATAN','ATN2','CEILING','COS','COT','DEGREES','EXP','FLOOR','LOG','LOG10', 'ABS', 'ACOS', 'ASIN', 'ATAN', 'ATN2', 'CEILING', 'COS', 'COT', 'DEGREES', 'EXP', 'FLOOR', 'LOG', 'LOG10',
'PI','POWER','RADIANS','RAND','ROUND','SIGN','SIN','SQRT','SQUARE','TAN', 'PI', 'POWER', 'RADIANS', 'RAND', 'ROUND', 'SIGN', 'SIN', 'SQRT', 'SQUARE', 'TAN',
// Metadata // Metadata
'APP_NAME','APPLOCK_MODE','APPLOCK_TEST','ASSEMBLYPROPERTY','COL_LENGTH','COL_NAME','COLUMNPROPERTY', 'APP_NAME', 'APPLOCK_MODE', 'APPLOCK_TEST', 'ASSEMBLYPROPERTY', 'COL_LENGTH', 'COL_NAME', 'COLUMNPROPERTY',
'DATABASE_PRINCIPAL_ID','DATABASEPROPERTYEX','DB_ID','DB_NAME','FILE_ID','FILE_IDEX','FILE_NAME','FILEGROUP_ID', 'DATABASE_PRINCIPAL_ID', 'DATABASEPROPERTYEX', 'DB_ID', 'DB_NAME', 'FILE_ID', 'FILE_IDEX', 'FILE_NAME', 'FILEGROUP_ID',
'FILEGROUP_NAME','FILEGROUPPROPERTY','FILEPROPERTY','FULLTEXTCATALOGPROPERTY','FULLTEXTSERVICEPROPERTY', 'FILEGROUP_NAME', 'FILEGROUPPROPERTY', 'FILEPROPERTY', 'FULLTEXTCATALOGPROPERTY', 'FULLTEXTSERVICEPROPERTY',
'INDEX_COL','INDEXKEY_PROPERTY','INDEXPROPERTY','OBJECT_DEFINITION','OBJECT_ID', 'INDEX_COL', 'INDEXKEY_PROPERTY', 'INDEXPROPERTY', 'OBJECT_DEFINITION', 'OBJECT_ID',
'OBJECT_NAME','OBJECT_SCHEMA_NAME','OBJECTPROPERTY','OBJECTPROPERTYEX','ORIGINAL_DB_NAME','PARSENAME', 'OBJECT_NAME', 'OBJECT_SCHEMA_NAME', 'OBJECTPROPERTY', 'OBJECTPROPERTYEX', 'ORIGINAL_DB_NAME', 'PARSENAME',
'SCHEMA_ID','SCHEMA_NAME','SCOPE_IDENTITY','SERVERPROPERTY','STATS_DATE','TYPE_ID','TYPE_NAME','TYPEPROPERTY', 'SCHEMA_ID', 'SCHEMA_NAME', 'SCOPE_IDENTITY', 'SERVERPROPERTY', 'STATS_DATE', 'TYPE_ID', 'TYPE_NAME', 'TYPEPROPERTY',
// Ranking // Ranking
'DENSE_RANK','NTILE','RANK','ROW_NUMBER', 'DENSE_RANK', 'NTILE', 'RANK', 'ROW_NUMBER',
// Replication // Replication
'PUBLISHINGSERVERNAME', 'PUBLISHINGSERVERNAME',
// Rowset // Rowset
'OPENDATASOURCE','OPENQUERY','OPENROWSET','OPENXML', 'OPENDATASOURCE', 'OPENQUERY', 'OPENROWSET', 'OPENXML',
// Security // Security
'CERTENCODED','CERTPRIVATEKEY','CURRENT_USER','HAS_DBACCESS','HAS_PERMS_BY_NAME','IS_MEMBER','IS_ROLEMEMBER','IS_SRVROLEMEMBER', 'CERTENCODED', 'CERTPRIVATEKEY', 'CURRENT_USER', 'HAS_DBACCESS', 'HAS_PERMS_BY_NAME', 'IS_MEMBER', 'IS_ROLEMEMBER', 'IS_SRVROLEMEMBER',
'LOGINPROPERTY','ORIGINAL_LOGIN','PERMISSIONS','PWDENCRYPT','PWDCOMPARE','SESSION_USER','SESSIONPROPERTY','SUSER_ID','SUSER_NAME', 'LOGINPROPERTY', 'ORIGINAL_LOGIN', 'PERMISSIONS', 'PWDENCRYPT', 'PWDCOMPARE', 'SESSION_USER', 'SESSIONPROPERTY', 'SUSER_ID', 'SUSER_NAME',
'SUSER_SID','SUSER_SNAME','SYSTEM_USER','USER','USER_ID','USER_NAME', 'SUSER_SID', 'SUSER_SNAME', 'SYSTEM_USER', 'USER', 'USER_ID', 'USER_NAME',
// String // String
'ASCII','CHAR','CHARINDEX','CONCAT','DIFFERENCE','FORMAT','LEFT','LEN','LOWER','LTRIM','NCHAR','PATINDEX', 'ASCII', 'CHAR', 'CHARINDEX', 'CONCAT', 'DIFFERENCE', 'FORMAT', 'LEFT', 'LEN', 'LOWER', 'LTRIM', 'NCHAR', 'PATINDEX',
'QUOTENAME','REPLACE','REPLICATE','REVERSE','RIGHT','RTRIM','SOUNDEX','SPACE','STR','STUFF','SUBSTRING','UNICODE','UPPER', 'QUOTENAME', 'REPLACE', 'REPLICATE', 'REVERSE', 'RIGHT', 'RTRIM', 'SOUNDEX', 'SPACE', 'STR', 'STUFF', 'SUBSTRING', 'UNICODE', 'UPPER',
// System // System
'BINARY_CHECKSUM','CHECKSUM','CONNECTIONPROPERTY','CONTEXT_INFO','CURRENT_REQUEST_ID','ERROR_LINE','ERROR_NUMBER','ERROR_MESSAGE', 'BINARY_CHECKSUM', 'CHECKSUM', 'CONNECTIONPROPERTY', 'CONTEXT_INFO', 'CURRENT_REQUEST_ID', 'ERROR_LINE', 'ERROR_NUMBER', 'ERROR_MESSAGE',
'ERROR_PROCEDURE','ERROR_SEVERITY','ERROR_STATE','FORMATMESSAGE','GETANSINULL','GET_FILESTREAM_TRANSACTION_CONTEXT','HOST_ID', 'ERROR_PROCEDURE', 'ERROR_SEVERITY', 'ERROR_STATE', 'FORMATMESSAGE', 'GETANSINULL', 'GET_FILESTREAM_TRANSACTION_CONTEXT', 'HOST_ID',
'HOST_NAME','ISNULL','ISNUMERIC','MIN_ACTIVE_ROWVERSION','NEWID','NEWSEQUENTIALID','ROWCOUNT_BIG','XACT_STATE', 'HOST_NAME', 'ISNULL', 'ISNUMERIC', 'MIN_ACTIVE_ROWVERSION', 'NEWID', 'NEWSEQUENTIALID', 'ROWCOUNT_BIG', 'XACT_STATE',
// TextImage // TextImage
'TEXTPTR','TEXTVALID', 'TEXTPTR', 'TEXTVALID',
// Trigger // Trigger
'COLUMNS_UPDATED','EVENTDATA','TRIGGER_NESTLEVEL','UPDATE', 'COLUMNS_UPDATED', 'EVENTDATA', 'TRIGGER_NESTLEVEL', 'UPDATE',
// ChangeTracking // ChangeTracking
'CHANGETABLE','CHANGE_TRACKING_CONTEXT','CHANGE_TRACKING_CURRENT_VERSION','CHANGE_TRACKING_IS_COLUMN_IN_MASK','CHANGE_TRACKING_MIN_VALID_VERSION', 'CHANGETABLE', 'CHANGE_TRACKING_CONTEXT', 'CHANGE_TRACKING_CURRENT_VERSION', 'CHANGE_TRACKING_IS_COLUMN_IN_MASK', 'CHANGE_TRACKING_MIN_VALID_VERSION',
// FullTextSearch // FullTextSearch
'CONTAINSTABLE','FREETEXTTABLE', 'CONTAINSTABLE', 'FREETEXTTABLE',
// SemanticTextSearch // SemanticTextSearch
'SEMANTICKEYPHRASETABLE','SEMANTICSIMILARITYDETAILSTABLE','SEMANTICSIMILARITYTABLE', 'SEMANTICKEYPHRASETABLE', 'SEMANTICSIMILARITYDETAILSTABLE', 'SEMANTICSIMILARITYTABLE',
// FileStream // FileStream
'FILETABLEROOTPATH','GETFILENAMESPACEPATH','GETPATHLOCATOR','PATHNAME', 'FILETABLEROOTPATH', 'GETFILENAMESPACEPATH', 'GETPATHLOCATOR', 'PATHNAME',
// ServiceBroker // ServiceBroker
'GET_TRANSMISSION_STATUS' 'GET_TRANSMISSION_STATUS'
], ],
builtinVariables: [ builtinVariables: [
// Configuration // Configuration
'@@DATEFIRST','@@DBTS','@@LANGID','@@LANGUAGE','@@LOCK_TIMEOUT','@@MAX_CONNECTIONS','@@MAX_PRECISION','@@NESTLEVEL', '@@DATEFIRST', '@@DBTS', '@@LANGID', '@@LANGUAGE', '@@LOCK_TIMEOUT', '@@MAX_CONNECTIONS', '@@MAX_PRECISION', '@@NESTLEVEL',
'@@OPTIONS','@@REMSERVER','@@SERVERNAME','@@SERVICENAME','@@SPID','@@TEXTSIZE','@@VERSION', '@@OPTIONS', '@@REMSERVER', '@@SERVERNAME', '@@SERVICENAME', '@@SPID', '@@TEXTSIZE', '@@VERSION',
// Cursor // Cursor
'@@CURSOR_ROWS','@@FETCH_STATUS', '@@CURSOR_ROWS', '@@FETCH_STATUS',
// Datetime // Datetime
'@@DATEFIRST', '@@DATEFIRST',
// Metadata // Metadata
'@@PROCID', '@@PROCID',
// System // System
'@@ERROR','@@IDENTITY','@@ROWCOUNT','@@TRANCOUNT', '@@ERROR', '@@IDENTITY', '@@ROWCOUNT', '@@TRANCOUNT',
// Stats // Stats
'@@CONNECTIONS','@@CPU_BUSY','@@IDLE','@@IO_BUSY','@@PACKET_ERRORS','@@PACK_RECEIVED','@@PACK_SENT', '@@CONNECTIONS', '@@CPU_BUSY', '@@IDLE', '@@IO_BUSY', '@@PACKET_ERRORS', '@@PACK_RECEIVED', '@@PACK_SENT',
'@@TIMETICKS','@@TOTAL_ERRORS','@@TOTAL_READ','@@TOTAL_WRITE' '@@TIMETICKS', '@@TOTAL_ERRORS', '@@TOTAL_READ', '@@TOTAL_WRITE'
], ],
pseudoColumns: [ pseudoColumns: [
'$ACTION', '$IDENTITY', '$ROWGUID', '$PARTITION' '$ACTION', '$IDENTITY', '$ROWGUID', '$PARTITION'
@ -1066,13 +1066,15 @@ export var language = <ILanguage> {
{ include: '@scopes' }, { include: '@scopes' },
[/[;,.]/, 'delimiter'], [/[;,.]/, 'delimiter'],
[/[()]/, '@brackets'], [/[()]/, '@brackets'],
[/[\w@#$]+/, { cases: { [/[\w@#$]+/, {
'@keywords': 'keyword', cases: {
'@operators': 'operator', '@keywords': 'keyword',
'@builtinVariables': 'predefined', '@operators': 'operator',
'@builtinFunctions': 'predefined', '@builtinVariables': 'predefined',
'@default': 'identifier' } '@builtinFunctions': 'predefined',
}], '@default': 'identifier'
}
}],
[/[<>=!%&+\-*/|~^]/, 'operator'], [/[<>=!%&+\-*/|~^]/, 'operator'],
], ],
whitespace: [ whitespace: [
@ -1091,10 +1093,12 @@ export var language = <ILanguage> {
[/./, 'comment'] [/./, 'comment']
], ],
pseudoColumns: [ pseudoColumns: [
[/[$][A-Za-z_][\w@#$]*/, { cases: { [/[$][A-Za-z_][\w@#$]*/, {
'@pseudoColumns': 'predefined', cases: {
'@default': 'identifier' '@pseudoColumns': 'predefined',
}}], '@default': 'identifier'
}
}],
], ],
numbers: [ numbers: [
[/0[xX][0-9a-fA-F]*/, 'number'], [/0[xX][0-9a-fA-F]*/, 'number'],

View file

@ -7,15 +7,15 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
comments: { comments: {
lineComment: '//', lineComment: '//',
blockComment: ['/*', '*/'], blockComment: ['/*', '*/'],
}, },
brackets: [ brackets: [
['{','}'], ['{', '}'],
['[',']'], ['[', ']'],
['(',')'] ['(', ')']
], ],
autoClosingPairs: [ autoClosingPairs: [
{ open: '{', close: '}' }, { open: '{', close: '}' },
@ -35,7 +35,7 @@ export var conf:IRichLanguageConfiguration = {
] ]
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.swift', tokenPostfix: '.swift',
@ -46,7 +46,7 @@ export var language = <ILanguage> {
'@autoclosure', '@noescape', '@noreturn', '@NSApplicationMain', '@NSCopying', '@NSManaged', '@autoclosure', '@noescape', '@noreturn', '@NSApplicationMain', '@NSCopying', '@NSManaged',
'@objc', '@UIApplicationMain', '@noreturn', '@availability', '@IBAction', '@IBDesignable', '@IBInspectable', '@IBOutlet' '@objc', '@UIApplicationMain', '@noreturn', '@availability', '@IBAction', '@IBDesignable', '@IBInspectable', '@IBOutlet'
], ],
accessmodifiers: [ 'public', 'private', 'internal' ], accessmodifiers: ['public', 'private', 'internal'],
keywords: [ keywords: [
'__COLUMN__', '__FILE__', '__FUNCTION__', '__LINE__', 'as', 'as!', 'as?', 'associativity', 'break', 'case', 'catch', '__COLUMN__', '__FILE__', '__FUNCTION__', '__LINE__', 'as', 'as!', 'as?', 'associativity', 'break', 'case', 'catch',
'class', 'continue', 'convenience', 'default', 'deinit', 'didSet', 'do', 'dynamic', 'dynamicType', 'class', 'continue', 'convenience', 'default', 'deinit', 'didSet', 'do', 'dynamic', 'dynamicType',
@ -87,69 +87,84 @@ export var language = <ILanguage> {
comment: [ comment: [
[ /\/\/\/.*$/, 'comment.doc' ], [/\/\/\/.*$/, 'comment.doc'],
[ /\/\*\*/, 'comment.doc', '@commentdocbody' ], [/\/\*\*/, 'comment.doc', '@commentdocbody'],
[ /\/\/.*$/, 'comment' ], [/\/\/.*$/, 'comment'],
[ /\/\*/, 'comment', '@commentbody' ] [/\/\*/, 'comment', '@commentbody']
], ],
commentdocbody: [ commentdocbody: [
[ /\/\*/, 'comment', '@commentbody' ], [/\/\*/, 'comment', '@commentbody'],
[ /\*\//, 'comment.doc', '@pop' ], [/\*\//, 'comment.doc', '@pop'],
[ /\:[a-zA-Z]+\:/, 'comment.doc.param' ], [/\:[a-zA-Z]+\:/, 'comment.doc.param'],
[ /./, 'comment.doc' ] [/./, 'comment.doc']
], ],
commentbody: [ commentbody: [
[ /\/\*/, 'comment', '@commentbody' ], [/\/\*/, 'comment', '@commentbody'],
[ /\*\//, 'comment', '@pop' ], [/\*\//, 'comment', '@pop'],
[ /./, 'comment' ] [/./, 'comment']
], ],
attribute: [ attribute: [
[ /\@@identifier/, { cases: { '@attributes': 'keyword.control', '@default': '' } } ] [/\@@identifier/, {
cases: {
'@attributes': 'keyword.control',
'@default': ''
}
}]
], ],
literal: [ literal: [
[ /"/, { token: 'string.quote', next: '@stringlit' } ], [/"/, { token: 'string.quote', next: '@stringlit' }],
[ /0[b]([01]_?)+/, 'number.binary' ], [/0[b]([01]_?)+/, 'number.binary'],
[ /0[o]([0-7]_?)+/, 'number.octal' ], [/0[o]([0-7]_?)+/, 'number.octal'],
[ /0[x]([0-9a-fA-F]_?)+([pP][\-+](\d_?)+)?/, 'number.hex' ], [/0[x]([0-9a-fA-F]_?)+([pP][\-+](\d_?)+)?/, 'number.hex'],
[ /(\d_?)*\.(\d_?)+([eE][\-+]?(\d_?)+)?/, 'number.float'], [/(\d_?)*\.(\d_?)+([eE][\-+]?(\d_?)+)?/, 'number.float'],
[ /(\d_?)+/, 'number' ] [/(\d_?)+/, 'number']
], ],
stringlit: [ stringlit: [
[ /\\\(/, { token: 'operator', next: '@interpolatedexpression' } ], [/\\\(/, { token: 'operator', next: '@interpolatedexpression' }],
[ /@escapes/, 'string' ], [/@escapes/, 'string'],
[ /\\./, 'string.escape.invalid' ], [/\\./, 'string.escape.invalid'],
[ /"/, { token: 'string.quote', next: '@pop' } ], [/"/, { token: 'string.quote', next: '@pop' }],
[ /./, 'string' ] [/./, 'string']
], ],
interpolatedexpression: [ interpolatedexpression: [
[ /\(/, { token: 'operator', next: '@interpolatedexpression' } ], [/\(/, { token: 'operator', next: '@interpolatedexpression' }],
[ /\)/, { token: 'operator', next: '@pop' } ], [/\)/, { token: 'operator', next: '@pop' }],
{ include: '@literal' }, { include: '@literal' },
{ include: '@keyword' }, { include: '@keyword' },
{ include: '@symbol' } { include: '@symbol' }
], ],
keyword: [ keyword: [
[ /`/, { token: 'operator', next: '@escapedkeyword' } ], [/`/, { token: 'operator', next: '@escapedkeyword' }],
[ /@identifier/, { cases: { '@keywords': 'keyword', '[A-Z][\a-zA-Z0-9$]*': 'type.identifier', '@default': 'identifier' } }] [/@identifier/, {
cases: {
'@keywords': 'keyword', '[A-Z][\a-zA-Z0-9$]*': 'type.identifier',
'@default': 'identifier'
}
}]
], ],
escapedkeyword: [ escapedkeyword: [
[ /`/, { token: 'operator', next: '@pop' } ], [/`/, { token: 'operator', next: '@pop' }],
[ /./, 'identifier' ] [/./, 'identifier']
], ],
// symbol: [ // symbol: [
// [ /@symbols/, 'operator' ], // [ /@symbols/, 'operator' ],
// [ /@operators/, 'operator' ] // [ /@operators/, 'operator' ]
// ], // ],
invokedmethod: [ invokedmethod: [
[/([.])(@identifier)/, { cases: { '$2': ['delimeter', 'type.identifier'], '@default': '' } }], [/([.])(@identifier)/, {
cases: {
'$2': ['delimeter', 'type.identifier'],
'@default': ''
}
}],
] ]
} }
}; };

138
src/vb.ts
View file

@ -8,38 +8,38 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
comments: { comments: {
lineComment: '\'', lineComment: '\'',
blockComment: ['/*', '*/'], blockComment: ['/*', '*/'],
}, },
brackets: [ brackets: [
['{','}'],['[',']'],['(',')'],['<','>'], ['{', '}'], ['[', ']'], ['(', ')'], ['<', '>'],
['addhandler','end addhandler'], ['addhandler', 'end addhandler'],
['class','end class'], ['class', 'end class'],
['enum','end enum'], ['enum', 'end enum'],
['event','end event'], ['event', 'end event'],
['function','end function'], ['function', 'end function'],
['get','end get'], ['get', 'end get'],
['if','end if'], ['if', 'end if'],
['interface','end interface'], ['interface', 'end interface'],
['module','end module'], ['module', 'end module'],
['namespace','end namespace'], ['namespace', 'end namespace'],
['operator','end operator'], ['operator', 'end operator'],
['property','end property'], ['property', 'end property'],
['raiseevent','end raiseevent'], ['raiseevent', 'end raiseevent'],
['removehandler','end removehandler'], ['removehandler', 'end removehandler'],
['select','end select'], ['select', 'end select'],
['set','end set'], ['set', 'end set'],
['structure','end structure'], ['structure', 'end structure'],
['sub','end sub'], ['sub', 'end sub'],
['synclock','end synclock'], ['synclock', 'end synclock'],
['try','end try'], ['try', 'end try'],
['while','end while'], ['while', 'end while'],
['with','end with'], ['with', 'end with'],
['using','end using'], ['using', 'end using'],
['do','loop'], ['do', 'loop'],
['for','next'] ['for', 'next']
], ],
autoClosingPairs: [ autoClosingPairs: [
{ open: '{', close: '}', notIn: ['string', 'comment'] }, { open: '{', close: '}', notIn: ['string', 'comment'] },
@ -50,41 +50,41 @@ export var conf:IRichLanguageConfiguration = {
] ]
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.vb', tokenPostfix: '.vb',
ignoreCase: true, ignoreCase: true,
brackets: [ brackets: [
{ token:'delimiter.bracket', open: '{', close: '}'}, { token: 'delimiter.bracket', open: '{', close: '}' },
{ token:'delimiter.array', open: '[', close: ']'}, { token: 'delimiter.array', open: '[', close: ']' },
{ token:'delimiter.parenthesis', open: '(', close: ')'}, { token: 'delimiter.parenthesis', open: '(', close: ')' },
{ token:'delimiter.angle', open: '<', close: '>'}, { token: 'delimiter.angle', open: '<', close: '>' },
// Special bracket statement pairs // Special bracket statement pairs
// according to https://msdn.microsoft.com/en-us/library/tsw2a11z.aspx // according to https://msdn.microsoft.com/en-us/library/tsw2a11z.aspx
{ token: 'keyword.tag-addhandler', open: 'addhandler', close: 'end addhandler'}, { token: 'keyword.tag-addhandler', open: 'addhandler', close: 'end addhandler' },
{ token: 'keyword.tag-class', open: 'class', close: 'end class'}, { token: 'keyword.tag-class', open: 'class', close: 'end class' },
{ token: 'keyword.tag-enum', open: 'enum', close: 'end enum'}, { token: 'keyword.tag-enum', open: 'enum', close: 'end enum' },
{ token: 'keyword.tag-event', open: 'event', close: 'end event'}, { token: 'keyword.tag-event', open: 'event', close: 'end event' },
{ token: 'keyword.tag-function', open: 'function', close: 'end function'}, { token: 'keyword.tag-function', open: 'function', close: 'end function' },
{ token: 'keyword.tag-get', open: 'get', close: 'end get'}, { token: 'keyword.tag-get', open: 'get', close: 'end get' },
{ token: 'keyword.tag-if', open: 'if', close: 'end if'}, { token: 'keyword.tag-if', open: 'if', close: 'end if' },
{ token: 'keyword.tag-interface', open: 'interface', close: 'end interface'}, { token: 'keyword.tag-interface', open: 'interface', close: 'end interface' },
{ token: 'keyword.tag-module', open: 'module', close: 'end module'}, { token: 'keyword.tag-module', open: 'module', close: 'end module' },
{ token: 'keyword.tag-namespace', open: 'namespace', close: 'end namespace'}, { token: 'keyword.tag-namespace', open: 'namespace', close: 'end namespace' },
{ token: 'keyword.tag-operator', open: 'operator', close: 'end operator'}, { token: 'keyword.tag-operator', open: 'operator', close: 'end operator' },
{ token: 'keyword.tag-property', open: 'property', close: 'end property'}, { token: 'keyword.tag-property', open: 'property', close: 'end property' },
{ token: 'keyword.tag-raiseevent', open: 'raiseevent', close: 'end raiseevent'}, { token: 'keyword.tag-raiseevent', open: 'raiseevent', close: 'end raiseevent' },
{ token: 'keyword.tag-removehandler', open: 'removehandler', close: 'end removehandler'}, { token: 'keyword.tag-removehandler', open: 'removehandler', close: 'end removehandler' },
{ token: 'keyword.tag-select', open: 'select', close: 'end select'}, { token: 'keyword.tag-select', open: 'select', close: 'end select' },
{ token: 'keyword.tag-set', open: 'set', close: 'end set'}, { token: 'keyword.tag-set', open: 'set', close: 'end set' },
{ token: 'keyword.tag-structure', open: 'structure', close: 'end structure'}, { token: 'keyword.tag-structure', open: 'structure', close: 'end structure' },
{ token: 'keyword.tag-sub', open: 'sub', close: 'end sub'}, { token: 'keyword.tag-sub', open: 'sub', close: 'end sub' },
{ token: 'keyword.tag-synclock', open: 'synclock', close: 'end synclock'}, { token: 'keyword.tag-synclock', open: 'synclock', close: 'end synclock' },
{ token: 'keyword.tag-try', open: 'try', close: 'end try'}, { token: 'keyword.tag-try', open: 'try', close: 'end try' },
{ token: 'keyword.tag-while', open: 'while', close: 'end while'}, { token: 'keyword.tag-while', open: 'while', close: 'end while' },
{ token: 'keyword.tag-with', open: 'with', close: 'end with'}, { token: 'keyword.tag-with', open: 'with', close: 'end with' },
// Other pairs // Other pairs
{ token: 'keyword.tag-using', open: 'using', close: 'end using' }, { token: 'keyword.tag-using', open: 'using', close: 'end using' },
@ -117,8 +117,8 @@ export var language = <ILanguage> {
], ],
// we include these common regular expressions // we include these common regular expressions
symbols: /[=><!~?;\.,:&|+\-*\/\^%]+/, symbols: /[=><!~?;\.,:&|+\-*\/\^%]+/,
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
integersuffix: /U?[DI%L&S@]?/, integersuffix: /U?[DI%L&S@]?/,
floatsuffix: /[R#F!]?/, floatsuffix: /[R#F!]?/,
@ -130,16 +130,20 @@ export var language = <ILanguage> {
{ include: '@whitespace' }, { include: '@whitespace' },
// special ending tag-words // special ending tag-words
[/next(?!\w)/, { token: 'keyword.tag-for'}], [/next(?!\w)/, { token: 'keyword.tag-for' }],
[/loop(?!\w)/, { token: 'keyword.tag-do' }], [/loop(?!\w)/, { token: 'keyword.tag-do' }],
// usual ending tags // usual ending tags
[/end\s+(?!for|do)([a-zA-Z_]\w*)/, { token: 'keyword.tag-$1' }], [/end\s+(?!for|do)([a-zA-Z_]\w*)/, { token: 'keyword.tag-$1' }],
// identifiers, tagwords, and keywords // identifiers, tagwords, and keywords
[/[a-zA-Z_]\w*/, { cases: { '@tagwords': {token:'keyword.tag-$0'}, [/[a-zA-Z_]\w*/, {
'@keywords': {token:'keyword.$0'}, cases: {
'@default': 'identifier' } }], '@tagwords': { token: 'keyword.tag-$0' },
'@keywords': { token: 'keyword.$0' },
'@default': 'identifier'
}
}],
// Preprocessor directive // Preprocessor directive
[/^\s*#\w+/, 'keyword'], [/^\s*#\w+/, 'keyword'],
@ -159,21 +163,21 @@ export var language = <ILanguage> {
[/@symbols/, 'delimiter'], [/@symbols/, 'delimiter'],
// strings // strings
[/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
[/"/, 'string', '@string' ], [/"/, 'string', '@string'],
], ],
whitespace: [ whitespace: [
[/[ \t\r\n]+/, ''], [/[ \t\r\n]+/, ''],
[/(\'|REM(?!\w)).*$/, 'comment'], [/(\'|REM(?!\w)).*$/, 'comment'],
], ],
string: [ string: [
[/[^\\"]+/, 'string'], [/[^\\"]+/, 'string'],
[/@escapes/, 'string.escape'], [/@escapes/, 'string.escape'],
[/\\./, 'string.escape.invalid'], [/\\./, 'string.escape.invalid'],
[/"C?/, 'string', '@pop' ] [/"C?/, 'string', '@pop']
], ],
}, },
}; };

View file

@ -8,12 +8,12 @@
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export var conf:IRichLanguageConfiguration = { export var conf: IRichLanguageConfiguration = {
comments: { comments: {
blockComment: ['<!--', '-->'], blockComment: ['<!--', '-->'],
}, },
brackets: [ brackets: [
['<','>'] ['<', '>']
], ],
autoClosingPairs: [ autoClosingPairs: [
{ open: '<', close: '>' }, { open: '<', close: '>' },
@ -27,7 +27,7 @@ export var conf:IRichLanguageConfiguration = {
] ]
}; };
export var language = <ILanguage> { export var language = <ILanguage>{
defaultToken: '', defaultToken: '',
tokenPostfix: '.xml', tokenPostfix: '.xml',
@ -77,7 +77,7 @@ export var language = <ILanguage> {
], ],
tag: [ tag: [
[/[ \t\r\n]+/, '' ], [/[ \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)(\s*=\s*)("[^">?\/]*|'[^'>?\/]*)(?=[\?\/]\>)/, ['attribute.name', '', 'attribute.value']],
[/(@qualifiedName)(\s*=\s*)("[^">]*|'[^'>]*)/, ['attribute.name', '', 'attribute.value']], [/(@qualifiedName)(\s*=\s*)("[^">]*|'[^'>]*)/, ['attribute.name', '', 'attribute.value']],
@ -95,10 +95,10 @@ export var language = <ILanguage> {
], ],
comment: [ comment: [
[/[^<\-]+/, 'comment.content' ], [/[^<\-]+/, 'comment.content'],
[/-->/, { token: 'comment', next: '@pop' } ], [/-->/, { token: 'comment', next: '@pop' }],
[/<!--/, 'comment.content.invalid'], [/<!--/, 'comment.content.invalid'],
[/[<\-]/, 'comment.content' ] [/[<\-]/, 'comment.content']
], ],
}, },
}; };

View file

@ -26,7 +26,7 @@ export const conf: IRichLanguageConfiguration = {
], ],
}; };
export const language = <ILanguage> { export const language = <ILanguage>{
tokenPostfix: '.yaml', tokenPostfix: '.yaml',
brackets: [ brackets: [
@ -48,8 +48,8 @@ export const language = <ILanguage> {
tokenizer: { tokenizer: {
root: [ root: [
{include: '@whitespace'}, { include: '@whitespace' },
{include: '@comment'}, { include: '@comment' },
// Directive // Directive
[/%[^ ]+.*$/, 'meta.directive'], [/%[^ ]+.*$/, 'meta.directive'],
@ -61,33 +61,38 @@ export const language = <ILanguage> {
// Block Structure Indicators // Block Structure Indicators
[/[-?:](?= )/, 'operators'], [/[-?:](?= )/, 'operators'],
{include: '@anchor'}, { include: '@anchor' },
{include: '@tagHandle'}, { include: '@tagHandle' },
{include: '@flowCollections'}, { include: '@flowCollections' },
{include: '@blockStyle'}, { include: '@blockStyle' },
// Numbers // Numbers
[/@numberInteger(?![ \t]*\S+)/, 'number'], [/@numberInteger(?![ \t]*\S+)/, 'number'],
[/@numberFloat(?![ \t]*\S+)/, 'number.float'], [/@numberFloat(?![ \t]*\S+)/, 'number.float'],
[/@numberOctal(?![ \t]*\S+)/, 'number.octal'], [/@numberOctal(?![ \t]*\S+)/, 'number.octal'],
[/@numberHex(?![ \t]*\S+)/, 'number.hex'], [/@numberHex(?![ \t]*\S+)/, 'number.hex'],
[/@numberInfinity(?![ \t]*\S+)/, 'number.infinity'], [/@numberInfinity(?![ \t]*\S+)/, 'number.infinity'],
[/@numberNaN(?![ \t]*\S+)/, 'number.nan'], [/@numberNaN(?![ \t]*\S+)/, 'number.nan'],
[/@numberDate(?![ \t]*\S+)/, 'number.date'], [/@numberDate(?![ \t]*\S+)/, 'number.date'],
// Key:Value pair // Key:Value pair
[/(".*?"|'.*?'|.*?)([ \t]*)(:)( |$)/, ['type', 'white', 'operators', 'white']], [/(".*?"|'.*?'|.*?)([ \t]*)(:)( |$)/, ['type', 'white', 'operators', 'white']],
{include: '@flowScalars'}, { include: '@flowScalars' },
// String nodes // String nodes
[/.+$/, {cases: {'@keywords': 'keyword', '@default': 'string'}}] [/.+$/, {
cases: {
'@keywords': 'keyword',
'@default': 'string'
}
}]
], ],
// Flow Collection: Flow Mapping // Flow Collection: Flow Mapping
object: [ object: [
{include: '@whitespace'}, { include: '@whitespace' },
{include: '@comment'}, { include: '@comment' },
// Flow Mapping termination // Flow Mapping termination
[/\}/, '@brackets', '@pop'], [/\}/, '@brackets', '@pop'],
@ -102,22 +107,27 @@ export const language = <ILanguage> {
[/(?:".*?"|'.*?'|[^,\{\[]+?)(?=: )/, 'type'], [/(?:".*?"|'.*?'|[^,\{\[]+?)(?=: )/, 'type'],
// Start Flow Style // Start Flow Style
{include: '@flowCollections'}, { include: '@flowCollections' },
{include: '@flowScalars'}, { include: '@flowScalars' },
// Scalar Data types // Scalar Data types
{include: '@tagHandle'}, { include: '@tagHandle' },
{include: '@anchor'}, { include: '@anchor' },
{include: '@flowNumber'}, { include: '@flowNumber' },
// Other value (keyword or string) // Other value (keyword or string)
[/[^\},]+/, {cases: {'@keywords': 'keyword', '@default': 'string'}}] [/[^\},]+/, {
cases: {
'@keywords': 'keyword',
'@default': 'string'
}
}]
], ],
// Flow Collection: Flow Sequence // Flow Collection: Flow Sequence
array: [ array: [
{include: '@whitespace'}, { include: '@whitespace' },
{include: '@comment'}, { include: '@comment' },
// Flow Sequence termination // Flow Sequence termination
[/\]/, '@brackets', '@pop'], [/\]/, '@brackets', '@pop'],
@ -126,24 +136,34 @@ export const language = <ILanguage> {
[/,/, 'delimiter.comma'], [/,/, 'delimiter.comma'],
// Start Flow Style // Start Flow Style
{include: '@flowCollections'}, { include: '@flowCollections' },
{include: '@flowScalars'}, { include: '@flowScalars' },
// Scalar Data types // Scalar Data types
{include: '@tagHandle'}, { include: '@tagHandle' },
{include: '@anchor'}, { include: '@anchor' },
{include: '@flowNumber'}, { include: '@flowNumber' },
// Other value (keyword or string) // Other value (keyword or string)
[/[^\],]+/, {cases: {'@keywords': 'keyword', '@default': 'string'}}] [/[^\],]+/, {
cases: {
'@keywords': 'keyword',
'@default': 'string'
}
}]
], ],
// Flow Scalars (quoted strings) // Flow Scalars (quoted strings)
string: [ string: [
[/[^\\"']+/, 'string'], [/[^\\"']+/, 'string'],
[/@escapes/, 'string.escape'], [/@escapes/, 'string.escape'],
[/\\./, 'string.escape.invalid'], [/\\./, 'string.escape.invalid'],
[/["']/, {cases: {'$#==$S2': {token: 'string', next: '@pop'}, '@default': 'string'}}] [/["']/, {
cases: {
'$#==$S2': { token: 'string', next: '@pop' },
'@default': 'string'
}
}]
], ],
// First line of a Block Style // First line of a Block Style
@ -154,7 +174,12 @@ export const language = <ILanguage> {
// Further lines of a Block Style // Further lines of a Block Style
// Workaround for indentation detection // Workaround for indentation detection
multiStringContinued: [ multiStringContinued: [
[/^( *).+$/, {cases: {'$1==$S2': 'string', '@default': {token: '@rematch', next: '@popall'}}}] [/^( *).+$/, {
cases: {
'$1==$S2': 'string',
'@default': { token: '@rematch', next: '@popall' }
}
}]
], ],
whitespace: [ whitespace: [
@ -174,8 +199,8 @@ export const language = <ILanguage> {
// Start Flow Scalars (quoted strings) // Start Flow Scalars (quoted strings)
flowScalars: [ flowScalars: [
[/"/, 'string', '@string."'], [/"/, 'string', '@string."'],
[/'/, 'string', '@string.\''] [/'/, 'string', '@string.\'']
], ],
// Start Block Scalar // Start Block Scalar
@ -185,13 +210,13 @@ export const language = <ILanguage> {
// Numbers in Flow Collections (terminate with ,]}) // Numbers in Flow Collections (terminate with ,]})
flowNumber: [ flowNumber: [
[/@numberInteger(?=[ \t]*[,\]\}])/, 'number'], [/@numberInteger(?=[ \t]*[,\]\}])/, 'number'],
[/@numberFloat(?=[ \t]*[,\]\}])/, 'number.float'], [/@numberFloat(?=[ \t]*[,\]\}])/, 'number.float'],
[/@numberOctal(?=[ \t]*[,\]\}])/, 'number.octal'], [/@numberOctal(?=[ \t]*[,\]\}])/, 'number.octal'],
[/@numberHex(?=[ \t]*[,\]\}])/, 'number.hex'], [/@numberHex(?=[ \t]*[,\]\}])/, 'number.hex'],
[/@numberInfinity(?=[ \t]*[,\]\}])/, 'number.infinity'], [/@numberInfinity(?=[ \t]*[,\]\}])/, 'number.infinity'],
[/@numberNaN(?=[ \t]*[,\]\}])/, 'number.nan'], [/@numberNaN(?=[ \t]*[,\]\}])/, 'number.nan'],
[/@numberDate(?=[ \t]*[,\]\}])/, 'number.date'] [/@numberDate(?=[ \t]*[,\]\}])/, 'number.date']
], ],
tagHandle: [ tagHandle: [

View file

@ -4,329 +4,381 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
'use strict'; 'use strict';
import {testTokenization} from './testRunner'; import { testTokenization } from './testRunner';
testTokenization('bat', [ testTokenization('bat', [
// Keywords // Keywords
[{ [{
line: '@echo off title Selfhost', line: '@echo off title Selfhost',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.bat' }, { startIndex: 0, type: 'keyword.bat' },
{ startIndex: 1, type: 'keyword.echo.bat' }, { startIndex: 1, type: 'keyword.echo.bat' },
{ startIndex: 5, type: '' }, { startIndex: 5, type: '' },
{ startIndex: 10, type: 'keyword.title.bat' }, { startIndex: 10, type: 'keyword.title.bat' },
{ startIndex: 15, type: '' } { startIndex: 15, type: '' }
]}], ]
}],
// Comments - single line // Comments - single line
[{ [{
line: 'REM', line: 'REM',
tokens: [ tokens: [
{ startIndex: 0, type: 'comment.bat' } { startIndex: 0, type: 'comment.bat' }
]}], ]
}],
[{ [{
line: ' REM a comment', line: ' REM a comment',
tokens: [ tokens: [
{ startIndex: 0, type: '' }, { startIndex: 0, type: '' },
{ startIndex: 4, type: 'comment.bat' } { startIndex: 4, type: 'comment.bat' }
]}], ]
}],
[{ [{
line: 'REM a comment', line: 'REM a comment',
tokens: [ tokens: [
{ startIndex: 0, type: 'comment.bat' } { startIndex: 0, type: 'comment.bat' }
]}], ]
}],
[{ [{
line: 'REMnot a comment', line: 'REMnot a comment',
tokens: [ tokens: [
{ startIndex: 0, type: '' } { startIndex: 0, type: '' }
]}], ]
}],
// number // number
[{ [{
line: '0', line: '0',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.bat' } { startIndex: 0, type: 'number.bat' }
]}], ]
}],
[{ [{
line: '0.0', line: '0.0',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.float.bat' } { startIndex: 0, type: 'number.float.bat' }
]}], ]
}],
[{ [{
line: '0x123', line: '0x123',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.hex.bat' } { startIndex: 0, type: 'number.hex.bat' }
]}], ]
}],
[{ [{
line: '23.5', line: '23.5',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.float.bat' } { startIndex: 0, type: 'number.float.bat' }
]}], ]
}],
[{ [{
line: '23.5e3', line: '23.5e3',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.float.bat' } { startIndex: 0, type: 'number.float.bat' }
]}], ]
}],
[{ [{
line: '23.5E3', line: '23.5E3',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.float.bat' } { startIndex: 0, type: 'number.float.bat' }
]}], ]
}],
[{ [{
line: '1.72e-3', line: '1.72e-3',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.float.bat' } { startIndex: 0, type: 'number.float.bat' }
]}], ]
}],
[{ [{
line: '0+0', line: '0+0',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.bat' }, { startIndex: 0, type: 'number.bat' },
{ startIndex: 1, type: 'delimiter.bat' }, { startIndex: 1, type: 'delimiter.bat' },
{ startIndex: 2, type: 'number.bat' } { startIndex: 2, type: 'number.bat' }
]}], ]
}],
[{ [{
line: '100+10', line: '100+10',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.bat' }, { startIndex: 0, type: 'number.bat' },
{ startIndex: 3, type: 'delimiter.bat' }, { startIndex: 3, type: 'delimiter.bat' },
{ startIndex: 4, type: 'number.bat' } { startIndex: 4, type: 'number.bat' }
]}], ]
}],
[{ [{
line: '0 + 0', line: '0 + 0',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.bat' }, { startIndex: 0, type: 'number.bat' },
{ startIndex: 1, type: '' }, { startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.bat' }, { startIndex: 2, type: 'delimiter.bat' },
{ startIndex: 3, type: '' }, { startIndex: 3, type: '' },
{ startIndex: 4, type: 'number.bat' } { startIndex: 4, type: 'number.bat' }
]}], ]
}],
// Strings // Strings
[{ [{
line: 'set s = "string"', line: 'set s = "string"',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.set.bat' }, { startIndex: 0, type: 'keyword.set.bat' },
{ startIndex: 3, type: '' }, { startIndex: 3, type: '' },
{ startIndex: 6, type: 'delimiter.bat' }, { startIndex: 6, type: 'delimiter.bat' },
{ startIndex: 7, type: '' }, { startIndex: 7, type: '' },
{ startIndex: 8, type: 'string.bat' } { startIndex: 8, type: 'string.bat' }
]}], ]
}],
[{ [{
line: '"use strict";', line: '"use strict";',
tokens: [ tokens: [
{ startIndex: 0, type: 'string.bat' }, { startIndex: 0, type: 'string.bat' },
{ startIndex: 12, type: 'delimiter.bat' } { startIndex: 12, type: 'delimiter.bat' }
]}], ]
}],
// Tags // Tags
[{ [{
line: 'setlocal endlocal', line: 'setlocal endlocal',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.tag-setlocal.bat' }, { startIndex: 0, type: 'keyword.tag-setlocal.bat' },
{ startIndex: 8, type: '' }, { startIndex: 8, type: '' },
{ startIndex: 9, type: 'keyword.tag-setlocal.bat' } { startIndex: 9, type: 'keyword.tag-setlocal.bat' }
]}], ]
}],
[{ [{
line: 'setlocal ENDLOCAL', line: 'setlocal ENDLOCAL',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.tag-setlocal.bat' }, { startIndex: 0, type: 'keyword.tag-setlocal.bat' },
{ startIndex: 8, type: '' }, { startIndex: 8, type: '' },
{ startIndex: 9, type: 'keyword.tag-setlocal.bat' } { startIndex: 9, type: 'keyword.tag-setlocal.bat' }
]}], ]
}],
[{ [{
line: 'SETLOCAL endlocal', line: 'SETLOCAL endlocal',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.tag-setlocal.bat' }, { startIndex: 0, type: 'keyword.tag-setlocal.bat' },
{ startIndex: 8, type: '' }, { startIndex: 8, type: '' },
{ startIndex: 9, type: 'keyword.tag-setlocal.bat' } { startIndex: 9, type: 'keyword.tag-setlocal.bat' }
]}], ]
}],
[{ [{
line: 'setlocal setlocal endlocal', line: 'setlocal setlocal endlocal',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.tag-setlocal.bat' }, { startIndex: 0, type: 'keyword.tag-setlocal.bat' },
{ startIndex: 8, type: '' }, { startIndex: 8, type: '' },
{ startIndex: 9, type: 'keyword.tag-setlocal.bat' }, { startIndex: 9, type: 'keyword.tag-setlocal.bat' },
{ startIndex: 17, type: '' }, { startIndex: 17, type: '' },
{ startIndex: 18, type: 'keyword.tag-setlocal.bat' } { startIndex: 18, type: 'keyword.tag-setlocal.bat' }
]}], ]
}],
// Monarch generated // Monarch generated
[{ [{
line: 'rem asdf', line: 'rem asdf',
tokens: [ tokens: [
{ startIndex: 0, type: 'comment.bat' } { startIndex: 0, type: 'comment.bat' }
]}, { ]
line: '', }, {
tokens: [ line: '',
tokens: [
]}, { ]
line: 'REM', }, {
tokens: [ line: 'REM',
{ startIndex: 0, type: 'comment.bat' } tokens: [
]}, { { startIndex: 0, type: 'comment.bat' }
line: '', ]
tokens: [ }, {
line: '',
tokens: [
]}, { ]
line: 'REMOVED not a comment really', }, {
tokens: [ line: 'REMOVED not a comment really',
{ startIndex: 0, type: '' }, tokens: [
{ startIndex: 8, type: 'keyword.not.bat' }, { startIndex: 0, type: '' },
{ startIndex: 11, type: '' } { startIndex: 8, type: 'keyword.not.bat' },
]}, { { startIndex: 11, type: '' }
line: '', ]
tokens: [ }, {
line: '',
tokens: [
]}, { ]
line: 'echo cool', }, {
tokens: [ line: 'echo cool',
{ startIndex: 0, type: 'keyword.echo.bat' }, tokens: [
{ startIndex: 4, type: '' } { startIndex: 0, type: 'keyword.echo.bat' },
]}, { { startIndex: 4, type: '' }
line: '@echo off', ]
tokens: [ }, {
{ startIndex: 0, type: 'keyword.bat' }, line: '@echo off',
{ startIndex: 1, type: 'keyword.echo.bat' }, tokens: [
{ startIndex: 5, type: '' } { startIndex: 0, type: 'keyword.bat' },
]}, { { startIndex: 1, type: 'keyword.echo.bat' },
line: '', { startIndex: 5, type: '' }
tokens: [ ]
}, {
line: '',
tokens: [
]}, { ]
line: 'setlocAL', }, {
tokens: [ line: 'setlocAL',
{ startIndex: 0, type: 'keyword.tag-setlocal.bat' } tokens: [
]}, { { startIndex: 0, type: 'keyword.tag-setlocal.bat' }
line: ' asdf', ]
tokens: [ }, {
{ startIndex: 0, type: '' } line: ' asdf',
]}, { tokens: [
line: ' asdf', { startIndex: 0, type: '' }
tokens: [ ]
{ startIndex: 0, type: '' } }, {
]}, { line: ' asdf',
line: 'endLocaL', tokens: [
tokens: [ { startIndex: 0, type: '' }
{ startIndex: 0, type: 'keyword.tag-setlocal.bat' } ]
]}, { }, {
line: '', line: 'endLocaL',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.tag-setlocal.bat' }
]
}, {
line: '',
tokens: [
]}, { ]
line: 'call', }, {
tokens: [ line: 'call',
{ startIndex: 0, type: 'keyword.call.bat' } tokens: [
]}, { { startIndex: 0, type: 'keyword.call.bat' }
line: '', ]
tokens: [ }, {
line: '',
tokens: [
]}, { ]
line: ':MyLabel', }, {
tokens: [ line: ':MyLabel',
{ startIndex: 0, type: 'metatag.bat' } tokens: [
]}, { { startIndex: 0, type: 'metatag.bat' }
line: 'some command', ]
tokens: [ }, {
{ startIndex: 0, type: '' } line: 'some command',
]}, { tokens: [
line: '', { startIndex: 0, type: '' }
tokens: [ ]
}, {
line: '',
tokens: [
]}, { ]
line: '%sdfsdf% ', }, {
tokens: [ line: '%sdfsdf% ',
{ startIndex: 0, type: 'variable.bat' }, tokens: [
{ startIndex: 8, type: '' } { startIndex: 0, type: 'variable.bat' },
]}, { { startIndex: 8, type: '' }
line: '', ]
tokens: [ }, {
line: '',
tokens: [
]}, { ]
line: 'this is "a string %sdf% asdf"', }, {
tokens: [ line: 'this is "a string %sdf% asdf"',
{ startIndex: 0, type: '' }, tokens: [
{ startIndex: 8, type: 'string.bat' }, { startIndex: 0, type: '' },
{ startIndex: 18, type: 'variable.bat' }, { startIndex: 8, type: 'string.bat' },
{ startIndex: 23, type: 'string.bat' } { startIndex: 18, type: 'variable.bat' },
]}, { { startIndex: 23, type: 'string.bat' }
line: '', ]
tokens: [ }, {
line: '',
tokens: [
]}, { ]
line: '', }, {
tokens: [ line: '',
tokens: [
]}, { ]
line: 'FOR %%A IN (1 2 3) DO (', }, {
tokens: [ line: 'FOR %%A IN (1 2 3) DO (',
{ startIndex: 0, type: 'keyword.for.bat' }, tokens: [
{ startIndex: 3, type: '' }, { startIndex: 0, type: 'keyword.for.bat' },
{ startIndex: 4, type: 'variable.bat' }, { startIndex: 3, type: '' },
{ startIndex: 7, type: '' }, { startIndex: 4, type: 'variable.bat' },
{ startIndex: 11, type: 'delimiter.parenthesis.bat' }, { startIndex: 7, type: '' },
{ startIndex: 12, type: 'number.bat' }, { startIndex: 11, type: 'delimiter.parenthesis.bat' },
{ startIndex: 13, type: '' }, { startIndex: 12, type: 'number.bat' },
{ startIndex: 14, type: 'number.bat' }, { startIndex: 13, type: '' },
{ startIndex: 15, type: '' }, { startIndex: 14, type: 'number.bat' },
{ startIndex: 16, type: 'number.bat' }, { startIndex: 15, type: '' },
{ startIndex: 17, type: 'delimiter.parenthesis.bat' }, { startIndex: 16, type: 'number.bat' },
{ startIndex: 18, type: '' }, { startIndex: 17, type: 'delimiter.parenthesis.bat' },
{ startIndex: 22, type: 'delimiter.parenthesis.bat' } { startIndex: 18, type: '' },
]}, { { startIndex: 22, type: 'delimiter.parenthesis.bat' }
line: ' SET VAR1=%VAR1%%%A', ]
tokens: [ }, {
{ startIndex: 0, type: '' }, line: ' SET VAR1=%VAR1%%%A',
{ startIndex: 1, type: 'keyword.set.bat' }, tokens: [
{ startIndex: 4, type: '' }, { startIndex: 0, type: '' },
{ startIndex: 9, type: 'delimiter.bat' }, { startIndex: 1, type: 'keyword.set.bat' },
{ startIndex: 10, type: 'variable.bat' } { startIndex: 4, type: '' },
]}, { { startIndex: 9, type: 'delimiter.bat' },
line: ' SET VAR2=%VAR2%%%A', { startIndex: 10, type: 'variable.bat' }
tokens: [ ]
{ startIndex: 0, type: '' }, }, {
{ startIndex: 1, type: 'keyword.set.bat' }, line: ' SET VAR2=%VAR2%%%A',
{ startIndex: 4, type: '' }, tokens: [
{ startIndex: 9, type: 'delimiter.bat' }, { startIndex: 0, type: '' },
{ startIndex: 10, type: 'variable.bat' } { startIndex: 1, type: 'keyword.set.bat' },
]}, { { startIndex: 4, type: '' },
line: ' use \'string %%a asdf asdf\'', { startIndex: 9, type: 'delimiter.bat' },
tokens: [ { startIndex: 10, type: 'variable.bat' }
{ startIndex: 0, type: '' }, ]
{ startIndex: 5, type: 'string.bat' }, }, {
{ startIndex: 13, type: 'variable.bat' }, line: ' use \'string %%a asdf asdf\'',
{ startIndex: 16, type: 'string.bat' } tokens: [
]}, { { startIndex: 0, type: '' },
line: ' non terminated "string %%aaa sdf', { startIndex: 5, type: 'string.bat' },
tokens: [ { startIndex: 13, type: 'variable.bat' },
{ startIndex: 0, type: '' }, { startIndex: 16, type: 'string.bat' }
{ startIndex: 16, type: 'string.bat' }, ]
{ startIndex: 24, type: 'variable.bat' }, }, {
{ startIndex: 29, type: 'string.bat' } line: ' non terminated "string %%aaa sdf',
]}, { tokens: [
line: ' this shold NOT BE red', { startIndex: 0, type: '' },
tokens: [ { startIndex: 16, type: 'string.bat' },
{ startIndex: 0, type: '' }, { startIndex: 24, type: 'variable.bat' },
{ startIndex: 12, type: 'keyword.not.bat' }, { startIndex: 29, type: 'string.bat' }
{ startIndex: 15, type: '' } ]
]}, { }, {
line: ')', line: ' this shold NOT BE red',
tokens: [ tokens: [
{ startIndex: 0, type: 'delimiter.parenthesis.bat' } { startIndex: 0, type: '' },
]}] { startIndex: 12, type: 'keyword.not.bat' },
]); { startIndex: 15, type: '' }
]
}, {
line: ')',
tokens: [
{ startIndex: 0, type: 'delimiter.parenthesis.bat' }
]
}]
]);

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -4,16 +4,17 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
'use strict'; 'use strict';
import {testTokenization} from './testRunner'; import { testTokenization } from './testRunner';
testTokenization('css', [ testTokenization('css', [
// Skip whitespace // Skip whitespace
[{ [{
line: ' body', line: ' body',
tokens: [ tokens: [
{ startIndex: 0, type: '' }, { startIndex: 0, type: '' },
{ startIndex: 6, type: 'tag.css' } { startIndex: 6, type: 'tag.css' }
]}], ]
}],
// CSS rule // CSS rule
// body { // body {
@ -24,242 +25,265 @@ testTokenization('css', [
// color: #000 // color: #000
// } // }
[{ [{
line: 'body {', line: 'body {',
tokens: [ tokens: [
{ startIndex: 0, type: 'tag.css' }, { startIndex: 0, type: 'tag.css' },
{ startIndex: 4, type: '' }, { startIndex: 4, type: '' },
{ startIndex: 5, type: 'delimiter.bracket.css' } { startIndex: 5, type: 'delimiter.bracket.css' }
]}, { ]
line: ' margin: 0;', }, {
tokens: [ line: ' margin: 0;',
{ startIndex: 0, type: '' }, tokens: [
{ startIndex: 2, type: 'attribute.name.css' }, { startIndex: 0, type: '' },
{ startIndex: 9, type: '' }, { startIndex: 2, type: 'attribute.name.css' },
{ startIndex: 10, type: 'attribute.value.number.css' }, { startIndex: 9, type: '' },
{ startIndex: 11, type: 'delimiter.css' } { startIndex: 10, type: 'attribute.value.number.css' },
]}, { { startIndex: 11, type: 'delimiter.css' }
line: ' padding: 3em 6em;', ]
tokens: [ }, {
{ startIndex: 0, type: '' }, line: ' padding: 3em 6em;',
{ startIndex: 2, type: 'attribute.name.css' }, tokens: [
{ startIndex: 10, type: '' }, { startIndex: 0, type: '' },
{ startIndex: 11, type: 'attribute.value.number.css' }, { startIndex: 2, type: 'attribute.name.css' },
{ startIndex: 12, type: 'attribute.value.unit.css' }, { startIndex: 10, type: '' },
{ startIndex: 14, type: '' }, { startIndex: 11, type: 'attribute.value.number.css' },
{ startIndex: 15, type: 'attribute.value.number.css' }, { startIndex: 12, type: 'attribute.value.unit.css' },
{ startIndex: 16, type: 'attribute.value.unit.css' }, { startIndex: 14, type: '' },
{ startIndex: 18, type: 'delimiter.css' } { startIndex: 15, type: 'attribute.value.number.css' },
]}, { { startIndex: 16, type: 'attribute.value.unit.css' },
line: ' font-family: tahoma, arial, sans-serif;', { startIndex: 18, type: 'delimiter.css' }
tokens: [ ]
{ startIndex: 0, type: '' }, }, {
{ startIndex: 2, type: 'attribute.name.css' }, line: ' font-family: tahoma, arial, sans-serif;',
{ startIndex: 14, type: '' }, tokens: [
{ startIndex: 15, type: 'attribute.value.css' }, { startIndex: 0, type: '' },
{ startIndex: 21, type: 'delimiter.css' }, { startIndex: 2, type: 'attribute.name.css' },
{ startIndex: 22, type: '' }, { startIndex: 14, type: '' },
{ startIndex: 23, type: 'attribute.value.css' }, { startIndex: 15, type: 'attribute.value.css' },
{ startIndex: 28, type: 'delimiter.css' }, { startIndex: 21, type: 'delimiter.css' },
{ startIndex: 29, type: '' }, { startIndex: 22, type: '' },
{ startIndex: 30, type: 'attribute.value.css' }, { startIndex: 23, type: 'attribute.value.css' },
{ startIndex: 40, type: 'delimiter.css' } { startIndex: 28, type: 'delimiter.css' },
]}, { { startIndex: 29, type: '' },
line: ' text-decoration: none !important;', { startIndex: 30, type: 'attribute.value.css' },
tokens: [ { startIndex: 40, type: 'delimiter.css' }
{ startIndex: 0, type: '' }, ]
{ startIndex: 2, type: 'attribute.name.css' }, }, {
{ startIndex: 18, type: '' }, line: ' text-decoration: none !important;',
{ startIndex: 19, type: 'attribute.value.css' }, tokens: [
{ startIndex: 23, type: '' }, { startIndex: 0, type: '' },
{ startIndex: 24, type: 'keyword.css' }, { startIndex: 2, type: 'attribute.name.css' },
{ startIndex: 34, type: 'delimiter.css' } { startIndex: 18, type: '' },
]}, { { startIndex: 19, type: 'attribute.value.css' },
line: ' color: #000', { startIndex: 23, type: '' },
tokens: [ { startIndex: 24, type: 'keyword.css' },
{ startIndex: 0, type: '' }, { startIndex: 34, type: 'delimiter.css' }
{ startIndex: 2, type: 'attribute.name.css' }, ]
{ startIndex: 8, type: '' }, }, {
{ startIndex: 9, type: 'attribute.value.hex.css' } line: ' color: #000',
]}, { tokens: [
line: ' }', { startIndex: 0, type: '' },
tokens: [ { startIndex: 2, type: 'attribute.name.css' },
{ startIndex: 0, type: '' }, { startIndex: 8, type: '' },
{ startIndex: 2, type: 'delimiter.bracket.css' } { startIndex: 9, type: 'attribute.value.hex.css' }
]}], ]
}, {
line: ' }',
tokens: [
{ startIndex: 0, type: '' },
{ startIndex: 2, type: 'delimiter.bracket.css' }
]
}],
// CSS units and numbers // CSS units and numbers
[{ [{
line: '* { padding: 3em -9pt -0.5px; }', line: '* { padding: 3em -9pt -0.5px; }',
tokens: [ tokens: [
{ startIndex: 0, type: 'tag.css' }, { startIndex: 0, type: 'tag.css' },
{ startIndex: 1, type: '' }, { startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.bracket.css' }, { startIndex: 2, type: 'delimiter.bracket.css' },
{ startIndex: 3, type: '' }, { startIndex: 3, type: '' },
{ startIndex: 4, type: 'attribute.name.css' }, { startIndex: 4, type: 'attribute.name.css' },
{ startIndex: 12, type: '' }, { startIndex: 12, type: '' },
{ startIndex: 13, type: 'attribute.value.number.css' }, { startIndex: 13, type: 'attribute.value.number.css' },
{ startIndex: 14, type: 'attribute.value.unit.css' }, { startIndex: 14, type: 'attribute.value.unit.css' },
{ startIndex: 16, type: '' }, { startIndex: 16, type: '' },
{ startIndex: 17, type: 'attribute.value.number.css' }, { startIndex: 17, type: 'attribute.value.number.css' },
{ startIndex: 19, type: 'attribute.value.unit.css' }, { startIndex: 19, type: 'attribute.value.unit.css' },
{ startIndex: 21, type: '' }, { startIndex: 21, type: '' },
{ startIndex: 22, type: 'attribute.value.number.css' }, { startIndex: 22, type: 'attribute.value.number.css' },
{ startIndex: 26, type: 'attribute.value.unit.css' }, { startIndex: 26, type: 'attribute.value.unit.css' },
{ startIndex: 28, type: 'delimiter.css' }, { startIndex: 28, type: 'delimiter.css' },
{ startIndex: 29, type: '' }, { startIndex: 29, type: '' },
{ startIndex: 30, type: 'delimiter.bracket.css' } { startIndex: 30, type: 'delimiter.bracket.css' }
]}], ]
}],
// CSS unfinished unit and numbers // CSS unfinished unit and numbers
[{ [{
line: '* { padding: -', line: '* { padding: -',
tokens: [ tokens: [
{ startIndex: 0, type: 'tag.css' }, { startIndex: 0, type: 'tag.css' },
{ startIndex: 1, type: '' }, { startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.bracket.css' }, { startIndex: 2, type: 'delimiter.bracket.css' },
{ startIndex: 3, type: '' }, { startIndex: 3, type: '' },
{ startIndex: 4, type: 'attribute.name.css' }, { startIndex: 4, type: 'attribute.name.css' },
{ startIndex: 12, type: '' }, { startIndex: 12, type: '' },
{ startIndex: 13, type: 'delimiter.css' } { startIndex: 13, type: 'delimiter.css' }
]}], ]
}],
// CSS single line comment // CSS single line comment
// h1 /*comment*/ p { // h1 /*comment*/ p {
[{ [{
line: 'h1 /*comment*/ p {', line: 'h1 /*comment*/ p {',
tokens: [ tokens: [
{ startIndex: 0, type: 'tag.css' }, { startIndex: 0, type: 'tag.css' },
{ startIndex: 2, type: '' }, { startIndex: 2, type: '' },
{ startIndex: 3, type: 'comment.css' }, { startIndex: 3, type: 'comment.css' },
{ startIndex: 14, type: '' }, { startIndex: 14, type: '' },
{ startIndex: 15, type: 'tag.css' }, { startIndex: 15, type: 'tag.css' },
{ startIndex: 16, type: '' }, { startIndex: 16, type: '' },
{ startIndex: 17, type: 'delimiter.bracket.css' } { startIndex: 17, type: 'delimiter.bracket.css' }
]}], ]
}],
// CSS multi line comment // CSS multi line comment
// h1 /*com // h1 /*com
// ment*/ p { // ment*/ p {
[{ [{
line: 'h1 /*com', line: 'h1 /*com',
tokens: [ tokens: [
{ startIndex: 0, type: 'tag.css' }, { startIndex: 0, type: 'tag.css' },
{ startIndex: 2, type: '' }, { startIndex: 2, type: '' },
{ startIndex: 3, type: 'comment.css' } { startIndex: 3, type: 'comment.css' }
]}, { ]
line: 'ment*/ p', }, {
tokens: [ line: 'ment*/ p',
{ startIndex: 0, type: 'comment.css' }, tokens: [
{ startIndex: 6, type: '' }, { startIndex: 0, type: 'comment.css' },
{ startIndex: 7, type: 'tag.css' } { startIndex: 6, type: '' },
]}], { startIndex: 7, type: 'tag.css' }
]
}],
// CSS ID rule // CSS ID rule
[{ [{
line: '#myID {', line: '#myID {',
tokens: [ tokens: [
{ startIndex: 0, type: 'tag.css' }, { startIndex: 0, type: 'tag.css' },
{ startIndex: 5, type: '' }, { startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.bracket.css' } { startIndex: 6, type: 'delimiter.bracket.css' }
]}], ]
}],
// CSS Class rules // CSS Class rules
[{ [{
line: '.myID {', line: '.myID {',
tokens: [ tokens: [
{ startIndex: 0, type: 'tag.css' }, { startIndex: 0, type: 'tag.css' },
{ startIndex: 5, type: '' }, { startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.bracket.css' } { startIndex: 6, type: 'delimiter.bracket.css' }
]}], ]
}],
// CSS @import etc // CSS @import etc
[{ [{
line: '@import url(\"something.css\");', line: '@import url(\"something.css\");',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.css' }, { startIndex: 0, type: 'keyword.css' },
{ startIndex: 7, type: '' }, { startIndex: 7, type: '' },
{ startIndex: 8, type: 'attribute.value.css' }, { startIndex: 8, type: 'attribute.value.css' },
{ startIndex: 11, type: 'delimiter.parenthesis.css' }, { startIndex: 11, type: 'delimiter.parenthesis.css' },
{ startIndex: 12, type: 'string.css' }, { startIndex: 12, type: 'string.css' },
{ startIndex: 27, type: 'delimiter.parenthesis.css' }, { startIndex: 27, type: 'delimiter.parenthesis.css' },
{ startIndex: 28, type: 'delimiter.css' } { startIndex: 28, type: 'delimiter.css' }
]}], ]
}],
// CSS multi-line string with an escaped newline // CSS multi-line string with an escaped newline
// body { // body {
// content: 'con\ // content: 'con\
// tent'; // tent';
[{ [{
line: 'body {', line: 'body {',
tokens: [ tokens: [
{ startIndex: 0, type: 'tag.css' }, { startIndex: 0, type: 'tag.css' },
{ startIndex: 4, type: '' }, { startIndex: 4, type: '' },
{ startIndex: 5, type: 'delimiter.bracket.css' }, { startIndex: 5, type: 'delimiter.bracket.css' },
]}, { ]
line: ' content: \"con\\', }, {
tokens: [ line: ' content: \"con\\',
{ startIndex: 0, type: '' }, tokens: [
{ startIndex: 2, type: 'attribute.name.css' }, { startIndex: 0, type: '' },
{ startIndex: 10, type: '' }, { startIndex: 2, type: 'attribute.name.css' },
{ startIndex: 11, type: 'string.css' } { startIndex: 10, type: '' },
]}, { { startIndex: 11, type: 'string.css' }
line: 'tent\";', ]
tokens: [ }, {
{ startIndex: 0, type: 'string.css' }, line: 'tent\";',
{ startIndex: 5, type: 'delimiter.css' } tokens: [
]}], { startIndex: 0, type: 'string.css' },
{ startIndex: 5, type: 'delimiter.css' }
]
}],
// CSS empty string value // CSS empty string value
// body { // body {
// content: ''; // content: '';
[{ [{
line: 'body {', line: 'body {',
tokens: [ tokens: [
{ startIndex: 0, type: 'tag.css' }, { startIndex: 0, type: 'tag.css' },
{ startIndex: 4, type: '' }, { startIndex: 4, type: '' },
{ startIndex: 5, type: 'delimiter.bracket.css' }, { startIndex: 5, type: 'delimiter.bracket.css' },
]}, { ]
line: ' content: \"\";', }, {
tokens: [ line: ' content: \"\";',
{ startIndex: 0, type: '' }, tokens: [
{ startIndex: 2, type: 'attribute.name.css' }, { startIndex: 0, type: '' },
{ startIndex: 10, type: '' }, { startIndex: 2, type: 'attribute.name.css' },
{ startIndex: 11, type: 'string.css' }, { startIndex: 10, type: '' },
{ startIndex: 13, type: 'delimiter.css' } { startIndex: 11, type: 'string.css' },
]}], { startIndex: 13, type: 'delimiter.css' }
]
}],
// CSS font face // CSS font face
// @font-face { // @font-face {
// font-family: 'Opificio'; // font-family: 'Opificio';
// } // }
[{ [{
line: '@font-face {', line: '@font-face {',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.css' }, { startIndex: 0, type: 'keyword.css' },
{ startIndex: 10, type: '' }, { startIndex: 10, type: '' },
{ startIndex: 11, type: 'delimiter.bracket.css' } { startIndex: 11, type: 'delimiter.bracket.css' }
]}, { ]
line: ' font-family: "Opificio";', }, {
tokens: [ line: ' font-family: "Opificio";',
{ startIndex: 0, type: '' }, tokens: [
{ startIndex: 2, type: 'attribute.name.css' }, { startIndex: 0, type: '' },
{ startIndex: 14, type: '' }, { startIndex: 2, type: 'attribute.name.css' },
{ startIndex: 15, type: 'string.css' }, { startIndex: 14, type: '' },
{ startIndex: 25, type: 'delimiter.css' } { startIndex: 15, type: 'string.css' },
]}], { startIndex: 25, type: 'delimiter.css' }
]
}],
// CSS string with escaped quotes // CSS string with escaped quotes
// 's\"tr' // 's\"tr'
[{ [{
line: '\"s\\\"tr\" ', line: '\"s\\\"tr\" ',
tokens: [ tokens: [
{ startIndex: 0, type: 'string.css' }, { startIndex: 0, type: 'string.css' },
{ startIndex: 7, type: '' } { startIndex: 7, type: '' }
]}], ]
}],
// CSS key frame animation syntax // CSS key frame animation syntax
//@-webkit-keyframes infinite-spinning { //@-webkit-keyframes infinite-spinning {
// from { // from {
// -webkit-transform: rotate(0deg); // -webkit-transform: rotate(0deg);
// } // }
// to { // to {
@ -267,210 +291,230 @@ testTokenization('css', [
// } // }
//} //}
[{ [{
line: '@-webkit-keyframes infinite-spinning {', line: '@-webkit-keyframes infinite-spinning {',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.css' }, { startIndex: 0, type: 'keyword.css' },
{ startIndex: 18, type: '' }, { startIndex: 18, type: '' },
{ startIndex: 19, type: 'attribute.value.css' }, { startIndex: 19, type: 'attribute.value.css' },
{ startIndex: 36, type: '' }, { startIndex: 36, type: '' },
{ startIndex: 37, type: 'delimiter.bracket.css' } { startIndex: 37, type: 'delimiter.bracket.css' }
]}, { ]
line: ' from {', }, {
tokens: [ line: ' from {',
{ startIndex: 0, type: '' }, tokens: [
{ startIndex: 2, type: 'attribute.value.css' }, { startIndex: 0, type: '' },
{ startIndex: 6, type: '' }, { startIndex: 2, type: 'attribute.value.css' },
{ startIndex: 7, type: 'delimiter.bracket.css' } { startIndex: 6, type: '' },
]}, { { startIndex: 7, type: 'delimiter.bracket.css' }
line: ' -webkit-transform: rotate(0deg);', ]
tokens: [ }, {
{ startIndex: 0, type: '' }, line: ' -webkit-transform: rotate(0deg);',
{ startIndex: 2, type: 'attribute.name.css' }, tokens: [
{ startIndex: 20, type: '' }, { startIndex: 0, type: '' },
{ startIndex: 21, type: 'attribute.value.css' }, { startIndex: 2, type: 'attribute.name.css' },
{ startIndex: 28, type: 'attribute.value.number.css' }, { startIndex: 20, type: '' },
{ startIndex: 29, type: 'attribute.value.unit.css' }, { startIndex: 21, type: 'attribute.value.css' },
{ startIndex: 32, type: 'attribute.value.css' }, { startIndex: 28, type: 'attribute.value.number.css' },
{ startIndex: 33, type: 'delimiter.css' } { startIndex: 29, type: 'attribute.value.unit.css' },
]}, { { startIndex: 32, type: 'attribute.value.css' },
line: ' }', { startIndex: 33, type: 'delimiter.css' }
tokens: [ ]
{ startIndex: 0, type: '' }, }, {
{ startIndex: 2, type: 'delimiter.bracket.css' } line: ' }',
]}, { tokens: [
line: ' to {', { startIndex: 0, type: '' },
tokens: [ { startIndex: 2, type: 'delimiter.bracket.css' }
{ startIndex: 0, type: '' }, ]
{ startIndex: 2, type: 'attribute.value.css' }, }, {
{ startIndex: 4, type: '' }, line: ' to {',
{ startIndex: 5, type: 'delimiter.bracket.css' } tokens: [
]}, { { startIndex: 0, type: '' },
line: ' -webkit-transform: rotate(360deg);', { startIndex: 2, type: 'attribute.value.css' },
tokens: [ { startIndex: 4, type: '' },
{ startIndex: 0, type: '' }, { startIndex: 5, type: 'delimiter.bracket.css' }
{ startIndex: 2, type: 'attribute.name.css' }, ]
{ startIndex: 20, type: '' }, }, {
{ startIndex: 21, type: 'attribute.value.css' }, line: ' -webkit-transform: rotate(360deg);',
{ startIndex: 28, type: 'attribute.value.number.css' }, tokens: [
{ startIndex: 31, type: 'attribute.value.unit.css' }, { startIndex: 0, type: '' },
{ startIndex: 34, type: 'attribute.value.css' }, { startIndex: 2, type: 'attribute.name.css' },
{ startIndex: 35, type: 'delimiter.css' } { startIndex: 20, type: '' },
]}, { { startIndex: 21, type: 'attribute.value.css' },
line: ' }', { startIndex: 28, type: 'attribute.value.number.css' },
tokens: [ { startIndex: 31, type: 'attribute.value.unit.css' },
{ startIndex: 0, type: '' }, { startIndex: 34, type: 'attribute.value.css' },
{ startIndex: 2, type: 'delimiter.bracket.css' } { startIndex: 35, type: 'delimiter.css' }
]}, { ]
line: '}', }, {
tokens: [ line: ' }',
{ startIndex: 0, type: 'delimiter.bracket.css' } tokens: [
]}], { startIndex: 0, type: '' },
{ startIndex: 2, type: 'delimiter.bracket.css' }
]
}, {
line: '}',
tokens: [
{ startIndex: 0, type: 'delimiter.bracket.css' }
]
}],
// CSS @import related coloring bug 9553 // CSS @import related coloring bug 9553
// @import url('something.css'); // @import url('something.css');
// .rule1{} // .rule1{}
// .rule2{} // .rule2{}
[{ [{
line: '@import url(\"something.css\");', line: '@import url(\"something.css\");',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.css' }, { startIndex: 0, type: 'keyword.css' },
{ startIndex: 7, type: '' }, { startIndex: 7, type: '' },
{ startIndex: 8, type: 'attribute.value.css' }, { startIndex: 8, type: 'attribute.value.css' },
{ startIndex: 11, type: 'delimiter.parenthesis.css' }, { startIndex: 11, type: 'delimiter.parenthesis.css' },
{ startIndex: 12, type: 'string.css' }, { startIndex: 12, type: 'string.css' },
{ startIndex: 27, type: 'delimiter.parenthesis.css' }, { startIndex: 27, type: 'delimiter.parenthesis.css' },
{ startIndex: 28, type: 'delimiter.css' } { startIndex: 28, type: 'delimiter.css' }
]}, { ]
line: '.rule1{}', }, {
tokens: [ line: '.rule1{}',
{ startIndex: 0, type: 'tag.css' }, tokens: [
{ startIndex: 6, type: 'delimiter.bracket.css' }, { startIndex: 0, type: 'tag.css' },
]}, { { startIndex: 6, type: 'delimiter.bracket.css' },
line: '.rule2{}', ]
tokens: [ }, {
{ startIndex: 0, type: 'tag.css' }, line: '.rule2{}',
{ startIndex: 6, type: 'delimiter.bracket.css' }, tokens: [
]}], { startIndex: 0, type: 'tag.css' },
{ startIndex: 6, type: 'delimiter.bracket.css' },
]
}],
// Triple quotes - bug #9870 // Triple quotes - bug #9870
[{ [{
line: '"""', line: '"""',
tokens: [ tokens: [
{ startIndex: 0, type: 'string.css' } { startIndex: 0, type: 'string.css' }
]}], ]
}],
[{ [{
line: '""""', line: '""""',
tokens: [ tokens: [
{ startIndex: 0, type: 'string.css' } { startIndex: 0, type: 'string.css' }
]}], ]
}],
[{ [{
line: '"""""', line: '"""""',
tokens: [ tokens: [
{ startIndex: 0, type: 'string.css' } { startIndex: 0, type: 'string.css' }
]}], ]
}],
// import statement - bug #10308 // import statement - bug #10308
// @import url('something.css');@import url('something.css'); // @import url('something.css');@import url('something.css');
[{ [{
line: '@import url(\"something.css\");@import url(\"something.css\");', line: '@import url(\"something.css\");@import url(\"something.css\");',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.css' }, { startIndex: 0, type: 'keyword.css' },
{ startIndex: 7, type: '' }, { startIndex: 7, type: '' },
{ startIndex: 8, type: 'attribute.value.css' }, { startIndex: 8, type: 'attribute.value.css' },
{ startIndex: 11, type: 'delimiter.parenthesis.css' }, { startIndex: 11, type: 'delimiter.parenthesis.css' },
{ startIndex: 12, type: 'string.css' }, { startIndex: 12, type: 'string.css' },
{ startIndex: 27, type: 'delimiter.parenthesis.css' }, { startIndex: 27, type: 'delimiter.parenthesis.css' },
{ startIndex: 28, type: 'delimiter.css' }, { startIndex: 28, type: 'delimiter.css' },
{ startIndex: 29, type: 'keyword.css' }, { startIndex: 29, type: 'keyword.css' },
{ startIndex: 36, type: '' }, { startIndex: 36, type: '' },
{ startIndex: 37, type: 'attribute.value.css' }, { startIndex: 37, type: 'attribute.value.css' },
{ startIndex: 40, type: 'delimiter.parenthesis.css' }, { startIndex: 40, type: 'delimiter.parenthesis.css' },
{ startIndex: 41, type: 'string.css' }, { startIndex: 41, type: 'string.css' },
{ startIndex: 56, type: 'delimiter.parenthesis.css' }, { startIndex: 56, type: 'delimiter.parenthesis.css' },
{ startIndex: 57, type: 'delimiter.css' } { startIndex: 57, type: 'delimiter.css' }
]}], ]
}],
// !important - bug #9578 // !important - bug #9578
// .a{background:#f5f9fc !important}.b{font-family:"Helvetica Neue", Helvetica;height:31px;} // .a{background:#f5f9fc !important}.b{font-family:"Helvetica Neue", Helvetica;height:31px;}
[{ [{
line: '.a{background:#f5f9fc !important}.b{font-family:"Helvetica Neue", Helvetica;height:31px;}', line: '.a{background:#f5f9fc !important}.b{font-family:"Helvetica Neue", Helvetica;height:31px;}',
tokens: [ tokens: [
{ startIndex: 0, type: 'tag.css' }, { startIndex: 0, type: 'tag.css' },
{ startIndex: 2, type: 'delimiter.bracket.css' }, { startIndex: 2, type: 'delimiter.bracket.css' },
{ startIndex: 3, type: 'attribute.name.css' }, { startIndex: 3, type: 'attribute.name.css' },
{ startIndex: 14, type: 'attribute.value.hex.css' }, { startIndex: 14, type: 'attribute.value.hex.css' },
{ startIndex: 21, type: '' }, { startIndex: 21, type: '' },
{ startIndex: 22, type: 'keyword.css' }, { startIndex: 22, type: 'keyword.css' },
{ startIndex: 32, type: 'delimiter.bracket.css' }, { startIndex: 32, type: 'delimiter.bracket.css' },
{ startIndex: 33, type: 'tag.css' }, { startIndex: 33, type: 'tag.css' },
{ startIndex: 35, type: 'delimiter.bracket.css' }, { startIndex: 35, type: 'delimiter.bracket.css' },
{ startIndex: 36, type: 'attribute.name.css' }, { startIndex: 36, type: 'attribute.name.css' },
{ startIndex: 48, type: 'string.css' }, { startIndex: 48, type: 'string.css' },
{ startIndex: 64, type: 'delimiter.css' }, { startIndex: 64, type: 'delimiter.css' },
{ startIndex: 65, type: '' }, { startIndex: 65, type: '' },
{ startIndex: 66, type: 'attribute.value.css' }, { startIndex: 66, type: 'attribute.value.css' },
{ startIndex: 75, type: 'delimiter.css' }, { startIndex: 75, type: 'delimiter.css' },
{ startIndex: 76, type: 'attribute.name.css' }, { startIndex: 76, type: 'attribute.name.css' },
{ startIndex: 83, type: 'attribute.value.number.css' }, { startIndex: 83, type: 'attribute.value.number.css' },
{ startIndex: 85, type: 'attribute.value.unit.css' }, { startIndex: 85, type: 'attribute.value.unit.css' },
{ startIndex: 87, type: 'delimiter.css' }, { startIndex: 87, type: 'delimiter.css' },
{ startIndex: 88, type: 'delimiter.bracket.css' } { startIndex: 88, type: 'delimiter.bracket.css' }
]}], ]
}],
// base64-encoded data uris - bug #9580 // base64-encoded data uris - bug #9580
//.even { background: #fff url(data:image/gif;base64,R0lGODlhBgASALMAAOfn5+rq6uvr6+zs7O7u7vHx8fPz8/b29vj4+P39/f///wAAAAAAAAAAAAAAAAAAACwAAAAABgASAAAIMAAVCBxIsKDBgwgTDkzAsKGAhxARSJx4oKJFAxgzFtjIkYDHjwNCigxAsiSAkygDAgA7) repeat-x bottom} //.even { background: #fff url(data:image/gif;base64,R0lGODlhBgASALMAAOfn5+rq6uvr6+zs7O7u7vHx8fPz8/b29vj4+P39/f///wAAAAAAAAAAAAAAAAAAACwAAAAABgASAAAIMAAVCBxIsKDBgwgTDkzAsKGAhxARSJx4oKJFAxgzFtjIkYDHjwNCigxAsiSAkygDAgA7) repeat-x bottom}
[{ [{
line: '.even { background: #fff url(data:image/gif;base64,R0lGODlhBgASALMAAOfn5+rq6uvr6+zs7O7u7vHx8fPz8/b29vj4+P39/f///wAAAAAAAAAAAAAAAAAAACwAAAAABgASAAAIMAAVCBxIsKDBgwgTDkzAsKGAhxARSJx4oKJFAxgzFtjIkYDHjwNCigxAsiSAkygDAgA7) repeat-x bottom}', line: '.even { background: #fff url(data:image/gif;base64,R0lGODlhBgASALMAAOfn5+rq6uvr6+zs7O7u7vHx8fPz8/b29vj4+P39/f///wAAAAAAAAAAAAAAAAAAACwAAAAABgASAAAIMAAVCBxIsKDBgwgTDkzAsKGAhxARSJx4oKJFAxgzFtjIkYDHjwNCigxAsiSAkygDAgA7) repeat-x bottom}',
tokens: [ tokens: [
{startIndex: 0, type: 'tag.css'}, { startIndex: 0, type: 'tag.css' },
{startIndex: 5, type: ''}, { startIndex: 5, type: '' },
{startIndex: 6, type: 'delimiter.bracket.css'}, { startIndex: 6, type: 'delimiter.bracket.css' },
{startIndex: 7, type: ''}, { startIndex: 7, type: '' },
{startIndex: 8, type: 'attribute.name.css'}, { startIndex: 8, type: 'attribute.name.css' },
{startIndex: 19, type: ''}, { startIndex: 19, type: '' },
{startIndex: 20, type: 'attribute.value.hex.css'}, { startIndex: 20, type: 'attribute.value.hex.css' },
{startIndex: 24, type: ''}, { startIndex: 24, type: '' },
{startIndex: 25, type: 'attribute.value.css'}, { startIndex: 25, type: 'attribute.value.css' },
{startIndex: 28, type: 'delimiter.parenthesis.css'}, { startIndex: 28, type: 'delimiter.parenthesis.css' },
{startIndex: 29, type: 'string.css'}, { startIndex: 29, type: 'string.css' },
{startIndex: 215, type: 'delimiter.parenthesis.css'}, { startIndex: 215, type: 'delimiter.parenthesis.css' },
{startIndex: 216, type: ''}, { startIndex: 216, type: '' },
{startIndex: 217, type: 'attribute.value.css'}, { startIndex: 217, type: 'attribute.value.css' },
{startIndex: 225, type: ''}, { startIndex: 225, type: '' },
{startIndex: 226, type: 'attribute.value.css'}, { startIndex: 226, type: 'attribute.value.css' },
{startIndex: 232, type: 'delimiter.bracket.css'} { startIndex: 232, type: 'delimiter.bracket.css' }
]}], ]
}],
// /a colorization is incorrect in url - bug #9581 // /a colorization is incorrect in url - bug #9581
//.a{background:url(/a.jpg)} //.a{background:url(/a.jpg)}
[{ [{
line: '.a{background:url(/a.jpg)}', line: '.a{background:url(/a.jpg)}',
tokens: [ tokens: [
{startIndex: 0, type: 'tag.css'}, { startIndex: 0, type: 'tag.css' },
{startIndex: 2, type: 'delimiter.bracket.css'}, { startIndex: 2, type: 'delimiter.bracket.css' },
{startIndex: 3, type: 'attribute.name.css'}, { startIndex: 3, type: 'attribute.name.css' },
{startIndex: 14, type: 'attribute.value.css'}, { startIndex: 14, type: 'attribute.value.css' },
{startIndex: 17, type: 'delimiter.parenthesis.css'}, { startIndex: 17, type: 'delimiter.parenthesis.css' },
{startIndex: 18, type: 'string.css'}, { startIndex: 18, type: 'string.css' },
{startIndex: 24, type: 'delimiter.parenthesis.css'}, { startIndex: 24, type: 'delimiter.parenthesis.css' },
{startIndex: 25, type: 'delimiter.bracket.css'} { startIndex: 25, type: 'delimiter.bracket.css' }
]}], ]
}],
// Bracket Matching // Bracket Matching
[{ [{
line: 'p{}', line: 'p{}',
tokens: [ tokens: [
{ startIndex: 0, type: 'tag.css' }, { startIndex: 0, type: 'tag.css' },
{ startIndex: 1, type: 'delimiter.bracket.css' }, { startIndex: 1, type: 'delimiter.bracket.css' },
]}], ]
}],
[{ [{
line: 'p:nth() {}', line: 'p:nth() {}',
tokens: [ tokens: [
{ startIndex: 0, type: 'tag.css' }, { startIndex: 0, type: 'tag.css' },
{ startIndex: 5, type: '' }, { startIndex: 5, type: '' },
{ startIndex: 8, type: 'delimiter.bracket.css' } { startIndex: 8, type: 'delimiter.bracket.css' }
]}], ]
}],
]); ]);

View file

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

View file

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

File diff suppressed because it is too large Load diff

View file

@ -5,8 +5,8 @@
'use strict'; 'use strict';
import {testTokenization} from './testRunner'; import { testTokenization } from './testRunner';
import {htmlTokenTypes} from '../src/handlebars'; import { htmlTokenTypes } from '../src/handlebars';
const HTML_DELIM_START = htmlTokenTypes.DELIM_START; const HTML_DELIM_START = htmlTokenTypes.DELIM_START;
const HTML_DELIM_END = htmlTokenTypes.DELIM_END; const HTML_DELIM_END = htmlTokenTypes.DELIM_END;
@ -30,13 +30,13 @@ testTokenization(['handlebars', 'css'], [
[{ [{
line: '<h1>handlebars!</h1>', line: '<h1>handlebars!</h1>',
tokens: [ tokens: [
{ startIndex:0, type: HTML_DELIM_START }, { startIndex: 0, type: HTML_DELIM_START },
{ startIndex:1, type: getTag('h1') }, { startIndex: 1, type: getTag('h1') },
{ startIndex:3, type: HTML_DELIM_END }, { startIndex: 3, type: HTML_DELIM_END },
{ startIndex:4, type: '' }, { startIndex: 4, type: '' },
{ startIndex:15, type: HTML_DELIM_START }, { startIndex: 15, type: HTML_DELIM_START },
{ startIndex:17, type: getTag('h1') }, { startIndex: 17, type: getTag('h1') },
{ startIndex:19, type: HTML_DELIM_END } { startIndex: 19, type: HTML_DELIM_END }
] ]
}], }],
@ -44,17 +44,17 @@ testTokenization(['handlebars', 'css'], [
[{ [{
line: '<h1>{{ title }}</h1>', line: '<h1>{{ title }}</h1>',
tokens: [ tokens: [
{ startIndex:0, type: HTML_DELIM_START }, { startIndex: 0, type: HTML_DELIM_START },
{ startIndex:1, type: getTag('h1') }, { startIndex: 1, type: getTag('h1') },
{ startIndex:3, type: HTML_DELIM_END }, { startIndex: 3, type: HTML_DELIM_END },
{ startIndex:4, type: handlebarsTokenTypes.EMBED }, { startIndex: 4, type: handlebarsTokenTypes.EMBED },
{ startIndex:6, type: '' }, { startIndex: 6, type: '' },
{ startIndex:7, type: handlebarsTokenTypes.VARIABLE }, { startIndex: 7, type: handlebarsTokenTypes.VARIABLE },
{ startIndex:12, type: '' }, { startIndex: 12, type: '' },
{ startIndex:13, type: handlebarsTokenTypes.EMBED }, { startIndex: 13, type: handlebarsTokenTypes.EMBED },
{ startIndex:15, type: HTML_DELIM_START }, { startIndex: 15, type: HTML_DELIM_START },
{ startIndex:17, type: getTag('h1') }, { startIndex: 17, type: getTag('h1') },
{ startIndex:19, type: HTML_DELIM_END } { startIndex: 19, type: HTML_DELIM_END }
] ]
}], }],
@ -62,15 +62,15 @@ testTokenization(['handlebars', 'css'], [
[{ [{
line: '<h1>{{title}}</h1>', line: '<h1>{{title}}</h1>',
tokens: [ tokens: [
{ startIndex:0, type: HTML_DELIM_START }, { startIndex: 0, type: HTML_DELIM_START },
{ startIndex:1, type: getTag('h1') }, { startIndex: 1, type: getTag('h1') },
{ startIndex:3, type: HTML_DELIM_END }, { startIndex: 3, type: HTML_DELIM_END },
{ startIndex:4, type: handlebarsTokenTypes.EMBED }, { startIndex: 4, type: handlebarsTokenTypes.EMBED },
{ startIndex:6, type: handlebarsTokenTypes.VARIABLE }, { startIndex: 6, type: handlebarsTokenTypes.VARIABLE },
{ startIndex:11, type: handlebarsTokenTypes.EMBED }, { startIndex: 11, type: handlebarsTokenTypes.EMBED },
{ startIndex:13, type: HTML_DELIM_START }, { startIndex: 13, type: HTML_DELIM_START },
{ startIndex:15, type: getTag('h1') }, { startIndex: 15, type: getTag('h1') },
{ startIndex:17, type: HTML_DELIM_END } { startIndex: 17, type: HTML_DELIM_END }
] ]
}], }],
@ -78,17 +78,17 @@ testTokenization(['handlebars', 'css'], [
[{ [{
line: '<h1>{{{ title }}}</h1>', line: '<h1>{{{ title }}}</h1>',
tokens: [ tokens: [
{ startIndex:0, type: HTML_DELIM_START }, { startIndex: 0, type: HTML_DELIM_START },
{ startIndex:1, type: getTag('h1') }, { startIndex: 1, type: getTag('h1') },
{ startIndex:3, type: HTML_DELIM_END }, { startIndex: 3, type: HTML_DELIM_END },
{ startIndex:4, type: handlebarsTokenTypes.EMBED_UNESCAPED }, { startIndex: 4, type: handlebarsTokenTypes.EMBED_UNESCAPED },
{ startIndex:7, type: '' }, { startIndex: 7, type: '' },
{ startIndex:8, type: handlebarsTokenTypes.VARIABLE }, { startIndex: 8, type: handlebarsTokenTypes.VARIABLE },
{ startIndex:13, type: '' }, { startIndex: 13, type: '' },
{ startIndex:14, type: handlebarsTokenTypes.EMBED_UNESCAPED }, { startIndex: 14, type: handlebarsTokenTypes.EMBED_UNESCAPED },
{ startIndex:17, type: HTML_DELIM_START }, { startIndex: 17, type: HTML_DELIM_START },
{ startIndex:19, type: getTag('h1') }, { startIndex: 19, type: getTag('h1') },
{ startIndex:21, type: HTML_DELIM_END } { startIndex: 21, type: HTML_DELIM_END }
] ]
}], }],
@ -96,29 +96,29 @@ testTokenization(['handlebars', 'css'], [
[{ [{
line: '<ul>{{#each items}}<li>{{item}}</li>{{/each}}</ul>', line: '<ul>{{#each items}}<li>{{item}}</li>{{/each}}</ul>',
tokens: [ tokens: [
{ startIndex:0, type: HTML_DELIM_START }, { startIndex: 0, type: HTML_DELIM_START },
{ startIndex:1, type: getTag('ul') }, { startIndex: 1, type: getTag('ul') },
{ startIndex:3, type: HTML_DELIM_END }, { startIndex: 3, type: HTML_DELIM_END },
{ startIndex:4, type: handlebarsTokenTypes.EMBED }, { startIndex: 4, type: handlebarsTokenTypes.EMBED },
{ startIndex:6, type: handlebarsTokenTypes.KEYWORD }, { startIndex: 6, type: handlebarsTokenTypes.KEYWORD },
{ startIndex:11, type: '' }, { startIndex: 11, type: '' },
{ startIndex:12, type: handlebarsTokenTypes.VARIABLE }, { startIndex: 12, type: handlebarsTokenTypes.VARIABLE },
{ startIndex:17, type: handlebarsTokenTypes.EMBED }, { startIndex: 17, type: handlebarsTokenTypes.EMBED },
{ startIndex:19, type: HTML_DELIM_START }, { startIndex: 19, type: HTML_DELIM_START },
{ startIndex:20, type: getTag('li') }, { startIndex: 20, type: getTag('li') },
{ startIndex:22, type: HTML_DELIM_END }, { startIndex: 22, type: HTML_DELIM_END },
{ startIndex:23, type: handlebarsTokenTypes.EMBED }, { startIndex: 23, type: handlebarsTokenTypes.EMBED },
{ startIndex:25, type: handlebarsTokenTypes.VARIABLE }, { startIndex: 25, type: handlebarsTokenTypes.VARIABLE },
{ startIndex:29, type: handlebarsTokenTypes.EMBED }, { startIndex: 29, type: handlebarsTokenTypes.EMBED },
{ startIndex:31, type: HTML_DELIM_START }, { startIndex: 31, type: HTML_DELIM_START },
{ startIndex:33, type: getTag('li') }, { startIndex: 33, type: getTag('li') },
{ startIndex:35, type: HTML_DELIM_END }, { startIndex: 35, type: HTML_DELIM_END },
{ startIndex:36, type: handlebarsTokenTypes.EMBED }, { startIndex: 36, type: handlebarsTokenTypes.EMBED },
{ startIndex:38, type: handlebarsTokenTypes.KEYWORD }, { startIndex: 38, type: handlebarsTokenTypes.KEYWORD },
{ startIndex:43, type: handlebarsTokenTypes.EMBED }, { startIndex: 43, type: handlebarsTokenTypes.EMBED },
{ startIndex:45, type: HTML_DELIM_START }, { startIndex: 45, type: HTML_DELIM_START },
{ startIndex:47, type: getTag('ul') }, { startIndex: 47, type: getTag('ul') },
{ startIndex:49, type: HTML_DELIM_END } { startIndex: 49, type: HTML_DELIM_END }
] ]
}], }],
@ -126,38 +126,38 @@ testTokenization(['handlebars', 'css'], [
[{ [{
line: '<div>', line: '<div>',
tokens: [ tokens: [
{ startIndex:0, type: HTML_DELIM_START }, { startIndex: 0, type: HTML_DELIM_START },
{ startIndex:1, type: getTag('div') }, { startIndex: 1, type: getTag('div') },
{ startIndex:4, type: HTML_DELIM_END } { startIndex: 4, type: HTML_DELIM_END }
] ]
}, { }, {
line: '{{#if foo}}', line: '{{#if foo}}',
tokens: [ tokens: [
{ startIndex:0, type: handlebarsTokenTypes.EMBED }, { startIndex: 0, type: handlebarsTokenTypes.EMBED },
{ startIndex:2, type: handlebarsTokenTypes.KEYWORD }, { startIndex: 2, type: handlebarsTokenTypes.KEYWORD },
{ startIndex:5, type: '' }, { startIndex: 5, type: '' },
{ startIndex:6, type: handlebarsTokenTypes.VARIABLE }, { startIndex: 6, type: handlebarsTokenTypes.VARIABLE },
{ startIndex:9, type: handlebarsTokenTypes.EMBED } { startIndex: 9, type: handlebarsTokenTypes.EMBED }
] ]
}, { }, {
line: '<span>{{bar}}</span>', line: '<span>{{bar}}</span>',
tokens: [ tokens: [
{ startIndex:0, type: HTML_DELIM_START }, { startIndex: 0, type: HTML_DELIM_START },
{ startIndex:1, type: getTag('span') }, { startIndex: 1, type: getTag('span') },
{ startIndex:5, type: HTML_DELIM_END }, { startIndex: 5, type: HTML_DELIM_END },
{ startIndex:6, type: handlebarsTokenTypes.EMBED }, { startIndex: 6, type: handlebarsTokenTypes.EMBED },
{ startIndex:8, type: handlebarsTokenTypes.VARIABLE }, { startIndex: 8, type: handlebarsTokenTypes.VARIABLE },
{ startIndex:11, type: handlebarsTokenTypes.EMBED }, { startIndex: 11, type: handlebarsTokenTypes.EMBED },
{ startIndex:13, type: HTML_DELIM_START }, { startIndex: 13, type: HTML_DELIM_START },
{ startIndex:15, type: getTag('span') }, { startIndex: 15, type: getTag('span') },
{ startIndex:19, type: HTML_DELIM_END } { startIndex: 19, type: HTML_DELIM_END }
] ]
}, { }, {
line: '{{/if}}', line: '{{/if}}',
tokens: [ tokens: [
{ startIndex:0, type: handlebarsTokenTypes.EMBED }, { startIndex: 0, type: handlebarsTokenTypes.EMBED },
{ startIndex:2, type: handlebarsTokenTypes.KEYWORD }, { startIndex: 2, type: handlebarsTokenTypes.KEYWORD },
{ startIndex:5, type: handlebarsTokenTypes.EMBED } { startIndex: 5, type: handlebarsTokenTypes.EMBED }
] ]
}], }],
@ -165,9 +165,9 @@ testTokenization(['handlebars', 'css'], [
[{ [{
line: '</div>', line: '</div>',
tokens: [ tokens: [
{ startIndex:0, type: HTML_DELIM_START }, { startIndex: 0, type: HTML_DELIM_START },
{ startIndex:2, type: getTag('div') }, { startIndex: 2, type: getTag('div') },
{ startIndex:5, type: HTML_DELIM_END } { startIndex: 5, type: HTML_DELIM_END }
] ]
}], }],
@ -175,27 +175,27 @@ testTokenization(['handlebars', 'css'], [
[{ [{
line: '<script type="text/x-handlebars-template"><h1>{{ title }}</h1></script>', line: '<script type="text/x-handlebars-template"><h1>{{ title }}</h1></script>',
tokens: [ tokens: [
{ startIndex:0, type: HTML_DELIM_START }, { startIndex: 0, type: HTML_DELIM_START },
{ startIndex:1, type: getTag('script') }, { startIndex: 1, type: getTag('script') },
{ startIndex:7, type: '' }, { startIndex: 7, type: '' },
{ startIndex:8, type: HTML_ATTRIB_NAME }, { startIndex: 8, type: HTML_ATTRIB_NAME },
{ startIndex:12, type: DELIM_ASSIGN }, { startIndex: 12, type: DELIM_ASSIGN },
{ startIndex:13, type: HTML_ATTRIB_VALUE }, { startIndex: 13, type: HTML_ATTRIB_VALUE },
{ startIndex:41, type: HTML_DELIM_END }, { startIndex: 41, type: HTML_DELIM_END },
{ startIndex:42, type: HTML_DELIM_START }, { startIndex: 42, type: HTML_DELIM_START },
{ startIndex:43, type: getTag('h1') }, { startIndex: 43, type: getTag('h1') },
{ startIndex:45, type: HTML_DELIM_END }, { startIndex: 45, type: HTML_DELIM_END },
{ startIndex:46, type: handlebarsTokenTypes.EMBED }, { startIndex: 46, type: handlebarsTokenTypes.EMBED },
{ startIndex:48, type: '' }, { startIndex: 48, type: '' },
{ startIndex:49, type: handlebarsTokenTypes.VARIABLE }, { startIndex: 49, type: handlebarsTokenTypes.VARIABLE },
{ startIndex:54, type: '' }, { startIndex: 54, type: '' },
{ startIndex:55, type: handlebarsTokenTypes.EMBED }, { startIndex: 55, type: handlebarsTokenTypes.EMBED },
{ startIndex:57, type: HTML_DELIM_START }, { startIndex: 57, type: HTML_DELIM_START },
{ startIndex:59, type: getTag('h1') }, { startIndex: 59, type: getTag('h1') },
{ startIndex:61, type: HTML_DELIM_END }, { startIndex: 61, type: HTML_DELIM_END },
{ startIndex:62, type: HTML_DELIM_START }, { startIndex: 62, type: HTML_DELIM_START },
{ startIndex:64, type: getTag('script') }, { startIndex: 64, type: getTag('script') },
{ startIndex:70, type: HTML_DELIM_END } { startIndex: 70, type: HTML_DELIM_END }
] ]
}], }],
@ -203,35 +203,35 @@ testTokenization(['handlebars', 'css'], [
[{ [{
line: '<script type="text/x-handlebars-template">', line: '<script type="text/x-handlebars-template">',
tokens: [ tokens: [
{ startIndex:0, type: HTML_DELIM_START }, { startIndex: 0, type: HTML_DELIM_START },
{ startIndex:1, type: getTag('script') }, { startIndex: 1, type: getTag('script') },
{ startIndex:7, type: '' }, { startIndex: 7, type: '' },
{ startIndex:8, type: HTML_ATTRIB_NAME }, { startIndex: 8, type: HTML_ATTRIB_NAME },
{ startIndex:12, type: DELIM_ASSIGN }, { startIndex: 12, type: DELIM_ASSIGN },
{ startIndex:13, type: HTML_ATTRIB_VALUE }, { startIndex: 13, type: HTML_ATTRIB_VALUE },
{ startIndex:41, type: HTML_DELIM_END } { startIndex: 41, type: HTML_DELIM_END }
] ]
}, { }, {
line: '<h1>{{ title }}</h1>', line: '<h1>{{ title }}</h1>',
tokens: [ tokens: [
{ startIndex:0, type: HTML_DELIM_START }, { startIndex: 0, type: HTML_DELIM_START },
{ startIndex:1, type: getTag('h1') }, { startIndex: 1, type: getTag('h1') },
{ startIndex:3, type: HTML_DELIM_END }, { startIndex: 3, type: HTML_DELIM_END },
{ startIndex:4, type: handlebarsTokenTypes.EMBED }, { startIndex: 4, type: handlebarsTokenTypes.EMBED },
{ startIndex:6, type: '' }, { startIndex: 6, type: '' },
{ startIndex:7, type: handlebarsTokenTypes.VARIABLE }, { startIndex: 7, type: handlebarsTokenTypes.VARIABLE },
{ startIndex:12, type: '' }, { startIndex: 12, type: '' },
{ startIndex:13, type: handlebarsTokenTypes.EMBED }, { startIndex: 13, type: handlebarsTokenTypes.EMBED },
{ startIndex:15, type: HTML_DELIM_START }, { startIndex: 15, type: HTML_DELIM_START },
{ startIndex:17, type: getTag('h1') }, { startIndex: 17, type: getTag('h1') },
{ startIndex:19, type: HTML_DELIM_END } { startIndex: 19, type: HTML_DELIM_END }
] ]
}, { }, {
line: '</script>', line: '</script>',
tokens: [ tokens: [
{ startIndex:0, type: HTML_DELIM_START }, { startIndex: 0, type: HTML_DELIM_START },
{ startIndex:2, type: getTag('script') }, { startIndex: 2, type: getTag('script') },
{ startIndex:8, type: HTML_DELIM_END } { startIndex: 8, type: HTML_DELIM_END }
] ]
}], }],
@ -239,18 +239,18 @@ testTokenization(['handlebars', 'css'], [
[{ [{
line: '{{foo}}<script></script>{{bar}}', line: '{{foo}}<script></script>{{bar}}',
tokens: [ tokens: [
{ startIndex:0, type: handlebarsTokenTypes.EMBED }, { startIndex: 0, type: handlebarsTokenTypes.EMBED },
{ startIndex:2, type: handlebarsTokenTypes.VARIABLE }, { startIndex: 2, type: handlebarsTokenTypes.VARIABLE },
{ startIndex:5, type: handlebarsTokenTypes.EMBED }, { startIndex: 5, type: handlebarsTokenTypes.EMBED },
{ startIndex:7, type: HTML_DELIM_START }, { startIndex: 7, type: HTML_DELIM_START },
{ startIndex:8, type: getTag('script') }, { startIndex: 8, type: getTag('script') },
{ startIndex:14, type: HTML_DELIM_END }, { startIndex: 14, type: HTML_DELIM_END },
// { startIndex:15, type: HTML_DELIM_START }, // { startIndex:15, type: HTML_DELIM_START },
{ startIndex:17, type: getTag('script') }, { startIndex: 17, type: getTag('script') },
{ startIndex:23, type: HTML_DELIM_END }, { startIndex: 23, type: HTML_DELIM_END },
{ startIndex:24, type: handlebarsTokenTypes.EMBED }, { startIndex: 24, type: handlebarsTokenTypes.EMBED },
{ startIndex:26, type: handlebarsTokenTypes.VARIABLE }, { startIndex: 26, type: handlebarsTokenTypes.VARIABLE },
{ startIndex:29, type: handlebarsTokenTypes.EMBED } { startIndex: 29, type: handlebarsTokenTypes.EMBED }
] ]
}], }],
@ -258,9 +258,9 @@ testTokenization(['handlebars', 'css'], [
[{ [{
line: '{{else}}', line: '{{else}}',
tokens: [ tokens: [
{ startIndex:0, type: handlebarsTokenTypes.EMBED }, { startIndex: 0, type: handlebarsTokenTypes.EMBED },
{ startIndex:2, type: handlebarsTokenTypes.KEYWORD }, { startIndex: 2, type: handlebarsTokenTypes.KEYWORD },
{ startIndex:6, type: handlebarsTokenTypes.EMBED } { startIndex: 6, type: handlebarsTokenTypes.EMBED }
] ]
}], }],
@ -268,9 +268,9 @@ testTokenization(['handlebars', 'css'], [
[{ [{
line: '{{elseFoo}}', line: '{{elseFoo}}',
tokens: [ tokens: [
{ startIndex:0, type: handlebarsTokenTypes.EMBED }, { startIndex: 0, type: handlebarsTokenTypes.EMBED },
{ startIndex:2, type: handlebarsTokenTypes.VARIABLE }, { startIndex: 2, type: handlebarsTokenTypes.VARIABLE },
{ startIndex:9, type: handlebarsTokenTypes.EMBED } { startIndex: 9, type: handlebarsTokenTypes.EMBED }
] ]
}], }],
@ -278,13 +278,13 @@ testTokenization(['handlebars', 'css'], [
[{ [{
line: '<a href="/posts/{{permalink}}">', line: '<a href="/posts/{{permalink}}">',
tokens: [ tokens: [
{ startIndex:0, type: HTML_DELIM_START }, { startIndex: 0, type: HTML_DELIM_START },
{ startIndex:1, type: getTag('a') }, { startIndex: 1, type: getTag('a') },
{ startIndex:2, type: '' }, { startIndex: 2, type: '' },
{ startIndex:3, type: HTML_ATTRIB_NAME }, { startIndex: 3, type: HTML_ATTRIB_NAME },
{ startIndex:7, type: DELIM_ASSIGN }, { startIndex: 7, type: DELIM_ASSIGN },
{ startIndex:8, type: HTML_ATTRIB_VALUE }, { startIndex: 8, type: HTML_ATTRIB_VALUE },
{ startIndex:30, type: HTML_DELIM_END } { startIndex: 30, type: HTML_DELIM_END }
] ]
}] }]
]); ]);

View file

@ -5,8 +5,8 @@
'use strict'; 'use strict';
import {testTokenization} from './testRunner'; import { testTokenization } from './testRunner';
import {htmlTokenTypes} from '../src/html'; import { htmlTokenTypes } from '../src/html';
const DELIM_START = htmlTokenTypes.DELIM_START + '.html'; const DELIM_START = htmlTokenTypes.DELIM_START + '.html';
const DELIM_END = htmlTokenTypes.DELIM_END + '.html'; const DELIM_END = htmlTokenTypes.DELIM_END + '.html';
@ -14,7 +14,7 @@ const ATTRIB_NAME = 'attribute.name.html';
const DELIM_ASSIGN = 'delimiter.html'; const DELIM_ASSIGN = 'delimiter.html';
const ATTRIB_VALUE = 'attribute.value.html'; const ATTRIB_VALUE = 'attribute.value.html';
function getTag(name:string): string { function getTag(name: string): string {
return htmlTokenTypes.getTag(name) + '.html'; return htmlTokenTypes.getTag(name) + '.html';
} }
@ -29,8 +29,8 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<abc', line: '<abc',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('abc') } { startIndex: 1, type: getTag('abc') }
] ]
}], }],
@ -38,8 +38,8 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<input', line: '<input',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('input') } { startIndex: 1, type: getTag('input') }
] ]
}], }],
@ -47,8 +47,8 @@ testTokenization(['html', 'css'], [
[{ [{
line: '< abc', line: '< abc',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: '' } { startIndex: 1, type: '' }
] ]
}], }],
@ -56,19 +56,19 @@ testTokenization(['html', 'css'], [
[{ [{
line: '< abc>', line: '< abc>',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: '' } { startIndex: 1, type: '' }
] ]
}], }],
// Open Start Tag #4 // Open Start Tag #4
[{ [{
line: 'i <len;', line: 'i <len;',
tokens: [ tokens: [
{ startIndex:0, type: '' }, { startIndex: 0, type: '' },
{ startIndex:2, type: DELIM_START }, { startIndex: 2, type: DELIM_START },
{ startIndex:3, type: getTag('len') }, { startIndex: 3, type: getTag('len') },
{ startIndex:6, type: '' } { startIndex: 6, type: '' }
] ]
}], }],
@ -76,7 +76,7 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<', line: '<',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START } { startIndex: 0, type: DELIM_START }
] ]
}], }],
@ -84,8 +84,8 @@ testTokenization(['html', 'css'], [
[{ [{
line: '</a', line: '</a',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:2, type: getTag('a') } { startIndex: 2, type: getTag('a') }
] ]
}], }],
@ -93,9 +93,9 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<abc>', line: '<abc>',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('abc') }, { startIndex: 1, type: getTag('abc') },
{ startIndex:4, type: DELIM_END } { startIndex: 4, type: DELIM_END }
] ]
}], }],
@ -103,10 +103,10 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<abc >', line: '<abc >',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('abc') }, { startIndex: 1, type: getTag('abc') },
{ startIndex:4, type: '' }, { startIndex: 4, type: '' },
{ startIndex:5, type: DELIM_END } { startIndex: 5, type: DELIM_END }
] ]
}], }],
@ -114,9 +114,9 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<foo:bar>', line: '<foo:bar>',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('foo-bar') }, { startIndex: 1, type: getTag('foo-bar') },
{ startIndex:8, type: DELIM_END } { startIndex: 8, type: DELIM_END }
] ]
}], }],
@ -124,9 +124,9 @@ testTokenization(['html', 'css'], [
[{ [{
line: '</abc>', line: '</abc>',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:2, type: getTag('abc') }, { startIndex: 2, type: getTag('abc') },
{ startIndex:5, type: DELIM_END } { startIndex: 5, type: DELIM_END }
] ]
}], }],
@ -134,10 +134,10 @@ testTokenization(['html', 'css'], [
[{ [{
line: '</abc >', line: '</abc >',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:2, type: getTag('abc') }, { startIndex: 2, type: getTag('abc') },
{ startIndex:5, type: '' }, { startIndex: 5, type: '' },
{ startIndex:7, type: DELIM_END } { startIndex: 7, type: DELIM_END }
] ]
}], }],
@ -145,10 +145,10 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<abc />', line: '<abc />',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('abc') }, { startIndex: 1, type: getTag('abc') },
{ startIndex:4, type: '' }, { startIndex: 4, type: '' },
{ startIndex:5, type: DELIM_END } { startIndex: 5, type: DELIM_END }
] ]
}], }],
@ -156,17 +156,17 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<script type="text/javascript">var i= 10;</script>', line: '<script type="text/javascript">var i= 10;</script>',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('script') }, { startIndex: 1, type: getTag('script') },
{ startIndex:7, type: '' }, { startIndex: 7, type: '' },
{ startIndex:8, type: ATTRIB_NAME }, { startIndex: 8, type: ATTRIB_NAME },
{ startIndex:12, type: DELIM_ASSIGN }, { startIndex: 12, type: DELIM_ASSIGN },
{ startIndex:13, type: ATTRIB_VALUE }, { startIndex: 13, type: ATTRIB_VALUE },
{ startIndex:30, type: DELIM_END }, { startIndex: 30, type: DELIM_END },
{ startIndex:31, type: '' }, { startIndex: 31, type: '' },
{ startIndex:41, type: DELIM_START }, { startIndex: 41, type: DELIM_START },
{ startIndex:43, type: getTag('script') }, { startIndex: 43, type: getTag('script') },
{ startIndex:49, type: DELIM_END } { startIndex: 49, type: DELIM_END }
] ]
}], }],
@ -174,25 +174,25 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<script type="text/javascript">', line: '<script type="text/javascript">',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('script') }, { startIndex: 1, type: getTag('script') },
{ startIndex:7, type: '' }, { startIndex: 7, type: '' },
{ startIndex:8, type: ATTRIB_NAME }, { startIndex: 8, type: ATTRIB_NAME },
{ startIndex:12, type: DELIM_ASSIGN }, { startIndex: 12, type: DELIM_ASSIGN },
{ startIndex:13, type: ATTRIB_VALUE }, { startIndex: 13, type: ATTRIB_VALUE },
{ startIndex:30, type: DELIM_END } { startIndex: 30, type: DELIM_END }
] ]
}, { }, {
line: 'var i= 10;', line: 'var i= 10;',
tokens: [ tokens: [
{ startIndex:0, type: '' }, { startIndex: 0, type: '' },
] ]
}, { }, {
line: '</script>', line: '</script>',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:2, type: getTag('script') }, { startIndex: 2, type: getTag('script') },
{ startIndex:8, type: DELIM_END } { startIndex: 8, type: DELIM_END }
] ]
}], }],
@ -200,21 +200,21 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<script type="text/javascript">var i= 10;', line: '<script type="text/javascript">var i= 10;',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('script') }, { startIndex: 1, type: getTag('script') },
{ startIndex:7, type: '' }, { startIndex: 7, type: '' },
{ startIndex:8, type: ATTRIB_NAME }, { startIndex: 8, type: ATTRIB_NAME },
{ startIndex:12, type: DELIM_ASSIGN }, { startIndex: 12, type: DELIM_ASSIGN },
{ startIndex:13, type: ATTRIB_VALUE }, { startIndex: 13, type: ATTRIB_VALUE },
{ startIndex:30, type: DELIM_END }, { startIndex: 30, type: DELIM_END },
{ startIndex:31, type: '' }, { startIndex: 31, type: '' },
] ]
}, { }, {
line: '</script>', line: '</script>',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:2, type: getTag('script') }, { startIndex: 2, type: getTag('script') },
{ startIndex:8, type: DELIM_END } { startIndex: 8, type: DELIM_END }
] ]
}], }],
@ -222,21 +222,21 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<script type="text/javascript">', line: '<script type="text/javascript">',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('script') }, { startIndex: 1, type: getTag('script') },
{ startIndex:7, type: '' }, { startIndex: 7, type: '' },
{ startIndex:8, type: ATTRIB_NAME }, { startIndex: 8, type: ATTRIB_NAME },
{ startIndex:12, type: DELIM_ASSIGN }, { startIndex: 12, type: DELIM_ASSIGN },
{ startIndex:13, type: ATTRIB_VALUE }, { startIndex: 13, type: ATTRIB_VALUE },
{ startIndex:30, type: DELIM_END } { startIndex: 30, type: DELIM_END }
] ]
}, { }, {
line: 'var i= 10;</script>', line: 'var i= 10;</script>',
tokens: [ tokens: [
{ startIndex:0, type: '' }, { startIndex: 0, type: '' },
{ startIndex:10, type: DELIM_START }, { startIndex: 10, type: DELIM_START },
{ startIndex:12, type: getTag('script') }, { startIndex: 12, type: getTag('script') },
{ startIndex:18, type: DELIM_END } { startIndex: 18, type: DELIM_END }
] ]
}], }],
@ -244,22 +244,22 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<script type="text/plain">a', line: '<script type="text/plain">a',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('script') }, { startIndex: 1, type: getTag('script') },
{ startIndex:7, type: '' }, { startIndex: 7, type: '' },
{ startIndex:8, type: ATTRIB_NAME }, { startIndex: 8, type: ATTRIB_NAME },
{ startIndex:12, type: DELIM_ASSIGN }, { startIndex: 12, type: DELIM_ASSIGN },
{ startIndex:13, type: ATTRIB_VALUE }, { startIndex: 13, type: ATTRIB_VALUE },
{ startIndex:25, type: DELIM_END }, { startIndex: 25, type: DELIM_END },
{ startIndex:26, type: '' }, { startIndex: 26, type: '' },
] ]
},{ }, {
line: '<a</script>', line: '<a</script>',
tokens: [ tokens: [
{ startIndex:0, type: '' }, { startIndex: 0, type: '' },
{ startIndex:2, type: DELIM_START }, { startIndex: 2, type: DELIM_START },
{ startIndex:4, type: getTag('script') }, { startIndex: 4, type: getTag('script') },
{ startIndex:10, type: DELIM_END } { startIndex: 10, type: DELIM_END }
] ]
}], }],
@ -267,20 +267,20 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<script>a</script><script>b</script>', line: '<script>a</script><script>b</script>',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('script') }, { startIndex: 1, type: getTag('script') },
{ startIndex:7, type: DELIM_END }, { startIndex: 7, type: DELIM_END },
{ startIndex:8, type: '' }, { startIndex: 8, type: '' },
{ startIndex:9, type: DELIM_START }, { startIndex: 9, type: DELIM_START },
{ startIndex:11, type: getTag('script') }, { startIndex: 11, type: getTag('script') },
{ startIndex:17, type: DELIM_END }, { startIndex: 17, type: DELIM_END },
// { startIndex:18, type: DELIM_START }, // { startIndex:18, type: DELIM_START },
{ startIndex:19, type: getTag('script') }, { startIndex: 19, type: getTag('script') },
{ startIndex:25, type: DELIM_END }, { startIndex: 25, type: DELIM_END },
{ startIndex:26, type: '' }, { startIndex: 26, type: '' },
{ startIndex:27, type: DELIM_START }, { startIndex: 27, type: DELIM_START },
{ startIndex:29, type: getTag('script') }, { startIndex: 29, type: getTag('script') },
{ startIndex:35, type: DELIM_END } { startIndex: 35, type: DELIM_END }
] ]
}], }],
@ -288,16 +288,16 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<script type="text/javascript"></script>', line: '<script type="text/javascript"></script>',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('script') }, { startIndex: 1, type: getTag('script') },
{ startIndex:7, type: '' }, { startIndex: 7, type: '' },
{ startIndex:8, type: ATTRIB_NAME }, { startIndex: 8, type: ATTRIB_NAME },
{ startIndex:12, type: DELIM_ASSIGN }, { startIndex: 12, type: DELIM_ASSIGN },
{ startIndex:13, type: ATTRIB_VALUE }, { startIndex: 13, type: ATTRIB_VALUE },
{ startIndex:30, type: DELIM_END }, { startIndex: 30, type: DELIM_END },
// { startIndex:31, type: DELIM_START }, // { startIndex:31, type: DELIM_START },
{ startIndex:33, type: getTag('script') }, { startIndex: 33, type: getTag('script') },
{ startIndex:39, type: DELIM_END } { startIndex: 39, type: DELIM_END }
] ]
}], }],
@ -305,13 +305,13 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<script>var i= 10;</script>', line: '<script>var i= 10;</script>',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('script') }, { startIndex: 1, type: getTag('script') },
{ startIndex:7, type: DELIM_END }, { startIndex: 7, type: DELIM_END },
{ startIndex:8, type: '' }, { startIndex: 8, type: '' },
{ startIndex:18, type: DELIM_START }, { startIndex: 18, type: DELIM_START },
{ startIndex:20, type: getTag('script') }, { startIndex: 20, type: getTag('script') },
{ startIndex:26, type: DELIM_END } { startIndex: 26, type: DELIM_END }
] ]
}], }],
@ -319,20 +319,20 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<script type="text/javascript" src="main.js"></script>', line: '<script type="text/javascript" src="main.js"></script>',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('script') }, { startIndex: 1, type: getTag('script') },
{ startIndex:7, type: '' }, { startIndex: 7, type: '' },
{ startIndex:8, type: ATTRIB_NAME }, { startIndex: 8, type: ATTRIB_NAME },
{ startIndex:12, type: DELIM_ASSIGN }, { startIndex: 12, type: DELIM_ASSIGN },
{ startIndex:13, type: ATTRIB_VALUE }, { startIndex: 13, type: ATTRIB_VALUE },
{ startIndex:30, type: '' }, { startIndex: 30, type: '' },
{ startIndex:31, type: ATTRIB_NAME }, { startIndex: 31, type: ATTRIB_NAME },
{ startIndex:34, type: DELIM_ASSIGN }, { startIndex: 34, type: DELIM_ASSIGN },
{ startIndex:35, type: ATTRIB_VALUE }, { startIndex: 35, type: ATTRIB_VALUE },
{ startIndex:44, type: DELIM_END }, { startIndex: 44, type: DELIM_END },
// { startIndex:45, type: DELIM_START }, // { startIndex:45, type: DELIM_START },
{ startIndex:47, type: getTag('script') }, { startIndex: 47, type: getTag('script') },
{ startIndex:53, type: DELIM_END } { startIndex: 53, type: DELIM_END }
] ]
}], }],
@ -340,13 +340,13 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<abc foo="bar">', line: '<abc foo="bar">',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('abc') }, { startIndex: 1, type: getTag('abc') },
{ startIndex:4, type: '' }, { startIndex: 4, type: '' },
{ startIndex:5, type: ATTRIB_NAME }, { startIndex: 5, type: ATTRIB_NAME },
{ startIndex:8, type: DELIM_ASSIGN }, { startIndex: 8, type: DELIM_ASSIGN },
{ startIndex:9, type: ATTRIB_VALUE }, { startIndex: 9, type: ATTRIB_VALUE },
{ startIndex:14, type: DELIM_END } { startIndex: 14, type: DELIM_END }
] ]
}], }],
@ -354,13 +354,13 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<abc foo=\'bar\'>', line: '<abc foo=\'bar\'>',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('abc') }, { startIndex: 1, type: getTag('abc') },
{ startIndex:4, type: '' }, { startIndex: 4, type: '' },
{ startIndex:5, type: ATTRIB_NAME }, { startIndex: 5, type: ATTRIB_NAME },
{ startIndex:8, type: DELIM_ASSIGN }, { startIndex: 8, type: DELIM_ASSIGN },
{ startIndex:9, type: ATTRIB_VALUE }, { startIndex: 9, type: ATTRIB_VALUE },
{ startIndex:14, type: DELIM_END } { startIndex: 14, type: DELIM_END }
] ]
}], }],
@ -368,13 +368,13 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<abc foo="">', line: '<abc foo="">',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('abc') }, { startIndex: 1, type: getTag('abc') },
{ startIndex:4, type: '' }, { startIndex: 4, type: '' },
{ startIndex:5, type: ATTRIB_NAME }, { startIndex: 5, type: ATTRIB_NAME },
{ startIndex:8, type: DELIM_ASSIGN }, { startIndex: 8, type: DELIM_ASSIGN },
{ startIndex:9, type: ATTRIB_VALUE }, { startIndex: 9, type: ATTRIB_VALUE },
{ startIndex:11, type: DELIM_END } { startIndex: 11, type: DELIM_END }
] ]
}], }],
@ -382,17 +382,17 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<abc foo="bar" bar=\'foo\'>', line: '<abc foo="bar" bar=\'foo\'>',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('abc') }, { startIndex: 1, type: getTag('abc') },
{ startIndex:4, type: '' }, { startIndex: 4, type: '' },
{ startIndex:5, type: ATTRIB_NAME }, { startIndex: 5, type: ATTRIB_NAME },
{ startIndex:8, type: DELIM_ASSIGN }, { startIndex: 8, type: DELIM_ASSIGN },
{ startIndex:9, type: ATTRIB_VALUE }, { startIndex: 9, type: ATTRIB_VALUE },
{ startIndex:14, type: '' }, { startIndex: 14, type: '' },
{ startIndex:15, type: ATTRIB_NAME }, { startIndex: 15, type: ATTRIB_NAME },
{ startIndex:18, type: DELIM_ASSIGN }, { startIndex: 18, type: DELIM_ASSIGN },
{ startIndex:19, type: ATTRIB_VALUE }, { startIndex: 19, type: ATTRIB_VALUE },
{ startIndex:24, type: DELIM_END } { startIndex: 24, type: DELIM_END }
] ]
}], }],
@ -400,17 +400,17 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<abc foo=bar bar=help-me>', line: '<abc foo=bar bar=help-me>',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('abc') }, { startIndex: 1, type: getTag('abc') },
{ startIndex:4, type: '' }, { startIndex: 4, type: '' },
{ startIndex:5, type: ATTRIB_NAME }, { startIndex: 5, type: ATTRIB_NAME },
{ startIndex:8, type: DELIM_ASSIGN }, { startIndex: 8, type: DELIM_ASSIGN },
{ startIndex:9, type: ATTRIB_NAME }, // slightly incorrect { startIndex: 9, type: ATTRIB_NAME }, // slightly incorrect
{ startIndex:12, type: '' }, { startIndex: 12, type: '' },
{ startIndex:13, type: ATTRIB_NAME }, { startIndex: 13, type: ATTRIB_NAME },
{ startIndex:16, type: DELIM_ASSIGN }, { startIndex: 16, type: DELIM_ASSIGN },
{ startIndex:17, type: ATTRIB_NAME }, // slightly incorrect { startIndex: 17, type: ATTRIB_NAME }, // slightly incorrect
{ startIndex:24, type: DELIM_END } { startIndex: 24, type: DELIM_END }
] ]
}], }],
@ -418,14 +418,14 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<abc foo= "bar">', line: '<abc foo= "bar">',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('abc') }, { startIndex: 1, type: getTag('abc') },
{ startIndex:4, type: '' }, { startIndex: 4, type: '' },
{ startIndex:5, type: ATTRIB_NAME }, { startIndex: 5, type: ATTRIB_NAME },
{ startIndex:8, type: DELIM_ASSIGN }, { startIndex: 8, type: DELIM_ASSIGN },
{ startIndex:9, type: '' }, { startIndex: 9, type: '' },
{ startIndex:11, type: ATTRIB_VALUE }, { startIndex: 11, type: ATTRIB_VALUE },
{ startIndex:16, type: DELIM_END } { startIndex: 16, type: DELIM_END }
] ]
}], }],
@ -433,15 +433,15 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<abc foo = "bar">', line: '<abc foo = "bar">',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('abc') }, { startIndex: 1, type: getTag('abc') },
{ startIndex:4, type: '' }, { startIndex: 4, type: '' },
{ startIndex:5, type: ATTRIB_NAME }, { startIndex: 5, type: ATTRIB_NAME },
{ startIndex:8, type: '' }, { startIndex: 8, type: '' },
{ startIndex:9, type: DELIM_ASSIGN }, { startIndex: 9, type: DELIM_ASSIGN },
{ startIndex:10, type: '' }, { startIndex: 10, type: '' },
{ startIndex:11, type: ATTRIB_VALUE }, { startIndex: 11, type: ATTRIB_VALUE },
{ startIndex:16, type: DELIM_END } { startIndex: 16, type: DELIM_END }
] ]
}], }],
@ -449,11 +449,11 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<abc foo>', line: '<abc foo>',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('abc') }, { startIndex: 1, type: getTag('abc') },
{ startIndex:4, type: '' }, { startIndex: 4, type: '' },
{ startIndex:5, type: ATTRIB_NAME }, { startIndex: 5, type: ATTRIB_NAME },
{ startIndex:8, type: DELIM_END } { startIndex: 8, type: DELIM_END }
] ]
}], }],
@ -461,13 +461,13 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<abc foo bar>', line: '<abc foo bar>',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('abc') }, { startIndex: 1, type: getTag('abc') },
{ startIndex:4, type: '' }, { startIndex: 4, type: '' },
{ startIndex:5, type: ATTRIB_NAME }, { startIndex: 5, type: ATTRIB_NAME },
{ startIndex:8, type: '' }, { startIndex: 8, type: '' },
{ startIndex:9, type: ATTRIB_NAME }, { startIndex: 9, type: ATTRIB_NAME },
{ startIndex:12, type: DELIM_END } { startIndex: 12, type: DELIM_END }
] ]
}], }],
@ -475,14 +475,14 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<abc foo!@#="bar">', line: '<abc foo!@#="bar">',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('abc') }, { startIndex: 1, type: getTag('abc') },
{ startIndex:4, type: '' }, { startIndex: 4, type: '' },
{ startIndex:5, type: ATTRIB_NAME }, { startIndex: 5, type: ATTRIB_NAME },
{ startIndex:8, type: '' }, { startIndex: 8, type: '' },
{ startIndex:11, type: DELIM_ASSIGN }, { startIndex: 11, type: DELIM_ASSIGN },
{ startIndex:12, type: ATTRIB_VALUE }, { startIndex: 12, type: ATTRIB_VALUE },
{ startIndex:17, type: DELIM_END } { startIndex: 17, type: DELIM_END }
] ]
}], }],
@ -490,25 +490,25 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<abc #myinput (click)="bar" [value]="someProperty" *ngIf="someCondition">', line: '<abc #myinput (click)="bar" [value]="someProperty" *ngIf="someCondition">',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('abc') }, { startIndex: 1, type: getTag('abc') },
{ startIndex:4, type: '' }, { startIndex: 4, type: '' },
{ startIndex:6, type: ATTRIB_NAME }, { startIndex: 6, type: ATTRIB_NAME },
{ startIndex:13, type: '' }, { startIndex: 13, type: '' },
{ startIndex:15, type: ATTRIB_NAME }, { startIndex: 15, type: ATTRIB_NAME },
{ startIndex:20, type: '' }, { startIndex: 20, type: '' },
{ startIndex:21, type: DELIM_ASSIGN }, { startIndex: 21, type: DELIM_ASSIGN },
{ startIndex:22, type: ATTRIB_VALUE }, { startIndex: 22, type: ATTRIB_VALUE },
{ startIndex:27, type: '' }, { startIndex: 27, type: '' },
{ startIndex:29, type: ATTRIB_NAME }, { startIndex: 29, type: ATTRIB_NAME },
{ startIndex:34, type: '' }, { startIndex: 34, type: '' },
{ startIndex:35, type: DELIM_ASSIGN }, { startIndex: 35, type: DELIM_ASSIGN },
{ startIndex:36, type: ATTRIB_VALUE }, { startIndex: 36, type: ATTRIB_VALUE },
{ startIndex:50, type: '' }, { startIndex: 50, type: '' },
{ startIndex:52, type: ATTRIB_NAME }, { startIndex: 52, type: ATTRIB_NAME },
{ startIndex:56, type: DELIM_ASSIGN }, { startIndex: 56, type: DELIM_ASSIGN },
{ startIndex:57, type: ATTRIB_VALUE }, { startIndex: 57, type: ATTRIB_VALUE },
{ startIndex:72, type: DELIM_END } { startIndex: 72, type: DELIM_END }
] ]
}], }],
@ -516,13 +516,13 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<abc foo=">', line: '<abc foo=">',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('abc') }, { startIndex: 1, type: getTag('abc') },
{ startIndex:4, type: '' }, { startIndex: 4, type: '' },
{ startIndex:5, type: ATTRIB_NAME }, { startIndex: 5, type: ATTRIB_NAME },
{ startIndex:8, type: DELIM_ASSIGN }, { startIndex: 8, type: DELIM_ASSIGN },
{ startIndex:9, type: '' }, { startIndex: 9, type: '' },
{ startIndex:10, type: DELIM_END } { startIndex: 10, type: DELIM_END }
] ]
}], }],
@ -530,9 +530,9 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<!--a-->', line: '<!--a-->',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_COMMENT }, { startIndex: 0, type: DELIM_COMMENT },
{ startIndex:4, type: COMMENT }, { startIndex: 4, type: COMMENT },
{ startIndex:5, type: DELIM_COMMENT } { startIndex: 5, type: DELIM_COMMENT }
] ]
}], }],
@ -540,9 +540,9 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<!--a>foo bar</a -->', line: '<!--a>foo bar</a -->',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_COMMENT }, { startIndex: 0, type: DELIM_COMMENT },
{ startIndex:4, type: COMMENT }, { startIndex: 4, type: COMMENT },
{ startIndex:17, type: DELIM_COMMENT } { startIndex: 17, type: DELIM_COMMENT }
] ]
}], }],
@ -550,19 +550,19 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<!--a>', line: '<!--a>',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_COMMENT }, { startIndex: 0, type: DELIM_COMMENT },
{ startIndex:4, type: COMMENT } { startIndex: 4, type: COMMENT }
] ]
},{ }, {
line: 'foo ', line: 'foo ',
tokens: [ tokens: [
{ startIndex:0, type: COMMENT }, { startIndex: 0, type: COMMENT },
] ]
},{ }, {
line: 'bar</a -->', line: 'bar</a -->',
tokens: [ tokens: [
{ startIndex:0, type: COMMENT }, { startIndex: 0, type: COMMENT },
{ startIndex:7, type: DELIM_COMMENT } { startIndex: 7, type: DELIM_COMMENT }
] ]
}], }],
@ -570,9 +570,9 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<!DOCTYPE a>', line: '<!DOCTYPE a>',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_DOCTYPE }, { startIndex: 0, type: DELIM_DOCTYPE },
{ startIndex:9, type: DOCTYPE }, { startIndex: 9, type: DOCTYPE },
{ startIndex:11, type: DELIM_DOCTYPE } { startIndex: 11, type: DELIM_DOCTYPE }
] ]
}], }],
@ -580,9 +580,9 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<!doctype a>', line: '<!doctype a>',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_DOCTYPE }, { startIndex: 0, type: DELIM_DOCTYPE },
{ startIndex:9, type: DOCTYPE }, { startIndex: 9, type: DOCTYPE },
{ startIndex:11, type: DELIM_DOCTYPE } { startIndex: 11, type: DELIM_DOCTYPE }
] ]
}], }],
@ -590,14 +590,14 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<!DOCTYPE a', line: '<!DOCTYPE a',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_DOCTYPE }, { startIndex: 0, type: DELIM_DOCTYPE },
{ startIndex:9, type: DOCTYPE }, { startIndex: 9, type: DOCTYPE },
] ]
}, { }, {
line: '"foo" \'bar\'>', line: '"foo" \'bar\'>',
tokens: [ tokens: [
{ startIndex:0, type: DOCTYPE }, { startIndex: 0, type: DOCTYPE },
{ startIndex:11, type: DELIM_DOCTYPE } { startIndex: 11, type: DELIM_DOCTYPE }
] ]
}], }],
@ -605,13 +605,13 @@ testTokenization(['html', 'css'], [
[{ [{
line: '<asdf:bar>asd</asdf:bar>', line: '<asdf:bar>asd</asdf:bar>',
tokens: [ tokens: [
{ startIndex:0, type: DELIM_START }, { startIndex: 0, type: DELIM_START },
{ startIndex:1, type: getTag('asdf:bar') }, { startIndex: 1, type: getTag('asdf:bar') },
{ startIndex:9, type: DELIM_END }, { startIndex: 9, type: DELIM_END },
{ startIndex:10, type: '' }, { startIndex: 10, type: '' },
{ startIndex:13, type: DELIM_START }, { startIndex: 13, type: DELIM_START },
{ startIndex:15, type: getTag('asdf:bar') }, { startIndex: 15, type: getTag('asdf:bar') },
{ startIndex:23, type: DELIM_END } { startIndex: 23, type: DELIM_END }
] ]
}] }]
]); ]);

View file

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

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -5,72 +5,77 @@
'use strict'; 'use strict';
import {testTokenization} from './testRunner'; import { testTokenization } from './testRunner';
testTokenization('lua', [ testTokenization('lua', [
// Keywords // Keywords
[{ [{
line: 'local x, y = 1, 10', line: 'local x, y = 1, 10',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.local.lua' }, { startIndex: 0, type: 'keyword.local.lua' },
{ startIndex: 5, type: '' }, { startIndex: 5, type: '' },
{ startIndex: 6, type: 'identifier.lua' }, { startIndex: 6, type: 'identifier.lua' },
{ startIndex: 7, type: 'delimiter.lua' }, { startIndex: 7, type: 'delimiter.lua' },
{ startIndex: 8, type: '' }, { startIndex: 8, type: '' },
{ startIndex: 9, type: 'identifier.lua' }, { startIndex: 9, type: 'identifier.lua' },
{ startIndex: 10, type: '' }, { startIndex: 10, type: '' },
{ startIndex: 11, type: 'delimiter.lua' }, { startIndex: 11, type: 'delimiter.lua' },
{ startIndex: 12, type: '' }, { startIndex: 12, type: '' },
{ startIndex: 13, type: 'number.lua' }, { startIndex: 13, type: 'number.lua' },
{ startIndex: 14, type: 'delimiter.lua' }, { startIndex: 14, type: 'delimiter.lua' },
{ startIndex: 15, type: '' }, { startIndex: 15, type: '' },
{ startIndex: 16, type: 'number.lua' } { startIndex: 16, type: 'number.lua' }
]}], ]
}],
[{ [{
line: 'foo = "Hello" .. "World"; local foo = foo', line: 'foo = "Hello" .. "World"; local foo = foo',
tokens: [ tokens: [
{ startIndex: 0, type: 'identifier.lua' }, { startIndex: 0, type: 'identifier.lua' },
{ startIndex: 3, type: '' }, { startIndex: 3, type: '' },
{ startIndex: 4, type: 'delimiter.lua' }, { startIndex: 4, type: 'delimiter.lua' },
{ startIndex: 5, type: '' }, { startIndex: 5, type: '' },
{ startIndex: 6, type: 'string.lua' }, { startIndex: 6, type: 'string.lua' },
{ startIndex: 13, type: '' }, { startIndex: 13, type: '' },
{ startIndex: 14, type: 'delimiter.lua' }, { startIndex: 14, type: 'delimiter.lua' },
{ startIndex: 16, type: '' }, { startIndex: 16, type: '' },
{ startIndex: 17, type: 'string.lua' }, { startIndex: 17, type: 'string.lua' },
{ startIndex: 24, type: 'delimiter.lua' }, { startIndex: 24, type: 'delimiter.lua' },
{ startIndex: 25, type: '' }, { startIndex: 25, type: '' },
{ startIndex: 26, type: 'keyword.local.lua' }, { startIndex: 26, type: 'keyword.local.lua' },
{ startIndex: 31, type: '' }, { startIndex: 31, type: '' },
{ startIndex: 32, type: 'identifier.lua' }, { startIndex: 32, type: 'identifier.lua' },
{ startIndex: 35, type: '' }, { startIndex: 35, type: '' },
{ startIndex: 36, type: 'delimiter.lua' }, { startIndex: 36, type: 'delimiter.lua' },
{ startIndex: 37, type: '' }, { startIndex: 37, type: '' },
{ startIndex: 38, type: 'identifier.lua' } { startIndex: 38, type: 'identifier.lua' }
]}], ]
}],
// Comments // Comments
[{ [{
line: '--[[ text ]] x', line: '--[[ text ]] x',
tokens: [ tokens: [
{ startIndex: 0, type: 'comment.lua' }, { startIndex: 0, type: 'comment.lua' },
{ startIndex: 12, type: '' }, { startIndex: 12, type: '' },
{ startIndex: 13, type: 'identifier.lua' } { startIndex: 13, type: 'identifier.lua' }
]}], ]
}],
[{ [{
line: '--[===[ text ]===] x', line: '--[===[ text ]===] x',
tokens: [ tokens: [
{ startIndex: 0, type: 'comment.lua' }, { startIndex: 0, type: 'comment.lua' },
{ startIndex: 18, type: '' }, { startIndex: 18, type: '' },
{ startIndex: 19, type: 'identifier.lua' } { startIndex: 19, type: 'identifier.lua' }
]}], ]
}],
[{ [{
line: '--[===[ text ]==] x', line: '--[===[ text ]==] x',
tokens: [ tokens: [
{ startIndex: 0, type: 'comment.lua' } { startIndex: 0, type: 'comment.lua' }
]}] ]
}]
]); ]);

View file

@ -5,40 +5,40 @@
'use strict'; 'use strict';
import {testTokenization} from './testRunner'; import { testTokenization } from './testRunner';
testTokenization('markdown', [ testTokenization('markdown', [
[{ [{
line: '# Some header', line: '# Some header',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.md' } { startIndex: 0, type: 'keyword.md' }
] ]
}], }],
[{ [{
line: '* Some list item', line: '* Some list item',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.md' }, { startIndex: 0, type: 'keyword.md' },
{ startIndex: 2, type: '' } { startIndex: 2, type: '' }
] ]
}], }],
[{ [{
line: 'some `code`', line: 'some `code`',
tokens: [ tokens: [
{ startIndex: 0, type: '' }, { startIndex: 0, type: '' },
{ startIndex: 5, type: 'variable.md' } { startIndex: 5, type: 'variable.md' }
] ]
}], }],
[{ [{
line: 'some ![link](http://link.com)', line: 'some ![link](http://link.com)',
tokens: [ tokens: [
{ startIndex: 0, type: '' }, { startIndex: 0, type: '' },
{ startIndex: 5, type: 'string.link.md' }, { startIndex: 5, type: 'string.link.md' },
{ startIndex: 7, type: '' }, { startIndex: 7, type: '' },
{ startIndex: 11, type: 'string.link.md' } { startIndex: 11, type: 'string.link.md' }
] ]
}] }]
]); ]);

View file

@ -5,366 +5,410 @@
'use strict'; 'use strict';
import {testTokenization} from './testRunner'; import { testTokenization } from './testRunner';
testTokenization('msdax', [ testTokenization('msdax', [
// Comments // Comments
[{ [{
line: '// a comment', line: '// a comment',
tokens: [ tokens: [
{ startIndex: 0, type: 'comment.msdax' } { startIndex: 0, type: 'comment.msdax' }
]}], ]
}],
[{ [{
line: '-almost a comment', line: '-almost a comment',
tokens: [ tokens: [
{ startIndex: 0, type: 'operator.msdax' }, { startIndex: 0, type: 'operator.msdax' },
{ startIndex: 1, type: 'identifier.msdax' }, { startIndex: 1, type: 'identifier.msdax' },
{ startIndex: 7, type: 'white.msdax' }, { startIndex: 7, type: 'white.msdax' },
{ startIndex: 8, type: 'identifier.msdax' }, { startIndex: 8, type: 'identifier.msdax' },
{ startIndex: 9, type: 'white.msdax' }, { startIndex: 9, type: 'white.msdax' },
{ startIndex: 10, type: 'identifier.msdax' } { startIndex: 10, type: 'identifier.msdax' }
]}], ]
}],
[{ [{
line: '/* a full line comment */', line: '/* a full line comment */',
tokens: [ tokens: [
{ startIndex: 0, type: 'comment.quote.msdax' }, { startIndex: 0, type: 'comment.quote.msdax' },
{ startIndex: 2, type: 'comment.msdax' }, { startIndex: 2, type: 'comment.msdax' },
{ startIndex: 23, type: 'comment.quote.msdax' } { startIndex: 23, type: 'comment.quote.msdax' }
]}], ]
}],
[{ [{
line: '/* /// *** /// */', line: '/* /// *** /// */',
tokens: [ tokens: [
{ startIndex: 0, type: 'comment.quote.msdax' }, { startIndex: 0, type: 'comment.quote.msdax' },
{ startIndex: 2, type: 'comment.msdax' }, { startIndex: 2, type: 'comment.msdax' },
{ startIndex: 15, type: 'comment.quote.msdax' } { startIndex: 15, type: 'comment.quote.msdax' }
]}], ]
}],
[{ [{
line: 'define measure x = /* a simple comment */ 1;', line: 'define measure x = /* a simple comment */ 1;',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.msdax' }, { startIndex: 0, type: 'keyword.msdax' },
{ startIndex: 6, type: 'white.msdax' }, { startIndex: 6, type: 'white.msdax' },
{ startIndex: 7, type: 'keyword.msdax' }, { startIndex: 7, type: 'keyword.msdax' },
{ startIndex: 14, type: 'white.msdax' }, { startIndex: 14, type: 'white.msdax' },
{ startIndex: 15, type: 'identifier.msdax' }, { startIndex: 15, type: 'identifier.msdax' },
{ startIndex: 16, type: 'white.msdax' }, { startIndex: 16, type: 'white.msdax' },
{ startIndex: 17, type: 'operator.msdax' }, { startIndex: 17, type: 'operator.msdax' },
{ startIndex: 18, type: 'white.msdax' }, { startIndex: 18, type: 'white.msdax' },
{ startIndex: 19, type: 'comment.quote.msdax' }, { startIndex: 19, type: 'comment.quote.msdax' },
{ startIndex: 21, type: 'comment.msdax' }, { startIndex: 21, type: 'comment.msdax' },
{ startIndex: 39, type: 'comment.quote.msdax' }, { startIndex: 39, type: 'comment.quote.msdax' },
{ startIndex: 41, type: 'white.msdax' }, { startIndex: 41, type: 'white.msdax' },
{ startIndex: 42, type: 'number.msdax' }, { startIndex: 42, type: 'number.msdax' },
{ startIndex: 43, type: 'delimiter.msdax' } { startIndex: 43, type: 'delimiter.msdax' }
]}], ]
}],
// Numbers // Numbers
[{ [{
line: '123', line: '123',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.msdax' } { startIndex: 0, type: 'number.msdax' }
]}], ]
}],
[{ [{
line: '-123', line: '-123',
tokens: [ tokens: [
{ startIndex: 0, type: 'operator.msdax' }, { startIndex: 0, type: 'operator.msdax' },
{ startIndex: 1, type: 'number.msdax' } { startIndex: 1, type: 'number.msdax' }
]}], ]
}],
[{ [{
line: '0xaBc123', line: '0xaBc123',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.msdax' } { startIndex: 0, type: 'number.msdax' }
]}], ]
}],
[{ [{
line: '0XaBc123', line: '0XaBc123',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.msdax' } { startIndex: 0, type: 'number.msdax' }
]}], ]
}],
[{ [{
line: '0x', line: '0x',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.msdax' } { startIndex: 0, type: 'number.msdax' }
]}], ]
}],
[{ [{
line: '0x0', line: '0x0',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.msdax' } { startIndex: 0, type: 'number.msdax' }
]}], ]
}],
[{ [{
line: '0xAB_CD', line: '0xAB_CD',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.msdax' }, { startIndex: 0, type: 'number.msdax' },
{ startIndex: 4, type: 'identifier.msdax' } { startIndex: 4, type: 'identifier.msdax' }
]}], ]
}],
[{ [{
line: '.', line: '.',
tokens: [ tokens: [
{ startIndex: 0, type: 'delimiter.msdax' } { startIndex: 0, type: 'delimiter.msdax' }
]}], ]
}],
[{ [{
line: '123', line: '123',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.msdax' } { startIndex: 0, type: 'number.msdax' }
]}], ]
}],
[{ [{
line: '123.5678', line: '123.5678',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.msdax' } { startIndex: 0, type: 'number.msdax' }
]}], ]
}],
[{ [{
line: '0.99', line: '0.99',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.msdax' } { startIndex: 0, type: 'number.msdax' }
]}], ]
}],
[{ [{
line: '.99', line: '.99',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.msdax' } { startIndex: 0, type: 'number.msdax' }
]}], ]
}],
[{ [{
line: '99.', line: '99.',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.msdax' } { startIndex: 0, type: 'number.msdax' }
]}], ]
}],
[{ [{
line: '0.', line: '0.',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.msdax' } { startIndex: 0, type: 'number.msdax' }
]}], ]
}],
[{ [{
line: '.0', line: '.0',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.msdax' } { startIndex: 0, type: 'number.msdax' }
]}], ]
}],
[{ [{
line: '1E-2', line: '1E-2',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.msdax' } { startIndex: 0, type: 'number.msdax' }
]}], ]
}],
[{ [{
line: '1E+2', line: '1E+2',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.msdax' } { startIndex: 0, type: 'number.msdax' }
]}], ]
}],
[{ [{
line: '1E2', line: '1E2',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.msdax' } { startIndex: 0, type: 'number.msdax' }
]}], ]
}],
[{ [{
line: '0.1E2', line: '0.1E2',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.msdax' } { startIndex: 0, type: 'number.msdax' }
]}], ]
}],
[{ [{
line: '1.E2', line: '1.E2',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.msdax' } { startIndex: 0, type: 'number.msdax' }
]}], ]
}],
[{ [{
line: '.1E2', line: '.1E2',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.msdax' } { startIndex: 0, type: 'number.msdax' }
]}], ]
}],
// Identifiers // Identifiers
[{ [{
line: '_abc01', line: '_abc01',
tokens: [ tokens: [
{ startIndex: 0, type: 'identifier.msdax' } { startIndex: 0, type: 'identifier.msdax' }
]}], ]
}],
[{ [{
line: 'abc01', line: 'abc01',
tokens: [ tokens: [
{ startIndex: 0, type: 'identifier.msdax' } { startIndex: 0, type: 'identifier.msdax' }
]}], ]
}],
[{ [{
line: 'evaluate filter', line: 'evaluate filter',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.msdax' }, { startIndex: 0, type: 'keyword.msdax' },
{ startIndex: 8, type: 'white.msdax' }, { startIndex: 8, type: 'white.msdax' },
{ startIndex: 9, type: 'keyword.msdax' } { startIndex: 9, type: 'keyword.msdax' }
]}], ]
}],
[{ [{
line: '[abc[[ 321 ]] xyz]', line: '[abc[[ 321 ]] xyz]',
tokens: [ tokens: [
{ startIndex: 0, type: 'identifier.quote.msdax' }, { startIndex: 0, type: 'identifier.quote.msdax' },
{ startIndex: 1, type: 'identifier.msdax' }, { startIndex: 1, type: 'identifier.msdax' },
{ startIndex: 17, type: 'identifier.quote.msdax' } { startIndex: 17, type: 'identifier.quote.msdax' }
]}], ]
}],
[{ [{
line: '[abc', line: '[abc',
tokens: [ tokens: [
{ startIndex: 0, type: 'identifier.quote.msdax' }, { startIndex: 0, type: 'identifier.quote.msdax' },
{ startIndex: 1, type: 'identifier.msdax' } { startIndex: 1, type: 'identifier.msdax' }
]}], ]
}],
[{ [{
line: 'define measure \'abc\'[def]', line: 'define measure \'abc\'[def]',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.msdax' }, { startIndex: 0, type: 'keyword.msdax' },
{ startIndex: 6, type: 'white.msdax' }, { startIndex: 6, type: 'white.msdax' },
{ startIndex: 7, type: 'keyword.msdax' }, { startIndex: 7, type: 'keyword.msdax' },
{ startIndex: 14, type: 'white.msdax' }, { startIndex: 14, type: 'white.msdax' },
{ startIndex: 15, type: 'identifier.quote.msdax' }, { startIndex: 15, type: 'identifier.quote.msdax' },
{ startIndex: 16, type: 'identifier.msdax' }, { startIndex: 16, type: 'identifier.msdax' },
{ startIndex: 19, type: 'identifier.quote.msdax' }, { startIndex: 19, type: 'identifier.quote.msdax' },
{ startIndex: 21, type: 'identifier.msdax' }, { startIndex: 21, type: 'identifier.msdax' },
{ startIndex: 24, type: 'identifier.quote.msdax' } { startIndex: 24, type: 'identifier.quote.msdax' }
]}], ]
}],
[{ [{
line: 'int', line: 'int',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.msdax' } { startIndex: 0, type: 'keyword.msdax' }
]}], ]
}],
[{ [{
line: '[int]', line: '[int]',
tokens: [ tokens: [
{ startIndex: 0, type: 'identifier.quote.msdax' }, { startIndex: 0, type: 'identifier.quote.msdax' },
{ startIndex: 1, type: 'identifier.msdax' }, { startIndex: 1, type: 'identifier.msdax' },
{ startIndex: 4, type: 'identifier.quote.msdax' } { startIndex: 4, type: 'identifier.quote.msdax' }
]}], ]
}],
// Strings // Strings
[{ [{
line: '"abc"" 321 "" xyz"', line: '"abc"" 321 "" xyz"',
tokens: [ tokens: [
{ startIndex: 0, type: 'string.msdax' } { startIndex: 0, type: 'string.msdax' }
]}], ]
}],
[{ [{
line: 'define var x=\"a string\"', line: 'define var x=\"a string\"',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.msdax' }, { startIndex: 0, type: 'keyword.msdax' },
{ startIndex: 6, type: 'white.msdax' }, { startIndex: 6, type: 'white.msdax' },
{ startIndex: 7, type: 'keyword.msdax' }, { startIndex: 7, type: 'keyword.msdax' },
{ startIndex: 10, type: 'white.msdax' }, { startIndex: 10, type: 'white.msdax' },
{ startIndex: 11, type: 'identifier.msdax' }, { startIndex: 11, type: 'identifier.msdax' },
{ startIndex: 12, type: 'operator.msdax' }, { startIndex: 12, type: 'operator.msdax' },
{ startIndex: 13, type: 'string.msdax' } { startIndex: 13, type: 'string.msdax' }
]}], ]
}],
[{ [{
line: '"a "" string with quotes"', line: '"a "" string with quotes"',
tokens: [ tokens: [
{ startIndex: 0, type: 'string.msdax' }, { startIndex: 0, type: 'string.msdax' },
]}], ]
}],
[{ [{
line: '"a // string with comment"', line: '"a // string with comment"',
tokens: [ tokens: [
{ startIndex: 0, type: 'string.msdax' }, { startIndex: 0, type: 'string.msdax' },
]}], ]
}],
[{ [{
line: 'N"a unicode string"', line: 'N"a unicode string"',
tokens: [ tokens: [
{ startIndex: 0, type: 'string.msdax' }, { startIndex: 0, type: 'string.msdax' },
]}], ]
}],
[{ [{
line: '"a endless string', line: '"a endless string',
tokens: [ tokens: [
{ startIndex: 0, type: 'string.msdax' }, { startIndex: 0, type: 'string.msdax' },
]}], ]
}],
// Operators // Operators
[{ [{
line: 'define var x=1+3', line: 'define var x=1+3',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.msdax' }, { startIndex: 0, type: 'keyword.msdax' },
{ startIndex: 6, type: 'white.msdax' }, { startIndex: 6, type: 'white.msdax' },
{ startIndex: 7, type: 'keyword.msdax' }, { startIndex: 7, type: 'keyword.msdax' },
{ startIndex: 10, type: 'white.msdax' }, { startIndex: 10, type: 'white.msdax' },
{ startIndex: 11, type: 'identifier.msdax' }, { startIndex: 11, type: 'identifier.msdax' },
{ startIndex: 12, type: 'operator.msdax' }, { startIndex: 12, type: 'operator.msdax' },
{ startIndex: 13, type: 'number.msdax' }, { startIndex: 13, type: 'number.msdax' },
{ startIndex: 14, type: 'operator.msdax' }, { startIndex: 14, type: 'operator.msdax' },
{ startIndex: 15, type: 'number.msdax' } { startIndex: 15, type: 'number.msdax' }
]}], ]
}],
[{ [{
line: 'define var x=1^+abc', line: 'define var x=1^+abc',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.msdax' }, { startIndex: 0, type: 'keyword.msdax' },
{ startIndex: 6, type: 'white.msdax' }, { startIndex: 6, type: 'white.msdax' },
{ startIndex: 7, type: 'keyword.msdax' }, { startIndex: 7, type: 'keyword.msdax' },
{ startIndex: 10, type: 'white.msdax' }, { startIndex: 10, type: 'white.msdax' },
{ startIndex: 11, type: 'identifier.msdax' }, { startIndex: 11, type: 'identifier.msdax' },
{ startIndex: 12, type: 'operator.msdax' }, { startIndex: 12, type: 'operator.msdax' },
{ startIndex: 13, type: 'number.msdax' }, { startIndex: 13, type: 'number.msdax' },
{ startIndex: 14, type: 'operator.msdax' }, { startIndex: 14, type: 'operator.msdax' },
{ startIndex: 16, type: 'identifier.msdax' } { startIndex: 16, type: 'identifier.msdax' }
]}], ]
}],
// Realistic queries and expressions // Realistic queries and expressions
[{ [{
line: 'EVALUATE \'Products\' ORDER BY [Product Id] DESC', line: 'EVALUATE \'Products\' ORDER BY [Product Id] DESC',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.msdax' }, { startIndex: 0, type: 'keyword.msdax' },
{ startIndex: 8, type: 'white.msdax' }, { startIndex: 8, type: 'white.msdax' },
{ startIndex: 9, type: 'identifier.quote.msdax' }, { startIndex: 9, type: 'identifier.quote.msdax' },
{ startIndex: 10, type: 'identifier.msdax' }, { startIndex: 10, type: 'identifier.msdax' },
{ startIndex: 18, type: 'identifier.quote.msdax' }, { startIndex: 18, type: 'identifier.quote.msdax' },
{ startIndex: 19, type: 'white.msdax' }, { startIndex: 19, type: 'white.msdax' },
{ startIndex: 20, type: 'keyword.msdax' }, { startIndex: 20, type: 'keyword.msdax' },
{ startIndex: 25, type: 'white.msdax' }, { startIndex: 25, type: 'white.msdax' },
{ startIndex: 26, type: 'keyword.msdax' }, { startIndex: 26, type: 'keyword.msdax' },
{ startIndex: 28, type: 'white.msdax' }, { startIndex: 28, type: 'white.msdax' },
{ startIndex: 29, type: 'identifier.quote.msdax' }, { startIndex: 29, type: 'identifier.quote.msdax' },
{ startIndex: 30, type: 'identifier.msdax' }, { startIndex: 30, type: 'identifier.msdax' },
{ startIndex: 40, type: 'identifier.quote.msdax' }, { startIndex: 40, type: 'identifier.quote.msdax' },
{ startIndex: 41, type: 'white.msdax' }, { startIndex: 41, type: 'white.msdax' },
{ startIndex: 42, type: 'keyword.msdax' } { startIndex: 42, type: 'keyword.msdax' }
]}], ]
}],
[{ [{
line: 'DATATABLE("Price", STRING, {{"Low"},{"Medium"}})', line: 'DATATABLE("Price", STRING, {{"Low"},{"Medium"}})',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.msdax' }, { startIndex: 0, type: 'keyword.msdax' },
{ startIndex: 9, type: 'delimiter.parenthesis.msdax' }, { startIndex: 9, type: 'delimiter.parenthesis.msdax' },
{ startIndex: 10, type: 'string.msdax' }, { startIndex: 10, type: 'string.msdax' },
{ startIndex: 17, type: 'delimiter.msdax' }, { startIndex: 17, type: 'delimiter.msdax' },
{ startIndex: 18, type: 'white.msdax' }, { startIndex: 18, type: 'white.msdax' },
{ startIndex: 19, type: 'keyword.msdax' }, { startIndex: 19, type: 'keyword.msdax' },
{ startIndex: 25, type: 'delimiter.msdax' }, { startIndex: 25, type: 'delimiter.msdax' },
{ startIndex: 26, type: 'white.msdax' }, { startIndex: 26, type: 'white.msdax' },
{ startIndex: 27, type: 'delimiter.brackets.msdax' }, { startIndex: 27, type: 'delimiter.brackets.msdax' },
{ startIndex: 29, type: 'string.msdax' }, { startIndex: 29, type: 'string.msdax' },
{ startIndex: 34, type: 'delimiter.brackets.msdax' }, { startIndex: 34, type: 'delimiter.brackets.msdax' },
{ startIndex: 35, type: 'delimiter.msdax' }, { startIndex: 35, type: 'delimiter.msdax' },
{ startIndex: 36, type: 'delimiter.brackets.msdax' }, { startIndex: 36, type: 'delimiter.brackets.msdax' },
{ startIndex: 37, type: 'string.msdax' }, { startIndex: 37, type: 'string.msdax' },
{ startIndex: 45, type: 'delimiter.brackets.msdax' }, { startIndex: 45, type: 'delimiter.brackets.msdax' },
{ startIndex: 47, type: 'delimiter.parenthesis.msdax' } { startIndex: 47, type: 'delimiter.parenthesis.msdax' }
]}] ]
}]
]); ]);

View file

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

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -5,101 +5,113 @@
'use strict'; 'use strict';
import {testTokenization} from './testRunner'; import { testTokenization } from './testRunner';
testTokenization('python', [ testTokenization('python', [
// Keywords // Keywords
[{ [{
line: 'def func():', line: 'def func():',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.python' }, { startIndex: 0, type: 'keyword.python' },
{ startIndex: 3, type: 'white.python' }, { startIndex: 3, type: 'white.python' },
{ startIndex: 4, type: 'identifier.python' }, { startIndex: 4, type: 'identifier.python' },
{ startIndex: 8, type: 'delimiter.parenthesis.python' }, { startIndex: 8, type: 'delimiter.parenthesis.python' },
{ startIndex: 10, type: 'delimiter.python' } { startIndex: 10, type: 'delimiter.python' }
]}], ]
}],
[{ [{
line: 'func(str Y3)', line: 'func(str Y3)',
tokens: [ tokens: [
{ startIndex: 0, type: 'identifier.python' }, { startIndex: 0, type: 'identifier.python' },
{ startIndex: 4, type: 'delimiter.parenthesis.python' }, { startIndex: 4, type: 'delimiter.parenthesis.python' },
{ startIndex: 5, type: 'keyword.python' }, { startIndex: 5, type: 'keyword.python' },
{ startIndex: 8, type: 'white.python' }, { startIndex: 8, type: 'white.python' },
{ startIndex: 9, type: 'identifier.python' }, { startIndex: 9, type: 'identifier.python' },
{ startIndex: 11, type: 'delimiter.parenthesis.python' } { startIndex: 11, type: 'delimiter.parenthesis.python' }
]}], ]
}],
[{ [{
line: '@Dec0_rator:', line: '@Dec0_rator:',
tokens: [ tokens: [
{ startIndex: 0, type: 'tag.python' }, { startIndex: 0, type: 'tag.python' },
{ startIndex: 11, type: 'delimiter.python' } { startIndex: 11, type: 'delimiter.python' }
]}], ]
}],
// Comments // Comments
[{ [{
line: ' # Comments! ## "jfkd" ', line: ' # Comments! ## "jfkd" ',
tokens: [ tokens: [
{ startIndex: 0, type: 'white.python' }, { startIndex: 0, type: 'white.python' },
{ startIndex: 1, type: 'comment.python' } { startIndex: 1, type: 'comment.python' }
]}], ]
}],
// Strings // Strings
[{ [{
line: '\'s0\'', line: '\'s0\'',
tokens: [ tokens: [
{ startIndex: 0, type: 'string.escape.python' }, { startIndex: 0, type: 'string.escape.python' },
{ startIndex: 1, type: 'string.python' }, { startIndex: 1, type: 'string.python' },
{ startIndex: 3, type: 'string.escape.python' } { startIndex: 3, type: 'string.escape.python' }
]}], ]
}],
[{ [{
line: '"\' " "', line: '"\' " "',
tokens: [ tokens: [
{ startIndex: 0, type: 'string.escape.python' }, { startIndex: 0, type: 'string.escape.python' },
{ startIndex: 1, type: 'string.python' }, { startIndex: 1, type: 'string.python' },
{ startIndex: 3, type: 'string.escape.python' }, { startIndex: 3, type: 'string.escape.python' },
{ startIndex: 4, type: 'white.python' }, { startIndex: 4, type: 'white.python' },
{ startIndex: 5, type: 'string.escape.python' } { startIndex: 5, type: 'string.escape.python' }
]}], ]
}],
[{ [{
line: '\'\'\'Lots of string\'\'\'', line: '\'\'\'Lots of string\'\'\'',
tokens: [ tokens: [
{ startIndex: 0, type: 'string.python' } { startIndex: 0, type: 'string.python' }
]}], ]
}],
[{ [{
line: '"""Lots \'\'\' \'\'\'"""', line: '"""Lots \'\'\' \'\'\'"""',
tokens: [ tokens: [
{ startIndex: 0, type: 'string.python' } { startIndex: 0, type: 'string.python' }
]}], ]
}],
[{ [{
line: '\'\'\'Lots \'\'\'0.3e-5', line: '\'\'\'Lots \'\'\'0.3e-5',
tokens: [ tokens: [
{ startIndex: 0, type: 'string.python' }, { startIndex: 0, type: 'string.python' },
{ startIndex: 11, type: 'number.python' } { startIndex: 11, type: 'number.python' }
]}], ]
}],
// Numbers // Numbers
[{ [{
line: '0xAcBFd', line: '0xAcBFd',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.hex.python' } { startIndex: 0, type: 'number.hex.python' }
]}], ]
}],
[{ [{
line: '0x0cH', line: '0x0cH',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.hex.python' }, { startIndex: 0, type: 'number.hex.python' },
{ startIndex: 4, type: 'identifier.python' } { startIndex: 4, type: 'identifier.python' }
]}], ]
}],
[{ [{
line: '456.7e-7j', line: '456.7e-7j',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.python' } { startIndex: 0, type: 'number.python' }
]}] ]
}]
]); ]);

View file

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

View file

@ -5,8 +5,8 @@
'use strict'; 'use strict';
import {testTokenization} from './testRunner'; import { testTokenization } from './testRunner';
import {htmlTokenTypes} from '../src/php'; import { htmlTokenTypes } from '../src/php';
const EMBED_CS = 'metatag.cs'; const EMBED_CS = 'metatag.cs';
@ -14,65 +14,68 @@ testTokenization('razor', [
// Embedding - embedded html // Embedding - embedded html
[{ [{
line: '@{ var x; <b>x</b> }', line: '@{ var x; <b>x</b> }',
tokens: [ tokens: [
{ startIndex: 0, type: EMBED_CS }, { startIndex: 0, type: EMBED_CS },
{ startIndex: 2, type: '' }, { startIndex: 2, type: '' },
{ startIndex: 3, type: 'keyword.cs' }, { startIndex: 3, type: 'keyword.cs' },
{ startIndex: 6, type: '' }, { startIndex: 6, type: '' },
{ startIndex: 7, type: 'identifier.cs' }, { startIndex: 7, type: 'identifier.cs' },
{ startIndex: 8, type: 'delimiter.cs' }, { startIndex: 8, type: 'delimiter.cs' },
{ startIndex: 9, type: '' }, { startIndex: 9, type: '' },
{ startIndex: 10, type: htmlTokenTypes.DELIM_START }, { startIndex: 10, type: htmlTokenTypes.DELIM_START },
{ startIndex: 11, type: htmlTokenTypes.getTag('b') }, { startIndex: 11, type: htmlTokenTypes.getTag('b') },
{ startIndex: 12, type: htmlTokenTypes.DELIM_END }, { startIndex: 12, type: htmlTokenTypes.DELIM_END },
{ startIndex: 13, type: 'identifier.cs' }, { startIndex: 13, type: 'identifier.cs' },
{ startIndex: 14, type: htmlTokenTypes.DELIM_START }, { startIndex: 14, type: htmlTokenTypes.DELIM_START },
{ startIndex: 16, type: htmlTokenTypes.getTag('b') }, { startIndex: 16, type: htmlTokenTypes.getTag('b') },
{ startIndex: 17, type: htmlTokenTypes.DELIM_END }, { startIndex: 17, type: htmlTokenTypes.DELIM_END },
{ startIndex: 18, type: '' }, { startIndex: 18, type: '' },
{ startIndex: 19, type: EMBED_CS } { startIndex: 19, type: EMBED_CS }
]}], ]
}],
// Comments - razor comment inside csharp // Comments - razor comment inside csharp
[{ [{
line: '@{ var x; @* comment *@ x= 0; }', line: '@{ var x; @* comment *@ x= 0; }',
tokens: [ tokens: [
{ startIndex: 0, type: EMBED_CS }, { startIndex: 0, type: EMBED_CS },
{ startIndex: 2, type: '' }, { startIndex: 2, type: '' },
{ startIndex: 3, type: 'keyword.cs' }, { startIndex: 3, type: 'keyword.cs' },
{ startIndex: 6, type: '' }, { startIndex: 6, type: '' },
{ startIndex: 7, type: 'identifier.cs' }, { startIndex: 7, type: 'identifier.cs' },
{ startIndex: 8, type: 'delimiter.cs' }, { startIndex: 8, type: 'delimiter.cs' },
{ startIndex: 9, type: '' }, { startIndex: 9, type: '' },
{ startIndex: 10, type: 'comment.cs' }, { startIndex: 10, type: 'comment.cs' },
{ startIndex: 23, type: '' }, { startIndex: 23, type: '' },
{ startIndex: 24, type: 'identifier.cs' }, { startIndex: 24, type: 'identifier.cs' },
{ startIndex: 25, type: 'delimiter.cs' }, { startIndex: 25, type: 'delimiter.cs' },
{ startIndex: 26, type: '' }, { startIndex: 26, type: '' },
{ startIndex: 27, type: 'number.cs' }, { startIndex: 27, type: 'number.cs' },
{ startIndex: 28, type: 'delimiter.cs' }, { startIndex: 28, type: 'delimiter.cs' },
{ startIndex: 29, type: '' }, { startIndex: 29, type: '' },
{ startIndex: 30, type: EMBED_CS } { startIndex: 30, type: EMBED_CS }
]}], ]
}],
// Blocks - simple // Blocks - simple
[{ [{
line: '@{ var total = 0; }', line: '@{ var total = 0; }',
tokens: [ tokens: [
{ startIndex: 0, type: EMBED_CS }, { startIndex: 0, type: EMBED_CS },
{ startIndex: 2, type: '' }, { startIndex: 2, type: '' },
{ startIndex: 3, type: 'keyword.cs' }, { startIndex: 3, type: 'keyword.cs' },
{ startIndex: 6, type: '' }, { startIndex: 6, type: '' },
{ startIndex: 7, type: 'identifier.cs' }, { startIndex: 7, type: 'identifier.cs' },
{ startIndex: 12, type: '' }, { startIndex: 12, type: '' },
{ startIndex: 13, type: 'delimiter.cs' }, { startIndex: 13, type: 'delimiter.cs' },
{ startIndex: 14, type: '' }, { startIndex: 14, type: '' },
{ startIndex: 15, type: 'number.cs' }, { startIndex: 15, type: 'number.cs' },
{ startIndex: 16, type: 'delimiter.cs' }, { startIndex: 16, type: 'delimiter.cs' },
{ startIndex: 17, type: '' }, { startIndex: 17, type: '' },
{ startIndex: 18, type: EMBED_CS } { startIndex: 18, type: EMBED_CS }
]}], ]
}],
// [{ // [{
// line: '@if(true){ var total = 0; }', // line: '@if(true){ var total = 0; }',
@ -98,59 +101,65 @@ testTokenization('razor', [
// Expressions - csharp expressions in html // Expressions - csharp expressions in html
[{ [{
line: 'test@xyz<br>', line: 'test@xyz<br>',
tokens: [ tokens: [
{ startIndex:0, type: '' }, { startIndex: 0, type: '' },
{ startIndex:4, type: EMBED_CS }, { startIndex: 4, type: EMBED_CS },
{ startIndex:5, type: 'identifier.cs' }, { startIndex: 5, type: 'identifier.cs' },
{ startIndex:8, type: htmlTokenTypes.DELIM_START }, { startIndex: 8, type: htmlTokenTypes.DELIM_START },
{ startIndex:9, type: htmlTokenTypes.getTag('br') }, { startIndex: 9, type: htmlTokenTypes.getTag('br') },
{ startIndex:11, type: htmlTokenTypes.DELIM_END } { startIndex: 11, type: htmlTokenTypes.DELIM_END }
]}], ]
}],
[{ [{
line: 'test@xyz', line: 'test@xyz',
tokens: [ tokens: [
{ startIndex:0, type: '' }, { startIndex: 0, type: '' },
{ startIndex:4, type: EMBED_CS }, { startIndex: 4, type: EMBED_CS },
{ startIndex:5, type: 'identifier.cs' } { startIndex: 5, type: 'identifier.cs' }
]}], ]
}],
[{ [{
line: 'test @ xyz', line: 'test @ xyz',
tokens: [ tokens: [
{ startIndex: 0, type: '' }, { startIndex: 0, type: '' },
{ startIndex: 5, type: EMBED_CS }, { startIndex: 5, type: EMBED_CS },
{ startIndex: 6, type: 'identifier.cs' } { startIndex: 6, type: 'identifier.cs' }
]}], ]
}],
[{ [{
line: 'test @(foo) xyz', line: 'test @(foo) xyz',
tokens: [ tokens: [
{ startIndex:0, type: '' }, { startIndex: 0, type: '' },
{ startIndex:5, type: EMBED_CS }, { startIndex: 5, type: EMBED_CS },
{ startIndex:7, type: 'identifier.cs' }, { startIndex: 7, type: 'identifier.cs' },
{ startIndex:10, type: EMBED_CS }, { startIndex: 10, type: EMBED_CS },
{ startIndex:11, type: '' } { startIndex: 11, type: '' }
]}], ]
}],
[{ [{
line: 'test @(foo(\")\")) xyz', line: 'test @(foo(\")\")) xyz',
tokens: [ tokens: [
{ startIndex:0, type: '' }, { startIndex: 0, type: '' },
{ startIndex:5, type: EMBED_CS }, { startIndex: 5, type: EMBED_CS },
{ startIndex:7, type: 'identifier.cs' }, { startIndex: 7, type: 'identifier.cs' },
{ startIndex:10, type: 'delimiter.parenthesis.cs' }, { startIndex: 10, type: 'delimiter.parenthesis.cs' },
{ startIndex:11, type: 'string.cs' }, { startIndex: 11, type: 'string.cs' },
{ startIndex:14, type: 'delimiter.parenthesis.cs' }, { startIndex: 14, type: 'delimiter.parenthesis.cs' },
{ startIndex:15, type: EMBED_CS }, { startIndex: 15, type: EMBED_CS },
{ startIndex:16, type: '' } { startIndex: 16, type: '' }
]}], ]
}],
// Escaping - escaped at character // Escaping - escaped at character
[{ [{
line: 'test@@xyz', line: 'test@@xyz',
tokens: [ tokens: [
{ startIndex:0, type: '' } { startIndex: 0, type: '' }
]}] ]
}]
]); ]);

View file

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

File diff suppressed because it is too large Load diff

View file

@ -1,218 +1,238 @@
'use strict'; 'use strict';
import {testTokenization} from './testRunner'; import { testTokenization } from './testRunner';
testTokenization('sol', [ testTokenization('sol', [
// Keywords // Keywords
[{ [{
line: 'pragma solidity ^0.4.0;', line: 'pragma solidity ^0.4.0;',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.pragma.sol' }, { startIndex: 0, type: 'keyword.pragma.sol' },
{ startIndex: 6, type: '' }, { startIndex: 6, type: '' },
{ startIndex: 7, type: 'keyword.solidity.sol' }, { startIndex: 7, type: 'keyword.solidity.sol' },
{ startIndex: 15, type: '' }, { startIndex: 15, type: '' },
{ startIndex: 16, type: 'delimiter.sol' }, { startIndex: 16, type: 'delimiter.sol' },
{ startIndex: 17, type: 'number.float.sol' }, { startIndex: 17, type: 'number.float.sol' },
{ startIndex: 22, type: 'delimiter.sol' }, { startIndex: 22, type: 'delimiter.sol' },
]}], ]
}],
[{ [{
line: 'contract Ballot {', line: 'contract Ballot {',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.contract.sol' }, { startIndex: 0, type: 'keyword.contract.sol' },
{ startIndex: 8, type: '' }, { startIndex: 8, type: '' },
{ startIndex: 9, type: 'identifier.sol' }, { startIndex: 9, type: 'identifier.sol' },
{ startIndex: 15, type: '' }, { startIndex: 15, type: '' },
{ startIndex: 16, type: 'delimiter.curly.sol' } { startIndex: 16, type: 'delimiter.curly.sol' }
]}], ]
}],
[{ [{
line: 'struct Voter {', line: 'struct Voter {',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.struct.sol' }, { startIndex: 0, type: 'keyword.struct.sol' },
{ startIndex: 6, type: '' }, { startIndex: 6, type: '' },
{ startIndex: 7, type: 'identifier.sol' }, { startIndex: 7, type: 'identifier.sol' },
{ startIndex: 12, type: '' }, { startIndex: 12, type: '' },
{ startIndex: 13, type: 'delimiter.curly.sol' } { startIndex: 13, type: 'delimiter.curly.sol' }
]}], ]
}],
[{ [{
line: 'address chairperson;', line: 'address chairperson;',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.address.sol' }, { startIndex: 0, type: 'keyword.address.sol' },
{ startIndex: 7, type: '' }, { startIndex: 7, type: '' },
{ startIndex: 8, type: 'identifier.sol' }, { startIndex: 8, type: 'identifier.sol' },
{ startIndex: 19, type: 'delimiter.sol' } { startIndex: 19, type: 'delimiter.sol' }
]}], ]
}],
[{ [{
line: 'int weight;', line: 'int weight;',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.int.sol' }, { startIndex: 0, type: 'keyword.int.sol' },
{ startIndex: 3, type: '' }, { startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.sol' }, { startIndex: 4, type: 'identifier.sol' },
{ startIndex: 10, type: 'delimiter.sol' }, { startIndex: 10, type: 'delimiter.sol' },
]}], ]
}],
[{ [{
line: 'mapping(address => Voter) voters;', line: 'mapping(address => Voter) voters;',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.mapping.sol' }, { startIndex: 0, type: 'keyword.mapping.sol' },
{ startIndex: 7, type: 'delimiter.parenthesis.sol' }, { startIndex: 7, type: 'delimiter.parenthesis.sol' },
{ startIndex: 8, type: 'keyword.address.sol' }, { startIndex: 8, type: 'keyword.address.sol' },
{ startIndex: 15, type: '' }, { startIndex: 15, type: '' },
{ startIndex: 19, type: 'identifier.sol' }, { startIndex: 19, type: 'identifier.sol' },
{ startIndex: 24, type: 'delimiter.parenthesis.sol' }, { startIndex: 24, type: 'delimiter.parenthesis.sol' },
{ startIndex: 25, type: '' }, { startIndex: 25, type: '' },
{ startIndex: 26, type: 'identifier.sol' }, { startIndex: 26, type: 'identifier.sol' },
{ startIndex: 32, type: 'delimiter.sol' }, { startIndex: 32, type: 'delimiter.sol' },
]}], ]
}],
[{ [{
line: 'function Ballot(uint8 _numProposals) {', line: 'function Ballot(uint8 _numProposals) {',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.function.sol' }, { startIndex: 0, type: 'keyword.function.sol' },
{ startIndex: 8, type: '' }, { startIndex: 8, type: '' },
{ startIndex: 9, type: 'identifier.sol' }, { startIndex: 9, type: 'identifier.sol' },
{ startIndex: 15, type: 'delimiter.parenthesis.sol' }, { startIndex: 15, type: 'delimiter.parenthesis.sol' },
{ startIndex: 16, type: 'keyword.uint8.sol' }, { startIndex: 16, type: 'keyword.uint8.sol' },
{ startIndex: 21, type: '' }, { startIndex: 21, type: '' },
{ startIndex: 22, type: 'identifier.sol' }, { startIndex: 22, type: 'identifier.sol' },
{ startIndex: 35, type: 'delimiter.parenthesis.sol' }, { startIndex: 35, type: 'delimiter.parenthesis.sol' },
{ startIndex: 36, type: '' }, { startIndex: 36, type: '' },
{ startIndex: 37, type: 'delimiter.curly.sol' }, { startIndex: 37, type: 'delimiter.curly.sol' },
]}], ]
}],
// Comments - single line // Comments - single line
[{ [{
line: '//', line: '//',
tokens: [ tokens: [
{ startIndex: 0, type: 'comment.sol' } { startIndex: 0, type: 'comment.sol' }
]}], ]
}],
[{ [{
line: ' // a comment', line: ' // a comment',
tokens: [ tokens: [
{ startIndex: 0, type: '' }, { startIndex: 0, type: '' },
{ startIndex: 4, type: 'comment.sol' } { startIndex: 4, type: 'comment.sol' }
]}], ]
}],
[{ [{
line: '// a comment', line: '// a comment',
tokens: [ tokens: [
{ startIndex: 0, type: 'comment.sol' } { startIndex: 0, type: 'comment.sol' }
]}], ]
}],
[{ [{
line: '//sticky comment', line: '//sticky comment',
tokens: [ tokens: [
{ startIndex: 0, type: 'comment.sol' } { startIndex: 0, type: 'comment.sol' }
]}], ]
}],
[{ [{
line: '/almost a comment', line: '/almost a comment',
tokens: [ tokens: [
{ startIndex: 0, type: 'delimiter.sol' }, { startIndex: 0, type: 'delimiter.sol' },
{ startIndex: 1, type: 'identifier.sol' }, { startIndex: 1, type: 'identifier.sol' },
{ startIndex: 7, type: '' }, { startIndex: 7, type: '' },
{ startIndex: 8, type: 'identifier.sol' }, { startIndex: 8, type: 'identifier.sol' },
{ startIndex: 9, type: '' }, { startIndex: 9, type: '' },
{ startIndex: 10, type: 'identifier.sol' } { startIndex: 10, type: 'identifier.sol' }
]}], ]
}],
[{ [{
line: '/* //*/ a', line: '/* //*/ a',
tokens: [ tokens: [
{ startIndex: 0, type: 'comment.sol' }, { startIndex: 0, type: 'comment.sol' },
{ startIndex: 7, type: '' }, { startIndex: 7, type: '' },
{ startIndex: 8, type: 'identifier.sol' } { startIndex: 8, type: 'identifier.sol' }
]}], ]
}],
[{ [{
line: '1 / 2; /* comment', line: '1 / 2; /* comment',
tokens: [ tokens: [
{ startIndex: 0, type: 'number.sol' }, { startIndex: 0, type: 'number.sol' },
{ startIndex: 1, type: '' }, { startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.sol' }, { startIndex: 2, type: 'delimiter.sol' },
{ startIndex: 3, type: '' }, { startIndex: 3, type: '' },
{ startIndex: 4, type: 'number.sol' }, { startIndex: 4, type: 'number.sol' },
{ startIndex: 5, type: 'delimiter.sol' }, { startIndex: 5, type: 'delimiter.sol' },
{ startIndex: 6, type: '' }, { startIndex: 6, type: '' },
{ startIndex: 7, type: 'comment.sol' } { startIndex: 7, type: 'comment.sol' }
]}], ]
}],
[{ [{
line: 'int x = 1; // my comment // is a nice one', line: 'int x = 1; // my comment // is a nice one',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.int.sol' }, { startIndex: 0, type: 'keyword.int.sol' },
{ startIndex: 3, type: '' }, { startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.sol' }, { startIndex: 4, type: 'identifier.sol' },
{ startIndex: 5, type: '' }, { startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.sol' }, { startIndex: 6, type: 'delimiter.sol' },
{ startIndex: 7, type: '' }, { startIndex: 7, type: '' },
{ startIndex: 8, type: 'number.sol' }, { startIndex: 8, type: 'number.sol' },
{ startIndex: 9, type: 'delimiter.sol' }, { startIndex: 9, type: 'delimiter.sol' },
{ startIndex: 10, type: '' }, { startIndex: 10, type: '' },
{ startIndex: 11, type: 'comment.sol' } { startIndex: 11, type: 'comment.sol' }
]}], ]
}],
// Comments - range comment, single line // Comments - range comment, single line
[{ [{
line: '/* a simple comment */', line: '/* a simple comment */',
tokens: [ tokens: [
{ startIndex: 0, type: 'comment.sol' } { startIndex: 0, type: 'comment.sol' }
]}], ]
}],
[{ [{
line: 'int x = /* a simple comment */ 1;', line: 'int x = /* a simple comment */ 1;',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.int.sol' }, { startIndex: 0, type: 'keyword.int.sol' },
{ startIndex: 3, type: '' }, { startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.sol' }, { startIndex: 4, type: 'identifier.sol' },
{ startIndex: 5, type: '' }, { startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.sol' }, { startIndex: 6, type: 'delimiter.sol' },
{ startIndex: 7, type: '' }, { startIndex: 7, type: '' },
{ startIndex: 8, type: 'comment.sol' }, { startIndex: 8, type: 'comment.sol' },
{ startIndex: 30, type: '' }, { startIndex: 30, type: '' },
{ startIndex: 31, type: 'number.sol' }, { startIndex: 31, type: 'number.sol' },
{ startIndex: 32, type: 'delimiter.sol' } { startIndex: 32, type: 'delimiter.sol' }
]}], ]
}],
[{ [{
line: 'int x = /* comment */ 1; */', line: 'int x = /* comment */ 1; */',
tokens: [ tokens: [
{ startIndex: 0, type: 'keyword.int.sol' }, { startIndex: 0, type: 'keyword.int.sol' },
{ startIndex: 3, type: '' }, { startIndex: 3, type: '' },
{ startIndex: 4, type: 'identifier.sol' }, { startIndex: 4, type: 'identifier.sol' },
{ startIndex: 5, type: '' }, { startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.sol' }, { startIndex: 6, type: 'delimiter.sol' },
{ startIndex: 7, type: '' }, { startIndex: 7, type: '' },
{ startIndex: 8, type: 'comment.sol' }, { startIndex: 8, type: 'comment.sol' },
{ startIndex: 21, type: '' }, { startIndex: 21, type: '' },
{ startIndex: 22, type: 'number.sol' }, { startIndex: 22, type: 'number.sol' },
{ startIndex: 23, type: 'delimiter.sol' }, { startIndex: 23, type: 'delimiter.sol' },
{ startIndex: 24, type: '' } { startIndex: 24, type: '' }
]}], ]
}],
[{ [{
line: 'x = /**/;', line: 'x = /**/;',
tokens: [ tokens: [
{ startIndex: 0, type: 'identifier.sol' }, { startIndex: 0, type: 'identifier.sol' },
{ startIndex: 1, type: '' }, { startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.sol' }, { startIndex: 2, type: 'delimiter.sol' },
{ startIndex: 3, type: '' }, { startIndex: 3, type: '' },
{ startIndex: 4, type: 'comment.sol' }, { startIndex: 4, type: 'comment.sol' },
{ startIndex: 8, type: 'delimiter.sol' } { startIndex: 8, type: 'delimiter.sol' }
]}], ]
}],
[{ [{
line: 'x = /*/;', line: 'x = /*/;',
tokens: [ tokens: [
{ startIndex: 0, type: 'identifier.sol' }, { startIndex: 0, type: 'identifier.sol' },
{ startIndex: 1, type: '' }, { startIndex: 1, type: '' },
{ startIndex: 2, type: 'delimiter.sol' }, { startIndex: 2, type: 'delimiter.sol' },
{ startIndex: 3, type: '' }, { startIndex: 3, type: '' },
{ startIndex: 4, type: 'comment.sol' } { startIndex: 4, type: 'comment.sol' }
]}], ]
}],
]); ]);

File diff suppressed because it is too large Load diff

View file

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

View file

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

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
import {testTokenization} from './testRunner'; import { testTokenization } from './testRunner';
testTokenization('yaml', [ testTokenization('yaml', [
// YAML directive // YAML directive
@ -238,7 +238,7 @@ testTokenization('yaml', [
}, { }, {
startIndex: 24, startIndex: 24,
type: 'delimiter.bracket.yaml' type: 'delimiter.bracket.yaml'
}, ] },]
}], }],
// Flow Sequence - Data types // Flow Sequence - Data types