Commit c7bb8530 authored by POTTIER Francois's avatar POTTIER Francois

Update demos/calc-param-dune.

parent 3be3e4a5
......@@ -5,9 +5,6 @@
# The following demos require menhirSdk:
# generate-printers
# The demos whose name ends in -dune require dune (a.k.a. jbuilder)
# and assume that Menhir is installed.
DEMOS := \
calc \
calc-alias \
......@@ -16,9 +13,6 @@ DEMOS := \
calc-incremental \
calc-inspection \
generate-printers \
# calc-dune \ # this demo causes [make check] to fail
# calc-incremental-dune \ # this demo causes [make check] to fail
# calc-inspection-dune \ # this demo requires new Dune, not yet released
.PHONY: all clean
......@@ -29,3 +23,21 @@ all clean::
clean::
/bin/rm -f *~ .*~
# The demos whose name ends in -dune require dune
# and assume that Menhir is installed. For now,
# they are not built by default. (TODO)
EXTRA := \
calc-dune \
calc-param-dune \
# calc-two-dune \
# calc-incremental-dune \
# calc-inspection-dune \
# generate-printers-dune \
.PHONY: extra
extra::
@for i in $(EXTRA) ; do \
$(MAKE) -C $$i all ; \
done
.PHONY: all clean test
DUNE := jbuilder
DUNE := dune
EXECUTABLE := calc.exe
all:
......@@ -15,5 +15,5 @@ clean:
rm -f *~
test: all
@echo "The following command should print 42.0:"
@echo "The following command should print 42.000000:"
echo "(1 + 2 * 10) * 2" | ./_build/default/$(EXECUTABLE)
......@@ -27,7 +27,7 @@ let process (line : string) =
let linebuf = Lexing.from_string line in
try
(* Run the parser on this line of input. *)
Printf.printf "%f\n%!" (FloatParser.main Lexer.token linebuf)
Printf.printf "%.6f\n%!" (FloatParser.main Lexer.token linebuf)
with
| Lexer.Error msg ->
Printf.fprintf stderr "%s%!" msg
......@@ -47,7 +47,6 @@ let rec repeat channel =
process optional_line;
if continue then
repeat channel
let () =
repeat (Lexing.from_channel stdin)
(jbuild_version 1)
(ocamllex (lexer))
(ocamllex
(modules lexer)
)
; Compile tokens.mly into a definition of the type [token].
(menhir (
(modules (tokens))
(menhir
(modules tokens)
(flags ("--only-tokens"))
))
)
; Compile parser.mly into a (parameterized) parser.
; We need tokens.mly too, because it contains the token definitions.
; The resulting OCaml files should be named parser.{ml,mli}
; and should *not* contain a definition of the [token] type.
(menhir (
(modules (tokens parser))
(menhir
(modules tokens parser)
(merge_into parser)
(flags ("--external-tokens" "Tokens"))
))
)
(executable
((name calc))
(name calc)
)
(lang dune 1.4)
(using menhir 2.0)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment