Ticket #177 (closed patch: fixed)

Opened 13 years ago

Last modified 13 years ago

[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

Attachments

delspace.patch Download (2.6 KB) - added by riffraff 13 years ago.
patch to reomve trailing whitespace on a action key

Change History

Changed 13 years ago by riffraff

patch to reomve trailing whitespace on a action key

Changed 13 years ago by pmichaud

Thank you for the patch. Unfortunately, it cuts keys off at the first space, and not the trailing space. And at least in STD.pm (on which the whole "key" notion is based), keys are definitely allowed to contain spaces.

Also, it would be better if this trimmed all whitespace, and not just spaces.

If you can update the patch, I'll be happy to apply it.

Thanks again!

Pm

Changed 13 years ago by pmichaud

  • status changed from new to closed
  • resolution set to fixed

This problem has since been resolved in a separate commit, making the patch unnecessary. Thanks!

Pm

Note: See TracTickets for help on using tickets.