Page
Library
Module
Module type
Parameter
Class
Class type
Source
Libnacc.Parsing
SourceType state
Type error
Type parser
Pure parser consuming no character and returning a value of type 'a
.
Test a predicate on the first character of the input. Resolve to this character if the predicate is verified
Binding operator using the let*
operator. This syntax is similar to Haskel's "do notation" :
let tuple_parser =
let* f1 = floatingpoint in
let* _ = char ',' in
let* f2 = floatingpoint in
pure (f1, f2)
Even if this operator can be usefull in extreme cases, users are encouraged to use the (<*>)
operator instead :
let tuple_parser =
(fun x y -> (x, y)) <$> floatingpoint <*> char ',' *> floatingpoint
The following operators are usefull to parse patterns which are left recursive by nature. The typical exemple is arithmetic expressions.
Eliminate left recursion in "left associative" chains. chainl op term
is a parser recognizing chains of terms term
bound by the operator op
. The operator is considered left associative.
Eliminate left recursion in "right associative" chains. chainr term op
is a parser recognizing chains of terms term
bound by the operator op
. The operator is considered right associative.
Feed a parser with a string (from left to right) This is verry different from do_parse
! No verifications are made on the remaining chars.
Feed a parser with a string (from right to left) p <-- input
is input --> p
. This function is just for convenience.