🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #6326

Re: Language Design

#6326
From: Alan J Rosenthal
Date: Fri, 17 Mar 1989 22:25
25 lines
1558 bytes
In article <9091@claris.com> hearn@claris.com (Bob Hearn) writes:
>Well, the *grammar* defining C programs is certainly context-free!  Just
>look in the back of K&R.

I'm looking in the back of K&R (first edition), and if I'm not mistaken I'm
seeing context-sensitive stuff in the grammar.

Suppose you're looking at a compound-statement and you've just seen the `{'
opening it.  Now suppose the next three tokens are `extern', "x", and `;'.
This is produced by a declaration-list, expanding to declaration, which expands
to decl-specifiers init-declarator-list[opt] ;.  `extern' is an sc-specifier,
and decl-specifiers -> sc-specifier decl_specifiers[opt].  Now is "x" a
declarator (init-declarator-list -> init-declarator -> declarator ->
identifier) or a typedef-name (decl-specifiers -> type-specifier ->
typedef-name -> identifier)?

It's ambiguous unless you use non-context-free information to tell you whether
or not "x" was previously declared via typedef.

ajr

--
"The goto statement has been the focus of much of this controversy."
	    -- Aho & Ullman, Principles of Compiler Design, A-W 1977, page 54.
Technical Details
Message-ID: <8903172225.AA05088@explorer.dgp.toronto.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!dgp.toronto.edu!flaps
References: <5200040@m.cs.uiuc.edu> <12443@watdragon.waterloo.edu> <9091@claris.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.misc
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!dgp.toronto.edu!flaps
From: flaps@dgp.toronto.edu (Alan J Rosenthal)
Subject: Re: Language Design
Message-ID: <8903172225.AA05088@explorer.dgp.toronto.edu>
Organization: Dynamic Graphics Project, University of Toronto
References: <5200040@m.cs.uiuc.edu> <12443@watdragon.waterloo.edu> <9091@claris.com>
Date: Fri, 17 Mar 89 17:25:30 EST