[antlr-interest] building ASTs in actions?

Johnicholas Hines johnicholas.hines at gmail.com
Tue Jun 20 06:57:21 PDT 2006


Hi.

I'm working on a grammar that has a range operator.
That is, "RANGE(1, 10)" should expand to "1, 2, 3, 4, 5, 6, 7, 8, 9, 10".

How would you recommend doing that?
At the moment I have this:

if ( first < second && second <= third ) {
int step = second-first;
                antlr::RefAST temp = #([COMMA, "COMMA"], a, b);
                for( int i= second+step; i<third; i+=step ) {
                    istringstream is;
                    is << i;
                    temp = #([COMMA, "COMMA"], temp, [INTEGER, is.str
().c_str()]);
                }
                #expr = #([COMMA, "COMMA", temp, c);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060620/da822d7f/attachment.html


More information about the antlr-interest mailing list