Re: Use of punctuation in a language?

Ron House <house@usq.edu.au>
3 Dec 2003 20:30:50 -0500

          From comp.compilers

Related articles
[7 earlier articles]
Re: Use of punctuation in a language? jcownie@etnus.com (James Cownie) (2003-11-11)
Re: Use of punctuation in a language? landauer@got.net (Doug Landauer) (2003-11-11)
Re: Use of punctuation in a language? Martin.Ward@durham.ac.uk (Martin Ward) (2003-11-11)
Re: Use of punctuation in a language? jvorbrueggen@mediasec.de (Jan C. =?iso-8859-1?Q?Vorbr=FCggen?=) (2003-11-21)
Re: Use of punctuation in a language? vbdis@aol.com (2003-11-21)
Re: Use of punctuation in a language? rkrayhawk@aol.com (2003-12-03)
Re: Use of punctuation in a language? house@usq.edu.au (Ron House) (2003-12-03)
| List of all articles for this month |

From: Ron House <house@usq.edu.au>
Newsgroups: comp.compilers
Date: 3 Dec 2003 20:30:50 -0500
Organization: Compilers Central
References: 03-10-129 03-11-006
Keywords: syntax
Posted-Date: 03 Dec 2003 20:30:50 EST

MattR wrote:
> I built a simple parser that makes some puntuation optional. Sometimes
> it's really nice but sometimes you can hang yourself. Be careful with
> unary operators that can be confused as binary opeators:
> if a<b -3 c=d
> could mean
> if( a<b) -3; c=d
> or
> if(a<b-3) c=d
> which is exactly what John said.
>
> This example blows up because -3 is a valid statement. If you ran it
> through bison with the glr option on it would complain that the grammar
> is ambiguous (and I'm being ambiguous about what it is because I think
> it won't complain until you run the string to be parsed through). If you
> can come up with a non-ambiguous grammar then it would probably be
> really nice to use. I can't type special characters without looking at
> the keyboard so I'd like it.


If I understand your meaning, you have it backwards. Decent tools like
Yacc (or bison) and other BNF->recogniser systems such as PCCTS will
object upon compiling your grammar if it is ambiguous, but, if you
insist on using the recogniser built from that grammar, will give you
unpredictable results. Bottom-up systems like yacc will always choose a
shift option over a reduce, but that is about the limit of the
predictability. You certainly won't get a message once your recogniser
is running that a particular input string has two parses, because the
mechanism, once built, does what it does. The sanity checks are in the
bnf tool.


And BTW: You type once, read many times. Typing efficiency is false
economy compared with clarity of the resulting document. Unpunctuated
words are hard to read. That's why punctuation in natural languages
was invented. It has hundreds of years of validation as a useful
comprehension aid, so abandon it at your peril.


--
Ron House house@usq.edu.au
                              http://www.sci.usq.edu.au/staff/house


Post a followup to this message

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