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: Tim Landscheidt
Subject: Re: Java parser throws ArrayIndexOutOfBoundsException if first token leads to syntax error
Date: Mon, 13 Feb 2012 23:19:50 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Akim Demaille <address@hidden> wrote:

>>>>            /* 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.

Ah, okay.

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

Well, you'd have to ask Paolo for the reasoning behind
that :-).

>> 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 :).

I meant the Java one.

Tim




reply via email to

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