[San-Diego-pm] Meeting Next Week
Dave Roe
david_roe at mac.com
Tue Nov 16 16:57:27 CST 2004
On Nov 11, 2004, at 9:13 PM, Christopher Hahn wrote:
> I am trying to use Parse::Recdescent on fairly simple data, but am
> getting
> stuck on
> capturing an escaped carriage return.
if you turn on $::RD_TRACE, you can see what is going on. it seems the
answer is to double-up your back-slashes:
EscCR: /\\\\\\\\n/ { print "Escaped CR!\n"; }
from perldoc Parse::RecDescent:
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: '\\\\'
});
HTH,
/dave
More information about the San-Diego-pm
mailing list