Article View: comp.lang.misc
Article #6324Re: Language Design
From: Bob Hearn
Date: Fri, 17 Mar 1989 20:50
Date: Fri, 17 Mar 1989 20:50
27 lines
1618 bytes
1618 bytes
>> (For example, in the language I'm learning now, C++, if you forget to >> declare a class, it is a *syntax* error. Not misuse of identifier or >> undefined class, *syntax* error.) >> > >Don't blame C++. Blame C. > >C is not context-free parsable [actually I believe it is, but not >with any sensible grammar]. >-- >Gordon V. Cormack CS Dept, University of Waterloo, Canada N2L 3G1 >gvcormack@waterloo.EDU gvcormack@uwaterloo.CA gvcormac@water.BITNET Well, the *grammar* defining C programs is certainly context-free! Just look in the back of K&R. This doesn't mean that any grammatically correct program is semantically correct. I don't know of any non-trivial language with a context-free grammar for semantically correct programs. (I may be wrong here, but certainly this is correct for most languages.) Actually, I've always thought parts of the grammar (e.g. type declarations) were hacked to facilitate easy parsing. Many compilers, however, do consider some semantic errors syntax errors, because it's easier that way. As for the C++ syntax error described above, that's compiler-dependent. MPW C++ tells me that the identifier is not a valid type name. Bob Hearn hearn@claris.com
Technical Details
Message-ID:
<9091@claris.com>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!claris!hearnReferences:
<5200040@m.cs.uiuc.edu> <12443@watdragon.waterloo.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!claris!hearn From: hearn@claris.com (Bob Hearn) Newsgroups: comp.lang.misc Subject: Re: Language Design Message-ID: <9091@claris.com> Date: 17 Mar 89 20:50:24 GMT References: <5200040@m.cs.uiuc.edu> <12443@watdragon.waterloo.edu> Reply-To: hearn@claris.com (Bob Hearn) Organization: Claris Corporation, Mountain View CA Lines: 27