[exo-jcr-commits] exo-jcr SVN: r2263 - jcr/trunk/exo.jcr.component.core/src/main/javacc/sql.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Apr 12 02:45:09 EDT 2010


Author: sergiykarpenko
Date: 2010-04-12 02:45:08 -0400 (Mon, 12 Apr 2010)
New Revision: 2263

Modified:
   jcr/trunk/exo.jcr.component.core/src/main/javacc/sql/JCRSQL.jjt
Log:
EXOJCR-498: TokenMgrError is wrapped by ParseException with new message.

Modified: jcr/trunk/exo.jcr.component.core/src/main/javacc/sql/JCRSQL.jjt
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/javacc/sql/JCRSQL.jjt	2010-04-09 15:21:21 UTC (rev 2262)
+++ jcr/trunk/exo.jcr.component.core/src/main/javacc/sql/JCRSQL.jjt	2010-04-12 06:45:08 UTC (rev 2263)
@@ -75,6 +75,30 @@
 //        this.resolver = resolver;
 //  } 
 
+  void handleTokenMgrError(TokenMgrError e) throws ParseException{
+    if (e.errorCode == e.LEXICAL_ERROR)
+    {
+      StringBuffer sb = new StringBuffer();
+      try
+      {
+        char c;
+        while ((c = token_source.input_stream.readChar()) != ' ')
+        {
+          sb.append(c);
+        }
+      }
+      catch (java.io.IOException ioe)
+      {
+        // probably EOF occurs, but any way, do not report this exceptions 
+      }
+
+      throw new ParseException("Unknown Query Construction : \"" + sb.toString() + "\". " + e.getMessage());
+    }
+    else
+    {
+      throw e;
+    }
+  }
 }
 
 PARSER_END(JCRSQLParser)
@@ -269,11 +293,18 @@
 ASTQuery Query() :
 {}
 {
+  try{
+
   <SELECT>
   SelectList()
   TableExpression()
   [ OrderByClause() ]
   <EOF>
+  
+  }catch(TokenMgrError e){
+    handleTokenMgrError(e);
+  }
+  
   { return jjtThis; }
 }
 



More information about the exo-jcr-commits mailing list