Newsgroups: comp.lang.c Path: utzoo!utgpu!jarvis.csri.toronto.edu!dgp.toronto.edu!flaps From: flaps@dgp.toronto.edu (Alan J Rosenthal) Subject: Re: ambiguous why? Message-ID: <8804080443.AA16177@explorer.dgp.toronto.edu> Organization: University of Toronto References: <1303@PT.CS.CMU.EDU> <3326@haddock.ISC.COM> <589@fig.bbn.com> Date: Thu, 7 Apr 88 22:43:47 EDT Eddie Wyatt and Rich Salz both write that i+=*p shouldn't be ambiguous because there is a rule that says that the lexer should always take the longest possible token. However, I think they are confusing different kinds of ambiguity. :-) One is an ambiguity between interpretations of expressions given a certain set of rules, and the other is an ambiguity between deciding which set of rules to use. When scanning `+=*', older compilers would ALWAYS take the token list to be `+' and `=*'. Newer compilers, based on the rule that the scanner should always take the longest possible token, would ALWAYS take the token list to be `+=' and `*'.[1] If you're writing a compiler which is supposed to act correctly in either circumstance, this code is ambiguous. ajr -- [1] In effect. -- "Comment, Spock?" "Very bad poetry, Captain."