Newsgroups: comp.lang.misc Path: 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 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.