Batteries user guide : Batteries.CharParser

# Module Batteries.CharParser

    module CharParser: BatCharParser

    type position = {

`` | `offset : `int`;` | `(*` | Offset on the line (starting at 0) | `*)`
`` | `line : `int`;` | `(*` | Line number (starting at 0) | `*)`

}
The position inside one file or one stream.

    val advance : char -> position -> position

Advance 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.t

Create a source from a latin-1 character string.

    val source_of_enum : char BatEnum.t -> (char, position) BatParserCo.Source.t

Create a source from a latin-1 character.

    val parse : (char, 'a, position) BatParserCo.t ->
           string ->
           ('a, position BatParserCo.report) BatPervasives.result

Apply a parser to a string.

###### Utilities

    val char : char -> (char, char, position) BatParserCo.t

Recognize exactly one char

    val none_of : char list -> (char, char, position) BatParserCo.t

Accept any value not in a list As `ParserCo.none_of`, just with improved error message.

    val not_char : char -> (char, char, position) BatParserCo.t

Accept any value not a given char As `none_of`.

    val string : string -> (char, string, position) BatParserCo.t

Recognize exactly one string

    val case_char : char -> (char, char, position) BatParserCo.t

As `char`, but case-insensitive

    val case_string : string -> (char, string, position) BatParserCo.t

As `case_string`, but case-insensitive

    val newline : (char, char, position) BatParserCo.t

Recognizes a newline

    val whitespace : (char, char, position) BatParserCo.t

Recognizes white-space

    val uppercase : (char, char, position) BatParserCo.t

Recognizes one upper-case ASCII character, including accentuated characters.

    val lowercase : (char, char, position) BatParserCo.t

Recognizes one lower-case ASCII character, including accentuated characters.

    val letter : (char, char, position) BatParserCo.t

Recognizes one lower- or upper-case ASCII character, including accentuated characters.

    val uppercase_latin1 : (char, char, position) BatParserCo.t

Recognizes one upper-case Latin-1 character, including accentuated characters.

    val lowercase_latin1 : (char, char, position) BatParserCo.t

Recognizes one lower-case Latin-1 character, including accentuated characters.

    val latin1 : (char, char, position) BatParserCo.t

Recognizes one lower- or upper-case Latin1 character, including accentuated characters.

    val digit : (char, char, position) BatParserCo.t

Recognizes one decimal digit

    val hex : (char, char, position) BatParserCo.t

Recognizes one hexadecimal digit (case-insensitive)