[antlr-interest] AST construction in C++

Ric Klaren klaren at cs.utwente.nl
Fri Feb 20 01:34:46 PST 2004


On Thu, Feb 19, 2004 at 07:21:49PM -0000, Dave Bailey wrote:
> I've been trying to get a simple parser/lexer working in C++ with
> buildAST = true.  I'm missing something and I don't know what it is. 
> Given the following grammar:

> main.cpp
> ====================================================================
> #include <iostream>
> #include <sstream>
> #include "test_lexer.hpp"
> #include "test_parser.hpp"
> 
> using namespace std;
> 
> int
> main ( int argc, char **argv )
> {
>   ostringstream ost;
> 
>   ost << "a = 1;" << endl << "b = 2;" << endl << "c = 3;" << endl;
> 
>   istringstream  ist(ost.str());
>   test_lexer     lexer(ist);
>   test_parser    parser(lexer);
>   parser.test();
> 
>   return 0;
> }
> ====================================================================

Looks like you forgot about the ASTfactory for example code check in the
examples subdir of the distro (calc example would do)

Cheers,

Ric
-- 
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
  Xander: "Buffy, we need to do something *now*"
  Angel: "We need a distraction."
  Buffy: "Right."
  Angel: "What are you going to do?"
  Buffy: "I'm going to kill them all. That oughtta distract 'em..."



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list