@@ -207,6 +207,24 @@ static void GrabString(char* s, Accessor& styler, Sci_Position start, Sci_Positi
207207 s[len] = ' \0 ' ;
208208}
209209
210+ static void ScanRawIdentifier (Accessor& styler, Sci_Position& pos) {
211+ Sci_Position start = pos;
212+ while (IsIdentifierContinue (styler.SafeGetCharAt (pos, ' \0 ' )))
213+ pos++;
214+
215+ char s[MAX_RUST_IDENT_CHARS + 1 ];
216+ Sci_Position len = pos - start;
217+ len = len > MAX_RUST_IDENT_CHARS ? MAX_RUST_IDENT_CHARS : len;
218+ GrabString (s, styler, start, len);
219+ // restricted values https://doc.rust-lang.org/reference/identifiers.html#raw-identifiers
220+ if (strcmp (s, " crate" ) != 0 && strcmp (s, " self" ) != 0 &&
221+ strcmp (s, " super" ) != 0 && strcmp (s, " Self" ) != 0 ) {
222+ styler.ColourTo (pos - 1 , SCE_RUST_IDENTIFIER);
223+ } else {
224+ styler.ColourTo (pos - 1 , SCE_RUST_LEXERROR);
225+ }
226+ }
227+
210228static void ScanIdentifier (Accessor& styler, Sci_Position& pos, WordList *keywords) {
211229 Sci_Position start = pos;
212230 while (IsIdentifierContinue (styler.SafeGetCharAt (pos, ' \0 ' )))
@@ -704,6 +722,9 @@ void SCI_METHOD LexerRust::Lex(Sci_PositionU startPos, Sci_Position length, int
704722 ScanWhitespace (styler, pos, max);
705723 } else if (c == ' /' && (n == ' /' || n == ' *' )) {
706724 ScanComments (styler, pos, max);
725+ } else if (c == ' r' && (n == ' #' && IsIdentifierStart (n2))) {
726+ pos += 2 ;
727+ ScanRawIdentifier (styler, pos);
707728 } else if (c == ' r' && (n == ' #' || n == ' "' )) {
708729 ScanRawString (styler, pos, max, false );
709730 } else if (c == ' b' && n == ' r' && (n2 == ' #' || n2 == ' "' )) {
0 commit comments