I just wrote part of a parser for Portage atoms (extended syntax and all) in #
Raku, to learn how the new regex and grammar systems work. My impressions so far:
- Thank god for insignificant whitespace. It makes regular expressions so much easier to read. In classic PCRE, I rarely ever found myself needing to match a specific number of only spaces and no other whitespace; I'd use
\s+
instead of a literal space 99% of the time.
- Raku regexes look a lot like the Backus-Naur Form/Pseudo Backus-Naur Form found in RFCs, with the quoted string literals and angle brackets for embedding named rules.
- I kinda dislike that
[ ]
denote non-capturing groups now; I'm still used to reading them as "any of these characters". I can't remember if PCRE did anything special with { }
, so why not use them for non-capturing groups instead, and leave the meaning of square brackets unchanged?
- Apparently you can interpolate variables and shit into Raku regexes? And even run arbitrary code in the middle of pattern-matching??? I have no clue how I could even use that, but it sounds fucking awesome.
- Overall, Raku regexes and grammars are pretty cool in my opinion. I like them a lot so far, and they seem quite powerful.