From: mtrenkmann <martin.trenkmann@googlemail.com>
Subject: OpenToken: Handling the empty word token
Date: Fri, 27 Jan 2012 08:22:12 -0800 (PST)
Date: 2012-01-27T08:22:12-08:00 [thread overview]
Message-ID: <62121d9d-f208-4e78-a109-749742da14a6@h12g2000yqg.googlegroups.com> (raw)
Hello all.
Very often grammars have so called epsilon-productions where one
alternative for a non-terminal symbol points to the empty word
(epsilon).
For example: Optional -> Something | epsilon
In OpenToken I modeled the epsilon token as an
OpenToken.Recognizer.Nothing.Instance and defined the production like
this:
Optional <= Something and
Optional <= epsilon
Now I realized that the lexer would actually never emit the epsilon
token, because of it's pure formal meaning, and thus the second
production would never be detected.
Is there a way to instrument the parser to silently accept the epsilon
token whenever it expects it without consuming a token from the lexer,
or is it a common convention to translate each grammar into a epsilon-
free representation?
Thanks in advance.
-- Martin
next reply other threads:[~2012-01-27 16:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-27 16:22 mtrenkmann [this message]
2012-01-27 16:48 ` OpenToken: Handling the empty word token Dmitry A. Kazakov
2012-01-28 3:42 ` Randy Brukardt
2012-01-29 17:45 ` Stephen Leake
2012-01-31 0:56 ` Randy Brukardt
2012-01-31 9:09 ` Georg Bauhaus
2012-01-31 12:16 ` Stephen Leake
2012-02-02 1:39 ` Randy Brukardt
2012-01-28 10:46 ` Stephen Leake
2012-01-30 16:28 ` mtrenkmann
2012-01-30 18:34 ` Dmitry A. Kazakov
2012-01-31 12:58 ` Stephen Leake
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox