|best grammar for handling optional symbols? firstname.lastname@example.org (2008-08-15)|
|Re: best grammar for handling optional symbols? email@example.com (Max Hailperin) (2008-08-16)|
|Re: best grammar for handling optional symbols? firstname.lastname@example.org (Johannes) (2008-08-17)|
|Re: best grammar for handling optional symbols? email@example.com (2008-08-18)|
|Re: best grammar for handling optional symbols? cfc@shell01.TheWorld.com (Chris F Clark) (2008-08-19)|
|Date:||Fri, 15 Aug 2008 18:41:28 -0700 (PDT)|
|Posted-Date:||15 Aug 2008 22:28:45 EDT|
I've been using BNF.
up until now, things have been OK with the optional symbols.
what is the proper way to implement an optional symbol where <code40>
<b> ::= <code40> "r" | "r"
but I would prefer
<b> ::= <a> "r"
<a> ::= <code40> | <nullsymbol???>
I don't know. I don't think this is right when it occurs 0 or 1
times. I seem to remember there was a symbol in BNF used to represent
the null terminal or something - it's not listed in wikipedia (lousy
wikipedia). what was it?
Anyway, the problem I am up against is that I have to define a symbol
that has 18 options. fully expanded, that makes 2^18 options, and I
have 200 more symbols to define for autocad, many with more options...
[Either is OK for optional symbols. For your Autocad problem, I would
suggest a much looser grammar that just accepts a list of symbols, and
check semantically to knock out duplicates. That both keeps the
grammar managable, and lets you produce much better errors, e.g.
"duplicate foo" or "foo not allowed after bar" rather than just
"syntax error". -John]
Return to the
Search the comp.compilers archives again.