a = b = 1 just syntactic sugar?

Martin v. Löwis martin at v.loewis.de
Tue Jun 10 07:13:34 CEST 2003


"Greg Ewing (using news.cis.dfn.de)" <g2h5dqi002 at sneakemail.com> writes:

> It *might* be the case that there is an equivalent LL(1)
> grammar for any grammar that pgen can handle, but I can't
> think of a proof of this off the top of my head.

I think it is as easy as this:

- Replace a construct FOO* with FOO_seq, and define

  FOO_seq: /* empty */
         | FOO FOO_seq

- Replace a construct [FOO] with FOO_opt, and define

  FOO_opt: /* empty */
         | FOO

This, of course, requires that the follow-sets of FOO_seq and FOO_opt
are disjoint with the first-sets of FOO, but pgen requires this
property as well.

Regards,
Martin





More information about the Python-list mailing list