Path: utzoo!attcan!telly!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!bonnie.concordia.ca!nstn.ns.ca!news.cs.indiana.edu!news.nd.edu!spool.mu.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!swrinde!ucsd!dog.ee.lbl.gov!pasteur!galileo.berkeley.edu!jbuck From: jbuck@galileo.berkeley.edu (Joe Buck) Newsgroups: comp.lang.c++ Subject: Re: C++ Grammar Message-ID: <11373@pasteur.Berkeley.EDU> Date: 23 Feb 91 02:28:16 GMT References: <3786@lupine.NCD.COM> <1991Feb08.130548.6878@iti.com> <70609@microsoft.UUCP> <112@shasta.Stanford.EDU> Sender: news@pasteur.Berkeley.EDU Reply-To: jbuck@galileo.berkeley.edu (Joe Buck) Lines: 24 In article <112@shasta.Stanford.EDU>, shap@shasta.Stanford.EDU (shap) writes: |> The problem with Roskind's grammar (at least the last time I looked - it |> may have been updated in the past few months) is that it requires the |> lexer to resolve "typedef" v/s "identifier", which is probably the most |> difficult problem in the language as far as parsing goes. If anyone has |> built a tool that overcomes this limitation, including the associated |> symtab support, I would be interested to see it. I've seen this point raised for years and years and years, and I've never understood it (mainly about typedefs in C, but it applies to C++). Why do people object so strenously to the parser asking the lexer for help when distinguishing identifiers from types? The implementation is obvious, it's clean, it's easy to do. Once a token has been declared as a type, mark it as such in the symbol table, so the next time the token appears, the lexer returns the token indicating that it's a type, not an identifier. It's simple, it's clean, and it works. But yet there is a faction that screams about the "impurity" of it. Why? Actually, I doubt if C++ can be parsed without using this trick, with anyone's grammar. -- Joe Buck jbuck@galileo.berkeley.edu {uunet,ucbvax}!galileo.berkeley.edu!jbuck