Library
Module
Module type
Parameter
Class
Class type
Utilities for parsing.
val with_loc : T.ctx -> 'a Angstrom.t -> ('a * T.loc) Angstrom.t
val fail_at : string -> 'a Angstrom.t
Parser failing with the given message where current position is added.
val parse_error_at : T.ctx -> T.parse_error -> 'a Angstrom.t
parse_error ctx e
raises a T.Error
with a parse error e
and last position of ctx
.
val opt_ : 'a Angstrom.t -> 'a option Angstrom.t
opt_ p
returns None
if p
fails, else return Some r
where r
is the result of p
.
val take_char : char option Angstrom.t
take_char
is a parser returning None
is there is no more char, else accept any character c
, Angstrom.advance
by 1 char and returns Some c
.
val take_while_upto : (char -> bool) -> int -> string Angstrom.t
take_while_upto pred n
accepts at most n
characters or as long a pred
returns true
. Returns accepted characters as a string.
val take_while1_upto : (char -> bool) -> int -> string Angstrom.t
Same as take_while_upto
but fails if no character is available.
val comment : T.ctx -> unit Angstrom.t
Accept a comment.
val ws : T.ctx -> unit Angstrom.t
ws ctx
accepts any number of white spaces or comments.
val map_fst : ('a -> ('b * 'c) Angstrom.t) -> 'a -> 'b Angstrom.t
val (&&&) : 'a Angstrom.t -> 'b Angstrom.t -> ('a * 'b) Angstrom.t
p1 &&& p2
returns a parser succeeding when p1
and p2
succeed, in any order.
val (|||) :
'a Angstrom.t ->
'b Angstrom.t ->
('a option * 'b option) Angstrom.t
p1 ||| p2
returns a parser accepting values for p1
or p2
or both.
val alt_1_2 :
'a ->
'a Angstrom.t ->
'b ->
'b Angstrom.t ->
('a * 'b) Angstrom.t
alt_1_2 def1 p1 def2 p2
is the same as (|||)
but returns the provided default values for each parser.
All these parser accept a character after optional white spaces or comments.
val lchar : char -> T.ctx -> char Angstrom.t
val lbracket : T.ctx -> char Angstrom.t
val rbracket : T.ctx -> char Angstrom.t
val lbrace : T.ctx -> char Angstrom.t
val rbrace : T.ctx -> char Angstrom.t
val lpar : T.ctx -> char Angstrom.t
val rpar : T.ctx -> char Angstrom.t
val dot : T.ctx -> char Angstrom.t
val colon : T.ctx -> char Angstrom.t
val semicolon : T.ctx -> char Angstrom.t
val ampersand : T.ctx -> char Angstrom.t
val comma : T.ctx -> char Angstrom.t
val dquote : T.ctx -> char Angstrom.t
val quote : T.ctx -> char Angstrom.t
val plus : T.ctx -> char Angstrom.t
val minus : T.ctx -> char Angstrom.t
val pipe : T.ctx -> char Angstrom.t
val sharp : T.ctx -> char Angstrom.t
val slash : T.ctx -> char Angstrom.t
val gt : T.ctx -> char Angstrom.t
val tilde : T.ctx -> char Angstrom.t
val sign : T.ctx -> char Angstrom.t
val integer : T.ctx -> int Angstrom.t