@@ -107,67 +107,66 @@ module Parsing =
107107 let _zzz1 = sscanf " %%(%s )" " %(hello)"
108108 let ( _x1 , _y1 , _z1 ) = sscanf " %s --%s -%s " " test--this-string"
109109
110- let inline (| Parsedf | _ |) pf = trySscanf pf
111- match " ab" with Parsedf " %c " _ -> failwith " wrong match" | Parsedf " %c%c " ( 'a' , 'b' ) -> () | _ -> failwith " didn't match"
112- match " abc" with Parsedf " %c%c " ( 'a' , 'b' ) -> failwith " wrong match" | Parsedf " %c%c%c%s " ( 'a' , 'b' , 'c' , " " ) -> () | _ -> failwith " didn't match"
110+ match " ab" with Scanned " %c " _ -> failwith " wrong match" | Scanned " %c%c " ( 'a' , 'b' ) -> () | _ -> failwith " didn't match"
111+ match " abc" with Scanned " %c%c " ( 'a' , 'b' ) -> failwith " wrong match" | Scanned " %c%c%c%s " ( 'a' , 'b' , 'c' , " " ) -> () | _ -> failwith " didn't match"
113112 match " (%hello)" with
114- | Parsedf " %d " _ | Parsedf " %f " _ | Parsedf " %x " _ -> failwith " wrong match"
115- | Parsedf " %%(%%%s )" _ | Parsedf " (%%%s a" _ | Parsedf " (%%hel%c " _ | Parsedf " %%h%c llo)" _ -> failwith " wrong match"
116- | Parsedf " (%%%s )" " hello" -> ()
113+ | Scanned " %d " _ | Scanned " %f " _ | Scanned " %x " _ -> failwith " wrong match"
114+ | Scanned " %%(%%%s )" _ | Scanned " (%%%s a" _ | Scanned " (%%hel%c " _ | Scanned " %%h%c llo)" _ -> failwith " wrong match"
115+ | Scanned " (%%%s )" " hello" -> ()
117116 | _ -> failwith " didn't match"
118- match " 3" with Parsedf " % d" 3 -> () | _ -> failwith " didn't match"
119- match " 3" with Parsedf " % d" 3 -> () | _ -> failwith " didn't match"
120- match " 3" with Parsedf " % d" 3 -> () | _ -> failwith " didn't match" // em space
121- match " 3 " with Parsedf " %-d " 3 -> () | _ -> failwith " didn't match"
122- match " 3 " with Parsedf " %-d " 3 -> () | _ -> failwith " didn't match"
123- match " 3 " with Parsedf " %-d " 3 -> () | _ -> failwith " didn't match" // em space
124- match " 3 " with Parsedf " % -d" 3 -> () | _ -> failwith " didn't match"
125- match " 3 " with Parsedf " % -d" 3 -> () | _ -> failwith " didn't match"
126- match " 3 " with Parsedf " % -d" 3 -> () | _ -> failwith " didn't match" // em space
127- match " test--this-gg" with Parsedf " %s --%s -%s " ( " test" , " this" , " gg" ) -> () | _ -> failwith " didn't match"
128- match " 1 2.1 3.4 .3 43.2e32 0 f f" with Parsedf " %f %F %g %G %e %E %c %c " ( 1 f, 2.1 , 3.4 m, 0.3 , 43.2e32 , 0. , 'f' , 'f' ) -> () | _ -> failwith " didn't match"
129- match " 1 2.1 3.4 .3 43.2e32 0 f f f" with Parsedf " %f % F %g %G %e %E %c %c %c " ( 1 m, 2.1 , 3.4 , 0.3 m, 43.2e32 , 0. , 'f' , 'f' , 'f' ) -> () | _ -> failwith " didn't match"
130- match " 1 2.1 3.4.3 43.2e32 0 f f ff" with Parsedf " %B %F %-g%G %e %E %c %c %c%c " ( 1 , 2.1 , 3.4 , 0.3 , 43.2e32 , 0. , 'f' , 'f' , 'f' , 'f' ) -> () | _ -> failwith " didn't match"
131- match " 1 2.1 3.4.3 43.2e32 0 f f fff" with Parsedf " %o %F % g%-G %e %E %c %c %c%c%c " ( 1 y, 2.1 , 3.4 , 0.3 , 43.2e32 , 0. , 'f' , 'f' , 'f' , 'f' , 'f' ) -> () | _ -> failwith " didn't match"
132- match " 1 2.1 3.4.3 43.2e32 0 f f fff16" with Parsedf " %x %F %- g%- G %e %E %c %c %c%c%c%i " ( 1 us, 2.1 , 3.4 , 0.3 , 43.2e32 , 0. , 'f' , 'f' , 'f' , 'f' , 'f' , 16 ) -> () | _ -> failwith " didn't match"
133- match " 1 2.1 3.4.3 43.2e32 0 f f fff16 17" with Parsedf " %X %F %g % G %e %E %c %c %c%c%c%i %f " ( 1 s, 2.1 , 3.4 , 0.3 , 43.2e32 , 0. , 'f' , 'f' , 'f' , 'f' , 'f' , 16 L, 17. ) -> () | _ -> failwith " didn't match"
134- match " 13 43 AA 77A" with Parsedf " %x %X %x %o%X " ( 0x13 , 0x43 , 0xAA , 0o77 , 0xA ) -> () | _ -> failwith " didn't match"
135- match " 13 43 AA 77A" with Parsedf " %B%x %X %x %o%X " ( 0b1 , 0x3 , 0x43 , 0xAA , 0o77 , 0xA ) -> () | _ -> failwith " didn't match"
136- match " 111AAA" with Parsedf " %B%s " ( 0b111 , " AAA" ) -> () | _ -> failwith " didn't match"
137- match " 100700 100 100" with Parsedf " %B%o %x %X " ( 0b100 , 0o700 , 0x100 , 0x100 ) -> () | _ -> failwith " didn't match"
117+ match " 3" with Scanned " % d" 3 -> () | _ -> failwith " didn't match"
118+ match " 3" with Scanned " % d" 3 -> () | _ -> failwith " didn't match"
119+ match " 3" with Scanned " % d" 3 -> () | _ -> failwith " didn't match" // em space
120+ match " 3 " with Scanned " %-d " 3 -> () | _ -> failwith " didn't match"
121+ match " 3 " with Scanned " %-d " 3 -> () | _ -> failwith " didn't match"
122+ match " 3 " with Scanned " %-d " 3 -> () | _ -> failwith " didn't match" // em space
123+ match " 3 " with Scanned " % -d" 3 -> () | _ -> failwith " didn't match"
124+ match " 3 " with Scanned " % -d" 3 -> () | _ -> failwith " didn't match"
125+ match " 3 " with Scanned " % -d" 3 -> () | _ -> failwith " didn't match" // em space
126+ match " test--this-gg" with Scanned " %s --%s -%s " ( " test" , " this" , " gg" ) -> () | _ -> failwith " didn't match"
127+ match " 1 2.1 3.4 .3 43.2e32 0 f f" with Scanned " %f %F %g %G %e %E %c %c " ( 1 f, 2.1 , 3.4 m, 0.3 , 43.2e32 , 0. , 'f' , 'f' ) -> () | _ -> failwith " didn't match"
128+ match " 1 2.1 3.4 .3 43.2e32 0 f f f" with Scanned " %f % F %g %G %e %E %c %c %c " ( 1 m, 2.1 , 3.4 , 0.3 m, 43.2e32 , 0. , 'f' , 'f' , 'f' ) -> () | _ -> failwith " didn't match"
129+ match " 1 2.1 3.4.3 43.2e32 0 f f ff" with Scanned " %B %F %-g%G %e %E %c %c %c%c " ( 1 , 2.1 , 3.4 , 0.3 , 43.2e32 , 0. , 'f' , 'f' , 'f' , 'f' ) -> () | _ -> failwith " didn't match"
130+ match " 1 2.1 3.4.3 43.2e32 0 f f fff" with Scanned " %o %F % g%-G %e %E %c %c %c%c%c " ( 1 y, 2.1 , 3.4 , 0.3 , 43.2e32 , 0. , 'f' , 'f' , 'f' , 'f' , 'f' ) -> () | _ -> failwith " didn't match"
131+ match " 1 2.1 3.4.3 43.2e32 0 f f fff16" with Scanned " %x %F %- g%- G %e %E %c %c %c%c%c%i " ( 1 us, 2.1 , 3.4 , 0.3 , 43.2e32 , 0. , 'f' , 'f' , 'f' , 'f' , 'f' , 16 ) -> () | _ -> failwith " didn't match"
132+ match " 1 2.1 3.4.3 43.2e32 0 f f fff16 17" with Scanned " %X %F %g % G %e %E %c %c %c%c%c%i %f " ( 1 s, 2.1 , 3.4 , 0.3 , 43.2e32 , 0. , 'f' , 'f' , 'f' , 'f' , 'f' , 16 L, 17. ) -> () | _ -> failwith " didn't match"
133+ match " 13 43 AA 77A" with Scanned " %x %X %x %o%X " ( 0x13 , 0x43 , 0xAA , 0o77 , 0xA ) -> () | _ -> failwith " didn't match"
134+ match " 13 43 AA 77A" with Scanned " %B%x %X %x %o%X " ( 0b1 , 0x3 , 0x43 , 0xAA , 0o77 , 0xA ) -> () | _ -> failwith " didn't match"
135+ match " 111AAA" with Scanned " %B%s " ( 0b111 , " AAA" ) -> () | _ -> failwith " didn't match"
136+ match " 100700 100 100" with Scanned " %B%o %x %X " ( 0b100 , 0o700 , 0x100 , 0x100 ) -> () | _ -> failwith " didn't match"
138137
139138 match " 1+1-2+2-8+8" with
140- | Parsedf " %s%o " _ -> failwith " wrong match"
141- | Parsedf " %+u%+u%+d%+u%+u%+u" _ -> failwith " wrong match"
142- | Parsedf " %+u%+u%+d%+u%+d%o " _ -> failwith " wrong match"
143- | Parsedf " %+u%+u%+d%+u%-d%u " _ -> failwith " wrong match"
144- | Parsedf " %+u%+u%+d%+u%u %+d" _ -> failwith " wrong match"
145- | Parsedf " %+u%+u%+d%+u%+o%+u" _ -> failwith " wrong match"
146- | Parsedf " %+u%+u%+d%+u%+B%+u" _ -> failwith " wrong match"
147- | Parsedf " %+u%+u%+d%+u%+x%+X" _ -> failwith " wrong match"
148- | Parsedf " %+u%+u%+d%+u%+d%+X" ( a, b, c, d, e, f) ->
139+ | Scanned " %s%o " _ -> failwith " wrong match"
140+ | Scanned " %+u%+u%+d%+u%+u%+u" _ -> failwith " wrong match"
141+ | Scanned " %+u%+u%+d%+u%+d%o " _ -> failwith " wrong match"
142+ | Scanned " %+u%+u%+d%+u%-d%u " _ -> failwith " wrong match"
143+ | Scanned " %+u%+u%+d%+u%u %+d" _ -> failwith " wrong match"
144+ | Scanned " %+u%+u%+d%+u%+o%+u" _ -> failwith " wrong match"
145+ | Scanned " %+u%+u%+d%+u%+B%+u" _ -> failwith " wrong match"
146+ | Scanned " %+u%+u%+d%+u%+x%+X" _ -> failwith " wrong match"
147+ | Scanned " %+u%+u%+d%+u%+d%+X" ( a, b, c, d, e, f) ->
149148 areEqual ( a |> box |> unbox< int>) 1
150149 areEqual ( b |> box |> unbox< int>) 1
151150 areEqual ( c |> box |> unbox< int>) - 2
152151 areEqual ( d |> box |> unbox< int>) 2
153152 areEqual ( e |> box |> unbox< int>) - 8
154153 areEqual ( f |> box |> unbox< int>) 8
155154 | _ -> failwith " didn't match"
156- match " 1+1-2+2-8+8" with Parsedf " %+-d%+d%+-d%+d%+-d%+d" ( 1 , 1 ,- 2 , 2 ,- 8 , 8 ) -> () | _ -> failwith " didn't match"
157- match " 1+1-2+2-8+8" with Parsedf " %d +%d%d %+d%d %+d" ( 1 , 1 ,- 2 , 2 ,- 8 , 8 ) -> () | _ -> failwith " didn't match"
158- match " 1+1-2+2-8+8" with Parsedf " %+B%+B-%+o%+o-%+X%+X" ( 1 , 1 , 2 , 2 , 8 , 8 ) -> () | _ -> failwith " didn't match"
159- match " 1+1-2+2-8+8e" with Parsedf " %+f%+F%+e%+E%+g%+G%+X" ( 1 f, 1. ,- 2 m, 2 f,- 8. , 8 M, 0xE ) -> () | _ -> failwith " didn't match"
160- match " 1+1-2+2-8+8e1a" with Parsedf " %+f%+F%+e%+E%+g%+G%+X" ( 1 f, 1. ,- 2 m, 2 f,- 8. , 80 M, 0xA ) -> () | _ -> failwith " didn't match"
161- match " 1+1-2+2-8+8e-1a" with Parsedf " %+f%+F%+e%+E%+g%+G%+X" ( 1 f, 1. ,- 2 m, 2 f,- 8. , 0.8 M, 0xA ) -> () | _ -> failwith " didn't match"
162- match " 1+1-2+2-8+8ea" with Parsedf " %+-f%+-F%+-e%+-E%+-g%+-G%+-X" ( 1 f, 1. ,- 2 m, 2 f,- 8. , 8 M, 0xEA ) -> () | _ -> failwith " didn't match"
155+ match " 1+1-2+2-8+8" with Scanned " %+-d%+d%+-d%+d%+-d%+d" ( 1 , 1 ,- 2 , 2 ,- 8 , 8 ) -> () | _ -> failwith " didn't match"
156+ match " 1+1-2+2-8+8" with Scanned " %d +%d%d %+d%d %+d" ( 1 , 1 ,- 2 , 2 ,- 8 , 8 ) -> () | _ -> failwith " didn't match"
157+ match " 1+1-2+2-8+8" with Scanned " %+B%+B-%+o%+o-%+X%+X" ( 1 , 1 , 2 , 2 , 8 , 8 ) -> () | _ -> failwith " didn't match"
158+ match " 1+1-2+2-8+8e" with Scanned " %+f%+F%+e%+E%+g%+G%+X" ( 1 f, 1. ,- 2 m, 2 f,- 8. , 8 M, 0xE ) -> () | _ -> failwith " didn't match"
159+ match " 1+1-2+2-8+8e1a" with Scanned " %+f%+F%+e%+E%+g%+G%+X" ( 1 f, 1. ,- 2 m, 2 f,- 8. , 80 M, 0xA ) -> () | _ -> failwith " didn't match"
160+ match " 1+1-2+2-8+8e-1a" with Scanned " %+f%+F%+e%+E%+g%+G%+X" ( 1 f, 1. ,- 2 m, 2 f,- 8. , 0.8 M, 0xA ) -> () | _ -> failwith " didn't match"
161+ match " 1+1-2+2-8+8ea" with Scanned " %+-f%+-F%+-e%+-E%+-g%+-G%+-X" ( 1 f, 1. ,- 2 m, 2 f,- 8. , 8 M, 0xEA ) -> () | _ -> failwith " didn't match"
163162
164163 let _date : ( DayOfWeek * string * uint16 * int ) option = trySscanf " %A %A %A %A " " Saturday March 25 1989"
165164 let _date1 : DateTime option = trySscanf " %A " " Saturday March 25 1989"
166165
167- match " 12:34" with Parsedf " %A " ( x: TimeSpan) -> areEqual ( TimeSpan( 12 , 34 , 0 )) x | _ -> failwith " Pattern match failed"
168- match " 12:34:56" with Parsedf " %O " ( x: TimeSpan) -> areEqual ( TimeSpan( 12 , 34 , 56 )) x | _ -> failwith " Pattern match failed"
169- match " 9876-5-4 3:2:1" with Parsedf " %A " ( x: DateTime) -> areEqual ( DateTime( 9876 , 5 , 4 , 3 , 2 , 1 )) x | _ -> failwith " Pattern match failed"
170- match " 9876-5-4 3:2:1 a" with Parsedf " %O %x " ( x: DateTime, y) -> areEqual ( DateTime( 9876 , 5 , 4 , 3 , 2 , 1 )) x; areEqual 0xA y | _ -> failwith " Pattern match failed"
166+ match " 12:34" with Scanned " %A " ( x: TimeSpan) -> areEqual ( TimeSpan( 12 , 34 , 0 )) x | _ -> failwith " Pattern match failed"
167+ match " 12:34:56" with Scanned " %O " ( x: TimeSpan) -> areEqual ( TimeSpan( 12 , 34 , 56 )) x | _ -> failwith " Pattern match failed"
168+ match " 9876-5-4 3:2:1" with Scanned " %A " ( x: DateTime) -> areEqual ( DateTime( 9876 , 5 , 4 , 3 , 2 , 1 )) x | _ -> failwith " Pattern match failed"
169+ match " 9876-5-4 3:2:1 a" with Scanned " %O %x " ( x: DateTime, y) -> areEqual ( DateTime( 9876 , 5 , 4 , 3 , 2 , 1 )) x; areEqual 0xA y | _ -> failwith " Pattern match failed"
171170
172171 let x = trySscanf " %X %x " " 13 43"
173172 let o = trySscanf " %o " " 10"
0 commit comments