Comment by raffraffraff
1 month ago
I had to take a look at some examples, because my last Perl work was over 15 years ago. This is neat:
grammar Parser {
rule TOP { I <love> <lang> }
token love { '♥' | love }
token lang { < Raku Perl Rust Go Python Ruby > }
}
say Parser.parse: 'I ♥ Raku';
# OUTPUT: 「I ♥ Raku」 love => 「♥」 lang => 「Raku」
The same thing in other languages would require a lot more code, without a parser module. An LLM tells me that functional languages can handle this stuff well too, but that Raku code is just extremely simple to grasp
So to be fair, "extremely simple to grasp" because looked at superficially. Once you dig into it, there is a lot happening in there. Both in what can go into an actual production grammar, and what is present in the parsing output. which is why I was mentioning learning curve.
But yeah, most stuff is easy, there is more than one way to do it, and the impossible isn't. Or something.