Re: Is C++ LL(k)? (Kaz Kylheku)
27 Jul 2001 02:50:11 -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: (Kaz Kylheku)
Newsgroups: comp.lang.c++,comp.compilers
Date: 27 Jul 2001 02:50:11 -0400
Organization: Psycho-Neurotic Institute for the Very, Very Nervous
References: <9jh5uu$olr$> <mSZ67.20253$> 01-07-138
Keywords: C++, parse
Posted-Date: 27 Jul 2001 02:50:11 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

You can add fake nonterminals to disambiguate as well. I don't have
experience writing a C++ parser, but in a C parser you can, for instance,
deal with typedef names by inventing a ``fake'' lexical category of
non-terminals called ``typename''. Have the lexical analyzer consult
the symbol table and then assign that category to an identifier that is
found to be a typedef name, rather than the category ``identifier''.

See the newsgroup comp.compilers; it may seem surprising, but
comp.lang.c++ isn't really for discussing parsing techniques for C++!

Post a followup to this message

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