Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!amdcad!lll-crg!seismo!mcvax!boring!jack From: jack@boring.uucp (Jack Jansen) Newsgroups: net.lang.c Subject: Re: C not LALR(1) & compiler bugs Message-ID: <6757@boring.UUCP> Date: Sat, 1-Feb-86 14:01:30 EST Article-I.D.: boring.6757 Posted: Sat Feb 1 14:01:30 1986 Date-Received: Mon, 3-Feb-86 05:34:59 EST References: <10200035@ada-uts.UUCP> <7800010@datacube.UUCP> Reply-To: jack@mcvax.UUCP (Jack Jansen) Organization: AMOEBA project, CWI, Amsterdam Lines: 37 Apparently-To: rnews@mcvax In article <7800010@datacube.UUCP> stephen@datacube.UUCP writes: > >C is context sensitive in many ways, but so is just about every other >programming language in existence. PASCAL or MODULA-II, for example, >have an ambiguity for: > >Statement ::= assign_stmt | procedure_invocation | ... > >assign_stmt ::= IDENTIFIER ':=' expression >procedure_invocation ::= IDENTIFIER ... > >This also must be resolved by feedback to the lexer. This is not true. The lexical analyzer doesn't have anything to do with it, since both things are IDENTIFIERs. The problem in C is that type-names are reserved words, so, in effect, a 'typedef' introduces a new reserved word. This makes it necessary to either tell lex about it (the quick-and-dirty approach, used by most compilers I know of), or mess up your yacc grammar in a truly horrible way. Also, note that, at least in pascal, where there are *no* procedure-type variables, you only have to look ahead exactly *one* token to find out wether it is an assignment or a call. (Next token is ( or any statement terminator => call else assigment). In C, you could conceivably have to look ahead an unlimited number of tokens: typedef int geheel_getal; geheel_getal ((((((((((((((((((((a)))))))))))))))))))); This makes the C typedef problem an order of magnitude more difficult. -- Jack Jansen, jack@mcvax.UUCP The shell is my oyster.