]> source.dussan.org Git - poi.git/commitdiff
Bug 45025 - improved FormulaParser parse error messages (r659452 had wrong bug number)
authorJosh Micich <josh@apache.org>
Fri, 23 May 2008 06:54:46 +0000 (06:54 +0000)
committerJosh Micich <josh@apache.org>
Fri, 23 May 2008 06:54:46 +0000 (06:54 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@659455 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/changes.xml
src/documentation/content/xdocs/status.xml
src/java/org/apache/poi/hssf/model/FormulaParser.java
src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java

index 720cce08082bce8d5db5d2fc48761f8e5aac2d55..b36ccbffa9e9d2ad4414c7e601ab1cc00c219b48 100644 (file)
@@ -37,7 +37,7 @@
 
                <!-- Don't forget to update status.xml too! -->
         <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">45066 - fixed sheet encoding size mismatch problems</action>
            <action dev="POI-DEVELOPERS" type="add">45003 - Support embeded HDGF visio documents</action>
index e68afab26857fa6da52c4d3776a59ce2e37bc58d..1b37e157cd06dcb0085760f21d3182a8b2a241c6 100644 (file)
@@ -34,7 +34,7 @@
        <!-- Don't forget to update changes.xml too! -->
     <changes>
         <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">45066 - fixed sheet encoding size mismatch problems</action>
            <action dev="POI-DEVELOPERS" type="add">45003 - Support embeded HDGF visio documents</action>
index c32df9396bd1ffa2f4835800f8457578b1edc3f2..b6c711729045474abbbf2177b6c5dc3cada542b9 100644 (file)
@@ -140,29 +140,21 @@ public final class FormulaParser {
         return new FormulaParseException(msg);
     }
 
-
-
     /** Recognize an Alpha Character */
     private boolean IsAlpha(char c) {
         return Character.isLetter(c) || c == '$' || c=='_';
     }
 
-
-
     /** Recognize a Decimal Digit */
     private boolean IsDigit(char c) {
-        //System.out.println("Checking digit for"+c);
         return Character.isDigit(c);
     }
 
-
-
     /** Recognize an Alphanumeric */
     private boolean  IsAlNum(char c) {
         return  (IsAlpha(c) || IsDigit(c));
     }
 
-
     /** Recognize White Space */
     private boolean IsWhite( char c) {
         return  (c ==' ' || c== TAB);
@@ -218,7 +210,6 @@ public final class FormulaParser {
         return Token.toString();
     }
 
-
     /** Get a Number */
     private String GetNum() {
         StringBuffer value = new StringBuffer();
@@ -564,9 +555,6 @@ public final class FormulaParser {
                 return new ParenthesisPtg();
             case '"':
                 return parseStringLiteral();
-            case ',':
-            case ')':
-                return new MissingArgPtg(); // TODO - not quite the right place to recognise a missing arg
         }
         if (IsAlpha(look) || look == '\''){
             return parseIdent();
@@ -710,8 +698,7 @@ public final class FormulaParser {
     }
 
 
-    private StringPtg parseStringLiteral()
-    {
+    private StringPtg parseStringLiteral() {
         Match('"');
 
         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() {
         pointer=0;
@@ -866,11 +854,12 @@ end;
      * a result of the parsing
      */
     public Ptg[] getRPNPtg() {
-     return getRPNPtg(FORMULA_TYPE_CELL);
+        return getRPNPtg(FORMULA_TYPE_CELL);
     }
 
     public Ptg[] getRPNPtg(int formulaType) {
         Node node = createTree();
+        // RVA is for 'operand class': 'reference', 'value', 'array'
         setRootLevelRVA(node, formulaType);
         setParameterRVA(node,formulaType);
         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.
      * @param book   workbook for 3D and named references
      * @param lptgs  list of Ptg, can be null or empty
@@ -966,7 +955,7 @@ end;
         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
      *  workbook for 3D and named references
      * @param lptgs  list of Ptg, can be null or empty
index f4d6d626924695ce2b3fdb133ed21e23cf7ac2bf..f2821140f3c325ae6cfdaac482463a9539635b12 100644 (file)
@@ -55,9 +55,7 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 
 /**
  * Test the low level formula parser functionality. High level tests are to
- *  be done via usermodel/HSSFCell.setFormulaValue() .
- * Some tests are also done in scratchpad, if they need
- *  HSSFFormulaEvaluator, which is there
+ * be done via usermodel/HSSFCell.setFormulaValue().
  */
 public final class TestFormulaParser extends TestCase {
 
@@ -76,6 +74,7 @@ public final class TestFormulaParser extends TestCase {
                Ptg[] ptgs = parseFormula("2+2");
                assertEquals(3, ptgs.length);
        }
+
        public void testFormulaWithSpace1() {
                Ptg[] ptgs = parseFormula(" 2 + 2 ");
                assertEquals(3, ptgs.length);