Module Parser_utils.Parser
The Parser module collects an API of parser-combinators for parsing FIX messages into OCaml types. Each combinator takes a continuation function that returns a ( 'a Parser.t * msg )
type
type msg
= (Imandra_prelude.string * Imandra_prelude.string) list
Type alias for a FIX message -- we assyme it is a list of string parirs
type 'a t
=
val (>|>=) : 'a t -> ('a -> 'b t * 'c list) -> 'b t * 'c list
The modified bind operator that applies a function that returns
( 'a Parser.t * msg )
pair
val rev_collect : 'a t list -> 'a list t
A "collect" function that convers
'a t list -> 'a list t
Note: Tail-recursive, but reverses the list.
val opt : (Imandra_prelude.string * Imandra_prelude.string) list -> Imandra_prelude.string -> (Imandra_prelude.string -> 'a option) -> ((Imandra_prelude.string * Imandra_prelude.string) list -> 'a option -> 'b t * 'c list) -> 'b t * 'c list
Optional field combinator, passes None into continuation if the tag is not present
val req : (Imandra_prelude.string * Imandra_prelude.string) list -> Imandra_prelude.string -> (Imandra_prelude.string -> 'a option) -> ((Imandra_prelude.string * Imandra_prelude.string) list -> 'a -> 'b t * 'c list) -> 'b t * 'c list
Required field combinator, returns RequiredTagMissing if the tag is not present
val block : msg -> (msg -> 'a t * msg) -> (msg -> 'a -> 'b t * msg) -> 'b t * msg
Block parser combinator parsers a record and passes it into the continuation
val repeating : msg -> Imandra_prelude.string -> (msg -> 'a t * msg) -> (msg -> 'a list -> 'b t * msg) -> 'b t * msg
Repeating group parser combinator, starting from the tag that encodes the length of the list, identifies the subgroups and passes each of them into the block parser. Performs a number of consistency checks on the parsed results.
val check_duplicate_tags : msg -> (Imandra_prelude.unit -> 'a t * msg) -> 'a t * msg
Checks for duplicate tags in messages -- should be called after all the repeating groups are porcessed