CC: | bug-text-balanced [...] rt.cpan.org |
Subject: | Adjacent anonymous subrules misparsed |
Date: | Thu, 22 Jan 2009 10:47:43 +0100 |
To: | bug-parse-recdescent [...] rt.cpan.org |
From: | Bjoern Hoehrmann <derhoermi [...] gmx.net> |
Hi,
With v1.96.0 of Parse::RecDescent and Text::Balanced v2.0.0 the
following grammar is not parsed as I would expect:
A: ( x x ) ( x x )
This results in 'Untranslatable item encountered: ")"'. This appears
to be a logic error in the code around line 1920 starting with
...
elsif ($grammar =~ m/(?=$IMPLICITSUBRULE)/gco
and do { ($code) = extract_codeblock($grammar,'{([',undef,'(',1);
$code })
{
$code =~ s/\A\s*\(|\)\Z//g;
...
Here $code is '( x x ) ( x x )' and is then turned into 'x x ) ( x x'.
I am somewhat unsure from the documentation of Text::Balanced whether
it is supposed to return '( x x ) ( x x )' rather than '( x x )', it may
be a good idea to document that one way or the other.
(By the way, the code passes five parameters to extract_codeblock while
it only seems to document four parameters, but then uses them all.)
regards,
--
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/