[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lojban] Re: PEG left recursive definitions



On 10/30/07, Chris Capel <pdf23ds@gmail.com> wrote:
> Does the PEG currently use left recursive definitions?

Left associativity is handled by rules such as:

 selbri-3 <- selbri-4+

or:

 sumti-2 <- sumti-3 (joik-ek sumti-3)*

so it is left implicit.

> If not, would it be helpful if it could?

It would be helpful if the parse tree is to show left associativity
explicitly.

> For instance. Example input:
>
> x ? x : x
>
> To parse this, we could write
>
> expr <- tri-cond / x
> tri-cond <- expr '?' expr ':' expr
> x <- 'x'

That's equivalent to:

  expr <- expr '?' expr ':' expr / 'x'

which would not be allowed in PEG.

> This would be translated to
>
> expr-1 <- x
> tri-cond <- expr-1 '?' expr ':' expr / expr-1
> expr <- tri-cond / expr-1
> x <- 'x'

This one is equivalent to:

  expr <- 'x' '?' expr ':' expr / 'x'

Which is allowed, but does not have an explicitly left associative parse tree.

mu'o mi'e xorxes


To unsubscribe from this list, send mail to lojban-list-request@lojban.org
with the subject unsubscribe, or go to http://www.lojban.org/lsg2/, or if
you're really stuck, send mail to secretary@lojban.org for help.