manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1163054 - /incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java
Date Mon, 29 Aug 2011 23:50:26 GMT
Author: kwright
Date: Mon Aug 29 23:50:26 2011
New Revision: 1163054

URL: http://svn.apache.org/viewvc?rev=1163054&view=rev
Log:
Fix issue with break outside of loop not getting reported.

Modified:
    incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java

Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java?rev=1163054&r1=1163053&r2=1163054&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java
(original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java
Mon Aug 29 23:50:26 2011
@@ -66,7 +66,18 @@ public class ScriptParser
     cvr.setReference(v);
     context.put(variableName,cvr);
   }
-  
+
+  /** Execute script. */
+  public void execute(TokenStream currentStream)
+    throws ScriptException
+  {
+    if (parseStatements(currentStream))
+      localError(currentStream,"Break command must be inside a loop");
+    Token t = currentStream.peek();
+    if (t != null)
+      t.throwException("Characters after end of script");
+  }
+
   // Statement return codes
   protected static final int STATEMENT_NOTME = 0;
   protected static final int STATEMENT_ISME = 1;
@@ -1166,10 +1177,7 @@ public class ScriptParser
         }
         sp.addVariable("__args__",va);
         TokenStream ts = new BasicTokenStream(reader);
-        sp.parseStatements(ts);
-        Token t = ts.peek();
-        if (t != null)
-          t.throwException("Characters after end of script");
+        sp.execute(ts);
       }
       else
       {
@@ -1177,18 +1185,17 @@ public class ScriptParser
       
         while (true)
         {
+          TokenStream ts = new BasicTokenStream(reader);
           try
           {
-            TokenStream ts = new BasicTokenStream(reader);
-            sp.parseStatements(ts);
-            Token t = ts.peek();
-            if (t != null)
-              t.throwException("Characters after end of script");
+            sp.execute(ts);
             break;
           }
           catch (ScriptException e)
           {
             System.out.println("Error: "+e.getMessage());
+            if (ts.peek() == null)
+              break;
           }
         }
       }



Mime
View raw message