in reply to Re: Parse RecDescent Nesting (Followup)
in thread Parse RecDescent Nesting (Followup)

Thanks again Randal (for the update). The stuff to flatten the arrayrefs looks promising, and I am trying to integrate that into what I have.

The updated grammar seemed dodgy to me though, because it had a circular reference -- "stuff" has "chunks", and "chunks" have "stuff". Or are circular references allowed/desirable/cool in a grammar specification? Trying to understand what this was doing made my brain swim.

Best, thomas.

Note: this was second reply to Randal.

  • Comment on Re^2: Parse RecDescent Nesting (Followup)

Replies are listed 'Best First'.
Re^3: Parse RecDescent Nesting (Followup)
by merlyn (Sage) on Jan 21, 2005 at 23:55 UTC
    Circular references are what permits nested open-close pairs. I wrote it the way I did so that the grammar was never ambiguous, and yet permits empty open-close pairs, or empty adjacent opens or closes. Allowing "empty" can get you into trouble in a grammar. And that fixes the problem from before.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Re^3: Parse RecDescent Nesting (Followup)
by bart (Canon) on Jan 22, 2005 at 13:07 UTC
    The "circular references", or, as they're more commonly known, "recursive definitions", are precisely what differentiates a grammar from a flat, regular pattern, and the thing Perl's regex-engine can't properly handle, making a parser like Parse::RecDescent useful.