Revision: 1891
          http://svn.sourceforge.net/vexi/?rev=1891&view=rev
Author:   mkpg2
Date:     2007-06-28 10:52:52 -0700 (Thu, 28 Jun 2007)

Log Message:
-----------
Backporting line number fix.

Modified Paths:
--------------
    core/branches/PRE_GRIDBOX_REMOVAL/org.ibex.js/src/org/ibex/js/Lexer.jpp

Modified: 
core/branches/PRE_GRIDBOX_REMOVAL/org.ibex.js/src/org/ibex/js/Lexer.jpp
===================================================================
--- core/branches/PRE_GRIDBOX_REMOVAL/org.ibex.js/src/org/ibex/js/Lexer.jpp     
2007-06-28 17:36:20 UTC (rev 1890)
+++ core/branches/PRE_GRIDBOX_REMOVAL/org.ibex.js/src/org/ibex/js/Lexer.jpp     
2007-06-28 17:52:52 UTC (rev 1891)
@@ -354,7 +354,8 @@
     private int pushBackDepth = 0;
     private int[] pushBackInts = new int[10];
     private Object[] pushBackObjects = new Object[10];
-
+    private int[] pushBackLines = new int[10];
+    
     /** push back a token */
     public final void pushBackToken(int op, Object obj) {
         if (pushBackDepth >= pushBackInts.length - 1) {
@@ -364,9 +365,16 @@
             Object[] newObjects = new Object[pushBackObjects.length * 2];
             System.arraycopy(pushBackObjects, 0, newObjects, 0, 
pushBackObjects.length);
             pushBackObjects = newObjects;
+            int[] newLines = new int[pushBackLines.length * 2];
+            System.arraycopy(pushBackLines, 0, newInts, 0, 
pushBackLines.length);
+            pushBackLines = newLines;
         }
         pushBackInts[pushBackDepth] = op;
         pushBackObjects[pushBackDepth] = obj;
+        // REMARK - do we really need to remember every line number? We have
+        // pushBackLines[0] == line. This would be enough to fix the line
+        // numbering of statements that aren't properly terminated with a ;
+        pushBackLines[pushBackDepth] = parserLine;
         pushBackDepth++;
     }
 
@@ -394,6 +402,11 @@
             number = pushBackObjects[pushBackDepth] instanceof Number ? 
(Number)pushBackObjects[pushBackDepth] : null;
             string = pushBackObjects[pushBackDepth] instanceof String ? 
(String)pushBackObjects[pushBackDepth] : null;
         }
+        // REMARK - pushBackLines[0]==line. This would be enough to have 
correct
+        // line numbers for unterminated statements (no ;). Possibly we don't 
need to
+        // remember the ln of every pushedBack token (??). Not inviting edge 
cases
+        // and doing it anyway.
+        parserLine = pushBackLines[pushBackDepth];
         return op;
     }
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to