module BatCharParser:sig..end
Parsing character strings.
This module defines common functions for parsing character strings,
encoded in Latin-1. These functions are meant to be used in conjunction
with the ParserCo module.
Note As ParserCo, this module is still very rough and needs testing.
type position = {
|
offset : |
(* | Offset on the line (starting at 0) | *) |
|
line : |
(* | Line number (starting at 0) | *) |
}
The position inside one file or one stream.
val advance : char -> position -> positionAdvance by one char.
advance c p returns a new position advanced by one char. If c is '\r' or '\n',
the result is {offset = 0; line = p.line + 1}. Other wise, the result is
{offset = p.offset + 1; line = p.line}.
val source_of_string : string -> (char, position) BatParserCo.Source.tCreate a source from a latin-1 character string.
val source_of_enum : char BatEnum.t -> (char, position) BatParserCo.Source.tCreate a source from a latin-1 character.
val parse : (char, 'a, position) BatParserCo.t ->
string ->
('a, position BatParserCo.report) BatPervasives.resultApply a parser to a string.
val char : char -> (char, char, position) BatParserCo.tRecognize exactly one char
val none_of : char list -> (char, char, position) BatParserCo.tAccept any value not in a list
As ParserCo.none_of, just with improved error message.
val not_char : char -> (char, char, position) BatParserCo.tAccept any value not a given char
As none_of.
val string : string -> (char, string, position) BatParserCo.tRecognize exactly one string
val case_char : char -> (char, char, position) BatParserCo.tAs char, but case-insensitive
val case_string : string -> (char, string, position) BatParserCo.tAs case_string, but case-insensitive
val newline : (char, char, position) BatParserCo.tRecognizes a newline
val whitespace : (char, char, position) BatParserCo.tRecognizes white-space
val uppercase : (char, char, position) BatParserCo.tRecognizes one upper-case ASCII character, including accentuated characters.
val lowercase : (char, char, position) BatParserCo.tRecognizes one lower-case ASCII character, including accentuated characters.
val letter : (char, char, position) BatParserCo.tRecognizes one lower- or upper-case ASCII character, including accentuated characters.
val uppercase_latin1 : (char, char, position) BatParserCo.tRecognizes one upper-case Latin-1 character, including accentuated characters.
val lowercase_latin1 : (char, char, position) BatParserCo.tRecognizes one lower-case Latin-1 character, including accentuated characters.
val latin1 : (char, char, position) BatParserCo.tRecognizes one lower- or upper-case Latin1 character, including accentuated characters.
val digit : (char, char, position) BatParserCo.tRecognizes one decimal digit
val hex : (char, char, position) BatParserCo.tRecognizes one hexadecimal digit (case-insensitive)