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 locked_user 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.