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

Utilities

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