Format code

pull/2748/head
Alex Dima 7 years ago
parent 1f658b24a4
commit 3b733d9822

@ -23,6 +23,7 @@ Colorization and configuration supports for multiple languages for the Monaco Ed
* r * r
* razor * razor
* ruby * ruby
* rust
* sql * sql
* swift * swift
* vb * vb

@ -41,124 +41,131 @@ export const conf: IRichLanguageConfiguration = {
}; };
export const language = <ILanguage>{ export const language = <ILanguage>{
tokenPostfix: '.rust', tokenPostfix: '.rust',
defaultToken: 'invalid', defaultToken: 'invalid',
keywords: [ keywords: [
'as', 'box', 'break', 'const', 'continue', 'crate', 'else', 'enum', 'as', 'box', 'break', 'const', 'continue', 'crate', 'else', 'enum',
'extern', 'false', 'fn', 'for', 'if', 'impl', 'in', 'let', 'loop', 'extern', 'false', 'fn', 'for', 'if', 'impl', 'in', 'let', 'loop',
'match', 'mod', 'move', 'mut', 'pub', 'ref', 'return', 'self', 'match', 'mod', 'move', 'mut', 'pub', 'ref', 'return', 'self',
'static', 'struct', 'super', 'trait', 'true', 'type', 'unsafe', 'use', 'static', 'struct', 'super', 'trait', 'true', 'type', 'unsafe', 'use',
'where', 'while', 'catch', 'default', 'union', 'static', 'abstract', 'where', 'while', 'catch', 'default', 'union', 'static', 'abstract',
'alignof', 'become', 'do', 'final', 'macro', 'offsetof', 'override', 'alignof', 'become', 'do', 'final', 'macro', 'offsetof', 'override',
'priv', 'proc', 'pure', 'sizeof', 'typeof', 'unsized', 'virtual', 'priv', 'proc', 'pure', 'sizeof', 'typeof', 'unsized', 'virtual',
'yield', 'yield',
], ],
typeKeywords: [ typeKeywords: [
'Self', 'm32', 'm64', 'm128', 'f80', 'f16', 'f128', 'int', 'uint', 'Self', 'm32', 'm64', 'm128', 'f80', 'f16', 'f128', 'int', 'uint',
'float', 'char', 'bool', 'u8', 'u16', 'u32', 'u64', 'f32', 'f64', 'i8', 'float', 'char', 'bool', 'u8', 'u16', 'u32', 'u64', 'f32', 'f64', 'i8',
'i16', 'i32', 'i64', 'str', 'Option', 'Either', 'c_float', 'c_double', 'i16', 'i32', 'i64', 'str', 'Option', 'Either', 'c_float', 'c_double',
'c_void', 'FILE', 'fpos_t', 'DIR', 'dirent', 'c_char', 'c_schar', 'c_void', 'FILE', 'fpos_t', 'DIR', 'dirent', 'c_char', 'c_schar',
'c_uchar', 'c_short', 'c_ushort', 'c_int', 'c_uint', 'c_long', 'c_uchar', 'c_short', 'c_ushort', 'c_int', 'c_uint', 'c_long',
'c_ulong', 'size_t', 'ptrdiff_t', 'clock_t', 'time_t', 'c_longlong', 'c_ulong', 'size_t', 'ptrdiff_t', 'clock_t', 'time_t', 'c_longlong',
'c_ulonglong', 'intptr_t', 'uintptr_t', 'off_t', 'dev_t', 'ino_t', 'c_ulonglong', 'intptr_t', 'uintptr_t', 'off_t', 'dev_t', 'ino_t',
'pid_t', 'mode_t', 'ssize_t', 'pid_t', 'mode_t', 'ssize_t',
], ],
constants: [ constants: [
'true', 'false', 'Some', 'None', 'Left', 'Right', 'Ok', 'Err', 'true', 'false', 'Some', 'None', 'Left', 'Right', 'Ok', 'Err',
], ],
supportConstants: [ supportConstants: [
'EXIT_FAILURE', 'EXIT_SUCCESS', 'RAND_MAX', 'EOF', 'SEEK_SET', 'EXIT_FAILURE', 'EXIT_SUCCESS', 'RAND_MAX', 'EOF', 'SEEK_SET',
'SEEK_CUR', 'SEEK_END', '_IOFBF', '_IONBF', '_IOLBF', 'BUFSIZ', 'SEEK_CUR', 'SEEK_END', '_IOFBF', '_IONBF', '_IOLBF', 'BUFSIZ',
'FOPEN_MAX', 'FILENAME_MAX', 'L_tmpnam', 'TMP_MAX', 'O_RDONLY', 'FOPEN_MAX', 'FILENAME_MAX', 'L_tmpnam', 'TMP_MAX', 'O_RDONLY',
'O_WRONLY', 'O_RDWR', 'O_APPEND', 'O_CREAT', 'O_EXCL', 'O_TRUNC', 'O_WRONLY', 'O_RDWR', 'O_APPEND', 'O_CREAT', 'O_EXCL', 'O_TRUNC',
'S_IFIFO', 'S_IFCHR', 'S_IFBLK', 'S_IFDIR', 'S_IFREG', 'S_IFMT', 'S_IFIFO', 'S_IFCHR', 'S_IFBLK', 'S_IFDIR', 'S_IFREG', 'S_IFMT',
'S_IEXEC', 'S_IWRITE', 'S_IREAD', 'S_IRWXU', 'S_IXUSR', 'S_IWUSR', 'S_IEXEC', 'S_IWRITE', 'S_IREAD', 'S_IRWXU', 'S_IXUSR', 'S_IWUSR',
'S_IRUSR', 'F_OK', 'R_OK', 'W_OK', 'X_OK', 'STDIN_FILENO', 'S_IRUSR', 'F_OK', 'R_OK', 'W_OK', 'X_OK', 'STDIN_FILENO',
'STDOUT_FILENO', 'STDERR_FILENO', 'STDOUT_FILENO', 'STDERR_FILENO',
], ],
supportMacros: [ supportMacros: [
'format!', 'print!', 'println!', 'panic!', 'format_args!', 'unreachable!', 'format!', 'print!', 'println!', 'panic!', 'format_args!', 'unreachable!',
'write!', 'writeln!' 'write!', 'writeln!'
], ],
operators: [ operators: [
'!', '!=', '%', '%=', '&', '&=', '&&', '*', '*=', '+', '+=', '-', '-=', '!', '!=', '%', '%=', '&', '&=', '&&', '*', '*=', '+', '+=', '-', '-=',
'->', '.', '..', '...', '/', '/=', ':', ';', '<<', '<<=', '<', '<=', '=', '->', '.', '..', '...', '/', '/=', ':', ';', '<<', '<<=', '<', '<=', '=',
'==', '=>', '>', '>=', '>>', '>>=', '@', '^', '^=', '|', '|=', '||', '_', '==', '=>', '>', '>=', '>>', '>>=', '@', '^', '^=', '|', '|=', '||', '_',
'?', '#' '?', '#'
], ],
escapes: /\\([nrt0\"''\\]|x\h{2}|u\{\h{1,6}\})/, escapes: /\\([nrt0\"''\\]|x\h{2}|u\{\h{1,6}\})/,
delimiters: /[,]/, delimiters: /[,]/,
symbols: /[\#\!\%\&\*\+\-\.\/\:\;\<\=\>\@\^\|_\?]+/, symbols: /[\#\!\%\&\*\+\-\.\/\:\;\<\=\>\@\^\|_\?]+/,
intSuffixes: /[iu](8|16|32|64|128|size)/, intSuffixes: /[iu](8|16|32|64|128|size)/,
floatSuffixes: /f(32|64)/, floatSuffixes: /f(32|64)/,
tokenizer: { tokenizer: {
root: [ root: [
[/[a-zA-Z][a-zA-Z0-9_]*!?|_[a-zA-Z0-9_]+/, [/[a-zA-Z][a-zA-Z0-9_]*!?|_[a-zA-Z0-9_]+/,
{ cases: { '@typeKeywords': 'keyword.type', {
'@keywords': 'keyword', cases: {
'@supportConstants': 'keyword', '@typeKeywords': 'keyword.type',
'@supportMacros': 'keyword', '@keywords': 'keyword',
'@constants': 'keyword', '@supportConstants': 'keyword',
'@default': 'identifier', } '@supportMacros': 'keyword',
} '@constants': 'keyword',
], '@default': 'identifier',
// Designator }
[/\$/, 'identifier'], }
// Lifetime annotations ],
[/'[a-zA-Z_][a-zA-Z0-9_]*(?=[^\'])/, 'identifier'], // Designator
// Byte literal [/\$/, 'identifier'],
[/'\S'/, 'string.byteliteral'], // Lifetime annotations
// Strings [/'[a-zA-Z_][a-zA-Z0-9_]*(?=[^\'])/, 'identifier'],
[/"/, { token: 'string.quote', bracket: '@open', next: '@string' }], // Byte literal
{include: '@numbers'}, [/'\S'/, 'string.byteliteral'],
// Whitespace + comments // Strings
{ include: '@whitespace' }, [/"/, { token: 'string.quote', bracket: '@open', next: '@string' }],
[/@delimiters/, { cases: { '@keywords': 'keyword', { include: '@numbers' },
'@default': 'delimiter' }}], // Whitespace + comments
{ include: '@whitespace' },
[/@delimiters/, {
cases: {
'@keywords': 'keyword',
'@default': 'delimiter'
}
}],
[/[{}()\[\]<>]/, '@brackets'], [/[{}()\[\]<>]/, '@brackets'],
[/@symbols/, { cases: {'@operators': 'operator', '@default' : '' }}], [/@symbols/, { cases: { '@operators': 'operator', '@default': '' } }],
], ],
whitespace: [ whitespace: [
[/[ \t\r\n]+/, 'white'], [/[ \t\r\n]+/, 'white'],
[/\/\*/, 'comment', '@comment'], [/\/\*/, 'comment', '@comment'],
[/\/\/.*$/, 'comment'], [/\/\/.*$/, 'comment'],
], ],
comment: [ comment: [
[/[^\/*]+/, 'comment' ], [/[^\/*]+/, 'comment'],
[/\/\*/, 'comment', '@push' ], [/\/\*/, 'comment', '@push'],
["\\*/", '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', bracket: '@close', next: '@pop' } ] [/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
], ],
numbers: [ numbers: [
//Octal //Octal
[/(0o[0-7_]+)(@intSuffixes)?/, {token: 'number', log: 'Octal'}], [/(0o[0-7_]+)(@intSuffixes)?/, { token: 'number', log: 'Octal' }],
//Binary //Binary
[/(0b[0-1_]+)(@intSuffixes)?/, {token: 'number', log: 'Binary'}], [/(0b[0-1_]+)(@intSuffixes)?/, { token: 'number', log: 'Binary' }],
//Exponent //Exponent
[/[\d][\d_]*(\.[\d][\d_]*)?[eE][+-][\d_]+(@floatSuffixes)?/, {token: 'number', log: 'Exponent'}], [/[\d][\d_]*(\.[\d][\d_]*)?[eE][+-][\d_]+(@floatSuffixes)?/, { token: 'number', log: 'Exponent' }],
//Float //Float
[/\b(\d\.?[\d_]*)(@floatSuffixes)?\b/,{token: 'number', log: 'Float'}], [/\b(\d\.?[\d_]*)(@floatSuffixes)?\b/, { token: 'number', log: 'Float' }],
//Hexadecimal //Hexadecimal
[/(0x[\da-fA-F]+)_?(@intSuffixes)?/, {token: 'number', log: 'Hexadecimal'}], [/(0x[\da-fA-F]+)_?(@intSuffixes)?/, { token: 'number', log: 'Hexadecimal' }],
//Integer //Integer
[/[\d][\d_]*(@intSuffixes?)?/, {token: 'number', log: 'Integer'}], [/[\d][\d_]*(@intSuffixes?)?/, { token: 'number', log: 'Integer' }],
] ]
} }
}; };

Loading…
Cancel
Save