]> Git — Sourcephile - haskell/symantic-parser.git/blob - tests/Golden/Splice/G4.expected.txt
!fixup impl: move `liftTypedString` to `Language.Haskell.TH.Show`
[haskell/symantic-parser.git] / tests / Golden / Splice / G4.expected.txt
1 \(input :: inp) ->
2 let !(#
3 initBuffer,
4 initPos,
5 readMore,
6 readNext,
7 append
8 #) =
9 let next buf pos =
10 let !( Data.Text.Unsafe.Iter
11 c
12 d
13 ) = Symantic.Parser.Machine.Input.Text.Buffer.iter buf pos
14 in (# c, pos GHC.Num.+ d #)
15 more buf pos = pos GHC.Classes.< Symantic.Parser.Machine.Input.Text.Buffer.length buf
16 append = Symantic.Parser.Machine.Input.Text.Buffer.pappend
17 in (#
18 Symantic.Parser.Machine.Input.Text.Buffer.buffer input,
19 0,
20 more,
21 next,
22 append
23 #)
24 finalRet = \_farInp _farExp v _inp _buf _end -> Symantic.Parser.Machine.Generate.returnST GHC.Base.$ Symantic.Parser.Machine.Generate.ResultDone v
25 finalRaise :: Symantic.Parser.Machine.Generate.ForallOnException inp =
26 Symantic.Parser.Machine.Generate.ForallOnException GHC.Base.$
27 ( \(!exn) _failInp (!farInp) (!farExp) buf end ->
28 Symantic.Parser.Machine.Generate.returnST GHC.Base.$
29 Symantic.Parser.Machine.Generate.ResultError
30 Symantic.Parser.Machine.Generate.ParsingError
31 { Symantic.Parser.Machine.Generate.parsingErrorOffset = Symantic.Parser.Machine.Input.position farInp,
32 Symantic.Parser.Machine.Generate.parsingErrorException = exn,
33 Symantic.Parser.Machine.Generate.parsingErrorUnexpected =
34 if readMore buf farInp
35 then
36 GHC.Maybe.Just
37 ( let (#
38 c,
39 _
40 #) = readNext buf farInp
41 in c
42 )
43 else GHC.Maybe.Nothing,
44 Symantic.Parser.Machine.Generate.parsingErrorExpecting =
45 let ( minHoriz,
46 res
47 ) =
48 Data.Set.Internal.foldr
49 ( \f
50 ( minH,
51 acc
52 ) -> case Symantic.Parser.Grammar.Combinators.unSomeFailure f of
53 GHC.Maybe.Just (Symantic.Parser.Grammar.Combinators.FailureHorizon h :: Symantic.Parser.Grammar.Combinators.Failure (Symantic.Parser.Grammar.Combinators.CombSatisfiable (Symantic.Parser.Machine.Input.InputToken inp)))
54 | GHC.Maybe.Just old <- minH ->
55 ( GHC.Maybe.Just (GHC.Classes.min old h),
56 acc
57 )
58 | GHC.Base.otherwise ->
59 ( GHC.Maybe.Just h,
60 acc
61 )
62 _ ->
63 ( minH,
64 f GHC.Types.: acc
65 )
66 )
67 ( GHC.Maybe.Nothing,
68 GHC.Types . []
69 )
70 farExp
71 in Data.Set.Internal.fromList GHC.Base.$
72 ( case minHoriz of
73 GHC.Maybe.Just h -> Symantic.Parser.Grammar.Combinators.SomeFailure (Symantic.Parser.Grammar.Combinators.FailureHorizon @(Symantic.Parser.Machine.Input.InputToken inp) h) GHC.Types.: res
74 GHC.Maybe.Nothing -> res
75 )
76 }
77 )
78 in let inputToken = Data.Proxy.Proxy :: Data.Proxy.Proxy (Symantic.Parser.Machine.Input.InputToken inp)
79 in let partialCont buf =
80 let readFail = Symantic.Parser.Machine.Generate.unForallOnException finalRaise
81 in let _ = "checkHorizon.newCheck: checkedHorizon=0 minHoriz=4"
82 in if readMore buf ((GHC.Num.+) @GHC.Types.Int 3 initPos)
83 then
84 let name = \(!callerOnReturn) (!callerInput) (!callerBuffer) (!callerEnd) (!callerOnExceptionStackByLabel) ->
85 let _ = "catch ExceptionFailure checkedHorizon=0"
86 in let onException =
87 let _ = "onException"
88 in \(!_exn) (!failInp) (!farInp) (!farExp) buf end ->
89 let _ = "loadInput checkedHorizon=0"
90 in let _ = "checkHorizon.noCheck"
91 in Data.Map.Strict.Internal.findWithDefault (Symantic.Parser.Machine.Generate.unForallOnException finalRaise) Symantic.Parser.Grammar.Combinators.ExceptionFailure callerOnExceptionStackByLabel Symantic.Parser.Grammar.Combinators.ExceptionFailure callerInput farInp farExp buf end
92 in let _ = "pushValue"
93 in let _ = "comment: satisfy ((GHC.Classes.==) 'a')"
94 in let partialCont buf =
95 let readFail = onException
96 in let _ = "checkHorizon.newCheck: checkedHorizon=0 minHoriz=4"
97 in if readMore buf ((GHC.Num.+) @GHC.Types.Int 3 callerInput)
98 then
99 let _ = "checkToken"
100 in let !(#
101 c,
102 cs
103 #) = readNext buf callerInput
104 in if (GHC.Classes.==) 'a' c
105 then
106 let _ = "lift2Value checkedHorizon=4"
107 in let _ = "comment: satisfy ((GHC.Classes.==) 'b')"
108 in let _ = "checkHorizon.oldCheck: checkedHorizon=4"
109 in let _ = "checkToken"
110 in let !(#
111 c,
112 cs
113 #) = readNext buf cs
114 in if (GHC.Classes.==) 'b' c
115 then
116 let _ = "lift2Value checkedHorizon=3"
117 in let _ = "comment: satisfy ((GHC.Classes.==) 'c')"
118 in let _ = "checkHorizon.oldCheck: checkedHorizon=3"
119 in let _ = "checkToken"
120 in let !(#
121 c,
122 cs
123 #) = readNext buf cs
124 in if (GHC.Classes.==) 'c' c
125 then
126 let _ = "lift2Value checkedHorizon=2"
127 in let _ = "comment: satisfy ((GHC.Classes.==) 'd')"
128 in let _ = "checkHorizon.oldCheck: checkedHorizon=2"
129 in let _ = "checkToken"
130 in let !(#
131 c,
132 cs
133 #) = readNext buf cs
134 in if (GHC.Classes.==) 'd' c
135 then
136 let _ = "lift2Value checkedHorizon=1"
137 in let _ = "commit"
138 in let _ = "resume"
139 in callerOnReturn
140 initPos
141 Data.Set.Internal.empty
142 ( let _ = "resume.genCode"
143 in (GHC.Types.:) 'a' ((GHC.Types.:) 'b' ((GHC.Types.:) 'c' ((GHC.Types.:) 'd' GHC.Types . [])))
144 )
145 cs
146 buf
147 callerEnd
148 else
149 let _ = "checkToken.fail"
150 in let failExp =
151 Data.Set.Internal.Bin
152 1
153 ( Symantic.Parser.Grammar.Combinators.SomeFailure
154 ( case inputToken of
155 (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureToken 'd'
156 )
157 )
158 Data.Set.Internal.Tip
159 Data.Set.Internal.Tip
160 in let (#
161 farInp,
162 farExp
163 #) = case GHC.Classes.compare @GHC.Types.Int initPos cs of
164 GHC.Types.LT ->
165 (#
166 cs,
167 failExp
168 #)
169 GHC.Types.EQ ->
170 (#
171 initPos,
172 failExp GHC.Base.<> Data.Set.Internal.empty
173 #)
174 GHC.Types.GT ->
175 (#
176 initPos,
177 Data.Set.Internal.empty
178 #)
179 in readFail Symantic.Parser.Grammar.Combinators.ExceptionFailure cs farInp farExp buf callerEnd
180 else
181 let _ = "checkToken.fail"
182 in let failExp =
183 Data.Set.Internal.Bin
184 1
185 ( Symantic.Parser.Grammar.Combinators.SomeFailure
186 ( case inputToken of
187 (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureToken 'c'
188 )
189 )
190 Data.Set.Internal.Tip
191 Data.Set.Internal.Tip
192 in let (#
193 farInp,
194 farExp
195 #) = case GHC.Classes.compare @GHC.Types.Int initPos cs of
196 GHC.Types.LT ->
197 (#
198 cs,
199 failExp
200 #)
201 GHC.Types.EQ ->
202 (#
203 initPos,
204 failExp GHC.Base.<> Data.Set.Internal.empty
205 #)
206 GHC.Types.GT ->
207 (#
208 initPos,
209 Data.Set.Internal.empty
210 #)
211 in readFail Symantic.Parser.Grammar.Combinators.ExceptionFailure cs farInp farExp buf callerEnd
212 else
213 let _ = "checkToken.fail"
214 in let failExp =
215 Data.Set.Internal.Bin
216 1
217 ( Symantic.Parser.Grammar.Combinators.SomeFailure
218 ( case inputToken of
219 (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureToken 'b'
220 )
221 )
222 Data.Set.Internal.Tip
223 Data.Set.Internal.Tip
224 in let (#
225 farInp,
226 farExp
227 #) = case GHC.Classes.compare @GHC.Types.Int initPos cs of
228 GHC.Types.LT ->
229 (#
230 cs,
231 failExp
232 #)
233 GHC.Types.EQ ->
234 (#
235 initPos,
236 failExp GHC.Base.<> Data.Set.Internal.empty
237 #)
238 GHC.Types.GT ->
239 (#
240 initPos,
241 Data.Set.Internal.empty
242 #)
243 in readFail Symantic.Parser.Grammar.Combinators.ExceptionFailure cs farInp farExp buf callerEnd
244 else
245 let _ = "checkToken.fail"
246 in let failExp =
247 Data.Set.Internal.Bin
248 1
249 ( Symantic.Parser.Grammar.Combinators.SomeFailure
250 ( case inputToken of
251 (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureToken 'a'
252 )
253 )
254 Data.Set.Internal.Tip
255 Data.Set.Internal.Tip
256 in let (#
257 farInp,
258 farExp
259 #) = case GHC.Classes.compare @GHC.Types.Int initPos callerInput of
260 GHC.Types.LT ->
261 (#
262 callerInput,
263 failExp
264 #)
265 GHC.Types.EQ ->
266 (#
267 initPos,
268 failExp GHC.Base.<> Data.Set.Internal.empty
269 #)
270 GHC.Types.GT ->
271 (#
272 initPos,
273 Data.Set.Internal.empty
274 #)
275 in readFail Symantic.Parser.Grammar.Combinators.ExceptionFailure callerInput farInp farExp buf callerEnd
276 else
277 let _ = "checkHorizon.newCheck.fail"
278 in let noMoreInput =
279 let failExp =
280 Data.Set.Internal.Bin
281 1
282 ( Symantic.Parser.Grammar.Combinators.SomeFailure
283 ( case inputToken of
284 (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureHorizon @tok' 4
285 )
286 )
287 Data.Set.Internal.Tip
288 Data.Set.Internal.Tip
289 in let (#
290 farInp,
291 farExp
292 #) = case GHC.Classes.compare @GHC.Types.Int initPos callerInput of
293 GHC.Types.LT ->
294 (#
295 callerInput,
296 failExp
297 #)
298 GHC.Types.EQ ->
299 (#
300 initPos,
301 failExp GHC.Base.<> Data.Set.Internal.empty
302 #)
303 GHC.Types.GT ->
304 (#
305 initPos,
306 Data.Set.Internal.empty
307 #)
308 in readFail Symantic.Parser.Grammar.Combinators.ExceptionFailure callerInput farInp farExp buf GHC.Types.True
309 in if callerEnd
310 then noMoreInput
311 else
312 Symantic.Parser.Machine.Generate.returnST GHC.Base.$
313 ( Symantic.Parser.Machine.Generate.ResultPartial GHC.Base.$
314 ( \newInput ->
315 if Symantic.Parser.Machine.Input.nullInput newInput
316 then noMoreInput
317 else partialCont (append buf newInput)
318 )
319 )
320 in partialCont callerBuffer
321 in let _ = "pushValue"
322 in name
323 ( let _ = "onReturn"
324 in \farInp farExp v (!inp) buf end ->
325 let _ = "lift2Value checkedHorizon=0"
326 in let _ = "pushValue"
327 in do
328 let dupv = \u -> u
329 reg <- GHC.STRef.newSTRef dupv
330 let _ = "iter"
331 in let onException loopInput =
332 let _ = "onException"
333 in \(!_exn) (!failInp) (!farInp) (!farExp) buf end ->
334 let _ = "comment: raiseAgainIfConsumed"
335 in let _ = "saveInput checkedHorizon=0"
336 in let _ = "lift2Value checkedHorizon=0"
337 in if (GHC.Classes.==) @GHC.Types.Int loopInput failInp
338 then
339 let _ = "choicesBranch checkedHorizon=0"
340 in do
341 sr <- GHC.STRef.readSTRef reg
342 let _ = "pushValue"
343 in let _ = "lift2Value checkedHorizon=0"
344 in let _ = "lift2Value checkedHorizon=0"
345 in let _ = "resume"
346 in finalRet
347 farInp
348 farExp
349 ( let _ = "resume.genCode"
350 in GHC.Show.show ((GHC.Types.:) v (sr GHC.Types . []))
351 )
352 failInp
353 buf
354 end
355 else
356 let _ = "choicesBranch.else"
357 in Symantic.Parser.Machine.Generate.unForallOnException finalRaise Symantic.Parser.Grammar.Combinators.ExceptionFailure failInp farInp farExp buf end
358 loop = \_callerOnReturn callerInput callerBuffer callerEnded callerOnExceptionStackByLabel ->
359 let _ = "pushValue"
360 in name
361 ( let _ = "onReturn"
362 in \farInp farExp v (!inp) buf end ->
363 let _ = "lift2Value checkedHorizon=0"
364 in let _ = "pushValue"
365 in let _ = "lift2Value checkedHorizon=0"
366 in do
367 sr <- GHC.STRef.readSTRef reg
368 let _ = "lift2Value checkedHorizon=0"
369 in do
370 let dupv = \u -> sr ((GHC.Types.:) v u)
371 GHC.STRef.writeSTRef reg dupv
372 let _ = "jump"
373 in loop (GHC.Err.error "invalid onReturn") inp buf end (Data.Map.Internal.Bin 1 Symantic.Parser.Grammar.Combinators.ExceptionFailure (onException callerInput) Data.Map.Internal.Tip Data.Map.Internal.Tip)
374 )
375 callerInput
376 callerBuffer
377 callerEnded
378 (Data.Map.Internal.Bin 1 Symantic.Parser.Grammar.Combinators.ExceptionFailure (onException callerInput) Data.Map.Internal.Tip Data.Map.Internal.Tip)
379 in let _ = "jump"
380 in loop finalRet inp buf end Data.Map.Internal.Tip
381 )
382 initPos
383 buf
384 GHC.Types.False
385 Data.Map.Internal.Tip
386 else
387 let _ = "checkHorizon.newCheck.fail"
388 in let noMoreInput =
389 let failExp =
390 Data.Set.Internal.Bin
391 1
392 ( Symantic.Parser.Grammar.Combinators.SomeFailure
393 ( case inputToken of
394 (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureHorizon @tok' 4
395 )
396 )
397 Data.Set.Internal.Tip
398 Data.Set.Internal.Tip
399 in let (#
400 farInp,
401 farExp
402 #) = case GHC.Classes.compare @GHC.Types.Int initPos initPos of
403 GHC.Types.LT ->
404 (#
405 initPos,
406 failExp
407 #)
408 GHC.Types.EQ ->
409 (#
410 initPos,
411 failExp GHC.Base.<> Data.Set.Internal.empty
412 #)
413 GHC.Types.GT ->
414 (#
415 initPos,
416 Data.Set.Internal.empty
417 #)
418 in Symantic.Parser.Machine.Generate.unForallOnException finalRaise Symantic.Parser.Grammar.Combinators.ExceptionFailure initPos farInp farExp buf GHC.Types.True
419 in if GHC.Types.False
420 then noMoreInput
421 else
422 Symantic.Parser.Machine.Generate.returnST GHC.Base.$
423 ( Symantic.Parser.Machine.Generate.ResultPartial GHC.Base.$
424 ( \newInput ->
425 if Symantic.Parser.Machine.Input.nullInput newInput
426 then noMoreInput
427 else partialCont (append buf newInput)
428 )
429 )
430 in partialCont initBuffer