Import Upstream version 20180207
[hcoop/debian/mlton.git] / regression / char.scan.sml
1 val dquote = "\""
2
3 val _ = print (concat [Bool.toString (isSome (Char.fromString dquote)), "\n"])
4
5 val scan: string -> unit =
6 fn s =>
7 let
8 val n = String.size s
9 fun reader i =
10 if i = n
11 then NONE
12 else SOME (String.sub (s, i), i + 1)
13 in
14 case Char.scan reader 0 of
15 NONE => print "NONE\n"
16 | SOME (c, i) => print (concat [str c, " at ", Int.toString i,
17 " of ", Int.toString n, "\n"])
18 end
19
20 val _ =
21 List.app scan ["a\\ \\", "\\ \\a", "\\ \\a\\ \\", "\\ \\\\ \\a",
22 "\\ \\"]