rouge
rouge copied to clipboard
nix: Fix identifier lexing
Fix #2176
Nix identifiers can contain ' and -, which are not "word" characters in Ruby regexp. Thus, the pattern /if\b/ (literal "if" followed by a word boundary) will match with if within if'.
This pull request defines id_boundary pattern as /(?![a-zA-Z_0-9'-])/, "not followed by Nix identifier characters" and replaces \b with it.
Nix manual: https://nix.dev/manual/nix/2.28/language/identifiers.html
Syntax
identifier ~
[A-Za-z_][A-Za-z0-9_'-]*