Ticket #177 (closed patch: fixed)
[PATCH] ignore trailing spaces in action keys
Reported by: | riffraff | Owned by: | pmichaud |
---|---|---|---|
Priority: | minor | Milestone: | 1.1 |
Component: | PGE | Version: | trunk |
Severity: | low | Keywords: | parsing pge action whitespace |
Cc: | Language: | ||
Patch status: | new | Platform: | all |
Description
While writing parsers with PGE I hit the following problem multiple times:
rule foo { <bar> {*} #= key <baz> {*} #= other }
'key' is actually followed by whitespace, which causes subsequent manipulations to fail miserably and it was a considerable waste of time the first time and still relevant the second.
The attached patch adds an additional step to the parsing of Perl6Regex to strip trailing whitespace.
This fixes the common problem (trailing non-space whitespace is much less likely to happen), but IMO it would be better to do an actual 'trim' of the string, possibly importing perl6's multimethod in String/Util.pir, in the end most HLL have/need a trim function.
Two tests are included, everything still passes in parrot 35590