Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Matching terminals with Parse::RecDescent

by fce2 (Sexton)
on Dec 12, 2006 at 04:01 UTC ( #589212=note: print w/replies, xml ) Need Help??


in reply to Re: Matching terminals with Parse::RecDescent
in thread Matching terminals with Parse::RecDescent

/foo$/ works for the example script. "foo" /\Z/ didn't match anything (though /foo\Z/ did). All fall down if I test with this grammar:
line: FOO BAR FOO: /foo\Z/ BAR: /bar\Z/
(and use $p->line instead of $p->foo). I probably should have been more specific, but I'm looking for a more generalised solution to this, or at least some understanding of where my expectations are wrong.

Replies are listed 'Best First'.
Re^3: Matching terminals with Parse::RecDescent
by ikegami (Patriarch) on Dec 12, 2006 at 06:36 UTC

    or at least some understanding of where my expectations are wrong.

    Your grammar expects to match

    1. 0 or more whitespace characters (see <skip>),
    2. followed by "foo",
    3. followed by the end of the string to parse,
    4. 0 or more whitespace characters,
    5. followed by "bar",
    6. followed by the end of the string to parse.
Re^3: Matching terminals with Parse::RecDescent
by GrandFather (Saint) on Dec 12, 2006 at 06:25 UTC

    With the grammar:

    line: FOO BAR /$/ FOO: "foo" BAR: "bar"

    and the invocation changed line to:

    if (defined (my $ret = $p->line($test))) {

    I get:

    no match: 'foo' no match: 'foo ' match: 'foo bar' -> '' no match: 'football' no match: 'fog' no match: 'barfoo' no match: 'bar foo'

    Is that not what you expect?


    DWIM is Perl's answer to Gödel

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://589212]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2022-07-07 08:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?