Re: Is C++ LL(k)?

kaz@ashi.footprints.net (Kaz Kylheku)
27 Jul 2001 02:50:11 -0400

          From comp.compilers

Related articles
Re: Is C++ LL(k)? lingu@cs.pku.edu.cn (Lin Gu) (2001-07-23)
Re: Is C++ LL(k)? kaz@ashi.footprints.net (2001-07-27)
Re: Is C++ LL(k)? mike@dimmick.demon.co.uk (Mike Dimmick) (2001-07-27)
Re: Is C++ LL(k)? isaac@latveria.castledoom.org (2001-08-06)
| List of all articles for this month |
From: kaz@ashi.footprints.net (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$1@sunlight.pku.edu.cn> <mSZ67.20253$zb.360918@news1.rdc1.bc.home.com> 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
>feasible.


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.