Re: C++ parser

Michael Tiomkin <>
19 Jan 2001 23:25:19 -0500

          From comp.compilers

Related articles
C++ parser (Henrique Bucher) (2001-01-18)
Re: C++ parser (Michael Tiomkin) (2001-01-19)
Re: C++ parser (Joel de Guzman) (2001-01-20)
Re: C++ parser (Henrique Bucher) (2001-01-20)
| List of all articles for this month |

From: Michael Tiomkin <>
Newsgroups: comp.compilers
Date: 19 Jan 2001 23:25:19 -0500
Organization: NetVision Israel
References: 01-01-097
Keywords: C++, parse
Posted-Date: 19 Jan 2001 23:25:19 EST

Henrique Bucher wrote:

> Hi, all
> I was wondering if there is a C++ parser class (public domain or GPL)
> that allows the definition of the grammar at runtime, not at compile
> time as yacc.  The objective is to ask the user for the grammar rules
> (with a nice interface, of course) and then instruct the parser to
> read a user file.  I am almost prepared to start coding but I would
> like to have this try first.

   Well, you'll also need to build the right finite state machines for
this grammar, for both lexer and parser, etc. etc.  I think the
easiest way is to build a .lex and .yacc file with your nice
interface, add a makefile, apply yacc, lex, and cc using this
makefile, and run the parser.   If you want to call a parser as a
function from your program, you can build the parser as a shared
library (.so/.dll) and (un)load it at runtime.

  Another possibility is to use a package that allows building and
compiling simple grammars at runtime, e.g. Python (re package or
somehting like that). After initial parsing, you can use tree
transformations in order to obtain the right object structures.  You
can easily find a parser written in Python and see what can be done

  Good luck!

[You might be able to cadge an Earley or Tomita parser somewhere. -John]

Post a followup to this message

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