812a1686219b2f85db051d2aa3f640b4d7a23713
1 (**************************************************************************)
5 (* François Pottier, INRIA Rocquencourt *)
6 (* Yann Régis-Gianas, PPS, Université Paris Diderot *)
8 (* Copyright 2005-2008 Institut National de Recherche en Informatique *)
9 (* et en Automatique. All rights reserved. This file is distributed *)
10 (* under the terms of the Q Public License version 1.0, with the change *)
11 (* described in file LICENSE. *)
13 (**************************************************************************)
15 (* Let's do floating-point evaluation, for a change. *)
17 module FloatSemantics
= struct
33 (* Let us now specialize our parameterized parser. *)
36 Parser.Make
(FloatSemantics
)
38 (* The rest is as usual. *)
41 let stdinbuf = Lexing.from_channel stdin
in
43 (* Read line by line. *)
44 let linebuf = Lexing.from_string
(Lexer.line
stdinbuf) in
46 (* Run the parser on a single line of input. *)
47 Printf.printf
"%.1f\n%!" (FloatParser.main
Lexer.token
linebuf)
50 Printf.fprintf stderr
"%s%!" msg
51 | FloatParser.Error
->
52 Printf.fprintf stderr
"At offset %d: syntax error.\n%!" (Lexing.lexeme_start
linebuf)