Make.Clf_parserinclude Common_parser.COMMON_PARSER
with type state = Parser.state
with type token = Parser.token
with type location = Parser.locationinclude Parser_combinator.PARSER
with type state = Parser.state
with type token = Parser.token
with type location = Parser.locationtype token = Parser.tokentype location = Parser.locationtype state = Parser.statetype 'a parser = 'a tinclude Support.Monad.MONAD with type 'a t := 'a tval return : 'a -> 'a treturn a injects a into the monadic type.
bind f a is the sequential composition of two actions, passing any value produced by a as argument to f.
compose g f is the Kleisli composition of f and g, passing the input to f, then binding the output to g.
( let* ) ma f is bind f ma. This is a binding operator, and it is used as let* a = ma in f a.
include Support.Functor.FUNCTOR with type 'a t := 'a tmap f is the function that maps values of t by f. The order of arguments is for use in function pipelines as fb = fa |> map (fun a -> (* ... *)).
( let+ ) ma f is map f a. This is a binding operator, and is used as let+ a = ma in f a
include Support.Apply.APPLY with type 'a t := 'a tap fa fab applies argument fa to fab under the abstract datatype t.
ap_first second first combines actions first and second but keeps only first. That is, ap_first second first = first. The order of arguments is for use in function pipelines as first = first |> ap_first second.
ap_second second first combines actions first and second but keeps only second. That is, ap_second second first = second. The order of arguments is for use in function pipelines as second = first |> ap_second second.
seq2 fa1 fa2 sequentially executes actions fa1 and fa2, and keeps their outputs under the abstract datatype t.
seq3 fa1 fa2 fa3 sequentially executes actions fa1, fa2 and fa3, and keeps their outputs under the abstract datatype t.
seq4 fa1 fa2 fa3 fa4 sequentially executes actions fa1, fa2, fa3 and fa4, and keeps their outputs under the abstract datatype t.
seq5 fa1 fa2 fa3 fa4 fa5 sequentially executes actions fa1, fa2, fa3, fa4 and fa5, and keeps their outputs under the abstract datatype t.
lift2 f ma1 ma2 sequentially executes actions ma1, ma2 and passes their outputs to f.
lift3 f ma1 ma2 ma3 sequentially executes actions ma1, ma2, ma3 and passes their outputs to f.
lift4 f ma1 ma2 ma3 ma4 sequentially executes actions ma1, ma2, ma3, ma4 and passes their outputs to f.
run p state is (state', result) where result is the output of parsing p using state.
This is only meant to be used internally, or when defining new parser combinators, since it does not prune the parser exception when result = Result.Error exn.
The end user of a parser should use run_exn.
run_exn p state is (state', parsed) where parsed is the object parsed from state using p. A pruned exception is raised if p fails.
catch p runs p and invokes the given handler to modify the outcome. Despite being called "catch", this parser is actually a kind of map, and is used to implement "low-level" parser transformations.
val fail : exn -> 'a tfail exn is the parser that always fails with exn.
val fail_at_location : Beluga_syntax.Location.t -> exn -> 'a tfail_at_location location exn is the parser that always fails with exn annotated with location.
val fail_at_next_location : exn -> 'a tfail_at_next_location exn is the parser that always fails with exn annotated with the next location in the input stream.
val fail_at_previous_location : exn -> 'a tfail_at_previous_location exn is the parser that always fails with exn annotated with the previous location in the input stream.
labelled label p is p' such that when p fails, p' annotates the exception with a label for error-reporting.
span p is the parser p' that additionally returns the source file location that spans the tokens consumed by p.
only p is the parser p' that expects p to succeed, then the end of input to be reached immediately after.
maybe p is the parser p' that may fail, in which case it returns Option.none.
many p is the parser p' that parses tokens following the EBNF grammar p*, meaning that it parses 0 or more occurrences of p.
val some : 'a t -> 'a Support.List1.t tsome p is the parser p' that parses tokens following the EBNF grammar p+, meaning that it parses 1 or more occurrences of p.
sep_by0 ~sep p is the parser p' that parses tokens following the EBNF grammar [p (sep p)*], meaning that it parses 0 or more occurrences of p separated by sep.
val sep_by1 : sep:unit t -> 'a t -> 'a Support.List1.t tsep_by1 ~sep p is the parser p' that parses tokens following the EBNF grammar p (sep p)+, meaning that it parses 1 or more occurrences of p separated by sep.
trying p is the parser p' that enables backtracking in the parser state if p fails, which signals that the erroneous state can be backtracked out of irrespective of the number of consumed tokens.
val choice : 'a t Support.List.t -> 'a tchoice ps is the parser p that sequentially tries the parsers in p.
For instance, choice [p1; p2] first runs p1. If it fails, p2 is run if one of the following is true.
p1 failed without consuming any input.p1 failed with backtracking enabled. Backtracking is enabled by the trying combinator.satisfy f is the basic parser p that performs an action based on whether the next token in the stream satisfies the predicate f. The parser is advanced only if the next token satisfies f. If the next token does not satisfy the predicate, then the error is annotated with the next token's location.
val eoi : unit teoi is the parser that expects the end of input to be reached. This is either the end of the input string, token stream, or file input channel.
val keyword : string -> unit tkeyword s parses the string s either as a keyword token, or an identifier matching s.
val integer : int tinteger parses an integer.
val dot_integer : int tdot_integer parses a dot followed by an integer.
val pragma : string -> unit tpragma s parses --s.
val string_literal : string tstring_literal parses an escaped string literal between double quotes.
val dot : unit tdot parses `.'.
val dots : unit tdots parses `..'.
val comma : unit tcomma parses `,'.
val colon : unit tcolon parses `:'.
val semicolon : unit tsemicolon parses `;'.
val slash : unit tslash pases `/'.
val equals : unit tequals parses `='.
val lambda : unit tlambda parses `\'.
val hat : unit that parses `^'.
val underscore : unit tunderscore parses `_'.
val pipe : unit tpipe parses `|'.
val forward_arrow : unit tforward_arrow parses `->'.
val backward_arrow : unit tbackward_arrow parses `<-'.
val thick_forward_arrow : unit tthick_forward_arrow parses `=>'.
val plus : unit tplus parses `+'.
val star : unit tstar parses `*'.
val hash : unit thash parses `#'. For identifiers prefixed by a hash symbol, see hash_identifier and omittable_hash_identifier.
val double_colon : unit tdouble_colon parses `::'.
val turnstile : unit tturnstile parses `|-'.
val turnstile_hash : unit tturnstile_hash parses `|-#'.
val left_parenthesis : unit tleft_parenthesis parses `('.
val right_parenthesis : unit tright_parenthesis parses `)'.
val left_brace : unit tleft_brace parses `{'.
val right_brace : unit tright_brace parses `}'.
val left_brack : unit tleft_brack parses `['.
val right_brack : unit tright_brack parses `]'.
val left_angle : unit tleft_angle parses `<'.
val right_angle : unit tright_angle parses `>'.
val identifier : Beluga_syntax.Identifier.t tidentifier parses a plain identifier.
val dot_identifier : Beluga_syntax.Identifier.t tdot_identifier parses a dot followed by an identifier.
val hash_identifier : Beluga_syntax.Identifier.t thash_identifier parses an identifier starting with `#'. The prefix `#' is included in the identifier.
val dollar_identifier : Beluga_syntax.Identifier.t tdollar_identifier parses an identifier starting with `$'. The prefix `$' is included in the identifier.
val omittable_identifier : Beluga_syntax.Identifier.t option tomittable_identifier parses `_' | <identifier>.
val omittable_hash_identifier : Beluga_syntax.Identifier.t option tomittable_hash_identifier parses `#_' | <hash-identifier>.
val omittable_dollar_identifier : Beluga_syntax.Identifier.t option tomittable_dollar_identifier parses `$_' | <dollar-identifier>.
val qualified_identifier : Beluga_syntax.Qualified_identifier.t tqualified_identifier parses <identifier> (<dot-identifier>)*.
val dot_qualified_identifier : Beluga_syntax.Qualified_identifier.t tdot_qualified_identifier parses a dot followed by a qualified identifier.
val qualified_or_plain_identifier :
[> `Plain of Beluga_syntax.Identifier.t
| `Qualified of Beluga_syntax.Qualified_identifier.t ]
tqualified_or_plain_identifier parses a plain identifier or a qualified identifier, whichever is the longest parse. That is, if qualified_or_plain_identifier parses a qualified identifier, then it has at least one namespace.
val omittable_meta_object_identifier :
(Beluga_syntax.Identifier.t option * [> `Dollar | `Hash | `Plain ]) tomittable_meta_object_identifier parses `_' | `#_' | `$_' | <identifier> | <hash-identifier> | <dollar-identifier>.
val meta_object_identifier :
(Beluga_syntax.Identifier.t * [> `Dollar | `Hash | `Plain ]) tmeta_object_identifier parses <identifier> | <hash-identifier> | <dollar-identifier>.
val hole : [> `Labelled of Beluga_syntax.Identifier.t | `Unlabelled ] parserhole parses `?' | `?'<identifier>.
val block_comment : (Beluga_syntax.Location.t * string) tblock_comment parses %{{ c }}%.
val clf_typ : Synprs.clf_object tval clf_term : Synprs.clf_object tval clf_term_pattern : Synprs.clf_object tval clf_context : Synprs.clf_context_object tval clf_substitution : Synprs.clf_context_object t