Merge pull request #2123 from ewanmellor/swift-fix-parse-cancellation

[Swift] Fix parse-cancellation in BailErrorStrategy.
This commit is contained in:
Terence Parr 2017-11-29 09:56:09 -08:00 committed by GitHub
commit b5e6147cd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 8 deletions

View File

@ -290,8 +290,6 @@ public class BaseSwiftTest implements RuntimeTestSupport {
"let tree = try parser.<parserStartRuleName>()\n" +
"<if(profile)>print(profiler.getDecisionInfo().description)<endif>\n" +
"try ParseTreeWalker.DEFAULT.walk(TreeShapeListener(), tree)\n" +
"}catch ANTLRException.cannotInvokeStartRule {\n" +
" print(\"error occur: cannotInvokeStartRule\")\n" +
"}catch ANTLRException.recognition(let e ) {\n" +
" print(\"error occur\\(e)\")\n" +
"}catch {\n" +
@ -333,8 +331,6 @@ public class BaseSwiftTest implements RuntimeTestSupport {
"do {\n" +
" try tokens.fill()\n" +
"} catch ANTLRException.cannotInvokeStartRule {\n" +
" print(\"error occur: cannotInvokeStartRule\")\n" +
"} catch ANTLRException.recognition(let e ) {\n" +
" print(\"error occur\\(e)\")\n" +
"} catch {\n" +

View File

@ -49,7 +49,7 @@ open class BailErrorStrategy: DefaultErrorStrategy {
context = (contextWrap.getParent() as? ParserRuleContext)
}
throw ANTLRException.recognition(e: e)
throw ANTLRException.parseCancellation(e: e)
}
///
@ -65,7 +65,7 @@ open class BailErrorStrategy: DefaultErrorStrategy {
context = (contextWrap.getParent() as? ParserRuleContext)
}
throw ANTLRException.recognition(e: e)
throw ANTLRException.parseCancellation(e: e)
}
///

View File

@ -19,5 +19,4 @@ public enum ANTLRError: Error {
case illegalState(msg:String)
case illegalArgument(msg:String)
case negativeArraySize(msg:String)
case parseCancellation
}

View File

@ -15,6 +15,6 @@
import Foundation
public enum ANTLRException: Error {
case cannotInvokeStartRule
case parseCancellation(e: RecognitionException)
case recognition(e: RecognitionException)
}