Commit 77bfdc1d authored by POTTIER Francois's avatar POTTIER Francois
Browse files

Set up [make test].

parent e1422da5
......@@ -5,20 +5,37 @@ ifndef MENHIR
MENHIR := $(shell ../../demos/find-menhir.sh)
endif
MENHIRFLAGS := --infer
MENHIRFLAGS := --infer -v
OCAMLBUILD := ocamlbuild -use-ocamlfind
MAIN := calc
all:
$(OCAMLBUILD) -build-dir _ocamlyacc $(MAIN).native
$(OCAMLBUILD) -build-dir _menhir -tag fancy $(MAIN).native \
@ $(OCAMLBUILD) -build-dir _ocamlyacc $(MAIN).native
@ $(OCAMLBUILD) -build-dir _menhir -tag fancy $(MAIN).native \
-use-menhir -menhir "$(MENHIR) $(MENHIRFLAGS)"
clean:
rm -f *~ .*~
$(OCAMLBUILD) -build-dir _ocamlyacc -clean
$(OCAMLBUILD) -build-dir _menhir -clean
@ rm -f *~ .*~
@ $(OCAMLBUILD) -build-dir _ocamlyacc -clean
@ $(OCAMLBUILD) -build-dir _menhir -clean
_ocamlyacc/%.out: %.in
_ocamlyacc/$(MAIN).native < $< > $@
_menhir/%.out: %.in
_menhir/$(MAIN).native < $< > $@
test: all
echo "(1 + 2 * 10) * 2" | _ocamlyacc/$(MAIN).native
echo "(1 + 2 * 10) * 2" | _menhir/$(MAIN).native
@ for f in *.in ; do \
out=$${f%*.in}.out ; \
log=$${f%*.in}.log ; \
for target in _ocamlyacc _menhir ; do \
$$target/$(MAIN).native < $$f > $$target/$$out ; \
done ; \
if diff _ocamlyacc/$$out _menhir/$$out > $$log ; then \
echo "OK $$f" ; \
else \
echo "FAILURE $$f" ; \
cat $$log ; \
fi ; \
done
......@@ -32,8 +32,8 @@ optional_dot:
raw_expr:
| INT
| LPAREN nothing expr RPAREN
| expr operator optional_dot expr
| optional_dot LPAREN nothing expr RPAREN optional_dot
| expr operator expr
| MINUS expr %prec UMINUS
{}
......
......@@ -32,15 +32,15 @@ optional_dot:
raw_expr:
| INT
{}
| LPAREN nothing expr RPAREN
| optional_dot LPAREN nothing expr RPAREN optional_dot
{}
| expr PLUS optional_dot expr
| expr PLUS expr
{}
| expr MINUS optional_dot expr
| expr MINUS expr
{}
| expr TIMES optional_dot expr
| expr TIMES expr
{}
| expr DIV optional_dot expr
| expr DIV expr
{}
| MINUS expr %prec UMINUS
{}
......
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