Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X 858fb365f -> 65a21bac4


Convert antlr exceptions into CompilationFailedException

(cherry picked from commit b17fc4d)


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

Branch: refs/heads/GROOVY_2_6_X
Commit: 581faad9e70f6c558968786dbd614de14d164b26
Parents: 858fb36
Author: sunlan <sun...@apache.org>
Authored: Mon Aug 7 12:50:40 2017 +0800
Committer: sunlan <sun...@apache.org>
Committed: Mon Aug 7 13:24:37 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/581faad9/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 520e581..ba314b9 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
@@ -169,22 +169,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