chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1615153 - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main: antlr3/org/apache/chemistry/opencmis/server/support/query/ java/org/apache/chemistry/opencmis/server/support/query/
Date Fri, 01 Aug 2014 15:49:51 GMT
Author: jens
Date: Fri Aug  1 15:49:51 2014
New Revision: 1615153

URL: http://svn.apache.org/r1615153
Log:
Prevent AntLR lexer errors to appear on stderr and introduce getErrors() method as in parser.

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisBaseLexer.g
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQlExtLexer.g
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQlStrictLexer.g
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtil.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtilStrict.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisBaseLexer.g
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisBaseLexer.g?rev=1615153&r1=1615152&r2=1615153&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisBaseLexer.g
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisBaseLexer.g
Fri Aug  1 15:49:51 2014
@@ -42,6 +42,29 @@ tokens {
     ORDER_BY;
 }
 
+@members {
+    private List<String> errorMessages = new ArrayList<String>();
+    
+    public boolean hasErrors() {
+    	return errorMessages.size() > 0;
+    }
+
+	public String getErrorMessages() {
+		StringBuffer allMessages = new StringBuffer();
+		
+		for (String msg : errorMessages)
+			allMessages.append(msg).append('\n');
+			
+		return allMessages.toString();
+	}
+
+    @Override
+    // Instead of sending all errors to System.err collect them in a list
+	public void emitErrorMessage(String msg) {
+		errorMessages.add(msg);
+	}
+	
+}
 
 // ----- Generic SQL -----
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQlExtLexer.g
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQlExtLexer.g?rev=1615153&r1=1615152&r2=1615153&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQlExtLexer.g
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQlExtLexer.g
Fri Aug  1 15:49:51 2014
@@ -63,4 +63,17 @@ package org.apache.chemistry.opencmis.se
 
 }
 
+@members {
+    public boolean hasErrors() {
+    	return gCmisBaseLexer.hasErrors();
+    }
+
+	public String getErrorMessages() {
+    	return gCmisBaseLexer.getErrorMessages();
+	}
+
+	public void emitErrorMessage(String msg) {
+    	gCmisBaseLexer.emitErrorMessage(msg);
+	}
+}
 DISTINCT : ('D'|'d')('I'|'i')('S'|'s')('T'|'t')('I'|'i')('N'|'n')('C'|'c')('T'|'t');

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQlStrictLexer.g
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQlStrictLexer.g?rev=1615153&r1=1615152&r2=1615153&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQlStrictLexer.g
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQlStrictLexer.g
Fri Aug  1 15:49:51 2014
@@ -56,6 +56,20 @@ import CmisBaseLexer;
 package org.apache.chemistry.opencmis.server.support.query;
 }
 
+@members {
+    public boolean hasErrors() {
+    	return gCmisBaseLexer.hasErrors();
+    }
+
+	public String getErrorMessages() {
+    	return gCmisBaseLexer.getErrorMessages();
+	}
+	
+	public void emitErrorMessage(String msg) {
+    	gCmisBaseLexer.emitErrorMessage(msg);
+	}
+}
+
 // all lexer rules for a strict CMIS parser are in the base lexer defined
 
 // we need a dummy rule to make AntLR happy (an empty file will not compile)

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtil.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtil.java?rev=1615153&r1=1615152&r2=1615153&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtil.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtil.java
Fri Aug  1 15:49:51 2014
@@ -72,13 +72,15 @@ public class QueryUtil extends QueryUtil
      */
     public static CmisQueryWalker getWalker(String statement) throws RecognitionException
{
         CharStream input = new ANTLRStringStream(statement);
-        TokenSource lexer = new CmisQlStrictLexer(input);
+        CmisQlStrictLexer lexer = new CmisQlStrictLexer(input);
         TokenStream tokens = new CommonTokenStream(lexer);
         CmisQlStrictParser parser = new CmisQlStrictParser(tokens);
         CommonTree parserTree; // the ANTLR tree after parsing phase
 
         query_return parsedStatement = parser.query();
-        if (parser.hasErrors()) {
+        if (lexer.hasErrors()) {
+            throw new CmisInvalidArgumentException(lexer.getErrorMessages());
+        } else if (parser.hasErrors()) {
             throw new CmisInvalidArgumentException(parser.getErrorMessages());
         } else if ( tokens.index()!=tokens.size() ) {
             throw new  CmisInvalidArgumentException("Query String has illegal tokens after
end of statement: " + tokens.get(tokens.index()));

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtilStrict.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtilStrict.java?rev=1615153&r1=1615152&r2=1615153&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtilStrict.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtilStrict.java
Fri Aug  1 15:49:51 2014
@@ -50,12 +50,14 @@ public class QueryUtilStrict extends Que
     @Override
     public CommonTree parseStatement() throws RecognitionException {
         CharStream input = new ANTLRStringStream(statement);
-        TokenSource lexer = new CmisQlStrictLexer(input);
+        CmisQlStrictLexer lexer = new CmisQlStrictLexer(input);
         tokens = new CommonTokenStream(lexer);
         CmisQlStrictParser parser = new CmisQlStrictParser(tokens);
 
         query_return parsedStatement = parser.query();
-        if (parser.hasErrors()) {
+        if (lexer.hasErrors()) {
+            throw new CmisInvalidArgumentException(lexer.getErrorMessages());
+        } else if (parser.hasErrors()) {
             throw new CmisInvalidArgumentException(parser.getErrorMessages());
         }
 



Mime
View raw message