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
Return to the
comp.compilers page.
Search the
comp.compilers archives again.