All~

On 7/1/05, Luke Palmer <[EMAIL PROTECTED]> wrote:
> > Attempting to come up with a simplistic math grammar that has one possible
> > operand (A) and one possible operator (*) - so that things like A, A*A, and
> > A*A*A*A*A are all parsed. This simplistic example (thanks to spinclad on
> > #perl6) cause PGE to explode.
> >
> > $ cat ta.p6r
> > grammar f;
> > rule atom  { A }
> > rule binary { <expr> \* <atom> }
> > rule expr { <binary> }
> 
> That probably shouldn't die so horribly, but it should die.  We don't
> support left-recursive grammars, and this is one.  A
> non-left-recursive grammar that matches the same language is:
> 
>     grammar f;
>     rule atom { A }
>     rule binary { <atom> \* <binary> }

Not to pick gnits or show off my ignorance too much, but shouldn't the
binary rule make the second part optional somehow?

 rule binary { <atom> [\* <binary>]? }

Matt
-- 
"Computer Science is merely the post-Turing Decline of Formal Systems Theory."
-???

Reply via email to