Correct parsing of ternary operator.

Daeshik Kim dkim at wam.umd.edu
Thu Jan 4 18:28:42 AEST 1990


In article <9493 at batcomputer.tn.cornell.edu> lijewski at batcomputer.tn.cornell.edu (Mike Lijewski) writes:
>
>	c ? c = a : c = b;
	
	The only way I can guess is follows:

	1. having top-down parsing (LL)	predictive grammar def.
	for fast parsing --> ERROR

		(c)[expr] (?) (c = a)[expr] (:) (c) ... 
						^^^
		HERE, left-to-right scan may predict the last token 'c'
		an expression

	2. having slow bottom-up (LR) right-most grammar
		--> off course, accept this
--
	Daeshik Kim	H: (301) 445-0475/2147 O: (703) 689-7308 (M,W,F)
	SCHOOL:	dkim at cscwam.umd.edu (uunet!haven!cscwam.umd.edu!dkim)
		dskim at eng.umd.edu (uunet!haven!eng.umd.edu!dskim)
	WORK:	dkim at daffy.uu.net (uunet!daffy!dkim)



More information about the Comp.lang.c mailing list