[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lojban] PEG left recursive definitions
- To: lojban-list@lojban.org
- Subject: [lojban] PEG left recursive definitions
- From: "Chris Capel" <pdf23ds@gmail.com>
- Date: Tue, 30 Oct 2007 19:44:38 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=Xh9NEJ+iYsPMqEjmg76eMigWqah9R0bj92P9dIKMnsI=; b=WqKb+aWFKTK4wTlFbYK+paMNT9DSKR7K/RKNRqYTbbRm5VewDGYBKKuzhWkvRoApuXWA6gABDqhCarcHxUq7mxE0xZgqSQUD9ULqK3WE3FavIJeanTz4nNX6jkQ8+Bz96Rhcw6n0amXTQ89EFlsr54xNidXTZjG4H1Ww1qkRb/M=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=HmxsnY05wFN+lFLzLR1b3jFKSvEOmLFHyScLD9lIT6DwC7F9o6z+VzFZF4ZefVT7UfbRelayfKFLrU3x9VqO5qGdXhYhXnv3zYx/+n4Bl91ail/gLZdZ44aTw0vRH4zKOQSlejHWholAjAE0iD3bdLR5vt3vew7TIh84voZ1BQE=
- Reply-to: lojban-list@lojban.org
- Sender: lojban-list-bounce@lojban.org
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.