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 15:18:39 +0100

Le 12 févr. 2012 à 02:46, Tim Landscheidt a écrit :

hi Tim,

> I wrote:
> 
>> [...]
>>  There is a test for syntax errors on the first token in
>> tests/java.at, but apparently only in combination with an
>> "error" token.  I hope fixing it is easier than isolating
>> it was :-).
> 
> Nope.  Anyway, attached is the fix.  The test case is a bit
> non-hackily lengthy, but I did not want to interlace it in
> the existing suite and subtly break half of them in the
> process.

Thanks for this!

>> From 415333112ba8224264d75164628ca1a173ffb514 Mon Sep 17 00:00:00 2001
> From: Tim Landscheidt <address@hidden>
> Date: Sun, 12 Feb 2012 01:29:41 +0000
> Subject: [PATCH] Java: Fix syntax error handling without error token.
> 
> * data/lalr1.java (YYParser::parse): Here.
> * tests/java.at: Add test case.
> ---
> data/lalr1.java |    2 +-
> tests/java.at   |   67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 68 insertions(+), 1 deletions(-)
> 
> diff --git a/data/lalr1.java b/data/lalr1.java
> index 57ff993..a40d6c2 100644
> --- a/data/lalr1.java
> +++ b/data/lalr1.java
> @@ -686,7 +686,7 @@ m4_popdef([b4_at_dollar])])dnl
>               }
> 
>             /* 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.

>               return false;
> 
>             ]b4_locations_if([yyerrloc = yystack.locationAt (0);])[

The fix is straightforward, but the test suite contribution
does require some paper work.  Could you please follow the
instructions in the attached file?  Thanks in advance!

Attachment: request-assign.future
Description: Binary data



reply via email to

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