[antlr-interest] Is this a bug of ANTLR3.1?

Ronghui Yu stoneyrh at gmail.com
Mon Sep 8 18:14:25 PDT 2008


Sorry that I change the mail address with my personal mail for eliminating
the disclaimer followed by each message

This is a good idea, I had thought about that before. My current solution
is, before matching the semicolon, look ahead to see if the next token is
semicolon, if not, then go around with it, something like this:

sql_statement_command
{
    if (next token is not semicolon)
    {
        goto noSemiStmt;
    }
}
';'
{
    noSemiStmt:
        do other things
}

Then I don't need to bother the code outside the parser itself.

Thanks


==============================
Regards,
Ronghui Yu
Sierra Atlantic
----- Original Message -----
From: "Austin Hastings" <Austin_Hastings at Yahoo.com>
To: "Ronghui Yu" <Ronghui.Yu at SierraAtlantic.com>
Cc: <antlr-interest at antlr.org>
Sent: Tuesday, September 09, 2008 8:03 AM
Subject: Re: [antlr-interest] Is this a bug of ANTLR3.1?


> Forgive me for stating the obvious, but if you get such a clear bonus
> from this change, why not just force a semicolon before you call your
> parser?
>
> =Austin
>
>
> Ronghui Yu wrote:
>> I am using ANTLR3.1 for developing a SQL parser
>> One of my main rule looks like this
>> sql_statement:
>> sql_statement_command (';')?
>> But when generating parser codes from grammar file to C source, it
>> always take a very long time and consume as much as 5G memory because
>> of the optional semicolon
>> Then in order to make the development easier, I make the semicolon a
>> mandatory by removing the question mark, like this
>> sql_statement:
>> sql_statement_command ';'
>> It does make the building faster and require much less memory.
>> But the problem now is, when parsing a statement without the
>> semicolon, such as the following
>> select * from tt
>> ANTLR won't handle this but issue a signal 11
>> His is the stack information when this happening, when all test has
>> been matched and is going to match the last semicolon
>> Program received signal SIGSEGV, Segmentation fault.
>> 0xb7370a09 in getMissingSymbol () from
>> /home/oracle/install/lib/libantlr3c.so
>> (gdb) where
>> #0 0xb7370a09 in getMissingSymbol ()
>> from /home/oracle/install/lib/libantlr3c.so
>> #1 0xb73701d0 in recoverFromMismatchedToken ()
>> from /home/oracle/install/lib/libantlr3c.so
>> #2 0xb736f7bb in match () from /home/oracle/install/lib/libantlr3c.so
>> In my opinion, ANTLR should initialize an exception that can be
>> processed by his own way, not issue this signal
>> Anyone has any ideas of suggestions on this?
>> Thanks a lot
>> ==============================
>> Regards,
>> Ronghui Yu
>> Sierra Atlantic
>>
>>
>>
________________________________________________________________________________________________________________
>> ------------------------------------------------------------------------
>>
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe:
>>
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080909/d7773868/attachment.html 


More information about the antlr-interest mailing list