Skip Menu |

This queue is for tickets about the Parse-RecDescent CPAN distribution.

Report information
The Basics
Id: 130382
Status: new
Priority: 0/
Queue: Parse-RecDescent

People
Owner: Nobody in particular
Requestors: Roman.Krenicky [...] de.bosch.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Text modifications of scored subrules get lost
Date: Mon, 26 Aug 2019 13:04:48 +0000
To: "bug-Parse-RecDescent [...] rt.cpan.org" <bug-Parse-RecDescent [...] rt.cpan.org>
From: "Krenicky Roman (CC-PS/ESY3)" <Roman.Krenicky [...] de.bosch.com>
Parse::RecDescent 1.967015 Hi, When using scored productions, as in: rule : match1 <score: ...> | match2 the match attempt for the second production (match2) will reset the remaining (i.e. unparsed) text, discarding any changes from earlier scored matches. If match2 fails, this results in incorrect behaviour. Please see the example code (test.pl): parsing the string "entry 1 #" fails, while it should succeed. The problem arises because every attempt to match a sub-production resets the local $text variable to the initial value (and potentially modifies it subsequently): sub Parse::RecDescent::TestParser::list { ... while (!$_matched && !$commit) { ... $text = $_[1]; ... # Trying production: match1 } while (!$_matched && !$commit) { ... $text = $_[1]; <=============== RESET ... # Trying production: match2 } ... $_[1] = $text; return $return; } To fix this I have introduced a variable "$score_text" which stores the remaining text in case of a successful scored match. This is essentially the same approach as with $score_return. (see ScoreText.patch) Bye!

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.