Bug 45025 - improved FormulaParser parse error messages (r659452 had wrong bug number)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@659455 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dc3f6b36b8
commit
a4aab681a7
@ -37,7 +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">45025 - 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>
|
||||||
|
@ -34,7 +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">45025 - 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>
|
||||||
|
@ -140,29 +140,21 @@ public final class FormulaParser {
|
|||||||
return new FormulaParseException(msg);
|
return new FormulaParseException(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Recognize an Alpha Character */
|
/** Recognize an Alpha Character */
|
||||||
private boolean IsAlpha(char c) {
|
private boolean IsAlpha(char c) {
|
||||||
return Character.isLetter(c) || c == '$' || c=='_';
|
return Character.isLetter(c) || c == '$' || c=='_';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Recognize a Decimal Digit */
|
/** Recognize a Decimal Digit */
|
||||||
private boolean IsDigit(char c) {
|
private boolean IsDigit(char c) {
|
||||||
//System.out.println("Checking digit for"+c);
|
|
||||||
return Character.isDigit(c);
|
return Character.isDigit(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Recognize an Alphanumeric */
|
/** Recognize an Alphanumeric */
|
||||||
private boolean IsAlNum(char c) {
|
private boolean IsAlNum(char c) {
|
||||||
return (IsAlpha(c) || IsDigit(c));
|
return (IsAlpha(c) || IsDigit(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Recognize White Space */
|
/** Recognize White Space */
|
||||||
private boolean IsWhite( char c) {
|
private boolean IsWhite( char c) {
|
||||||
return (c ==' ' || c== TAB);
|
return (c ==' ' || c== TAB);
|
||||||
@ -218,7 +210,6 @@ public final class FormulaParser {
|
|||||||
return Token.toString();
|
return Token.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Get a Number */
|
/** Get a Number */
|
||||||
private String GetNum() {
|
private String GetNum() {
|
||||||
StringBuffer value = new StringBuffer();
|
StringBuffer value = new StringBuffer();
|
||||||
@ -564,9 +555,6 @@ public final class FormulaParser {
|
|||||||
return new ParenthesisPtg();
|
return new ParenthesisPtg();
|
||||||
case '"':
|
case '"':
|
||||||
return parseStringLiteral();
|
return parseStringLiteral();
|
||||||
case ',':
|
|
||||||
case ')':
|
|
||||||
return new MissingArgPtg(); // TODO - not quite the right place to recognise a missing arg
|
|
||||||
}
|
}
|
||||||
if (IsAlpha(look) || look == '\''){
|
if (IsAlpha(look) || look == '\''){
|
||||||
return parseIdent();
|
return parseIdent();
|
||||||
@ -710,8 +698,7 @@ public final class FormulaParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private StringPtg parseStringLiteral()
|
private StringPtg parseStringLiteral() {
|
||||||
{
|
|
||||||
Match('"');
|
Match('"');
|
||||||
|
|
||||||
StringBuffer token = new StringBuffer();
|
StringBuffer token = new StringBuffer();
|
||||||
@ -841,8 +828,9 @@ end;
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
/** API call to execute the parsing of the formula
|
/**
|
||||||
*
|
* API call to execute the parsing of the formula
|
||||||
|
* @deprecated use Ptg[] FormulaParser.parse(String, HSSFWorkbook) directly
|
||||||
*/
|
*/
|
||||||
public void parse() {
|
public void parse() {
|
||||||
pointer=0;
|
pointer=0;
|
||||||
@ -871,6 +859,7 @@ end;
|
|||||||
|
|
||||||
public Ptg[] getRPNPtg(int formulaType) {
|
public Ptg[] getRPNPtg(int formulaType) {
|
||||||
Node node = createTree();
|
Node node = createTree();
|
||||||
|
// RVA is for 'operand class': 'reference', 'value', 'array'
|
||||||
setRootLevelRVA(node, formulaType);
|
setRootLevelRVA(node, formulaType);
|
||||||
setParameterRVA(node,formulaType);
|
setParameterRVA(node,formulaType);
|
||||||
return (Ptg[]) tokens.toArray(new Ptg[0]);
|
return (Ptg[]) tokens.toArray(new Ptg[0]);
|
||||||
@ -951,7 +940,7 @@ end;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Convience method which takes in a list then passes it to the
|
* Convenience method which takes in a list then passes it to the
|
||||||
* other toFormulaString signature.
|
* other toFormulaString signature.
|
||||||
* @param book workbook for 3D and named references
|
* @param book workbook for 3D and named references
|
||||||
* @param lptgs list of Ptg, can be null or empty
|
* @param lptgs list of Ptg, can be null or empty
|
||||||
@ -966,7 +955,7 @@ end;
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Convience method which takes in a list then passes it to the
|
* Convenience method which takes in a list then passes it to the
|
||||||
* other toFormulaString signature. Works on the current
|
* other toFormulaString signature. Works on the current
|
||||||
* workbook for 3D and named references
|
* workbook for 3D and named references
|
||||||
* @param lptgs list of Ptg, can be null or empty
|
* @param lptgs list of Ptg, can be null or empty
|
||||||
|
@ -56,8 +56,6 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|||||||
/**
|
/**
|
||||||
* Test the low level formula parser functionality. High level tests are to
|
* Test the low level formula parser functionality. High level tests are to
|
||||||
* be done via usermodel/HSSFCell.setFormulaValue().
|
* be done via usermodel/HSSFCell.setFormulaValue().
|
||||||
* Some tests are also done in scratchpad, if they need
|
|
||||||
* HSSFFormulaEvaluator, which is there
|
|
||||||
*/
|
*/
|
||||||
public final class TestFormulaParser extends TestCase {
|
public final class TestFormulaParser extends TestCase {
|
||||||
|
|
||||||
@ -76,6 +74,7 @@ public final class TestFormulaParser extends TestCase {
|
|||||||
Ptg[] ptgs = parseFormula("2+2");
|
Ptg[] ptgs = parseFormula("2+2");
|
||||||
assertEquals(3, ptgs.length);
|
assertEquals(3, ptgs.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFormulaWithSpace1() {
|
public void testFormulaWithSpace1() {
|
||||||
Ptg[] ptgs = parseFormula(" 2 + 2 ");
|
Ptg[] ptgs = parseFormula(" 2 + 2 ");
|
||||||
assertEquals(3, ptgs.length);
|
assertEquals(3, ptgs.length);
|
||||||
|
Loading…
Reference in New Issue
Block a user