[antlr-interest] C target help

Ilyevsky, Leonid (Equity Trading) Leonid_Ilyevsky at ml.com
Tue Dec 16 11:44:52 PST 2008


 Jim,

I did some debugging of your antlr code (just using the print
statements), and I found a problem. It is in antlr3baserecognizer.c,
around line 1025.

The fragment is below.

First of all, "theToken" is checked for NULL after it is used for
evaluating ttext. So I tried to move the ttext evaluation inside the
"else" block, just before it is used. Unfortunately, I found that in my
case theToken is not NULL, but the program still died somewhere inside
"theToken->toString(theToken)" call.

So I just commented that ttext evaluation out, and it does not die now.

Obviously this is not a proper fix, so please look into that.

Regards,

Leonid



=============================================
 switch  (recognizer->type)
        {
        case    ANTLR3_TYPE_PARSER:

                // Prepare the knowledge we know we have
                //
                parser      = (pANTLR3_PARSER) (recognizer->super);
                tparser     = NULL;
                is                      = parser->tstream->istream;
                theToken    =
(pANTLR3_COMMON_TOKEN)(recognizer->state->exception->token);
                ttext       = theToken->toString(theToken);

                ANTLR3_FPRINTF(stderr, ", at offset %d",
recognizer->state->exception->charPositionInLine);
                if  (theToken != NULL)
                {
                        if (theToken->type == ANTLR3_TOKEN_EOF)
                        {
                                ANTLR3_FPRINTF(stderr, ", at <EOF>");
                        }
                        else
                        {
                                // Guard against null text in a token
                                //
                                ANTLR3_FPRINTF(stderr, "\n    near %s\n
", ttext == NULL ? (pANTLR3_UINT8)"<no text for the token>" :
ttext->chars);
                        }
                }
                break;

=============================================


-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Ilyevsky, Leonid
(Equity Trading)
Sent: Tuesday, December 16, 2008 12:47 PM
To: Jim Idle; antlr-interest at antlr.org
Subject: Re: [antlr-interest] C target help

Hi Jim,

I made some progress since yesterday, so now I am doing some testing.

Here is the next problem I hit. If the text to parse is good, then it
goes through OK (I did not come to analyze the result yet). But if there
is an error, then the program just dies after logging the error message.
For example:

-memory-(1)  : error 1 : Unexpected token

Yes, indeed, there is an unexpected token there, but why does it die? It
happens inside the psr->statement(psr) call.
The psr is my parser and "statement" is the top expression.

Any suggestions? 

Thanks,

Leonid

-----Original Message-----
From: Jim Idle [mailto:jimi at temporal-wave.com] 
Sent: Monday, December 15, 2008 6:24 PM
To: Ilyevsky, Leonid (Equity Trading); antlr-interest at antlr.org
Subject: Re: [antlr-interest] C target help

On Mon, 15 Dec 2008 15:10:31 -0800, Ilyevsky, Leonid (Equity Trading)  
<Leonid_Ilyevsky at ml.com> wrote:

> Jim,
>
> Just few more questions.
> I looked at your example in main.c, and it seems I can follow the
story
> there.
> Except that I would like some more details around the end of it.
> After you invoke the parser
>
> 	psr->translation_unit(psr);
>
> You say that we can finish there, and this is what I don't quite

Look at the tree parsing examples, or the polydiff example.

Jim

------------------------------------------------------------------------
--
This message w/attachments (message) may be privileged, confidential or
proprietary, and if you are not an intended recipient, please notify the
sender, do not use or share it and delete it. Unless specifically
indicated, this message is not an offer to sell or a solicitation of any
investment products or other financial product or service, an official
confirmation of any transaction, or an official statement of Merrill
Lynch. Subject to applicable law, Merrill Lynch may monitor, review and
retain e-communications (EC) traveling through its networks/systems. The
laws of the country of each sender/recipient may impact the handling of
EC, and EC may be archived, supervised and produced in countries other
than the country in which you are located. This message cannot be
guaranteed to be secure or error-free. This message is subject to terms
available at the following link:
http://www.ml.com/e-communications_terms/. By messaging with Merrill
Lynch you consent to the foregoing.
------------------------------------------------------------------------
--
 

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-addr
ess



More information about the antlr-interest mailing list