Code formatting

This commit is contained in:
Alex Dima 2020-02-26 18:19:32 +01:00
parent 128d4befd8
commit 8589ee2ccd
No known key found for this signature in database
GPG key ID: 6E58D7B045760DA0
2 changed files with 20 additions and 17 deletions

View file

@ -34,7 +34,7 @@ testTokenization('lexon', [
[{ [{
line: 'COMMENT: 3.f - an escrow that is controlled by a third party for a fee.', line: 'COMMENT: 3.f - an escrow that is controlled by a third party for a fee.',
tokens: [ tokens: [
{ startIndex: 0, type: 'comment.lexon' }, { startIndex: 0, type: 'comment.lexon' },
] ]
}], }],

View file

@ -40,7 +40,7 @@ export const conf: IRichLanguageConfiguration = {
} }
}; };
export const language = <ILanguage> { export const language = <ILanguage>{
// Set defaultToken to invalid to see what you do not tokenize yet // Set defaultToken to invalid to see what you do not tokenize yet
// defaultToken: 'invalid', // defaultToken: 'invalid',
tokenPostfix: '.lexon', tokenPostfix: '.lexon',
@ -62,7 +62,7 @@ export const language = <ILanguage> {
], ],
// we include these common regular expressions // we include these common regular expressions
symbols: /[=><!~?:&|+\-*\/\^%]+/, symbols: /[=><!~?:&|+\-*\/\^%]+/,
// The main tokenizer for our languages // The main tokenizer for our languages
@ -72,17 +72,20 @@ export const language = <ILanguage> {
[/^(\s*)(comment:?(?:\s.*|))$/, ['', 'comment']], [/^(\s*)(comment:?(?:\s.*|))$/, ['', 'comment']],
// special identifier cases // special identifier cases
[/"/, { token: 'identifier.quote', bracket: '@open', next: '@quoted_identifier' } ], [/"/, { token: 'identifier.quote', bracket: '@open', next: '@quoted_identifier' }],
['LEX$', { token: 'keyword', bracket: '@open', next: '@identifier_until_period' }], ['LEX$', { token: 'keyword', bracket: '@open', next: '@identifier_until_period' }],
['LEXON', { token: 'keyword', bracket: '@open', next: '@semver' }], ['LEXON', { token: 'keyword', bracket: '@open', next: '@semver' }],
[':', { token: 'delimiter', bracket: '@open', next: '@identifier_until_period' }], [':', { token: 'delimiter', bracket: '@open', next: '@identifier_until_period' }],
// identifiers and keywords // identifiers and keywords
[/[a-z_$][\w$]*/, { cases: { [/[a-z_$][\w$]*/, {
'@operators': 'operator', cases: {
'@typeKeywords': 'keyword.type', '@operators': 'operator',
'@keywords': 'keyword', '@typeKeywords': 'keyword.type',
'@default': 'identifier' } }], '@keywords': 'keyword',
'@default': 'identifier'
}
}],
// whitespace // whitespace
{ include: '@whitespace' }, { include: '@whitespace' },
@ -103,8 +106,8 @@ export const language = <ILanguage> {
], ],
quoted_identifier: [ quoted_identifier: [
[/[^\\"]+/, 'identifier'], [/[^\\"]+/, 'identifier'],
[/"/, { token: 'identifier.quote', bracket: '@close', next: '@pop' } ] [/"/, { token: 'identifier.quote', bracket: '@close', next: '@pop' }]
], ],
space_identifier_until_period: [ space_identifier_until_period: [
@ -115,19 +118,19 @@ export const language = <ILanguage> {
identifier_until_period: [ identifier_until_period: [
{ include: '@whitespace' }, { include: '@whitespace' },
[':', { token: 'delimiter', next: '@identifier_rest' }], [':', { token: 'delimiter', next: '@identifier_rest' }],
[/[^\\.]+/, 'identifier'], [/[^\\.]+/, 'identifier'],
[/\./, { token: 'delimiter', bracket: '@close', next: '@pop' } ] [/\./, { token: 'delimiter', bracket: '@close', next: '@pop' }]
], ],
identifier_rest: [ identifier_rest: [
[/[^\\.]+/, 'identifier'], [/[^\\.]+/, 'identifier'],
[/\./, { token: 'delimiter', bracket: '@close', next: '@pop' } ] [/\./, { token: 'delimiter', bracket: '@close', next: '@pop' }]
], ],
semver: [ semver: [
{ include: '@whitespace' }, { include: '@whitespace' },
[':', 'delimiter'], [':', 'delimiter'],
[/\d*\.\d*\.\d*/, { token: 'number.semver', bracket: '@close', next: '@pop' } ] [/\d*\.\d*\.\d*/, { token: 'number.semver', bracket: '@close', next: '@pop' }]
], ],
whitespace: [ whitespace: [