package earley
Install
Dune Dependency
Authors
Maintainers
Sources
md5=6b666c0392dc5b153f81c27d6ef49b12
sha512=a81d2bcf05088a3aaa5c3c0fb3a38306061a624ddf6d8bbefee1b4a17d7a5961ad1b12c0af9bd8dce86aa14b6f05f1956b3f7b5731f3c552bec7f4550182c398
doc/earley.core/Earley_core/Input/index.html
Module Earley_core.Input
Source
A module providing efficient input buffers with preprocessing.
Type
The abstract type for an input buffer.
Reading from a buffer
read buf pos
returns the character at position pos
in the buffer buf
, together with the new buffer and position.
get buf pos
returns the character at position pos
in the buffer buf
.
Creating a buffer
from_channel ~filename ch
returns a buffer constructed using the channel ch
. The optional filename
is only used as a reference to the channel in error messages.
from_string ~filename str
returns a buffer constructed using the string str
. The optional filename
is only used as a reference to the channel in error messages.
from_fun finalise name get data
returns a buffer constructed from the object data
using the get
function. The get function is used to obtain one line of input from data
. The finalise
function is applied to data
when the end of file is reached. The name
string is used to reference the origin of the data in error messages.
Creating buffers with a custom preprocessor
Exception 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.
pp_error name msg
raises Preprocessor_error(name,msg)
.
Specification of a preprocessor.
Functor for building buffers with a preprocessor.
Buffer manipulation functions
line_beginning buf
returns the offset of the current line in the buffer buf
.
line_length buf
returns the length of the current line in the buffer buf
.
utf8_col_num buf pos
returns the utf8 column number corresponding to the position pos
in buf
.
normalize buf pos
ensures that pos
is less than the length of the current line in str
.
leq_bug b1 i1 b2 i2
returns true if the position b1, i1
is before b2, i2
. Gives meaningless result if b1
and b2
do not refer to the same file.
....
First kind of table: association list in file order (first position in the beginning