Article View: comp.lang.misc
Article #6401Re: Language Design, or: is C's Grammar Context Free
From: Micha Berger
Date: Tue, 11 Apr 1989 23:22
Date: Tue, 11 Apr 1989 23:22
32 lines
1918 bytes
1918 bytes
> Consider the following in C, however:
> . . . { T (x); . . . }
> How should the construct be parsed?
It would have to be an expression, since anything within brackets ain't a
decleration. This isn't Pascal kiddees, all functions are global.
> Consider instead the one that someone else posted:
>
> { T * x; . . . }
This just shows that your grammar is poor. Obviously it has to be the
interpreter's job to distinguish between decleration and expression.
I don't see any qualitative difference between typedef's and variable
decleration. An identifier is an identifier. Are you going to tell me
that Pascal isn't CF because A*B could have diffent meanings, because
multiplying integers creates different code than multiplynig reals?
Another thing. No language is a CFG. A language just isn't a grammar.
In order to prove that C isn't A CFL, you'ld have to prove that there
doesn't exist a CFG that only accepts valid C programs. A grammar
doesn't care what you do with each statement, so who cares how it would
be parsed? You'll just get a very complicated interpreter, since very
little could be said about statement types in advance.
--
Micha Berger
Disclaimer: All opinions expressed here are my own. The spelling, noone's.
email: ...!cmcl2!phri!dasys1!aj-mberg Aspaklaria Publications
vox: (718) 380-7572 73-32 173 St, Hillcrest, NY 11366
Technical Details
Message-ID:
<9313@dasys1.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!unisoft!hoptoad!dasys1!aj-mbergReferences:
<5200040@m.cs.uiuc.edu> <12443@watdragon.waterloo.edu> <920@m10ux.ATT.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!unisoft!hoptoad!dasys1!aj-mberg From: aj-mberg@dasys1.UUCP (Micha Berger) Newsgroups: comp.lang.misc Subject: Re: Language Design, or: is C's Grammar Context Free Summary: Sol'ns Keywords: BNF, Grammars, Silliness Message-ID: <9313@dasys1.UUCP> Date: 11 Apr 89 23:22:02 GMT References: <5200040@m.cs.uiuc.edu> <12443@watdragon.waterloo.edu> <920@m10ux.ATT.COM> Organization: The Big Electric Cat Lines: 32