bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Java parser throws ArrayIndexOutOfBoundsException if first token lea


From: Akim Demaille
Subject: Re: Java parser throws ArrayIndexOutOfBoundsException if first token leads to syntax error
Date: Mon, 13 Feb 2012 17:43:27 +0100

Le 13 févr. 2012 à 17:29, Tim Landscheidt a écrit :

>>>            /* Pop the current state because it cannot handle the error 
>>> token.  */
>>> -            if (yystack.height == 1)
>>> +            if (yystack.height == 0)
> 
>> Is this O(1)?  We keep the height of the stack up to
>> date ourselves?  I'm surprised we don't rely on some
>> Java container to do this for us.
> 
> What do you mean by O(1) in this case?

In C++ that's a typical case where list.size() == 0 is
a bad idea, since it costs a full traversal of the list
to compute its length, while list.empty() is immediate.

But here it appears that we deal with the length of the
stack by hand, which is OK, but surprised me.

> The parser logic
> here is shared with the C++ skeleton (and yacc.c looks
> similar as well).  The stack implementation doesn't look
> very frightening performance-wise.

That the stacks needs to be implemented by hand in C is
no surprise :).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]