Bug 45041 - improved FormulaParser parse error messages

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@659452 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2008-05-23 06:43:51 +00:00
parent c8c2d0139e
commit 71418f099d
4 changed files with 767 additions and 821 deletions

View File

@ -37,6 +37,7 @@
<!-- Don't forget to update status.xml too! --> <!-- Don't forget to update status.xml too! -->
<release version="3.1-final" date="2008-06-??"> <release version="3.1-final" date="2008-06-??">
<action dev="POI-DEVELOPERS" type="add">45041 - improved FormulaParser parse error messages</action>
<action dev="POI-DEVELOPERS" type="add">45046 - allowed EXTERNALBOOK(0x01AE) to be optional in the LinkTable</action> <action dev="POI-DEVELOPERS" type="add">45046 - allowed EXTERNALBOOK(0x01AE) to be optional in the LinkTable</action>
<action dev="POI-DEVELOPERS" type="add">45066 - fixed sheet encoding size mismatch problems</action> <action dev="POI-DEVELOPERS" type="add">45066 - fixed sheet encoding size mismatch problems</action>
<action dev="POI-DEVELOPERS" type="add">45003 - Support embeded HDGF visio documents</action> <action dev="POI-DEVELOPERS" type="add">45003 - Support embeded HDGF visio documents</action>

View File

@ -34,6 +34,7 @@
<!-- Don't forget to update changes.xml too! --> <!-- Don't forget to update changes.xml too! -->
<changes> <changes>
<release version="3.1-final" date="2008-06-??"> <release version="3.1-final" date="2008-06-??">
<action dev="POI-DEVELOPERS" type="add">45041 - improved FormulaParser parse error messages</action>
<action dev="POI-DEVELOPERS" type="add">45046 - allowed EXTERNALBOOK(0x01AE) to be optional in the LinkTable</action> <action dev="POI-DEVELOPERS" type="add">45046 - allowed EXTERNALBOOK(0x01AE) to be optional in the LinkTable</action>
<action dev="POI-DEVELOPERS" type="add">45066 - fixed sheet encoding size mismatch problems</action> <action dev="POI-DEVELOPERS" type="add">45066 - fixed sheet encoding size mismatch problems</action>
<action dev="POI-DEVELOPERS" type="add">45003 - Support embeded HDGF visio documents</action> <action dev="POI-DEVELOPERS" type="add">45003 - Support embeded HDGF visio documents</action>

View File

@ -134,7 +134,7 @@ public final class FormulaParser {
/** Report What Was Expected */ /** Report What Was Expected */
private RuntimeException expected(String s) { private RuntimeException expected(String s) {
String msg = "Parse error near char " + (pointer-1) + "'" + look + "'" String msg = "Parse error near char " + (pointer-1) + " '" + look + "'"
+ " in specified formula '" + formulaString + "'. Expected " + " in specified formula '" + formulaString + "'. Expected "
+ s; + s;
return new FormulaParseException(msg); return new FormulaParseException(msg);
@ -288,7 +288,7 @@ public final class FormulaParser {
for(int i = 0; i < book.getNumberOfNames(); i++) { for(int i = 0; i < book.getNumberOfNames(); i++) {
// named range name matching is case insensitive // named range name matching is case insensitive
if(book.getNameAt(i).getNameName().equalsIgnoreCase(name)) { if(book.getNameAt(i).getNameName().equalsIgnoreCase(name)) {
return new NamePtg(name, book); return new NamePtg(name, book);
} }
} }
@ -486,17 +486,16 @@ public final class FormulaParser {
} }
boolean missedPrevArg = true; boolean missedPrevArg = true;
int numArgs = 0; int numArgs = 0;
while(true) { while (true) {
SkipWhite(); SkipWhite();
if(isArgumentDelimiter(look)) { if (isArgumentDelimiter(look)) {
if(missedPrevArg) { if (missedPrevArg) {
tokens.add(new MissingArgPtg()); tokens.add(new MissingArgPtg());
addArgumentPointer(argumentPointers); addArgumentPointer(argumentPointers);
numArgs++; numArgs++;
} }
if(look == ')') { if (look == ')') {
break; break;
} }
Match(','); Match(',');
@ -507,6 +506,10 @@ public final class FormulaParser {
addArgumentPointer(argumentPointers); addArgumentPointer(argumentPointers);
numArgs++; numArgs++;
missedPrevArg = false; missedPrevArg = false;
SkipWhite();
if (!isArgumentDelimiter(look)) {
throw expected("',' or ')'");
}
} }
return numArgs; return numArgs;
} }

File diff suppressed because it is too large Load Diff