[antlr-interest] Can one identify the type of parser needed for a given BNF grammar

Douglas Godfrey douglasgodfrey at gmail.com
Mon Jul 11 13:37:04 PDT 2011


Antlr plus a SymbolTable is much more powerful and expressive than Antlr
alone.

I believe that C++ CAN be parsed by Antlr if you have a good set of
SymbolTable
classes. All of the constructor vs function and namespace ambiguities as
well as
templates and inheritance can be resolved by the SymbolTable.

The Lexer would process all pre-processor commands. The Parser would
validate
the source while simultaneously building the SymbolTable and the AST. A
TreeParser
would do any semantic checks that cannot be done by the parser. Zero or more

TreeParsers would transform the AST to apply optimizations. A final
TreeParser
would perform code generation. The same SymbolTable would be passed to the
Parser and all TreeParsers.


On Mon, Jul 11, 2011 at 2:51 PM, Loring Craymer <lgcraymer at yahoo.com> wrote:

> And then you have to figure out how to prune the GLR-generated "forests".
>  C++
> is nasty; it can be parsed with ANTLR (as shown by NEXT and David Wigg's
> adaptions of that grammar), but I believe that the right strategy with
> ANTLR is
> actually to use multi-pass recognition to sort out the ambiguities.  That
> has
> not been done yet.
>
> The problem is that C++ cannot be adequately described with a context-free
> grammar; you have to do some context-sensitive processing to resolve the
> syntax
> that is semantically ambiguous.
>
> --Loring
>
>
> ----- Original Message ----
> > From: The Researcher <researcher0x00 at gmail.com>
> > To: antlr-interest at antlr.org
> > Sent: Mon, July 11, 2011 11:25:07 AM
> > Subject: [antlr-interest] Can one identify the type of parser needed for
> a
> >given BNF grammar
> >
> > Maybe I dreaming but maybe lady luck is with me today.
> >
> > Does anyone know  of program, paper, algorithm that given a BNF grammar
> it
> > will tell you what  type of algorithm/parser can parse it.
> >
> > Types of algorithms/parsers would  be Regular Expression (RE), LL, LR,
> LALR,
> > GLR, SLR and how much look ahead is  needed?
> >
> > If another website is better for posting this, that would be
>  appreciated.
> >
> > The tie into to ANTLR here is that the more I learn about  parsing C++
> the
> > more the answer comes back GLR.
> >
> > Thanks   Eric
> >
> > List: http://www.antlr.org/mailman/listinfo/antlr-interest
> > Unsubscribe:
> >http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> >
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>


More information about the antlr-interest mailing list