Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: $Revision: 1.6.2.16 $; site datacube.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!datacube!stephen From: stephen@datacube.UUCP Newsgroups: net.lang.c Subject: Re: C not LALR(1) & compiler bugs Message-ID: <7800010@datacube.UUCP> Date: Mon, 27-Jan-86 10:39:00 EST Article-I.D.: datacube.7800010 Posted: Mon Jan 27 10:39:00 1986 Date-Received: Thu, 30-Jan-86 05:49:58 EST References: <10200035@ada-uts.UUCP> Lines: 22 Nf-ID: #R:ada-uts:10200035:datacube:7800010:000:860 Nf-From: datacube!stephen Jan 27 10:39:00 1986 > C's grammar is CONTEXT SENSITIVE !? Can it be ?! ... 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. In a general sense, any programming language where variables are declared is context-sensitive, since the semantics of later invocations of the variable depend on what type the variable was declared. Really, you are flaming the lack of power of an LALR(n) grammar. However, due to considerations of efficiency and convenience, an LALR grammar is probably one of the best choices for parsing a language (especially if you have yacc available).