-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[stdune] add scanf module
- Loading branch information
Showing
9 changed files
with
62 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Scanf = Dune_caml.Scanf | ||
|
||
let unescaped x = | ||
match Scanf.unescaped x with | ||
| exception Scanf.Scan_failure _ -> Error () | ||
| x -> Ok x | ||
|
||
exception E | ||
let sscanf x fmt f = | ||
match Scanf.ksscanf x (fun _ _ -> raise_notrace E) fmt f with | ||
| exception E -> Error () | ||
| x -> Ok x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
(** Safe version of Scanf from the stdlib. Does not raise parsing errors | ||
errors. *) | ||
|
||
val unescaped : string -> (string, unit) Result.t | ||
|
||
val sscanf : | ||
string | ||
-> ( 'a | ||
, Dune_caml.Scanf.Scanning.in_channel | ||
, 'b | ||
, 'c -> 'd | ||
, 'a -> 'e | ||
, 'e ) | ||
format6 | ||
-> 'c | ||
-> ('d, unit) result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters