Commit 50cc2e0d authored by POTTIER Francois's avatar POTTIER Francois

Moved calc-two to ocamlbuild.

parent 71afdfb2
calc calc.native
lexer.ml _build
*.cmi
*.cmo
*.cmx
*.o
*.d
algebraic.ml
algebraic.mli
reverse.ml
reverse.mli
tokens.ml
tokens.mli
.PHONY: all clean test
# Find Menhir. # Find Menhir.
ifndef MENHIR ifndef MENHIR
MENHIR := $(shell ../find-menhir.sh) MENHIR := $(shell ../find-menhir.sh)
endif endif
# Add --table on the next line to use Menhir's table-based back-end.
PGFLAGS := --infer MENHIRFLAGS := --infer
GENERATED := tokens.ml tokens.mli algebraic.ml algebraic.mli reverse.ml reverse.mli lexer.ml
MODULES := algebraic reverse lexer calc OCAMLBUILD := ocamlbuild -use-ocamlfind -use-menhir -menhir "$(MENHIR) $(MENHIRFLAGS)"
EXECUTABLE := calc
OCAMLDEPWRAPPER := ../ocamldep.wrapper MAIN := calc
include ../Makefile.shared
$(eval $(call menhir_monomodule,tokens,--only-tokens)) all:
$(eval $(call menhir_multimodule,algebraic,tokens.mly algebraic.mly common.mly,--external-tokens Tokens)) $(OCAMLBUILD) $(MAIN).native
$(eval $(call menhir_multimodule,reverse,tokens.mly reverse.mly common.mly,--external-tokens Tokens))
clean:
rm -f *~ .*~
$(OCAMLBUILD) -clean
test: all
@echo "The following command should print 42:"
echo "(1 + 2 * 10) * 2" | ./$(MAIN).native
# This is the old Makefile, based on Makefile.shared.
# Superseded by the new Makefile, based on ocamlbuild.
# Find Menhir.
ifndef MENHIR
MENHIR := $(shell ../find-menhir.sh)
endif
# Add --table on the next line to use Menhir's table-based back-end.
PGFLAGS := --infer
GENERATED := tokens.ml tokens.mli algebraic.ml algebraic.mli reverse.ml reverse.mli lexer.ml
MODULES := algebraic reverse lexer calc
EXECUTABLE := calc
OCAMLDEPWRAPPER := ../ocamldep.wrapper
include ../Makefile.shared
$(eval $(call menhir_monomodule,tokens,--only-tokens))
$(eval $(call menhir_multimodule,algebraic,tokens.mly algebraic.mly common.mly,--external-tokens Tokens))
$(eval $(call menhir_multimodule,reverse,tokens.mly reverse.mly common.mly,--external-tokens Tokens))
<tokens.mlypack>: only_tokens
<algebraic.mly>: external_tokens(Tokens)
<reverse.mly>: external_tokens(Tokens)
Tokens Algebraic Common
open Ocamlbuild_plugin
open Command
let menhir_flags() =
(* Define two ocamlbuild flags [only_tokens] and [external_tokens(Foo)]
which correspond to menhir's [--only-tokens] and [--external-tokens Foo].
When they are used, these flags should be passed both to [menhir] and to
[menhir --raw-depend]. *)
List.iter (fun mode ->
flag [ mode; "only_tokens" ] (S[A "--only-tokens"]);
pflag [ mode ] "external_tokens" (fun name ->
S[A "--external-tokens"; A name]
)
) [ "menhir"; "menhir_ocamldep" ]
let () =
dispatch (fun event ->
match event with
| After_rules ->
menhir_flags()
| _ -> ()
)
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