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

[lojban] PEG left recursive definitions



Does the PEG currently use left recursive definitions? If not, would
it be helpful if it could? For instance. Example input:

x ? x : x

To parse this, we could write

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

This would be translated to

expr-1 <- x
tri-cond <- expr-1 '?' expr ':' expr / expr-1
expr <- tri-cond / expr-1
x <- 'x'

I'm currently writing a PEG parser in C# that I hope will be able to
support indirect left recursion, among other nice features. I have a
quasi-mathematical algorithm that I believe shows that any level or
complexity of indirect left-recursion can be resolved, (if anyone's
interested I can post it,) but I'm not sure how it's going to work
out. It could make a mess of the grammar, or maybe make optimizations
much harder, or who knows what.

Chris Capel
-- 
"What is it like to be a bat? What is it like to bat a bee? What is it
like to be a bee being batted? What is it like to be a batted bee?"
-- The Mind's I (Hofstadter, Dennet)


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.