[antlr-interest] advocacy of C++ support in ANTLR 3.x

Tomas Potrusil potrto at centrum.cz
Fri Mar 28 02:28:18 PDT 2008


Hallo,

 

I'm new to the list. I'm trying to use ANTLR for generating a SQL parser
because our current parser doesn't support Unicode input - it was generated
by Lex/Yacc. We use C++ and we have our own complex AST that is used by a
SQL engine already... So my idea is to write a tree adapter that would
create our existing AST nodes (they would just inherit ANTLR tree
interface).

 

And here comes a problem that ANTLR 3.x doesn't contain support for "pure"
C++ implementation. I've just found Jim Idle's "promise":

 

> Later I may well produce a complete C++ implementation from scratch,

> however, at this point I am not sure that it buys you anything. Please

> let me know if there are things you cannot do with the system as it

> stands (other than access the tokens and so on using C++ objects, which

> will be done later). 

 

I know that the problem could be solved with the current system somehow, but
it would be probably very ugly. So yes, complete C++ implementation will buy
us something! Or we can use ANTLR 2.x.

 

Right now we will probably try to build the AST by hand:

 

atom returns [OurNode* result]

@init { $result = NULL; }

:              NUMBER

                {

                               std::string str((char*)$NUMBER.text->chars,
$NUMBER.text->len);

                               $result = new OurNumberNode(str);

                };

 

Or do you have some other ideas?

 

Thanks

 

Tom

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080328/aa5043fd/attachment.html 


More information about the antlr-interest mailing list