Re: Is C++ LL(k)?

"Lin Gu" <>
23 Jul 2001 23:26:05 -0400

          From comp.compilers

Related articles
Re: Is C++ LL(k)? (Lin Gu) (2001-07-23)
Re: Is C++ LL(k)? (2001-07-27)
Re: Is C++ LL(k)? (Mike Dimmick) (2001-07-27)
Re: Is C++ LL(k)? (2001-08-06)
| List of all articles for this month |

From: "Lin Gu" <>
Newsgroups: comp.lang.c++,comp.compilers
Date: 23 Jul 2001 23:26:05 -0400
Organization: Peking University
References: <9jh5uu$olr$> <mSZ67.20253$>
Keywords: C++, parse
Posted-Date: 23 Jul 2001 23:26:05 EDT

Thanks for the clear elumination.

Your example also reminds me the 'if...if...else' ambiguation. Surely it is
not LR(k).

However, I may have to use an LL(k) compiler generator (Antlr) to
write a compiler for it. Is it difficult? It is expected that I need
to add some rules to disambiguate, but I want to know whether this is



"Kaz Kylheku" <> wrote in message
> In article <9jh5uu$olr$>, Lin Gu wrote:
> >I think C++ is LR(1). But is it LL(k)?
> >
> >I am to write a compiler for a C++ like language and get confused with
> >problem.
> The C++ grammar is not LR(1) or LL(k), because it contains ambiguities
> that are resolved by dynamically determining the lexical category of an
> identifier, based on the semantics of an earlier declaration. Is X(Y)
> a function call, or a declaration that Y is of type X? Depends on what
> X is, of course.
> I believe the C++ grammar can be factored to eliminate left recursion,
> and subsequently can be parsed by a recursive descent parser with
> only one token of lookahead.

Post a followup to this message

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