Re: Lookahead vs. Scanner Feedback

bill@twwells.com (T. William Wells)
Wed, 8 Jan 1992 02:59:43 GMT

          From comp.compilers

Related articles
[2 earlier articles]
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)
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)
Re: Lookahead vs. Scanner Feedback jwoods@convex.com (1992-01-10)
Re: Lookahead vs. Scanner Feedback bliss@sp64.csrd.uiuc.edu (1992-01-13)
[1 later articles]
| List of all articles for this month |

Newsgroups: comp.compilers
From: bill@twwells.com (T. William Wells)
Keywords: yacc, parse
Organization: None, Mt. Laurel, NJ
References: 92-01-012 92-01-022
Date: Wed, 8 Jan 1992 02:59:43 GMT

In article 92-01-022 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.


It works fine with my yacc/lex based parser. The trick is that when you
see the char, you have to make sure that the lexer is told of the change
of state soon enough. But thanks for noting the potential problem; I'll
add it to my list of test cases.


In answer to the original question: you don't know if the parser will or
will not get a lookahead. That depends on the parser implementation. For
yacc and bison, you can study the -v output to find out.


In general, for an LR parser, you can tell if the parser MUST get a
lookahead by examining the action table: if all the non error entries are
identical, you don't need a lookahead token; otherwise, you do.


---
Bill { uunet | decwrl | telesci }!twwells!bill
bill@twwells.com
--


Post a followup to this message

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