Module BatUCharParser


module BatUCharParser: sig .. end
Parsing unicode text

This module defines common functions for parsing Unicode texts. 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.
Author(s): David Teller


type position = BatCharParser.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 : BatCamomile.UChar.t -> 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_rope : BatRope.t ->
(BatCamomile.UChar.t, position) BatParserCo.Source.t
Create a source from a Unicode Rope.
val source_of_enum : BatCamomile.UChar.t BatEnum.t ->
(BatCamomile.UChar.t, position) BatParserCo.Source.t
Create a source from an enumeration of unicode characters.
val parse : (BatCamomile.UChar.t, 'a, position) BatParserCo.t ->
BatRope.t -> ('a, position BatParserCo.report) BatStd.result
Apply a parser to a Unicode Rope.

Utilities

val char : BatCamomile.UChar.t ->
(BatCamomile.UChar.t, BatCamomile.UChar.t, position)
BatParserCo.t
Recognize exactly one char
val none_of : BatCamomile.UChar.t list ->
(BatCamomile.UChar.t, BatCamomile.UChar.t, position)
BatParserCo.t
Accept any value not in a list As ParserCo.none_of, just with improved error message.
val not_char : BatCamomile.UChar.t ->
(BatCamomile.UChar.t, BatCamomile.UChar.t, position)
BatParserCo.t
Accept any value not a given char As none_of.
val string : string ->
(BatCamomile.UChar.t, string, position) BatParserCo.t
Recognize exactly one string
val rope : BatRope.t ->
(BatCamomile.UChar.t, BatRope.t, position) BatParserCo.t
Recognize exactly one string
val ustring : BatUTF8.t ->
(BatCamomile.UChar.t, BatUTF8.t, position) BatParserCo.t
Recognize exactly one string
val case_char : BatCamomile.UChar.t ->
(BatCamomile.UChar.t, BatUTF8.t, position) BatParserCo.t
As char, but case-insensitive
val case_string : string ->
(BatCamomile.UChar.t, string, position) BatParserCo.t
As string, but case-insensitive
val case_ustring : BatUTF8.t ->
(BatCamomile.UChar.t, BatUTF8.t, position) BatParserCo.t
As ustring, but case-insensitive
val case_rope : BatRope.t ->
(BatCamomile.UChar.t, BatRope.t, position) BatParserCo.t
As rope, but case-insensitive
val newline : (BatCamomile.UChar.t, BatCamomile.UChar.t, position)
BatParserCo.t
Recognizes a newline
val whitespace : (BatCamomile.UChar.t, BatCamomile.UChar.t, position)
BatParserCo.t
Recognizes white-space
val uppercase : (BatCamomile.UChar.t, BatCamomile.UChar.t, position)
BatParserCo.t
Recognizes one upper-case ASCII character, including accentuated characters.
val lowercase : (BatCamomile.UChar.t, BatCamomile.UChar.t, position)
BatParserCo.t
Recognizes one lower-case character, including accentuated characters.
val letter : (BatCamomile.UChar.t, BatCamomile.UChar.t, position)
BatParserCo.t
Recognizes one lower- or upper-case character.
val digit : (BatCamomile.UChar.t, BatCamomile.UChar.t, position)
BatParserCo.t
Recognizes one decimal digit
val hex : (BatCamomile.UChar.t, BatCamomile.UChar.t, position)
BatParserCo.t
Recognizes one hexadecimal digit (case-insensitive)