[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Java parser throws ArrayIndexOutOfBoundsException if first token leads t
From: |
Tim Landscheidt |
Subject: |
Java parser throws ArrayIndexOutOfBoundsException if first token leads to syntax error |
Date: |
Wed, 11 Jan 2012 21:59:47 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
Hi,
given the attached grammar, the generated parser throws
java.lang.ArrayIndexOutOfBoundsException if the first token
leads to a syntax error:
| address@hidden ~/src/bison-2.5]$ src/bison --version
| bison (GNU Bison) 2.5
| Written by Robert Corbett and Richard Stallman.
| Copyright (C) 2011 Free Software Foundation, Inc.
| This is free software; see the source for copying conditions. There is NO
| warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
| address@hidden ~/src/bison-2.5]$ BISON_PKGDATADIR=data src/bison java-test.y
| address@hidden ~/src/bison-2.5]$ gcj -o java-test --main=YYParser
java-test.java
| java-test.java:247: warning: The field YYParser.YYRETURN is never read locally
| private static final int YYRETURN = 8;
| ^^^^^^^^
| java-test.java:380: warning: The local variable yyresult is never read
| int yyresult;
| ^^^^^^^^
| java-test.java:745: warning: The field YYParser.yytoken_number_ is never read
locally
| yytoken_number_[] =
| ^^^^^^^^^^^^^^^
| java-test.java:849: warning: The field YYParser.yynnts_ is never read locally
| private static final int yynnts_ = 2;
| ^^^^^^^
| java-test.java:853: warning: The field YYParser.yyerrcode_ is never read
locally
| private static final int yyerrcode_ = 256;
| ^^^^^^^^^^
| 5 problems (5 warnings)
| address@hidden ~/src/bison-2.5]$ ./java-test --
| address@hidden ~/src/bison-2.5]$ ./java-test -+
| syntax error
| address@hidden ~/src/bison-2.5]$ ./java-test +-
| syntax error
| Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
| at YYParser$YYStack.stateAt(java-test)
| at YYParser.parse(java-test)
| at YYParser.main(java-test)
| address@hidden ~/src/bison-2.5]$
This bug also shows up in HEAD.
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 :-).
Tim
java-test.y
Description: Binary data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Java parser throws ArrayIndexOutOfBoundsException if first token leads to syntax error,
Tim Landscheidt <=