Re: newlines and no newlines
[email protected] (Damian Conway)
| Newsgroups | perl.recdescent |
|---|---|
| Message-ID | <[email protected]> |
Hi Cortland. You noted: > The following grammar parses fine with no intermixed newlines. > It fails with newlines. E.g.: > > c t a b int B # parses > c t a > b int B # does not > > I do not understand why the second fails. Insight? The problem is not in RecDescent. The problem is in: > while (<>) which reads in a single line at a time and sends it to the parser. So, in the case of intermixed newlines, it just reads in "c t a\n" or just reads in "b int B\n", neither of which individually satisfies the grammar. And, to anticipate the obvious follow-up question: no, there is currently no easy way to set up a RecDescent grammar that parses incrementally. I'm working on that, but it really requires incremental regex matches, which will probably not be available until Perl 6. :-( Damian