Generate classic-style tokens for less and add tests

This commit is contained in:
Alex Dima 2016-12-11 19:05:03 +01:00
parent f487f4f76d
commit 6b4e9948dc
3 changed files with 1314 additions and 23 deletions

View file

@ -25,10 +25,10 @@ export var conf: IRichLanguageConfiguration = {
] ]
}; };
const TOKEN_SELECTOR = 'entity.name.selector'; const TOKEN_SELECTOR = 'tag';
const TOKEN_SELECTOR_TAG = 'entity.name.tag'; const TOKEN_SELECTOR_TAG = 'tag';
const TOKEN_PROPERTY = 'support.type.property-name'; const TOKEN_PROPERTY = 'attribute.name';
const TOKEN_VALUE = 'support.property-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> {
@ -39,10 +39,10 @@ export var language = <ILanguage> {
identifierPlus: '-?-?([a-zA-Z:.]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))([\\w\\-:.]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))*', identifierPlus: '-?-?([a-zA-Z:.]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))([\\w\\-:.]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))*',
brackets: [ brackets: [
{ open: '{', close: '}', token: 'punctuation.curly' }, { open: '{', close: '}', token: 'delimiter.curly' },
{ open: '[', close: ']', token: 'punctuation.bracket' }, { open: '[', close: ']', token: 'delimiter.bracket' },
{ open: '(', close: ')', token: 'punctuation.parenthesis' }, { open: '(', close: ')', token: 'delimiter.parenthesis' },
{ open: '<', close: '>', token: 'punctuation.angle' } { open: '<', close: '>', token: 'delimiter.angle' }
], ],
tokenizer: { tokenizer: {
@ -57,10 +57,10 @@ 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: 'function', bracket: '@open', next: '@urldeclaration'}], ['url(\\-prefix)?\\(', { token: 'tag', bracket: '@open', next: '@urldeclaration'}],
['[{}()\\[\\]]', '@brackets'], ['[{}()\\[\\]]', '@brackets'],
['[,:;]', 'punctuation'], ['[,:;]', 'delimiter'],
['#@identifierPlus', TOKEN_SELECTOR + '.id'], ['#@identifierPlus', TOKEN_SELECTOR + '.id'],
['&', TOKEN_SELECTOR_TAG], ['&', TOKEN_SELECTOR_TAG],
@ -77,12 +77,12 @@ export var language = <ILanguage> {
], ],
nestedJSBegin: [ nestedJSBegin: [
['``', 'punctuation.backtick'], ['``', 'delimiter.backtick'],
<any[]>['`', { token: 'punctuation.backtick', bracket: '@open', next: '@nestedJSEnd', nextEmbedded: 'text/javascript' }], <any[]>['`', { token: 'delimiter.backtick', bracket: '@open', next: '@nestedJSEnd', nextEmbedded: 'text/javascript' }],
], ],
nestedJSEnd: [ nestedJSEnd: [
<any[]>['`', { token: 'punctuation.backtick', bracket: '@close', next: '@pop' }], <any[]>['`', { token: 'delimiter.backtick', bracket: '@close', next: '@pop' }],
<any[]>['.', { token: '@rematch', next: '@javascript_block' }], <any[]>['.', { token: '@rematch', next: '@javascript_block' }],
], ],
@ -121,8 +121,8 @@ export var language = <ILanguage> {
['[)\\}]', '@brackets', '@pop'], ['[)\\}]', '@brackets', '@pop'],
['[{}()\\[\\]>]', '@brackets'], ['[{}()\\[\\]>]', '@brackets'],
['[;]', 'punctuation', '@pop'], ['[;]', 'delimiter', '@pop'],
['[,=:]', 'punctuation'], ['[,=:]', 'delimiter'],
['\\s', ''], ['\\s', ''],
['.', TOKEN_VALUE] ['.', TOKEN_VALUE]
@ -139,8 +139,8 @@ export var language = <ILanguage> {
], ],
numbers: [ numbers: [
<any[]>['(\\d*\\.)?\\d+([eE][\\-+]?\\d+)?', { token: TOKEN_VALUE + '.numeric', next: '@units' }], <any[]>['(\\d*\\.)?\\d+([eE][\\-+]?\\d+)?', { token: TOKEN_VALUE + '.number', next: '@units' }],
['#[0-9a-fA-F_]+(?!\\w)', TOKEN_VALUE + '.rgb-value'] ['#[0-9a-fA-F_]+(?!\\w)', TOKEN_VALUE + '.hex']
], ],
units: [ units: [
@ -148,27 +148,27 @@ export var language = <ILanguage> {
], ],
strings: [ strings: [
<any[]>['~?"', { token: 'string.punctuation', bracket: '@open', next: '@stringsEndDoubleQuote' }], <any[]>['~?"', { token: 'string.delimiter', bracket: '@open', next: '@stringsEndDoubleQuote' }],
<any[]>['~?\'', { token: 'string.punctuation', bracket: '@open', next: '@stringsEndQuote' }] <any[]>['~?\'', { token: 'string.delimiter', bracket: '@open', next: '@stringsEndQuote' }]
], ],
stringsEndDoubleQuote: [ stringsEndDoubleQuote: [
['\\\\"', 'string'], ['\\\\"', 'string'],
<any[]>['"', { token: 'string.punctuation', next: '@popall', bracket: '@close' }], <any[]>['"', { token: 'string.delimiter', next: '@popall', bracket: '@close' }],
['.', 'string'] ['.', 'string']
], ],
stringsEndQuote: [ stringsEndQuote: [
['\\\\\'', 'string'], ['\\\\\'', 'string'],
<any[]>['\'', { token: 'string.punctuation', next: '@popall', bracket: '@close' }], <any[]>['\'', { token: 'string.delimiter', next: '@popall', bracket: '@close' }],
['.', 'string'] ['.', 'string']
], ],
atRules: <any[]>[ atRules: <any[]>[
{ include: '@comments' }, { include: '@comments' },
{ include: '@strings' }, { include: '@strings' },
['[()]', 'punctuation'], ['[()]', 'delimiter'],
['[\\{;]', 'punctuation', '@pop'], ['[\\{;]', 'delimiter', '@pop'],
['.', 'key'] ['.', 'key']
] ]
} }

View file

@ -35,6 +35,7 @@ requirejs([
'out/test/html.test', 'out/test/html.test',
'out/test/jade.test', 'out/test/jade.test',
'out/test/java.test', 'out/test/java.test',
'out/test/less.test',
'out/test/lua.test', 'out/test/lua.test',
'out/test/markdown.test', 'out/test/markdown.test',
'out/test/objective-c.test', 'out/test/objective-c.test',

1290
test/less.test.ts Normal file

File diff suppressed because it is too large Load diff