@@ -5,9 +5,10 @@ extension Compiler {
55 var options : MatchingOptions
66 var builder = _MatchingEngine. Program< String> . Builder( )
77
8- mutating func finish( ) -> _MatchingEngine . Program < String > {
8+ mutating func finish(
9+ ) throws -> _MatchingEngine . Program < String > {
910 builder. buildAccept ( )
10- return builder. assemble ( )
11+ return try builder. assemble ( )
1112 }
1213 }
1314}
@@ -90,7 +91,7 @@ extension Compiler.ByteCodeGen {
9091
9192 case . resetStartOfMatch:
9293 // FIXME: Figure out how to communicate this out
93- throw unsupported ( #"\K (reset/keep assertion)"# )
94+ throw Unsupported ( #"\K (reset/keep assertion)"# )
9495
9596 case . firstMatchingPositionInSubject:
9697 // TODO: We can probably build a nice model with API here
@@ -100,11 +101,11 @@ extension Compiler.ByteCodeGen {
100101
101102 case . textSegment:
102103 // This we should be able to do!
103- throw unsupported ( #"\y (text segment)"# )
104+ throw Unsupported ( #"\y (text segment)"# )
104105
105106 case . notTextSegment:
106107 // This we should be able to do!
107- throw unsupported ( #"\Y (not text segment)"# )
108+ throw Unsupported ( #"\Y (not text segment)"# )
108109
109110 case . startOfLine:
110111 builder. buildAssert { ( input, pos, bounds) in
@@ -204,7 +205,7 @@ extension Compiler.ByteCodeGen {
204205 _ child: DSLTree . Node
205206 ) throws {
206207 guard kind. forwards else {
207- throw unsupported ( " backwards assertions " )
208+ throw Unsupported ( " backwards assertions " )
208209 }
209210
210211 let positive = kind. positive
@@ -259,7 +260,7 @@ extension Compiler.ByteCodeGen {
259260 switch kind {
260261 case . lookahead, . negativeLookahead,
261262 . lookbehind, . negativeLookbehind:
262- fatalError ( " unreachable " )
263+ throw Unreachable ( " TODO: reason " )
263264
264265 case . capture, . namedCapture:
265266 let cap = builder. makeCapture ( )
@@ -299,7 +300,7 @@ extension Compiler.ByteCodeGen {
299300 // Ok
300301 break
301302 default :
302- fatalError ( " unreachable? " )
303+ throw Unreachable ( " TODO: reason " )
303304 }
304305
305306 // Compiler and/or parser should enforce these invariants
0 commit comments