Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Is the skip: directive broken in Parse::RecDescent ?

by ikegami (Patriarch)
on Aug 11, 2008 at 21:44 UTC ( [id://703754]=note: print w/replies, xml ) Need Help??


in reply to Is the skip: directive broken in Parse::RecDescent ? [Solved - PEBKAC]

<skip:qr/#\w+/> 'foo' 'bar'
is equivalent to
/(?>#\w+)(?>foo)(?>#\w+)(?>bar)/

/#\w+/ isn't matched by the "#skdjslkdjsakdjadjlksa\n" before "foo" (note the newline).
/#\w+/ isn't matched by the "" before "bar".

I think you want <skip:qr/(?:#\w+\n)?/>

By the way,
/#\w+/ 'foo' 'bar'
is equivalent to
/(?>\s*)(?>#\w+)(?>\s*)(?>foo)(?>\s*)(?>bar)/
since the default skip is /\s*/.

Update: Added "by the way" bit.

Replies are listed 'Best First'.
Re^2: Is the skip: directive broken in Parse::RecDescent ?
by Hercynium (Hermit) on Aug 11, 2008 at 22:01 UTC
    Thanks again, ikegami. You've given me another avenue to search for my solution. I'm curious though - the trace shows that the skip block is being treated like a production... and it's returning a value! [\s*]

    Do all modified prefix matches return this, or just skip directives?
      Quote the docs,

      The <skip> directive evaluates to the previous terminal prefix, so it's easy to reinstate a prefix later in a production

      (Followed by an example)

        Silly me... I think by then my brain was too frazzled to understand the docs! Thanks!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-18 02:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found