Re: Infinite look ahead required by C++?

Chris F Clark <cfc@shell01.TheWorld.com>
Sat, 27 Feb 2010 22:27:16 -0500

          From comp.compilers

Related articles
[8 earlier articles]
Re: Infinite look ahead required by C++? martin@gkc.org.uk (Martin Ward) (2010-02-11)
Re: Infinite look ahead required by C++? idbaxter@semdesigns.com (Ira Baxter) (2010-02-13)
Re: Infinite look ahead required by C++? sh006d3592@blueyonder.co.uk (Stephen Horne) (2010-02-14)
Re: Infinite look ahead required by C++? wclodius@los-alamos.net (2010-02-13)
Re: Infinite look ahead required by C++? krzikalla@gmx.de (Olaf Krzikalla) (2010-02-19)
Re: Infinite look ahead required by C++? ng2010@att.net (ng2010) (2010-02-23)
Re: Infinite look ahead required by C++? cfc@shell01.TheWorld.com (Chris F Clark) (2010-02-27)
Re: Infinite look ahead required by C++? bartc@freeuk.com (bartc) (2010-02-28)
Re: language twiddling, was Infinite look ahead required by C++? cfc@shell01.TheWorld.com (Chris F Clark) (2010-03-01)
Re: Infinite look ahead required by C++? torbenm@diku.dk (2010-03-02)
Re: language twiddling, was Infinite look ahead required by C++? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2010-03-03)
Re: language twiddling, was Infinite look ahead required by C++? bobduff@shell01.TheWorld.com (Robert A Duff) (2010-03-05)
Re: language twiddling, was Infinite look ahead required by C++? bobduff@shell01.TheWorld.com (Robert A Duff) (2010-03-05)
[9 later articles]
| List of all articles for this month |

From: Chris F Clark <cfc@shell01.TheWorld.com>
Newsgroups: comp.compilers
Date: Sat, 27 Feb 2010 22:27:16 -0500
Organization: The World Public Access UNIX, Brookline, MA
References: 10-02-024 10-02-039 10-02-086
Keywords: parse, design
Posted-Date: 28 Feb 2010 00:19:13 EST

"ng2010" <ng2010@att.net> writes:


> // var declaration
> var mystruct x


If you are going to go that route, follow the footsteps of a languqage
that was designed to be (relatively} easily parseable, Pascal.
Seriously, Pascal was designed to be almost entirely LL(1).
Syntactically, there are relatively few goofs in Pascal. Playing
around trying to re-invent that on your own is a recipe for failure.


Sticking a var keyword on the beginning of C declarations, that
declare a variable is only a poor bandage that doesn't solve many
(much less most) of the ambiguities in C. You will need a func
keyword to introduce function declarations also. Perhaps a type
keyword to introduce type declarations. Hmmm, we are well on our way
to re-building Pascal. Plus, since we've mixed C and Pascal, we will
still have issues.


> I'm trying to avoid lex/parse generators. I want to do it by hand
> and bootstrap from C/C++ until my language can compile itself.


Again, wrong approach. The purpose of generators is to make your life
easier and to prevent you from making foolish mistakes. The language
of most generators is a variation on BNF and is relatively simple to
learn. You will not learn more by not using a generator. You will
simply make more mistakes and quite probably define an ad-hack
language--an inconsistent language whose only definition is the source
code used to compile it.


Okay, I'll get off my soapbox now,
-Chris


******************************************************************************
Chris Clark email: christopher.f.clark@compiler-resources.com
Compiler Resources, Inc. Web Site: http://world.std.com/~compres
23 Bailey Rd voice: (508) 435-5016
Berlin, MA 01503 USA twitter: @intel_chris


Post a followup to this message

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