Re: [QUERY] A "ignorant newbie" question about compiler-writing.

kanze@gabi-soft.fr (J. Kanze)
29 Jan 1997 12:02:04 -0500

          From comp.compilers

Related articles
[QUERY] A "ignorant newbie" question about compiler-writing. synaptik@why.net (1997-01-02)
Re: [QUERY] A "ignorant newbie" question about compiler-writing. dennis@netcom.com (1997-01-03)
Re: [QUERY] A "ignorant newbie" question about compiler-writing. jlilley@empathy.com (1997-01-03)
Re: [QUERY] A "ignorant newbie" question about compiler-writing. robison@kai.com (Arch Robison) (1997-01-03)
Re: [QUERY] A "ignorant newbie" question about compiler-writing. mw@ipx2.rz.uni-mannheim.de (1997-01-04)
Re: [QUERY] A "ignorant newbie" question about compiler-writing. kanze@gabi-soft.fr (1997-01-29)
Re: [QUERY] A "ignorant newbie" question about compiler-writing. kanze@gabi-soft.fr (1997-01-29)
Re: [QUERY] A "ignorant newbie" question about compiler-writing. mw@ipx2.rz.uni-mannheim.de (1997-01-30)
Re: [QUERY] A "ignorant newbie" question about compiler-writing. darius@phidani.be (Darius Blasband) (1997-01-30)
Re: [QUERY] A "ignorant newbie" question about compiler-writing. kanze@gabi-soft.fr (J. Kanze) (1997-01-30)
Re: [QUERY] A "ignorant newbie" question about compiler-writing. iainf@bristol.st.com (1997-02-07)
Re: [QUERY] A "ignorant newbie" question about compiler-writing. mff@research.att.com (Mary Fernandez) (1997-02-11)
[7 later articles]
| List of all articles for this month |
From: kanze@gabi-soft.fr (J. Kanze)
Newsgroups: comp.compilers
Date: 29 Jan 1997 12:02:04 -0500
Organization: GABI Software, Sarl.
References: 97-01-013 97-01-029 97-01-034
Keywords: parse, symbols



John Lilley (jlilley@empathy.com) wrote:
  > The symbol table in some languages like Java, C or C++ is necessary
  > even for a syntactic parse, because typedefs determine what is an
  > identifier vs a type, and there are places in the grammar where it
  > must be known what is a type and what is not for the parse to
  > proceed correctly.


mw@ipx2.rz.uni-mannheim.de (Marc Wachowitz) writes:
> That's not true for Java. The language specification (available online
> as http://java.sun.com/doc/language_specification.html) contains a
> chapter with a complete LALR(1) grammar, which one can feed to yacc
> without complaints, after expanding the usage of an "opt"-Suffix to
> several alternatives with and without the respective optional element.


I can't believe that no one answered this. The fact that the you can
feed the grammar to yacc without complaints doesn't contradict what
John said. Yacc only handles the tokens it gets from the lexer, and
John's point was just that you need some sort of feedback in order for
the lexer to return the right token.


I'm not familiar enough with Java to assert that this is true, but it
looks enough like C/C++ to make me think it is probably so. And of
course, the same problem affects languages in the Pascal family:
typically, feedback to the lexer is used to disambiguate between
procedure calls and assignment statements early in the game. (I think
that it would be possible to write an LALR grammar for Pascal which
didn't require it, but it would be much more difficult than
implementing the feedback.)


--
James Kanze +33 (0)1 39 55 85 62 email: kanze@gabi-soft.fr
GABI Software, Sarl., 22 rue Jacques-Lemercier, 78000 Versailles, France
--


Post a followup to this message

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