Module Earley_core.Input
Type
Reading from a buffer
val read : buffer -> int -> char * buffer * intread buf posreturns the character at positionposin the bufferbuf, together with the new buffer and position.
val get : buffer -> int -> charget buf posreturns the character at positionposin the bufferbuf.
Creating a buffer
val from_file : string -> bufferfrom_file fnreturns a buffer constructed using the filefn.
val from_channel : ?filename:string -> Stdlib.in_channel -> bufferfrom_channel ~filename chreturns a buffer constructed using the channelch. The optionalfilenameis only used as a reference to the channel in error messages.
val from_string : ?filename:string -> string -> bufferfrom_string ~filename strreturns a buffer constructed using the stringstr. The optionalfilenameis only used as a reference to the channel in error messages.
val from_fun : ('a -> unit) -> string -> ('a -> string) -> 'a -> bufferfrom_fun finalise name get datareturns a buffer constructed from the objectdatausing thegetfunction. The get function is used to obtain one line of input fromdata. Thefinalisefunction is applied todatawhen the end of file is reached. Thenamestring is used to reference the origin of the data in error messages.
Creating buffers with a custom preprocessor
exceptionPreprocessor_error of string * stringException that can be raised by a preprocessor in case of error. The first string references the name of the buffer (e.g. the name of the corresponding file) and the second string contains the message.
module type Preprocessor = sig ... endSpecification of a preprocessor.
module WithPP : functor (PP : Preprocessor) -> sig ... endFunctor for building buffers with a preprocessor.
Buffer manipulation functions
val is_empty : buffer -> int -> boolis_empty buftest whether the bufferbufis empty.
val line_num : buffer -> intline_num bufreturns the current line number ofbuf.
val line_offset : buffer -> intline_beginning bufreturns the offset of the current line in the bufferbuf.
val line : buffer -> stringline bufreturns the current line in the bufferbuf.
val line_length : buffer -> intline_length bufreturns the length of the current line in the bufferbuf.
val utf8_col_num : buffer -> int -> intutf8_col_num buf posreturns the utf8 column number corresponding to the positionposinbuf.
val normalize : buffer -> int -> buffer * intnormalize buf posensures thatposis less than the length of the current line instr.
val filename : buffer -> stringfilename bufreturns the file name associated to thebuf.
val buffer_uid : buffer -> intbuffer_uid bufreturns a unique identifier forbuf.
val buffer_before : buffer -> int -> buffer -> int -> boolleq_bug b1 i1 b2 i2returns true if the positionb1, i1is beforeb2, i2. Gives meaningless result ifb1andb2do not refer to the same file.
module OrdTbl : sig ... endmodule Tbl : sig ... endSecond kind of table: unordered, but imperative and more efficient