Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: using two Parse::RecDescent parsers together

by ikegami (Patriarch)
on Aug 12, 2005 at 14:26 UTC ( [id://483289]=note: print w/replies, xml ) Need Help??


in reply to using two Parse::RecDescent parsers together

From the docs,

$text: The remaining (unparsed) text. Changes to $text do not propagate out of unsuccessful productions, but do survive successful productions.

So we need to remove from $text what the query parser matches. Also from the docs,

If, however, the text to be matched is passed by reference [...] then any text which was consumed during the match will be removed from the start of [the referenced string].

So it's quite simple:

$TemplateParser = Parse::RecDescent->new(<<'__GRAMMAR__'); template: identifier 'TEMPLATE' '{' statement(s) '}' statement: expression | conditional | loopcontrol | { $QueryParser->query(\$text) } __GRAMMAR__

Tested.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2024-04-25 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found