Click here to get back home

double back-slash in Parse::RecDescent grammars?

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
double back-slash in Parse::RecDescent grammars? ~greg 10-09-2006
Get Chitika Premium
Posted by ~greg on October 9, 2006, 5:43 pm
Please log in for more thread options


The documentation for Parse::RecDescent
says this:
======================================================
It is important to remember that, since each grammar is specified in a Perl
string, all instances of the universal escape character
'\' within a grammar must be ``doubled'', so that they interpolate to single
'\'s when the string is compiled. For example, to use
the grammar:
word: /\S+/ | backslash
line: prefix word(s) "\n"
backslash: '\'
the following code is required:
$parser = new Parse::RecDescent (q{
word: /\S+/ | backslash
line: prefix word(s) "\n"
backslash: '\'
});
===========================================================

But what is that taking about???

Becaue none of the demos do that,
and nothing that I've gotten to work works by doing that.

As far as I can see, single \ works.
Double \ does not work.


So what's the deal?

~greg




Posted by ~greg on October 10, 2006, 3:01 am
Please log in for more thread options


I think it's that the example in the documentation is in error,
in that it uses single quotes q,
whereas it should use double quotes qq.

(It'd make sense if it was double quotes,
but in single quotes the backslash is special only when
it occurs in front of the closing bracket: q{ ... \} ... },
'...\'... ', etc.)

The real problem I'm having is that it seems to me that
Parse::RecDescent doesn't distinguish between \z and \Z.
I have to use /\n|\z/ (or /\n|\Z/) to do what /\Z/ is supposed to do.
Can anyone confirm if that's the case?

~greg





> The documentation for Parse::RecDescent
> says this:
> ======================================================
> It is important to remember that, since each grammar is specified in a Perl
string, all instances of the universal escape
> character
> '\' within a grammar must be ``doubled'', so that they interpolate to single
'\'s when the string is compiled. For example, to use
> the grammar:
> word: /\S+/ | backslash
> line: prefix word(s) "\n"
> backslash: '\'
> the following code is required:
> $parser = new Parse::RecDescent (q{
> word: /\S+/ | backslash
> line: prefix word(s) "\n"
> backslash: '\'
> });
> ===========================================================
>
> But what is that taking about???
>
> Becaue none of the demos do that,
> and nothing that I've gotten to work works by doing that.
>
> As far as I can see, single \ works.
> Double \ does not work.
>
>
> So what's the deal?
>
> ~greg
>
>
>



Similar ThreadsPosted
Parse::RecDescent demo_Cgrammar.pl March 14, 2006, 6:17 pm
three Parse::RecDescent related questions October 7, 2005, 1:23 pm
Problem to get Parse::Yapp and Parse:Flex working together November 2, 2005, 3:15 pm
XML::Twig produces double encoded UTF-8 January 4, 2007, 3:36 pm
Apparent bug in Win32::API if function returns a float or a double May 22, 2008, 12:06 am
Apparent bug in Win32::API if function returns a float or a double May 22, 2008, 12:05 am
Parse::Readelf 0.01 - parse the output of readelf September 24, 2007, 12:07 pm
Problems with Parse::Lex May 5, 2005, 8:22 pm
I want to take over module Parse::Lex, how to do it? April 17, 2006, 10:49 pm
Parse::FixedLength. where did pars() go? September 30, 2004, 2:02 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap