Fix microsoft/monaco-editor#703. c++ 11 raw string literal.

pull/2748/head
Peng Lyu 7 years ago
parent acfa9cf274
commit 51df390edc

@ -240,10 +240,14 @@ export const language = <ILanguage>{
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]?/,
encoding: /u|u8|U|L/,
// The main tokenizer for our languages // The main tokenizer for our languages
tokenizer: { tokenizer: {
root: [ root: [
// C++ 11 Raw String
[/@encoding?R\"(?:([^ ()\\\t]*))\(/, { token: 'string.raw.begin', next: '@raw.$1' }],
// identifiers and keywords // identifiers and keywords
[/[a-zA-Z_]\w*/, { [/[a-zA-Z_]\w*/, {
cases: { cases: {
@ -318,5 +322,16 @@ export const language = <ILanguage>{
[/\\./, 'string.escape.invalid'], [/\\./, 'string.escape.invalid'],
[/"/, 'string', '@pop'] [/"/, 'string', '@pop']
], ],
raw: [
[/(.*)(\))(?:([^ ()\\\t]*))(\")/, {
cases: {
'$3==$S2': ['string.raw', 'string.raw.end', 'string.raw.end', { token: 'string.raw.end', next: '@pop' }],
'@default': ['string.raw', 'string.raw', 'string.raw', 'string.raw']
}
}
],
[/.*/, 'string.raw']
]
}, },
}; };

@ -776,5 +776,13 @@ testTokenization('cpp', [
{ startIndex: 25, type: 'identifier.cpp' }, { startIndex: 25, type: 'identifier.cpp' },
{ startIndex: 26, type: 'delimiter.parenthesis.cpp' } { startIndex: 26, type: 'delimiter.parenthesis.cpp' }
] ]
}, {
line: 'uR"V0G0N(abc)V0G0N"def',
tokens: [
{ startIndex: 0, type: 'string.raw.begin.cpp' },
{ startIndex: 9, type: 'string.raw.cpp' },
{ startIndex: 12, type: 'string.raw.end.cpp' },
{ startIndex: 19, type: 'identifier.cpp' }
]
}] }]
]); ]);

Loading…
Cancel
Save