Re: Lookahead vs. Scanner Feedback

smk@dcs.edinburgh.ac.uk
Tue, 7 Jan 92 12:24:16 GMT

          From comp.compilers

Related articles
Lookahead vs. Scanner Feedback hjelm+@cs.cmu.edu (1992-01-03)
Re: Lookahead vs. Scanner Feedback rockwell@socrates.umd.edu (Raul Deluth Miller-Rockwell) (1992-01-04)
Re: Lookahead vs. Scanner Feedback bliss@sp64.csrd.uiuc.edu (1992-01-07)
Re: Lookahead vs. Scanner Feedback sef@kithrup.COM (1992-01-07)
Re: Lookahead vs. Scanner Feedback Jan.Rekers@cwi.nl (1992-01-07)
Re: Lookahead vs. Scanner Feedback burley@geech.gnu.ai.mit.edu (1992-01-07)
Re: Lookahead vs. Scanner Feedback drw@lagrange.mit.edu (1992-01-07)
Re: Lookahead vs. Scanner Feedback smk@dcs.edinburgh.ac.uk (1992-01-07)
Re: Lookahead vs. Scanner Feedback bill@twwells.com (1992-01-08)
Should scanners see symbol table ? (was Re: Lookahead vs. Scanner Feed blakemor@software.org (1992-01-08)
Re: Lookahead vs. Scanner Feedback bliss@sp64.csrd.uiuc.edu (1992-01-08)
Re: Lookahead vs. Scanner Feedback nigelh@sol.UVic.CA (1992-01-08)
Re: Lookahead vs. Scanner Feedback dww@inf.fu-berlin.de (1992-01-08)
Re: Lookahead vs. Scanner Feedback jwoods@convex.com (1992-01-09)
[4 later articles]
| List of all articles for this month |
Newsgroups: comp.compilers
From: smk@dcs.edinburgh.ac.uk
Keywords: parse, C
Organization: Compilers Central
Date: Tue, 7 Jan 92 12:24:16 GMT

bliss@sp64.csrd.uiuc.edu (Brian Bliss) writes:


> One place where every yacc/lex based C compiler I know of is
> broken is on a typedef name redefined in an inner scope:
>
> typedef int foo;
>
> main ()
> {
> char foo;
> }
>
> is legal ANSI C. I think there was a thread on this a while back.


I missed this thread, but anyway:


The above shouldn't be a problem, because this is not really an ambiguous
occurrence. You can deal with that by having a production


any_ident : ident | type_ident;


and using any_ident for the identifier in a declarator (and several other
places). This should be possible without introducing any ambiguities.


But for some parts of the C syntax this is not so easy, for labels you
probably have to expand the any_ident production to allow programs like


typef int foo;
main ()
{ foo: ;
}


because otherwise there is a shift-reduce conflict
(reduce type_ident to any_ident for labels, shift for declarations).
[It's not impossible, but it's tricky and messy to get right. -John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.