Re: best grammar for handling optional symbols?

jmichae3@yahoo.com
Mon, 18 Aug 2008 22:49:57 -0700 (PDT)

          From comp.compilers

Related articles
best grammar for handling optional symbols? jmichae3@yahoo.com (2008-08-15)
Re: best grammar for handling optional symbols? max@gustavus.edu (Max Hailperin) (2008-08-16)
Re: best grammar for handling optional symbols? jaluber@gmail.com (Johannes) (2008-08-17)
Re: best grammar for handling optional symbols? jmichae3@yahoo.com (2008-08-18)
Re: best grammar for handling optional symbols? cfc@shell01.TheWorld.com (Chris F Clark) (2008-08-19)
| List of all articles for this month |
From: jmichae3@yahoo.com
Newsgroups: comp.compilers
Date: Mon, 18 Aug 2008 22:49:57 -0700 (PDT)
Organization: Compilers Central
References: 08-08-021 08-08-022
Keywords: parse
Posted-Date: 19 Aug 2008 22:19:30 EDT

> If you are fortunate enough to use EBNF, but again have a required
> fixed order, the clutziness would go away. You could just write the
> 18 options out with each in brackets or followed by a question mark,
> and life would be good. Or to adopt John's phrase, you would have
> kept your grammar manageable.
>
> But nothing like that is possible if the order is variable. In that
> case, even if you are writing for humans, your best bet is to escape
> from the BNF or EBNF into some more general means of communication --
> which for a human, might well be a natural-language explanation.
>
> -Max Hailperin
> Professor of Computer Science
> Gustavus Adolphus College


I did not know about following an optional symbol with ? but I did
miss in wikipedia where they surround optionals with [].
My options, as far as I can tell from the reference, are in a sequence
- fortunately for me - I think.
otherwise I would write it as
<option> := "a" | "b" | "c" | "d" "e" | "f"
<sequence> ::= <option>*


I guess this means I am going to have to "look ahead"


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.