Repository: groovy
Updated Branches:
  refs/heads/master c123dc365 -> b17fc4dbf


Convert antlr exceptions into CompilationFailedException


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/b17fc4db
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/b17fc4db
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/b17fc4db

Branch: refs/heads/master
Commit: b17fc4dbf6232054f8461f63b7edf66d39a2204c
Parents: c123dc3
Author: sunlan <sun...@apache.org>
Authored: Mon Aug 7 12:50:40 2017 +0800
Committer: sunlan <sun...@apache.org>
Committed: Mon Aug 7 12:50:40 2017 +0800

----------------------------------------------------------------------
 .../apache/groovy/parser/antlr4/AstBuilder.java | 28 +++++++++++---------
 1 file changed, 16 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/b17fc4db/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
----------------------------------------------------------------------
diff --git 
a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
 
b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
index f980110..dbe9c43 100644
--- 
a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
+++ 
b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
@@ -171,22 +171,26 @@ public class AstBuilder extends 
GroovyParserBaseVisitor<Object> implements Groov
         this.groovydocManager = new GroovydocManager(this);
     }
 
-    private GroovyParserRuleContext buildCST() {
+    private GroovyParserRuleContext buildCST() throws 
CompilationFailedException {
         GroovyParserRuleContext result;
 
-        // parsing have to wait util clearing is complete.
-        AtnManager.RRWL.readLock().lock();
         try {
-            result = buildCST(PredictionMode.SLL);
-        } catch (Throwable t) {
-            // if some syntax error occurred in the lexer, no need to retry 
the powerful LL mode
-            if (t instanceof GroovySyntaxError && GroovySyntaxError.LEXER == 
((GroovySyntaxError) t).getSource()) {
-                throw t;
-            }
+            // parsing have to wait util clearing is complete.
+            AtnManager.RRWL.readLock().lock();
+            try {
+                result = buildCST(PredictionMode.SLL);
+            } catch (Throwable t) {
+                // if some syntax error occurred in the lexer, no need to 
retry the powerful LL mode
+                if (t instanceof GroovySyntaxError && GroovySyntaxError.LEXER 
== ((GroovySyntaxError) t).getSource()) {
+                    throw t;
+                }
 
-            result = buildCST(PredictionMode.LL);
-        } finally {
-            AtnManager.RRWL.readLock().unlock();
+                result = buildCST(PredictionMode.LL);
+            } finally {
+                AtnManager.RRWL.readLock().unlock();
+            }
+        } catch (Throwable t) {
+            throw createParsingFailedException(t);
         }
 
         return result;

Reply via email to