module Scanning: sig .. end
Scanfmodule: those channels provide all the machinery necessary to read from a given
Scanf.Scanning.in_channelvalue is also called a formatted input channel or equivalently a scanning buffer. The type
scanbufbelow is an alias for
type scanbuf = in_channel;
Note: a scanning action may often require to examine one character in
advance; when this 'lookahead' character does not belong to the token
read, it is stored back in the scanning buffer and becomes the next
character yet to be read.
let stdin: in_channel;
Scanning.stdinis the formatted input channel attached to
Note: in the interactive system, when input is read from
newline character that triggers the evaluation is incorporated in the
input; thus, the scanning specifications must properly skip this
additional newline character (for instance, simply add a
'\n' as the
last character of the format string).
type file_name = string;
let open_in: file_name => in_channel;
Scanning.open_in fnamereturns a formatted input channel for bufferized reading in text mode from file
open_in returns a formatted input channel that efficiently reads
characters in large chunks; in contrast,
from_channel below returns
formatted input channels that must read one character at a time, leading
to a much slower scanning rate.
let open_in_bin: file_name => in_channel;
Scanning.open_in_bin fnamereturns a formatted input channel for bufferized reading in binary mode from file
let close_in: in_channel => unit;
Pervasives.in_channelassociated with the given
Scanning.in_channelformatted input channel.
let from_file: file_name => in_channel;
let from_file_bin: string => in_channel;
let from_string: string => in_channel;
Scanning.from_string sreturns a formatted input channel which reads from the given string. Reading starts from the first character in the string. The end-of-input condition is set when the end of the string is reached.
let from_function: (unit => char) => in_channel;
Scanning.from_function freturns a formatted input channel with the given function as its reading method.
When scanning needs one more character, the given function is called.
When the function has no more character to provide, it must signal an
end-of-input condition by raising the exception
let from_channel: Pervasives.in_channel => in_channel;
Scanning.from_channel icreturns a formatted input channel which reads from the regular input channel
icargument, starting at the current reading position.
let end_of_input: in_channel => bool;
Scanning.end_of_input ictests the end-of-input condition of the given formatted input channel.
let beginning_of_input: in_channel => bool;
Scanning.beginning_of_input ictests the beginning of input condition of the given formatted input channel.
let name_of_input: in_channel => string;
Scanning.name_of_input icreturns the name of the character source for the formatted input channel
let stdib: in_channel;
Scanning.stdin, the scanning buffer reading from