Legend:
Library
Module
Module type
Parameter
Class
Class type
A simple parser combinator library.
This module permits the simple definition of highly modular, dynamic parsers with unlimited backtracking. It may be used to parse any form of enumeration, including regular text, latin-1 text, bits, etc.
This library is vastly more powerful than Lexing, Str, Parsing or Scanf. It is also considerably slower.
Module CharParser contains pre-defined parsers to deal specifically with latin-1 text. Module Genlex contains a number of pre-defined parsers to deal specifically with programming languages.
Note This library is still very rough and needs much testing.
Base definitions
type'a state =
| Eof
(*
The end of the source has been reached.
*)
| Stateof'a
The current state of the parser.
The actual set of states is defined by the user. States are typically used to convey informations, such as position in the file (i.e. line number and character).
A source for parsing. Unless you are parsing from exotic sources, you will probably not need to use this module directly. Rather, use CharParser.source_of_string or CharParser.source_of_enum.
Primitives
type('a, 'b, 'c) t
A parser for elements of type 'a, producing elements of type 'b, with user-defined states of type 'c.
run p s executes parser p on source s. In case of success, returns Ok v, where v is the return value of p. In case of failure, returns Bad f, with f containing details on the parsing error.