Article View: comp.lang.misc
Article #6386Re: Language Design, or: is C's Grammar Context Free
From: Rahul Dhesi
Date: Sun, 09 Apr 1989 19:32
Date: Sun, 09 Apr 1989 19:32
24 lines
1504 bytes
1504 bytes
In article <10148@megaron.arizona.edu> gudeman@arizona.edu (David Gudeman)
writes:
>There is no context free grammar that recognises all valid C programs.
Well...there is no context free grammar that recognizes all valid C
programs and *no others*.
Not surprising, since there is no context-free grammar that recognizes
exactly all valid programs in *any* real programming language in common
use.
It's tempting to wonder if BASIC and FORTRAN might be exceptions, since
they do not require variables to be declared before use.
Unfortunately, if you say "GOTO 10000" in either, there had better be a
label or line number called "10000" somewhere, and no context-free
grammar can guarantee that. TECO (the text editor, whose programs are
indistinguishable from line noise by common mortals) may be another
candidate, but it too wants jump labels to exist.
Try one of the functional programming languages, in their purest form
(no jump labels, no variables). They may come close.
--
Rahul Dhesi <dhesi@bsu-cs.bsu.edu>
UUCP: ...!{iuvax,pur-ee}!bsu-cs!dhesi
Technical Details
Message-ID:
<6670@bsu-cs.bsu.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!bsu-cs!dhesiReferences:
<10148@megaron.arizona.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!bsu-cs!dhesi From: dhesi@bsu-cs.bsu.edu (Rahul Dhesi) Newsgroups: comp.lang.misc Subject: Re: Language Design, or: is C's Grammar Context Free Message-ID: <6670@bsu-cs.bsu.edu> Date: 9 Apr 89 19:32:33 GMT References: <10148@megaron.arizona.edu> Reply-To: dhesi@bsu-cs.bsu.edu (Rahul Dhesi) Organization: CS Dept, Ball St U, Muncie, Indiana Lines: 24