Library
Module
Module type
Parameter
Class
Class type
Utilities for parsing.
val fail_at : T.ctx -> T.parse_error -> 'a
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
.
opt_ p
returns None
if p
fails, else return Some r
where r
is the result of p
.
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
.
take_while_upto pred n
accepts at most n
characters or as long a pred
returns true
. Returns accepted characters as a string.
Same as take_while_upto
but fails if no character is available.
val comment : T.ctx -> string Angstrom.t
Accept a comment.
val ws : T.ctx -> string Angstrom.t
ws ctx
accepts any number of white spaces or comments.
p1 &&& p2
returns a parser succeeding when p1
and p2
succeed, in any order.
p1 ||| p2
returns a parser accepting values for p1
or p2
or both.
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