package pacomb
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=e48dc9fae5b96632bd1de929a49af71c
sha512=e4bf5dcfb0d4c5225a81fffe8e74cd9c147221eb9c8278b05d22391da0e06c6997e5b9a83a6431d72829f07f402da2449778cfe0bd56e7e2d3c8e08bbc1a73d5
doc/pacomb/Pacomb/Input/index.html
Module Pacomb.InputSource
A module providing efficient input buffers with preprocessing.
Type
Information for a file for reopening
The abstract type for an input buffer.
Type of fixed data attached to the buffer (like file name)
returns the stream_infos stored in infos
utf8 infos return the unicode context in use for this file
The abstract type position relative to the current buffer
The abstract position relative to the beginning of buffer
Reading from a buffer
read buf idx returns the character at position idx in the buffer buf, together with the new buffer and position. Read infinitely many '\255' at end of buffer
sub b i len returns len characters from position idx. If the end of buffer is reached, the string is filed with eof '\255'
get buf idx returns the character at position idx in the buffer buf.
Creating a buffer
from_file fn returns a buffer constructed using the file fn.
If utf8 is Utf8.UTF8 or Utf8.CJK_UTF8 (Utf8.ASCII is the default), positions are reported according to utf8. read is still reading bytes.
Getting line number and column number requires rescanning the file and if the file is not a regular file, it is kept in memory. Setting rescan to false avoid this, but only byte position and file name will be available.
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.
uft8 and rescan as in from_file.
Same as above for file descriptor
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.
Buffer manipulation functions
get spos from buffer and idx, to get line_num and col_num if needed later.
buffer_uid buf returns a unique identifier. Input.read does not change the uid. The uid is created when creating the initial buffer.
buffer_before 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, i.e. do not have the same uid.