@@ -229,9 +229,43 @@ export const language = <monaco.languages.IMonarchLanguage>{
229229 // Recognize strings, including those broken across lines with \ (but not without)
230230 strings : [
231231 [ / ' $ / , 'string.escape' , '@popall' ] ,
232- [ / ' / , 'string.escape' , '@stringBody' ] ,
232+ [ / ( [ f F ] | [ f F ] [ r R ] | [ r R ] [ f F ] ) ? ' / , 'string.escape' , '@fStringBody' ] ,
233+ [ / [ r R u U b B ] ? ' / , 'string.escape' , '@stringBody' ] ,
233234 [ / " $ / , 'string.escape' , '@popall' ] ,
234- [ / " / , 'string.escape' , '@dblStringBody' ] ,
235+ [ / ( [ f F ] | [ f F ] [ r R ] | [ r R ] [ f F ] ) ? " / , 'string.escape' , '@dblFStringBody' ] ,
236+ [ / [ r R u U b B ] ? " / , 'string.escape' , '@dblStringBody' ] ,
237+ ] ,
238+ fStringBody : [
239+ [ / ( [ ^ \\ ' { } ] | \{ \{ | \} \} (? ! \} [ ^ } ] ) ) + $ / , 'string' , '@popall' ] ,
240+ [ / ( [ ^ \\ ' { } ] | \{ \{ | \} \} (? ! \} [ ^ } ] ) ) + / , 'string' ] ,
241+ [ / \\ ./ , 'string' ] ,
242+ [ / ' / , 'string.escape' , '@popall' ] ,
243+ [ / \\ $ / , 'string' ] ,
244+ [
245+ / \{ / ,
246+ {
247+ token : 'delimiter.curly' ,
248+ next : '@fStringReplacement' ,
249+ nextEmbedded : pybricksMicroPythonId ,
250+ } ,
251+ ] ,
252+ [ / \} / , 'delimiter.curly' ] ,
253+ ] ,
254+ dblFStringBody : [
255+ [ / ( [ ^ \\ " { } ] | \{ \{ | \} \} (? ! \} [ ^ } ] ) ) + $ / , 'string' , '@popall' ] ,
256+ [ / ( [ ^ \\ " { } ] | \{ \{ | \} \} (? ! \} [ ^ } ] ) ) + / , 'string' ] ,
257+ [ / \\ ./ , 'string' ] ,
258+ [ / " / , 'string.escape' , '@popall' ] ,
259+ [ / \\ $ / , 'string' ] ,
260+ [
261+ / \{ / ,
262+ {
263+ token : 'delimiter.curly' ,
264+ next : '@fStringReplacement' ,
265+ nextEmbedded : pybricksMicroPythonId ,
266+ } ,
267+ ] ,
268+ [ / \} / , 'delimiter.curly' ] ,
235269 ] ,
236270 stringBody : [
237271 [ / [ ^ \\ ' ] + $ / , 'string' , '@popall' ] ,
@@ -247,6 +281,9 @@ export const language = <monaco.languages.IMonarchLanguage>{
247281 [ / " / , 'string.escape' , '@popall' ] ,
248282 [ / \\ $ / , 'string' ] ,
249283 ] ,
284+ fStringReplacement : [
285+ [ / \} / , { token : '@rematch' , next : '@pop' , nextEmbedded : '@pop' } ] ,
286+ ] ,
250287
251288 operators : [
252289 [
0 commit comments