[antlr-interest] SOLVED Creation of Lexer and Parser in the loop? Bad idea
Ruslan Zasukhin
sunshine at public.kherson.ua
Mon Oct 18 23:40:27 PDT 2004
On 10/18/04 1:32 PM, "Ruslan Zasukhin" <sunshine at public.kherson.ua> wrote:
Hi All,
This task is solved, thanks to everybody who have help.
> Hi All,
>
> I have note that we must write such code in C++
>
> Foo( string SqlQuery )
> {
> istringstream inp( SqlQuery.c_str() );
>
>
> Lexer lex( inp );
> Parser parser(lex);
>
> ..............
> }
>
>
> But if we look into constructor of Lexer we have
>
> VSQL_Lexer::VSQL_Lexer(std::istream& in)
> : antlr::CharScanner(new antlr::CharBuffer(in),false)
> {
> initLiterals();
> }
>
> void VSQL_Lexer::initLiterals()
> {
> literals["words"] = 218;
> literals["local"] = 212;
> literals["blob"] = 111;
> literals["byte"] = 89;
> literals["action"] = 227;
> literals["nullif"] = 144;
> ..............
> }
>
>
> ---------------------------------------------
> I hope it is easy to see that Lexer must built the map for N elements.
> For big grammar this is few hundreds of items.
>
> Guys, this is terrible!
>
> For example, if I will do in the loop 100,000 or million SQL commands
> INSERT INTO ...
>
> Then I will need million times create/destroy objects of lexer and parer,
> And what is the worst I need million (!!!!!!) times create and fill THE SAME
> std::map. I believe this is just silly.
>
> And I do not see that ANTLR can allow me create Lexer/Parser only once,
> And reuse them for different texts many times.
> Or I have miss something ?
>
>
> I am sure that this DESIGN MISTAKE must be fixed in the ANTLR.
>
> Any comments?
> Or advices how to reuse Lexer/Parser in huge loops?
>
> And this is NOT theoretical tasks. SQL Server can get such loops very often.
>
--
Best regards,
Ruslan Zasukhin [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com
To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------
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