Module Scanf.Scanning
Contents
Instructions: Use this module in your project
In the IDE (CLion, Visual Studio Code, Xcode, etc.) you use for your DkSDK project:
Add the following to your project's
dependencies/CMakeLists.txt:DkSDKProject_DeclareAvailable(ocaml CONSTRAINT "= 4.14.0" FINDLIBS str unix runtime_events threads dynlink) DkSDKProject_MakeAvailable(ocaml)Add the
Findlib::ocamllibrary to any desired targets insrc/*/CMakeLists.txt:target_link_libraries(YourPackage_YourLibraryName # ... existing libraries, if any ... Findlib::ocaml)Click your IDE's
Buildbutton
Not using DkSDK?
FIRST, do one or all of the following:
Run:
opam install ocaml.4.14.0Edit your
dune-projectand add:(package (name YourExistingPackage) (depends ; ... existing dependenices ... (ocaml (>= 4.14.0))))Then run:
dune build *.opam # if this fails, run: dune buildEdit your
<package>.opamfile and add:depends: [ # ... existing dependencies ... "ocaml" {>= "4.14.0"} ]Then run:
opam install . --deps-only
FINALLY, add the library to any desired (library)and/or (executable) targets in your **/dune files:
(library
(name YourLibrary)
; ... existing library options ...
(libraries
; ... existing libraries ...
))
(executable
(name YourExecutable)
; ... existing executable options ...
(libraries
; ... existing libraries ...
))typein_channel
The notion of input channel for the Scanf module:
those channels provide all the machinery necessary to read from any
source of characters, including a
Stdlib.in_channel value. A
Scanf.Scanning.in_channel value is also called a formatted input
channel or equivalently a scanning buffer. The type
Scanning.scanbuf below is an alias for
Scanning.in_channel.
- since 3.12.0
typescanbuf`` =in_channel
The type of scanning buffers. A scanning buffer is the source from which a formatted input function gets characters. The scanning buffer holds the current state of the scan, plus a function to get the next char from the input, and a token buffer to store the string matched so far.
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.
valstdin :in_channel
The standard input notion for the Scanf module.
Scanning.stdin is the Scanning.in_channel
formatted input channel attached to
Stdlib.stdin.
Note: in the interactive system, when input is read from
Stdlib.stdin, the newline character that
triggers evaluation is part of 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).
- since 3.12.0
typefile_name`` = string
A convenient alias to designate a file name.
- since 4.00.0
valopen_in :file_name->in_channel
Scanning.open_in fname returns a
Scanning.in_channel formatted input channel for
bufferized reading in text mode from file fname.
Note: 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.
- since 3.12.0
valopen_in_bin :file_name->in_channel
Scanning.open_in_bin fname returns a
Scanning.in_channel formatted input channel for
bufferized reading in binary mode from file fname.
- since 3.12.0
valclose_in :in_channel->unit
Closes the Stdlib.in_channel associated
with the given Scanning.in_channel formatted input
channel.
- since 3.12.0
valfrom_file :file_name->in_channel
An alias for Scanning.open_in above.
valfrom_file_bin : ``string->in_channel
An alias for Scanning.open_in_bin above.
valfrom_string : ``string->in_channel
Scanning.from_string s returns a
Scanning.in_channel 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.
valfrom_function : ``(``unit->char)``->in_channel
Scanning.from_function f returns a
Scanning.in_channel 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 End_of_file.
valfrom_channel :in_channel->in_channel
Scanning.from_channel ic returns a
Scanning.in_channel formatted input channel which
reads from the regular
Stdlib.in_channel input channel ic
argument. Reading starts at current reading position of ic.
valend_of_input :in_channel->bool
Scanning.end_of_input ic tests the end-of-input condition of the given
Scanning.in_channel formatted input channel.
valbeginning_of_input :in_channel->bool
Scanning.beginning_of_input ic tests the beginning of input condition
of the given Scanning.in_channel formatted input
channel.
valname_of_input :in_channel->string
Scanning.name_of_input ic returns the name of the character source for
the given Scanning.in_channel formatted input
channel.
- since 3.09.0
valstdib :in_channel
A deprecated alias for Scanning.stdin, the scanning
buffer reading from Stdlib.stdin.
- deprecated Use Scanf.Scanning.stdin instead.
