Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
Predefined token parsers.
This module provides parsers for tokens that are commonly used in parsing computer languages. All parsers in this module skip the spaces (as defined by the MParser.spaces
parser) that occur after a token. Where they are applied to a user-defined parser p
, however, they do not skip the spaces occurring after the characters parsed by p
. For example, parens p
is equivalent to char '(' >> spaces >> p << char ')' << spaces
.
val symbol : string -> (string, 's) t
symbol sym
parses the literal string sym
and returns it.
val skip_symbol : string -> (unit, 's) t
skip_symbol sym
is equivalent to skip (symbol sym)
.
val semi : (char, 's) t
Parses a semicolon ';'
.
val comma : (char, 's) t
Parses a comma ','
.
val colon : (char, 's) t
Parses a colon ':'
.
val dot : (char, 's) t
Parses a dot '.'
.
semi_sep p
parses zero or more occurrences of p
, separated by ';'
. It returns a list of the results returned by p
.
semi_sep1 p
parses one or more occurrences of p
, separated by ';'
. It returns a list of the results returned by p
.
semi_sep_end p
parses zero or more occurrences of p
, separated and optionally ended by ';'
. It returns a list of the results returned by p
.
semi_sep_end1 p
parses one or more occurrences of p
, separated and optionally ended by ';'
. It returns a list of the results returned by p
.
semi_end p
parses zero or more occurrences of p
, separated and ended by ';'
. It returns a list of the results returned by p
.
semi_sep_end1 p
parses one or more occurrences of p
, separated and ended by ';'
. It returns a list of the results returned by p
.
comma_sep p
parses zero or more occurrences of p
, separated by ','
. It returns a list of the results returned by p
.
comma_sep1 p
parses one or more occurrences of p
, separated by ','
. It returns a list of the results returned by p
.
val char_literal : (char, 's) t
Parses a character literal as defined in the OCaml language and returns the character. The literal may contain an escape sequence.
val string_literal : (string, 's) t
Parses a string literal as defined in the OCaml language and returns the string. The literal may contain escape sequences.
val decimal : (int, 's) t
Parses a decimal natural number and returns it as an integer value. Fails with a Message_error
if the parsed number is larger than max_int
.
val hexadecimal : (int, 's) t
Parses a hexadecimal natural number as defined in the OCaml language (prefixed with "0x"
or "0X"
) and returns it as an integer value. Fails with a Message_error
if the parsed number is larger than max_int
.
val octal : (int, 's) t
Parses an octal natural number as defined in the OCaml language (prefixed with "0o"
or "0O"
) and returns it as an integer value. Fails with a Message_error
if the parsed number is larger than max_int
.
val binary : (int, 's) t
Parses a binary natural number as defined in the OCaml language (prefixed with "0b"
or "0B"
) and returns it as an integer value. Fails with a Message_error
if the parsed number is larger than max_int
.
val integer : (int, 's) t
Parses a decimal integer number and returns its value. Fails with a Message_error
if the parsed number is smaller than min_int
or larger than max_int
.
val float : (float, 's) t
Parses floating-point literal as defined in the OCaml language and returns its value. Fails with a Message_error
if the parsed number is not a valid representation of a float
value.