Re: How to parse keywords that can be used as identifiers?

itz@rahul.net (Ian T Zimmerman)
24 Aug 1996 21:35:47 -0400

          From comp.compilers

Related articles
How to parse keywords that can be used as identifiers? mark@research.techforce.nl (Mark Thiehatten) (1996-08-19)
Re: How to parse keywords that can be used as identifiers? anton@a0.complang.tuwien.ac.at (1996-08-20)
Re: How to parse keywords that can be used as identifiers? kanze@lts.sel.alcatel.de (1996-08-20)
Re: How to parse keywords that can be used as identifiers? leichter@smarts.com (Jerry Leichter) (1996-08-21)
Re: How to parse keywords that can be used as identifiers? ph@anweald.exnet.co.uk (1996-08-24)
Re: How to parse keywords that can be used as identifiers? grosch@cocolab.sub.com (1996-08-24)
Re: How to parse keywords that can be used as identifiers? dlmoore@ix.netcom.com (David L Moore) (1996-08-24)
Re: How to parse keywords that can be used as identifiers? itz@rahul.net (1996-08-24)
Re: How to parse keywords that can be used as identifiers? peter@bj-ig.de (Peter Brueckner) (1996-08-27)
Re: How to parse keywords that can be used as identifiers? stefan.monnier@lia.di.epfl.ch (Stefan Monnier) (1996-08-27)
Re: How to parse keywords that can be used as identifiers? fjh@mundook.cs.mu.OZ.AU (1996-08-27)
Re: How to parse keywords that can be used as identifiers? iwm@doc.ic.ac.uk (Ian Moor) (1996-09-03)
Re: How to parse keywords that can be used as identifiers? ok@cs.rmit.edu.au (1996-09-05)
Re: How to parse keywords that can be used as identifiers? jpff@maths.bath.ac.uk (1996-09-05)
| List of all articles for this month |
From: itz@rahul.net (Ian T Zimmerman)
Newsgroups: comp.compilers
Date: 24 Aug 1996 21:35:47 -0400
Organization: My own fan club
References: <96-08-058@comp.compilers 96-08-070
Keywords: parse, comment

Jerry Leichter <leichter@smarts.com> writes:


> With modern languages, much of the semantics of the language is not
> in the statements themselves, but in the libraries. For typical
> object- oriented languages, the descriptions of the libraries are
> many times the size of the language descriptions! However, no one
> proposes that the names of library classes, much less their members
> be reserved! If it's so important to reserve the keywords, why not
> the library names?


Actually, AFAIK, the C++ draft standard says that reusing names from the std
namespace leads to undefined behaviour. Now this isn't "reserved" in the
same sense (the compiler is not required to diagnose), but as far as the end
result goes it's pretty much the same thing. You _are_ supposed to know the
whole standard library if you use the language.


> As PL/I long ago demonstrated, it's quite possible to define a
> reasonable programming-language grammar with *no* reserved words. It's
> quite true that "bad examples" like the famous:
>
> IF IF = THEN THEN THEN = ELSE ELSE ELSE = END END
>
> are then possible. So? Reasonable programmers won't write such things;
> few programmers will use a keyword *of which they are aware* as a
> variable name. But what's the big deal if they use, say, UNSPEC as a
> variable name, even if an advanced PL/I programmer knows that that's a
> build-in pseudo-function (or whatever it's called)?


One problem (admittedly of a different nature) is that allowing this makes
implementation much harder. Therefore, there'll be fewer and more expensive
implementations, and the organisations responsible for the few
implementations will wield near monopoly power over the language. In the
end, users may lose.


--
Ian T Zimmerman <itz@rahul.net>
[Previous messages suggest that parsing such languages isn't actually all that
much harder so long as you have tools that can backtrack. -John]
--


Post a followup to this message

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