]> Git — Sourcephile - haskell/symantic-parser.git/blob - tests/Golden/Splice/G11.expected.txt
!fixup impl: move `liftTypedString` to `Language.Haskell.TH.Show`
[haskell/symantic-parser.git] / tests / Golden / Splice / G11.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=1"
82 in if readMore buf initPos
83 then
84 let
85 in let _ = "pushValue"
86 in let _ = "pushValue"
87 in do
88 let dupv = \u -> u
89 reg <- GHC.STRef.newSTRef dupv
90 let _ = "iter"
91 in let onException loopInput =
92 let _ = "onException"
93 in \(!_exn) (!failInp) (!farInp) (!farExp) buf end ->
94 let _ = "comment: raiseAgainIfConsumed"
95 in let _ = "saveInput checkedHorizon=0"
96 in let _ = "lift2Value checkedHorizon=0"
97 in if (GHC.Classes.==) @GHC.Types.Int loopInput failInp
98 then
99 let _ = "choicesBranch checkedHorizon=0"
100 in do
101 sr <- GHC.STRef.readSTRef reg
102 let _ = "pushValue"
103 in let _ = "lift2Value checkedHorizon=0"
104 in let _ = "lift2Value checkedHorizon=0"
105 in let _ = "comment: satisfy ((GHC.Classes.==) 'b')"
106 in let partialCont buf =
107 let readFail = Symantic.Parser.Machine.Generate.unForallOnException finalRaise
108 in let _ = "checkHorizon.newCheck: checkedHorizon=0 minHoriz=1"
109 in if readMore buf failInp
110 then
111 let _ = "checkToken"
112 in let !(#
113 c,
114 cs
115 #) = readNext buf failInp
116 in if (GHC.Classes.==) 'b' c
117 then
118 let _ = "lift2Value checkedHorizon=1"
119 in let _ = "resume"
120 in finalRet
121 farInp
122 farExp
123 ( let _ = "resume.genCode"
124 in GHC.Show.show (sr GHC.Types . [])
125 )
126 cs
127 buf
128 end
129 else
130 let _ = "checkToken.fail"
131 in let failExp =
132 Data.Set.Internal.Bin
133 1
134 ( Symantic.Parser.Grammar.Combinators.SomeFailure
135 ( case inputToken of
136 (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureToken 'b'
137 )
138 )
139 Data.Set.Internal.Tip
140 Data.Set.Internal.Tip
141 in let (#
142 farInp,
143 farExp
144 #) = case GHC.Classes.compare @GHC.Types.Int farInp failInp of
145 GHC.Types.LT ->
146 (#
147 failInp,
148 failExp
149 #)
150 GHC.Types.EQ ->
151 (#
152 farInp,
153 failExp GHC.Base.<> farExp
154 #)
155 GHC.Types.GT ->
156 (#
157 farInp,
158 farExp
159 #)
160 in Symantic.Parser.Machine.Generate.unForallOnException finalRaise Symantic.Parser.Grammar.Combinators.ExceptionFailure failInp farInp farExp buf end
161 else
162 let _ = "checkHorizon.newCheck.fail"
163 in let noMoreInput =
164 let failExp =
165 Data.Set.Internal.Bin
166 1
167 ( Symantic.Parser.Grammar.Combinators.SomeFailure
168 ( case inputToken of
169 (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureHorizon @tok' 1
170 )
171 )
172 Data.Set.Internal.Tip
173 Data.Set.Internal.Tip
174 in let (#
175 farInp,
176 farExp
177 #) = case GHC.Classes.compare @GHC.Types.Int farInp failInp of
178 GHC.Types.LT ->
179 (#
180 failInp,
181 failExp
182 #)
183 GHC.Types.EQ ->
184 (#
185 farInp,
186 failExp GHC.Base.<> farExp
187 #)
188 GHC.Types.GT ->
189 (#
190 farInp,
191 farExp
192 #)
193 in Symantic.Parser.Machine.Generate.unForallOnException finalRaise Symantic.Parser.Grammar.Combinators.ExceptionFailure failInp farInp farExp buf GHC.Types.True
194 in if end
195 then noMoreInput
196 else
197 Symantic.Parser.Machine.Generate.returnST GHC.Base.$
198 ( Symantic.Parser.Machine.Generate.ResultPartial GHC.Base.$
199 ( \newInput ->
200 if Symantic.Parser.Machine.Input.nullInput newInput
201 then noMoreInput
202 else partialCont (append buf newInput)
203 )
204 )
205 in partialCont buf
206 else
207 let _ = "choicesBranch.else"
208 in Symantic.Parser.Machine.Generate.unForallOnException finalRaise Symantic.Parser.Grammar.Combinators.ExceptionFailure failInp farInp farExp buf end
209 loop = \_callerOnReturn callerInput callerBuffer callerEnded callerOnExceptionStackByLabel ->
210 let _ = "pushValue"
211 in let _ = "comment: satisfy ((GHC.Classes.==) 'a')"
212 in let partialCont buf =
213 let readFail = onException callerInput
214 in let _ = "checkHorizon.newCheck: checkedHorizon=0 minHoriz=1"
215 in if readMore buf callerInput
216 then
217 let _ = "checkToken"
218 in let !(#
219 c,
220 cs
221 #) = readNext buf callerInput
222 in if (GHC.Classes.==) 'a' c
223 then
224 let _ = "lift2Value checkedHorizon=1"
225 in let _ = "pushValue"
226 in let _ = "lift2Value checkedHorizon=1"
227 in do
228 sr <- GHC.STRef.readSTRef reg
229 let _ = "lift2Value checkedHorizon=1"
230 in do
231 let dupv = \u -> sr ((GHC.Types.:) 'a' u)
232 GHC.STRef.writeSTRef reg dupv
233 let _ = "jump"
234 in loop (GHC.Err.error "invalid onReturn") cs buf callerEnded (Data.Map.Internal.Bin 1 Symantic.Parser.Grammar.Combinators.ExceptionFailure readFail Data.Map.Internal.Tip Data.Map.Internal.Tip)
235 else
236 let _ = "checkToken.fail"
237 in let failExp =
238 Data.Set.Internal.Bin
239 1
240 ( Symantic.Parser.Grammar.Combinators.SomeFailure
241 ( case inputToken of
242 (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureToken 'a'
243 )
244 )
245 Data.Set.Internal.Tip
246 Data.Set.Internal.Tip
247 in let (#
248 farInp,
249 farExp
250 #) = case GHC.Classes.compare @GHC.Types.Int initPos callerInput of
251 GHC.Types.LT ->
252 (#
253 callerInput,
254 failExp
255 #)
256 GHC.Types.EQ ->
257 (#
258 initPos,
259 failExp GHC.Base.<> Data.Set.Internal.empty
260 #)
261 GHC.Types.GT ->
262 (#
263 initPos,
264 Data.Set.Internal.empty
265 #)
266 in readFail Symantic.Parser.Grammar.Combinators.ExceptionFailure callerInput farInp farExp buf callerEnded
267 else
268 let _ = "checkHorizon.newCheck.fail"
269 in let noMoreInput =
270 let failExp =
271 Data.Set.Internal.Bin
272 1
273 ( Symantic.Parser.Grammar.Combinators.SomeFailure
274 ( case inputToken of
275 (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureHorizon @tok' 1
276 )
277 )
278 Data.Set.Internal.Tip
279 Data.Set.Internal.Tip
280 in let (#
281 farInp,
282 farExp
283 #) = case GHC.Classes.compare @GHC.Types.Int initPos callerInput of
284 GHC.Types.LT ->
285 (#
286 callerInput,
287 failExp
288 #)
289 GHC.Types.EQ ->
290 (#
291 initPos,
292 failExp GHC.Base.<> Data.Set.Internal.empty
293 #)
294 GHC.Types.GT ->
295 (#
296 initPos,
297 Data.Set.Internal.empty
298 #)
299 in readFail Symantic.Parser.Grammar.Combinators.ExceptionFailure callerInput farInp farExp buf GHC.Types.True
300 in if callerEnded
301 then noMoreInput
302 else
303 Symantic.Parser.Machine.Generate.returnST GHC.Base.$
304 ( Symantic.Parser.Machine.Generate.ResultPartial GHC.Base.$
305 ( \newInput ->
306 if Symantic.Parser.Machine.Input.nullInput newInput
307 then noMoreInput
308 else partialCont (append buf newInput)
309 )
310 )
311 in partialCont callerBuffer
312 in let _ = "jump"
313 in loop finalRet initPos buf GHC.Types.False Data.Map.Internal.Tip
314 else
315 let _ = "checkHorizon.newCheck.fail"
316 in let noMoreInput =
317 let failExp =
318 Data.Set.Internal.Bin
319 1
320 ( Symantic.Parser.Grammar.Combinators.SomeFailure
321 ( case inputToken of
322 (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureHorizon @tok' 1
323 )
324 )
325 Data.Set.Internal.Tip
326 Data.Set.Internal.Tip
327 in let (#
328 farInp,
329 farExp
330 #) = case GHC.Classes.compare @GHC.Types.Int initPos initPos of
331 GHC.Types.LT ->
332 (#
333 initPos,
334 failExp
335 #)
336 GHC.Types.EQ ->
337 (#
338 initPos,
339 failExp GHC.Base.<> Data.Set.Internal.empty
340 #)
341 GHC.Types.GT ->
342 (#
343 initPos,
344 Data.Set.Internal.empty
345 #)
346 in Symantic.Parser.Machine.Generate.unForallOnException finalRaise Symantic.Parser.Grammar.Combinators.ExceptionFailure initPos farInp farExp buf GHC.Types.True
347 in if GHC.Types.False
348 then noMoreInput
349 else
350 Symantic.Parser.Machine.Generate.returnST GHC.Base.$
351 ( Symantic.Parser.Machine.Generate.ResultPartial GHC.Base.$
352 ( \newInput ->
353 if Symantic.Parser.Machine.Input.nullInput newInput
354 then noMoreInput
355 else partialCont (append buf newInput)
356 )
357 )
358 in partialCont initBuffer