xsawyerx / guacamole

Guacamole is a parser toolkit for Standard Perl. It provides fully static BNF-based parsing capability to a reasonable subset of Perl.
https://metacpan.org/pod/Guacamole
20 stars 8 forks source link

s///e doesn't parse the replacement part #110

Closed haukex closed 2 years ago

haukex commented 3 years ago

As the title says, s///e doesn't parse the replacement part, which is a Perl expression. Therefore, non-standard.pm code is allowed in the replacement part. I'm not sure how difficult this is to implement or not, but perhaps it should be documented as a limitation for now.

xsawyerx commented 3 years ago

I put the bug label and removed it because I don't think it's a bug.

Technically, the only reason it doesn't understand the regexp modifier as a separate unit is that it sees it as a lexeme, not a rule. I don't remember why all of these regex functions are defined as lexemes instead of rules, though... I wouldn't touch it again without enough tests, to be honest.

haukex commented 3 years ago

Yes, I noticed that a regex is returned in the AST as one lexeme, which means that code trying to use the AST couldn't pick apart regexes further. But since Guacamole's current focus seems to be on verifying Standard Perl for now, that's probably ok. Anyway, yes, I wouldn't really call it a bug either, but a limitation, so perhaps a mention in the docs for now?

xsawyerx commented 3 years ago

It'd be great to have either more tests of it or a PR to improve this. I think separating the regex vs. modifier is a good idea. For the regex parts, it would be useful, but it also depends on the Perl version.

xsawyerx commented 2 years ago

Closing this for now. When it comes up again, we'll raise a proper ticket. (This should also not be considered a Q-like value, since it's the s keyword instead, but one issue at a time.)