Export de end_of_input.

Implementation de la semantique des espaces conforme a la doc (seul le
caractère 32 est reconnu pour appeler skip_spaces).


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5207 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Pierre Weis 2002-10-30 23:46:21 +00:00
parent 52e953e9a8
commit 03625b7620
2 changed files with 9 additions and 4 deletions

View File

@ -357,7 +357,8 @@ let scan_float max ib =
| c -> scan_exp_part max ib;;
(* Scan a regular string: it stops with a space or one of the
characters in stp. *)
characters in stp. It also stops when the maximum number of
characters has been read.*)
let scan_string stp max ib =
let rec loop max =
if max = 0 || Scanning.end_of_input ib then max else
@ -568,7 +569,7 @@ let kscanf ib ef fmt f =
let rec scan_fmt f i =
if i > lim then f else
match fmt.[i] with
| ' ' | '\t' | '\n' | '\r' -> skip_whites ib; scan_fmt f (i + 1)
| ' ' -> skip_whites ib; scan_fmt f (i + 1)
| '%' -> scan_fmt_width f (i + 1)
| '@' as t ->
let i = i + 1 in

View File

@ -42,6 +42,10 @@ val from_function : (unit -> char) -> scanbuf;;
When the function has no more character to provide, it must set
an end-of-input condition by raising the exception [End_of_file]. *)
val end_of_input : scanbuf -> bool;;
(** [Scanning.end_of_input scanbuf] tests the end of input condition
of the given buffer. *)
end;;
exception Scan_failure of string;;
@ -76,7 +80,7 @@ val bscanf :
matches any amount of whitespace in the input.
Conversion specifications consist in the [%] character, followed
by optional field width, followed by one or two conversion
by an optional field width, followed by one or two conversion
characters. The conversion characters and their meanings are:
- [d]: reads an optionally signed decimal integer.
- [i]: reads an optionally signed integer
@ -116,7 +120,7 @@ val bscanf :
The field widths are composed of an optional integer literal
indicating the maximal width of the token to read.
For instance, [%6d] reads an integer, having at most 6 decimal digits;
and [%4f] reads a float with 4 characters.
and [%4f] reads a float with at most 4 characters.
Scanning indications appear just after string conversions [s] and
[\[ range \]] to delimit the end of the token. A scanning