Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Parse::RecDescent grammar that winds its way all the way back to start

by moritz (Cardinal)
on Sep 23, 2010 at 15:36 UTC ( [id://861585]=note: print w/replies, xml ) Need Help??


in reply to Parse::RecDescent grammar that winds its way all the way back to start

What I want, I think, is for the parser, having recognized one occurrence of job_statement, to at that point <commit> to it.

So, <commit> after each successfully parsed job_statement. Then offer an alternative that slurps up the rest of the file, as a dummy, to make the grammar match in the end.

I don't know Parse::RecDescent enough to express what I mean in code, so I'll try in Perl 6 rules, maybe that's sufficiently readable for you to translate it to your needs:

grammar Jobs { token TOP { ^ '$JOBS' <job_def> $ } role job_def { [ <single_job_definiton> <commit> || .* # if there is no way to parse # a job definition, dummy-parse # the rest of the string to prevent # outright failure ]+ } }
Perl 6 - links to (nearly) everything that is Perl 6.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-04-24 13:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found