Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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

by gnosti (Friar)
on Sep 23, 2010 at 16:33 UTC ( #861605=note: print w/replies, xml ) Need Help??


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

You might design your parser to consume only one entry at a time. Pass your data to the parser as scalar reference. This way the scalar will be left with the remaining (unconsumed) text.
$parser->start_rule(\$data) or warn("not a job file"), return; while( $data ){ $parser->job_statement(\$data) }
Since you're calling the parser anew each time, you won't have a problem with unwinding entries.

This doesn't address the question of how to resync if you encounter a bad entry.

  • Comment on Re: Parse::RecDescent grammar that winds its way all the way back to start
  • Download Code

Replies are listed 'Best First'.
Re^2: Parse::RecDescent grammar that winds its way all the way back to start
by sundialsvc4 (Abbot) on Sep 23, 2010 at 20:04 UTC

    That is a very clever strategy.   I will ponder it carefully.

    In this case, “resyncing after a syntax error” is a non-issue.   I am interested in the error messages because I am debugging the grammar.

    Thanks for all your help, everyone.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://861605]
help
Chatterbox?
[marto]: oddly the last time I was there I saw a zeppelin in flight for the first time
[Corion]: ambrus: I don't know how far the budget estimate has been overrun yet
[Corion]: marto: Heh ;) No, you were likely at Tegel or Schönefeld, the new one ("BER") will be somewhat outside of Berlin ;)
[marto]: Corion Schoenfeld, but my friend has been telling me about this new airport for about 7-8 years now :P
[marto]: I doubt it even exists as a building site :P
[ambrus]: Corion: does building airports "somewhat outside of" a city ever work? cities always grow around the airport quickly, because it's practical to be close to it, and after that, people start to complain that the airplanes land so close to their house and sh
[ambrus]: ould keep down the noise

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2017-02-23 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (346 votes). Check out past polls.