Skip to content
Commits on Source (8)
Camlp5 Version 7.07:
--------------------
* [10 Oct 18] Changed '/bin/rm' into 'rm' in Makefiles. Can be changed by
user by 'make RM=...'.
* [08 Oct 18] Updated for ocaml version 4.07.2.
* [19 Sep 18] Updated for ocaml upcomming version 4.08.0.
* [18 Sep 18] Fixed bug: using camlp5 in ocaml toplevel, the errors locations
in files (with #use) where not displayed.
* [30 Aug 18] Updated for ocaml version 4.07.1 and upcomming version 4.08.0.
Camlp5 Version 7.06:
--------------------
* [17 Jul 18] Support nonrec type declaration (Kakadu).
* [27 Jun 18] Updated for ocaml upcomming version 4.08.0.
* [19 Jun 18] Add support for OCaml 4.07.0
* [19 Jun 18] Fix OPAM file [in particular avoid the filesystem deletion bug]
* [06 Apr 18] Safe API for grammar extension (Pierre-Marie Pedrot).
Camlp5 Version 7.05:
--------------------
* [22 Feb 18] Fixed compilation failure when compiled with ocaml
versions 3.08.0 to 4.02.4 due to the time when the constructor
Pconst_integer was created (at ocaml version 4.03.0 actually).
* [22 Feb 18] Added compatibility with (old) ocaml version 4.03.3.
* [20 Feb 18] Changed "make install" and "make uninstall" so that they
do nothing if "configure" had failed.
Camlp5 Version 7.04:
--------------------
* [19 Feb 18] Updated for ocaml version 4.06.1 and 4.06.2.
* [02 Jan 18] Fixed missing treatment of native, 32 and 64 integers.
Camlp5 Version 7.03:
--------------------
* [20 Oct 17] Updated (again) for ocaml version 4.06.0.
Camlp5 Version 7.02:
--------------------
* [07 Oct 17] Updated for ocaml version 4.06.0.
* [22 Jul 17] Now "a.[i] := b" generates a call to Bytes.set instead
of String.set, as from ocaml version 4.02.0.
* [18 Jul 17] Updated for ocaml future version 4.05.1.
* [13 Jul 17] Compilation from OCaml version 4.00.0 now using parsetree
distributed with OCaml (-I +compiler-libs), no more the one copied from
OCaml sources (on ocaml_stuff directory). Set at "configure" time. (Not
fully implemented: the magic numbers are still read in ocaml_stuff
directory.) Is going to simplify Camlp5 update when new version of
OCaml is released.
* [11 Jul 17] Fixed problem of associativity in backtracking grammars,
preventing Coq to compile with CAMLP5PARAM=f or b.
Camlp5 Version 7.01:
--------------------
......
......@@ -49,20 +49,28 @@ depend:
for i in $(DIRS) compile; do (cd $$i; $(MAKE) depend; cd ..); done
install:
rm -rf "$(DESTDIR)$(LIBDIR)/$(CAMLP5N)"
@if test -z "$(LIBDIR)"; then \
echo "*** Variable LIBDIR not set"; exit 1; fi
@if test -z "$(CAMLP5N)"; then \
echo "*** Variable CAMLP5N not set"; exit 1; fi
$(RM) -rf "$(DESTDIR)$(LIBDIR)/$(CAMLP5N)"
for i in $(DIRS) compile; do \
(cd $$i; $(MAKE) install DESTDIR=$(DESTDIR); cd ..); \
done
uninstall:
rm -rf "$(DESTDIR)$(LIBDIR)/$(CAMLP5N)"
cd "$(DESTDIR)$(BINDIR)"; rm -f *$(CAMLP5N)* odyl ocpp; cd ..
cd "$(DESTDIR)$(MANDIR)/man1"; rm -f *$(CAMLP5N)* odyl ocpp; cd ../..
@if test -z "$(LIBDIR)"; then \
echo "*** Variable LIBDIR not set"; exit 1; fi
@if test -z "$(CAMLP5N)"; then \
echo "*** Variable CAMLP5N not set"; exit 1; fi
$(RM) -rf "$(DESTDIR)$(LIBDIR)/$(CAMLP5N)"
cd "$(DESTDIR)$(BINDIR)"; $(RM) -f *$(CAMLP5N)* odyl ocpp; cd ..
cd "$(DESTDIR)$(MANDIR)/man1"; $(RM) -f *$(CAMLP5N)* odyl ocpp
clean::
$(MAKE) clean_hot clean_cold
rm -f boot/*.cm[oi] boot/$(CAMLP5N)*
rm -rf boot/SAVED
$(RM) -f boot/*.cm[oi] boot/$(CAMLP5N)*
$(RM) -rf boot/SAVED
cd test; $(MAKE) clean; cd ..
scratch: clean
......@@ -87,7 +95,7 @@ backup:
restore:
mv boot/SAVED boot.new
$(MAKE) mv_git FROM=boot TO=boot.new
rm -rf boot
$(RM) -rf boot
mv boot.new boot
promote:
......@@ -111,7 +119,7 @@ compare_test:
done)
cleanboot:
rm -rf boot/SAVED/SAVED
$(RM) -rf boot/SAVED/SAVED
# Core and core bootstrap
......@@ -183,7 +191,7 @@ compare_stolen:
# Bootstrap the sources
bootstrap_sources:
rm -rf ocaml_src.new
$(RM) -rf ocaml_src.new
mkdir ocaml_src.new
$(MAKE) new_sources
$(MAKE) untouch_sources
......@@ -191,7 +199,7 @@ bootstrap_sources:
$(MAKE) clean_sources
bootstrap_source:
rm -rf ocaml_src.new
$(RM) -rf ocaml_src.new
mkdir -p ocaml_src.new/$$DIR
$(MAKE) new_source DIR=$$DIR FILE=$$FILE
mv ocaml_src.new/$$DIR/$$FILE ocaml_src/$$DIR/$$FILE
......@@ -350,7 +358,7 @@ unpromote_sources:
$(MAKE) mv_git FROM=ocaml_src.new TO=ocaml_src
clean_sources:
rm -rf ocaml_src/SAVED/SAVED
$(RM) -rf ocaml_src/SAVED/SAVED
printer:
cd etc; $(MAKE) $(PR_O)
......
......@@ -2,10 +2,10 @@ OVERVIEW
Camlp5 is a preprocessor-pretty-printer of ocaml.
It is compatible with all versions of ocaml from 1.07 to 4.06.0 (when
It is compatible with all versions of ocaml from 1.07 to 4.07.2 (when
they compile), and jocaml 3.12.0 to 3.12.1.
This Camlp5 version is 7.01.
This Camlp5 version is 7.07.
INSTALL
......
synopsis: "Preprocessor-pretty-printer of OCaml"
description:
"""
Camlp5 is a preprocessor and pretty-printer for OCaml programs. It also provides parsing and printing tools.
As a preprocessor, it allows to:
extend the syntax of OCaml,
redefine the whole syntax of the language.
As a pretty printer, it allows to:
display OCaml programs in an elegant way,
convert from one syntax to another,
check the results of syntax extensions.
Camlp5 also provides some parsing and pretty printing tools:
extensible grammars
extensible printers
stream parsers and lexers
pretty print module
It works as a shell command and can also be used in the OCaml toplevel.
"""
opam-version: "2.0"
maintainer: "https://github.com/ocaml/opam-repository/issues"
authors: ["Daniel de Rauglaudre"]
homepage: "https://camlp5.github.io"
license: "BSD-3-Clause"
bug-reports: "https://github.com/camlp5/camlp5/issues"
dev-repo: "https://github.com/camlp5/camlp5.git"
doc: "https://camlp5.github.io/doc/html"
depends: [
"ocaml" { >= "4.02" & <= "4.07.1" }
]
build: [
["./configure" "--prefix" prefix "-libdir" lib "-mandir" man]
[make "world.opt"]
]
install: [make "install"]
remove: [
["sh" "-ecx" "./configure --prefix '%{prefix}%' -libdir '%{lib}%' -mandir '%{man}%' && %{make}% uninstall"]
[ "rm" "-rf" "%{lib}%/camlp5" ]
[ "rm" "-f" "%{man}%/man1/camlp5.1" "%{man}%/man1/camlp5o.1" "%{man}%/man1/camlp5o.opt.1" "%{man}%/man1/camlp5r.1" "%{man}%/man1/camlp5r.opt.1" "%{man}%/man1/camlp5sch.1" "%{man}%/man1/mkcamlp5.1" "%{man}%/man1/mkcamlp5.opt.1" "%{man}%/man1/ocpp5.1" ]
]
......@@ -9,6 +9,7 @@ SRC=../etc/pa_o.ml ../etc/pa_op.ml
D=o
COMP_OPT=-strict_parsing
COMP_OPT=-e "Grammar.Entry.obj Pcaml.interf" -e "Grammar.Entry.obj Pcaml.implem" -e "Grammar.Entry.obj Pcaml.top_phrase" -e "Grammar.Entry.obj Pcaml.use_file"
RM=rm
all: out
......@@ -16,18 +17,18 @@ out: $(CAMLP5N)$D.fast
opt: $(CAMLP5N)$D.fast.opt
$(CAMLP5N)$D.fast: pa_$D_fast.cmo
rm -f $(CAMLP5N)$D.fast
$(RM) -f $(CAMLP5N)$D.fast
cd ../main; $(MAKE) CAMLP5=../compile/$(CAMLP5N)$D.fast CAMLP5M="../compile/pa_$D_fast.cmo ../meta/pr_dump.cmo"
$(CAMLP5N)$D.fast.opt: pa_$D_fast.cmx
rm -f $(CAMLP5N)$D.fast.opt
$(RM) -f $(CAMLP5N)$D.fast.opt
cd ../main; $(MAKE) optp5 CAMLP5OPT=../compile/$(CAMLP5N)$D.fast.opt CAMLP5M="../compile/pa_$D_fast.cmx ../meta/pr_dump.cmx"
pa_$D_fast.ml: comp_head.ml.tpl $D_fast.ml.tmp comp_trail.ml.tpl
cat $(SRC) | sed -e "s/Plexer.gmake ()/Lazy.force P.lexer/" -e "/EXTEND/,/END/d" -e "/Grammar.Entry.of_parser/d" -e "/Grammar.Entry.gcreate/d" -e "/Grammar.Entry.create/d" | grep -v '#load' | grep -v "^IFDEF" | grep -v "^END" | grep -v DELETE_RULE | cat comp_head.ml.tpl - $D_fast.ml.tmp comp_trail.ml.tpl > pa_$D_fast.ml
$D_fast.ml.tmp: compile.cmo $(SRC)
OCAMLN=$(OCAMLN) CAMLP5N=$(CAMLP5N) EXE=$(EXE) ./compile.sh $(COMP_OPT) $(SRC) > $D_fast.ml.tmp
OCAMLN=$(OCAMLN) CAMLP5N=$(CAMLP5N) EXE=$(EXE) RM=$(RM) ./compile.sh $(COMP_OPT) $(SRC) > $D_fast.ml.tmp
install:
if test -f $(CAMLP5N)o.fast.opt; then \
......@@ -38,15 +39,15 @@ install:
fi
clean::
rm -f *.cm* *.pp[io] *.[oa] *.lib *.obj *.bak .*.bak *.out *.opt
rm -f *.fast tmp.* pa_*_fast.ml *_fast.ml.tmp
$(RM) -f *.cm* *.pp[io] *.[oa] *.lib *.obj *.bak .*.bak *.out *.opt
$(RM) -f *.fast tmp.* pa_*_fast.ml *_fast.ml.tmp
depend:
cp .depend .depend.bak
> .depend
@export LC_ALL=C; for i in *.ml; do \
../tools/depend.sh $(INCLUDES) -name $(CAMLP5N) $$i | \
sed -e 's| $(OTOP)| $$(OTOP)|g' >> .depend; \
../tools/depend.sh $(INCLUDES) -name $(CAMLP5N) $$i \
>> .depend; \
done
include .depend
......@@ -550,7 +550,7 @@ and scan_symbol list =
| Sflag s -> scan_symbol list s
| Stree t -> scan_tree list t
| Svala _ s -> scan_symbol list s
| Smeta _ _ _ | Sself | Snext | Stoken _ -> list ]
| Smeta _ _ _ | Sself | Snext | Scut | Stoken _ -> list ]
and scan_level list lev =
let list = scan_tree list lev.lsuffix in
let list = scan_tree list lev.lprefix in
......
......@@ -15,7 +15,8 @@ while test "" != "$1"; do
shift
done
cat $FILES | sed -e 's/Pcaml.parse_i.*$//' | grep -v '#load' > tmp.ml
cat $FILES | sed -e 's/Pcaml.parse_i.*$//' -e 's|/; ||g' |
grep -v '#load' > tmp.ml
echo "Compile.entries.val := [$ENTRIES];" >> tmp.ml
> tmp.mli
echo "${OCAMLN}c -c tmp.mli" 1>&2
......@@ -24,8 +25,8 @@ echo "${OCAMLN}run$EXE ../meta/${CAMLP5N}r$EXE -nolib -I ../meta pa_macro.cmo pa
${OCAMLN}run$EXE ../meta/${CAMLP5N}r$EXE -nolib -I ../meta pa_macro.cmo pa_extend.cmo q_MLast.cmo -meta_action tmp.ml -o tmp.ppo
echo "${OCAMLN}c -I ../lib -I ../main -c -impl tmp.ppo" 1>&2
${OCAMLN}c -I ../lib -I ../main -c -impl tmp.ppo
echo "rm tmp.ppo" 1>&2
rm tmp.ppo
echo "${RM} tmp.ppo" 1>&2
${RM} tmp.ppo
echo "${OCAMLN}run$EXE ../main/${CAMLP5N}$EXE ./compile.cmo ./tmp.cmo ../etc/pr_r.cmo ../etc/pr_rp.cmo $ARGS -sep "\n\n" -impl - < /dev/null" 1>&2
${OCAMLN}run$EXE ../main/${CAMLP5N}$EXE ./compile.cmo ./tmp.cmo ../etc/pr_r.cmo ../etc/pr_rp.cmo $ARGS -sep "\n\n" -impl - < /dev/null
rm tmp.*
${RM} tmp.*
......@@ -5,6 +5,7 @@ OCAMLC=@OPT=$(OPT) EXE=$(EXE) OCAMLN=$(OCAMLN) ../tools/ocamlc.sh
OCAMLOPT=@OPT=$(OPT) EXE=$(EXE) OCAMLN=$(OCAMLN) ../tools/ocamlopt.sh
OCAMLCFLAGS=
MKDIR=mkdir -p
RM=rm
TEST_DIR=test `basename "$<"` = "$<" || { echo "File \"$<\" needs to be recompiled."; echo "Please run 'make' in directory '$$(dirname "$<")' first."; exit 1; }
COMPWITH=old
......@@ -14,16 +15,16 @@ COMPWITH=old
@$(TEST_DIR)
@$(CAMLP5_COMM) $< -o $*.ppi
$(OCAMLC) $(OCAMLCFLAGS) -c -intf $*.ppi
rm -f $*.ppi
$(RM) -f $*.ppi
.ml.cmo:
@$(TEST_DIR)
@$(CAMLP5_COMM) $< -o $*.ppo
$(OCAMLC) $(OCAMLCFLAGS) -c -impl $*.ppo
rm -f $*.ppo
$(RM) -f $*.ppo
.ml.cmx:
@$(TEST_DIR)
@$(CAMLP5_COMM) $< -o $*.ppo
$(OCAMLOPT) $(OCAMLCFLAGS) -c -impl $*.ppo
rm -f $*.ppo
$(RM) -f $*.ppo
......@@ -189,9 +189,9 @@ x="$(echo 'Sys.os_type;;' | ocaml | grep 'Win32')"
if test "$x" = ""; then win32=false; else win32=true; fi
OLIBDIR="$y"
if [ "$OVERSION" "<" "4.00" ]; then
OCLIBDIR="$y"
OCLIBDIR="."
else
OCLIBDIR="$y/compiler-libs"
OCLIBDIR="+compiler-libs"
fi
if test "$win" = "true"; then
......@@ -269,7 +269,6 @@ echo EXT_LIB=$EXT_LIB
echo OVERSION=$OVERSION
echo VERSION=$VERSION
echo VERSDIR=$verspfx
echo "OTOP=\$(TOP)/ocaml_stuff$verspfx/$OVERSION"
echo OCAMLC_W_Y=\"$OCAMLC_W_Y\"
echo WARNERR=\"$WARNERR\"
echo NO_PR_DIR=$NO_PR_DIR
......@@ -278,6 +277,14 @@ echo OCLIBDIR=$OCLIBDIR
if test "$prefix" != ""; then
echo PREFIX=$prefix
fi
if test "$OVERSION" "<" "4.00.0"; then
echo "OTOPP=\$(TOP)/ocaml_stuff$verspfx/$OVERSION/parsing"
echo "OTOPW=\$(TOP)/ocaml_stuff$verspfx/$OVERSION/utils"
else
echo "OTOPP=$OCLIBDIR"
echo "OTOPW=$OCLIBDIR"
fi
echo "OTOPU=\$(TOP)/ocaml_stuff$verspfx/$OVERSION/utils"
echo BINDIR=$BINDIR
echo LIBDIR=$LIBDIR
echo MANDIR=$MANDIR
......
camlp5 (7.01-2) UNRELEASED; urgency=medium
camlp5 (7.07-1) UNRELEASED; urgency=medium
* New upstream release
* Bump debhelper compat level to 12 and switch to dh
* Update Vcs-*
* Bump Standards-Version to 4.4.0
......
......@@ -51,15 +51,15 @@ META: META.tpl
$(CAMLP5N)o$(EXE): ../main/$(CAMLP5N)$(EXE) $(CAMLP5OM)
rm -f $(CAMLP5N)o$(EXE)
$(RM) -f $(CAMLP5N)o$(EXE)
cd ../main; $(MAKE) CAMLP5=../etc/$(CAMLP5N)o$(EXE) CAMLP5M="-I ../etc $(CAMLP5OM)"
$(CAMLP5N)sch$(EXE): ../main/$(CAMLP5N)$(EXE) $(CAMLP5SCHM)
rm -f $(CAMLP5N)sch$(EXE)
$(RM) -f $(CAMLP5N)sch$(EXE)
cd ../main; $(MAKE) CAMLP5=../etc/$(CAMLP5N)sch$(EXE) CAMLP5M="-I ../etc $(CAMLP5SCHM)"
$(CAMLP5N)o.opt: $(CAMLP5OMX)
rm -f $(CAMLP5N)o.opt
$(RM) -f $(CAMLP5N)o.opt
cd ../main; $(MAKE) optp5 CAMLP5OPT=../etc/$(CAMLP5N)o.opt CAMLP5M="-I ../etc $(CAMLP5OMX)"
mk$(CAMLP5N).sh: mkcamlp5.sh.tpl
......@@ -81,30 +81,31 @@ bootstrap_l:
ocamlrun$(EXE) ../boot/$(CAMLP5N) ./pa_$Lr.cmo -I ../boot pa_extend.cmo ./pr_r.cmo ./pr_extend.cmo ./pr_rp.cmo ./q_phony.cmo pa_$L.ml > tmp
mv pa_$Lr.ml pa_$Lr.ml.old
sed -e 's/^;; \(.*\)$$/(* \1 *)/' -e 's/^; \(.*\)$$/(* \1 *)/' -e 's|./pa_$Lr.cmo|pa_r.cmo pa_rp.cmo|' -e 's/$$Id.*\$$/File generated by pretty print; do not edit!/' tmp > pa_$Lr.ml
rm -f tmp
$(RM) -f tmp
compare_l:
ocamlrun$(EXE) ../boot/$(CAMLP5N) ./pa_$Lr.cmo -I ../boot pa_extend.cmo ./pr_r.cmo ./pr_extend.cmo ./pr_rp.cmo ./q_phony.cmo pa_$L.ml | sed -e 's/^;; \(.*\)$$/(* \1 *)/' -e 's/^; \(.*\)$$/(* \1 *)/' -e 's|./pa_$Lr.cmo|pa_r.cmo pa_rp.cmo|' -e 's/$$Id.*\$$/File generated by pretty print; do not edit!/' | diff -c pa_$Lr.ml -
clean::
rm -f *.cm* *.pp[io] *.[ao] *.obj *.lib *.bak .*.bak *.out *.opt
rm -f mk$(CAMLP5N).sh mk$(CAMLP5N).opt.sh $(CAMLP5N)o$(EXE) $(CAMLP5N)sch$(EXE)
rm -f META
$(RM) -f *.cm* *.pp[io] *.[ao] *.obj *.lib *.bak .*.bak *.out *.opt
$(RM) -f mk$(CAMLP5N).sh mk$(CAMLP5N).opt.sh $(CAMLP5N)o$(EXE) $(CAMLP5N)sch$(EXE)
$(RM) -f META
depend:
cp .depend .depend.bak
> .depend
@export LC_ALL=C; for i in $$(ls *.mli *.ml); do \
../tools/depend.sh $(INCLUDES) -name $(CAMLP5N) $$i | \
sed -e 's| $(OTOP)| $$(OTOP)|g' >> .depend; \
../tools/depend.sh $(INCLUDES) -name $(CAMLP5N) $$i \
>> .depend; \
done
get_promote:
install:
-$(MKDIR) "$(DESTDIR)$(LIBDIR)/$(CAMLP5N)" "$(DESTDIR)$(BINDIR)"
rm -f "$(DESTDIR)$(LIBDIR)/$(CAMLP5N)/pa_lex.cmo"
$(RM) -f "$(DESTDIR)$(LIBDIR)/$(CAMLP5N)/pa_lex.cmo"
cp $(OBJS) "$(DESTDIR)$(LIBDIR)/$(CAMLP5N)/."
cp META "$(DESTDIR)$(LIBDIR)/$(CAMLP5N)/."
cp lib.sml "$(DESTDIR)$(LIBDIR)/$(CAMLP5N)/."
cp $(CAMLP5N)o$(EXE) $(CAMLP5N)sch$(EXE) "$(DESTDIR)$(BINDIR)/."
cp mk$(CAMLP5N).sh "$(DESTDIR)$(BINDIR)/mk$(CAMLP5N)"
......
......@@ -4,6 +4,7 @@
OLIB=`OCAMLNc -where`
LIB=LIBDIR/CAMLP5N
RM=rm -f
INTERFACES=
OPTS=
INCL="-I ."
......@@ -42,4 +43,4 @@ trap 'rm -f $CRC.ml $CRC.cmi $CRC.cmo' 0 2
$OLIB/extract_crc -I $OLIB $INCL $INTERFACES > $CRC.ml
echo "let _ = Dynlink.add_available_units crc_unit_list" >> $CRC.ml
OCAMLNc -I $LIB odyl.cma CAMLP5N.cma $CRC.ml $INCL $OPTS odyl.cmo -linkall
rm -f $CRC.ml $CRC.cmi $CRC.cmo
$RM $CRC.ml $CRC.cmi $CRC.cmo
......@@ -412,8 +412,8 @@ EXTEND
<:str_item< module type $_:i$ = $mt$ >>
| "open"; i = V mod_ident "list" "" ->
<:str_item< open $_:i$ >>
| "type"; tdl = V (LIST1 type_decl SEP "and") ->
<:str_item< type $_list:tdl$ >>
| "type"; nr = V (FLAG "nonrec"); tdl = V (LIST1 type_decl SEP "and") ->
<:str_item< type $_flag:nr$ $_list:tdl$ >>
| "let"; r = V (FLAG "rec"); l = V (LIST1 let_binding SEP "and"); "in";
x = expr ->
let e = <:expr< let $_flag:r$ $_list:l$ in $x$ >> in
......@@ -425,7 +425,8 @@ EXTEND
[ <:patt< _ >> -> <:str_item< $exp:e$ >>
| _ -> <:str_item< value $_flag:r$ $_list:l$ >> ]
| _ -> <:str_item< value $_flag:r$ $_list:l$ >> ]
| "let"; "module"; m = V UIDENT; mb = mod_fun_binding; "in"; e = expr ->
| "let"; "module"; m = V UIDENT; mb = mod_fun_binding; "in";
e = expr ->
<:str_item< let module $_uid:m$ = $mb$ in $e$ >>
| "let"; "open"; m = module_expr; "in"; e = expr ->
<:str_item< let open $m$ in $e$ >>
......@@ -1351,7 +1352,7 @@ EXTEND
| EOI -> ([], Some loc) ] ]
;
str_item_semi:
[ [ si = str_item; OPT ";;" -> (si, loc) ] ]
[ [ /; si = str_item; OPT ";;" -> (si, loc) ] ]
;
top_phrase:
[ [ ph = phrase; ";;" -> Some ph
......
......@@ -811,8 +811,8 @@ value val_tab = do {
fun loc ->
{ctyp =
<:ctyp<
MLast.loc -> list MLast.type_decl -> MLast.str_item >>;
expr = Obj.repr (fun loc tdl -> MLast.StTyp loc tdl);
MLast.loc -> bool -> list MLast.type_decl -> MLast.str_item >>;
expr = Obj.repr (fun loc flg tdl -> MLast.StTyp loc flg tdl);
patt = no_patt loc});
("MLast.StVal",
fun loc ->
......
......@@ -51,6 +51,7 @@ type symbol =
| Sflag of symbol
| Sself
| Snext
| Scut
| Stoken of alt Plexing.pattern MLast.expr
| Srules of list (list (option MLast.patt * symbol) * option MLast.expr)
| Svala of list string and option string and symbol ]
......@@ -168,10 +169,38 @@ value rec unrule =
in
let sl = unpsymbol_list (List.rev pl) e1 in
(sl, a)
| <:expr< Grammar.production ($e1$, $e2$) >> ->
let (pl, a) =
match unaction e2 with
[ ([], None) -> let loc = Ploc.dummy in ([], Some <:expr< () >>)
| x -> x ]
in
let e1 =
loop [] e1 where rec loop rel =
fun
[ <:expr< Grammar.r_next $el$ $e$ >> -> loop [e :: rel] el
| <:expr< Grammar.r_stop >> -> rel
| <:expr:< Grammar.r_cut $el$ >> -> loop [<:expr< cut >> :: rel] el
| _ -> raise Not_found ]
in
let sl = safe_unpsymbol_list (List.rev pl) e1 in
(sl, a)
| _ -> raise Not_found ]
and safe_unpsymbol_list pl el =
match (pl, el) with
| ([], []) -> []
| (pl, [<:expr< cut >> :: el]) ->
[(None, Scut) :: safe_unpsymbol_list pl el]
| ([p :: pl], [e :: el]) ->
let op = match p with [ <:patt< _ >> -> None | _ -> Some p ] in
[(op, safe_unsymbol e) :: safe_unpsymbol_list pl el]
| _ -> raise Not_found
end
and unpsymbol_list pl e =
match (pl, e) with
[ ([], <:expr< [] >>) -> []
| (_, <:expr< [Gramext.Scut :: $el$] >>) ->
[(None, Scut) :: unpsymbol_list pl el]
| ([p :: pl], <:expr< [$e$ :: $el$] >>) ->
let op =
match p with
......@@ -180,6 +209,27 @@ and unpsymbol_list pl e =
in
[(op, unsymbol e) :: unpsymbol_list pl el]
| _ -> raise Not_found ]
and safe_unsymbol =
fun
| <:expr< Grammar.s_facto $e$ >> -> safe_unsymbol e
| <:expr< Grammar.s_nterm ($e$ : $_$) >> -> Snterm e
| <:expr< Grammar.s_nterml ($e$ : $_$) $str:s$ >> -> Snterml e s
| <:expr< Grammar.s_list0 $e$ >> -> Slist0 (safe_unsymbol e)
| <:expr< Grammar.s_list0sep $e1$ $e2$ $b$ >> ->
Slist0sep (safe_unsymbol e1) (safe_unsymbol e2) (unbool b)
| <:expr< Grammar.s_list1 $e$ >> -> Slist1 (safe_unsymbol e)
| <:expr< Grammar.s_list1sep $e1$ $e2$ $b$ >> ->
Slist1sep (safe_unsymbol e1) (safe_unsymbol e2) (unbool b)
| <:expr< Grammar.s_opt $e$ >> -> Sopt (safe_unsymbol e)
| <:expr< Grammar.s_flag $e$ >> -> Sflag (safe_unsymbol e)
| <:expr< Grammar.s_self >> -> Sself
| <:expr< Grammar.s_next >> -> Snext
| <:expr< Grammar.s_token $e$ >> -> Stoken (untoken e)
| <:expr< Grammar.s_rules $e$ >> -> Srules (rev_unlist unrule [] e)
| <:expr< Grammar.s_vala $ls$ $e$ >> ->
Svala (unlist unstring ls) None (safe_unsymbol e)
| _ -> raise Not_found
end
and unsymbol =
fun
[ <:expr< Gramext.Sfacto $e$ >> -> unsymbol e
......@@ -202,6 +252,7 @@ and unsymbol =
| <:expr< Gramext.Sflag $e$ >> -> Sflag (unsymbol e)
| <:expr< Gramext.Sself >> -> Sself
| <:expr< Gramext.Snext >> -> Snext
| <:expr< Gramext.Scut >> -> Scut
| <:expr< Gramext.Stoken $e$ >> -> Stoken (untoken e)
| <:expr< Gramext.srules $e$ >> -> Srules (rev_unlist unrule [] e)
| <:expr< Gramext.Svala $ls$ $e$ >> ->
......@@ -222,6 +273,10 @@ value unentry =
(Grammar.Entry.obj ($e$ : Grammar.Entry.e '$_$), $pos$, $ll$)
>> ->
(e, unposition pos, unlist unlevel ll)
| <:expr<
Grammar.extension ($e$ : Grammar.Entry.e '$_$) $pos$ $ll$
>> ->
(e, unposition pos, unlist unlevel ll)
| _ -> raise Not_found ]
;
......@@ -328,7 +383,7 @@ value rec rule force_vertic pc (sl, a) =
[ None -> not_impl "rule 1" pc sl
| Some a ->
if sl = [] then
pprintf pc "@[<4>->%p %q@]" comment (MLast.loc_of_expr a)
pprintf pc "@[<4>%p %q@]" comment (MLast.loc_of_expr a)
(action expr) a "|"
else
match
......@@ -336,7 +391,7 @@ value rec rule force_vertic pc (sl, a) =
(fun () ->
let s =
let pc = {(pc) with aft = ""} in
pprintf pc "%p ->" (hlistl (semi_after psymbol) psymbol) sl
pprintf pc "%p " (hlistl (semi_after psymbol) psymbol) sl
in
Some s)
(fun () -> None)
......@@ -351,7 +406,7 @@ value rec rule force_vertic pc (sl, a) =
pprintf pc "%s@;<1 4>%q" s1 (action expr) a "|")
| None ->
let sl = List.map (fun s -> (s, ";")) sl in
pprintf pc "@[<2>%p ->@;%q@]" (plist psymbol 0) sl
pprintf pc "@[<2>%p @;%q@]" (plist psymbol 0) sl
(action expr) a "|" ] ]
and psymbol pc (p, s) =
match p with
......@@ -397,6 +452,7 @@ and simple_symbol pc sy =
[ Snterm <:expr< $lid:s$ >> -> pprintf pc "%s" s
| Sself -> pprintf pc "SELF"
| Snext -> pprintf pc "NEXT"
| Scut -> pprintf pc "/"
| Srules rl ->
match check_slist rl with
[ Some _ -> pprintf pc "(%p)" symbol sy
......@@ -576,15 +632,23 @@ value extend pc e =
pprintf pc "EXTEND@;%p@ END" extend_body ex
with
[ Not_found -> pprintf pc "Grammar.extend@;@[<1>(%p)@]" expr e ]
| <:expr< Grammar.safe_extend $e$ >> ->
try
let ex = unextend_body e in
pprintf pc "EXTEND@;%p@ END" extend_body ex
with
[ Not_found -> pprintf pc "Grammar.safe_extend@;@[<1>(%p)@]" expr e ]
| e -> expr pc e ]
;
EXTEND_PRINTER
pr_expr: LEVEL "apply"
[ [ <:expr< Grammar.extend $_$ >> as e -> next pc e ] ]
[ [ <:expr< Grammar.extend $_$ >> as e -> next pc e
| <:expr< Grammar.safe_extend $_$ >> as e -> next pc e ] ]
;
pr_expr: LEVEL "simple"
[ [ <:expr< Grammar.extend $_$ >> as e -> extend pc e ] ]
[ [ <:expr< Grammar.extend $_$ >> as e -> extend pc e
| <:expr< Grammar.safe_extend $_$ >> as e -> extend pc e ] ]
;
END;
......
......@@ -1560,8 +1560,8 @@ EXTEND_PRINTER
sig_module_or_module_type "module type" False '=' pc (m, mt)
| <:str_item:< open $i$ >> ->
pprintf pc "open %p" mod_ident (loc, i)
| <:str_item:< type $list:tdl$ >> ->
pprintf pc "type %p"
| <:str_item:< type $flag:nonrf$ $list:tdl$ >> ->
pprintf pc "type%s %p" (if nonrf then " nonrec" else "")
(vlist2 type_decl (and_before type_decl)) tdl
| <:str_item:< value $flag:rf$ $list:pel$ >> ->
horiz_vertic
......
......@@ -1654,8 +1654,9 @@ EXTEND_PRINTER
sig_module_or_module_type "module type" '=' pc (m, mt)
| <:str_item:< open $i$ >> ->
pprintf pc "open %p" mod_ident (loc, i)
| <:str_item< type $list:tdl$ >> ->
pprintf pc "type %p" (vlist2 type_decl (and_before type_decl)) tdl
| <:str_item< type $flag:nonrf$ $list:tdl$ >> ->
pprintf pc "type%s %p" (if nonrf then " nonrec" else "")
(vlist2 type_decl (and_before type_decl)) tdl
| <:str_item< value $flag:rf$ $list:pel$ >> ->
horiz_vertic
(fun () ->
......
......@@ -34,11 +34,3 @@ stdpp.cmi: ploc.cmi
token.cmo: plexing.cmi ploc.cmi token.cmi
token.cmx: plexing.cmx ploc.cmx token.cmi
token.cmi: plexing.cmi ploc.cmi
versdep.cmo: $(OTOP)/parsing/asttypes.cmi \
$(OTOP)/parsing/location.cmi \
$(OTOP)/parsing/longident.cmi \
$(OTOP)/parsing/parsetree.cmi
versdep.cmx: $(OTOP)/parsing/asttypes.cmi \
$(OTOP)/parsing/location.cmi \
$(OTOP)/parsing/longident.cmi \
$(OTOP)/parsing/parsetree.cmi
......@@ -3,8 +3,7 @@
TOP=..
include $(TOP)/config/Makefile
INCLUDES=-I $(OTOP)/parsing
OCAMLCFLAGS=$(WARNERR) $(INCLUDES)
OCAMLCFLAGS=$(WARNERR) -I $(OTOPP)
OBJS=versdep.cmo ploc.cmo plexing.cmo plexer.cmo fstream.cmo gramext.cmo grammar.cmo diff.cmo extfold.cmo extfun.cmo pretty.cmo pprintf.cmo eprinter.cmo stdpp.cmo token.cmo
SHELL=/bin/sh
TARGET=gramlib.cma
......@@ -19,15 +18,14 @@ $(TARGET:.cma=.cmxa): $(OBJS:.cmo=.cmx)
$(OCAMLOPT) $(OBJS:.cmo=.cmx) -a -o $(TARGET:.cma=.cmxa)
clean::
rm -f *.cm[ioax] *.cmxa *.pp[io] *.[ao] *.obj *.lib *.bak .*.bak
rm -f $(TARGET)
$(RM) -f *.cm[ioax] *.cmxa *.pp[io] *.[ao] *.obj *.lib *.bak .*.bak
$(RM) -f $(TARGET)
depend:
cp .depend .depend.bak
> .depend
@export LC_ALL=C; for i in $$(ls *.mli *.ml); do \
../tools/depend.sh $(INCLUDES) -name $(CAMLP5N) $$i | \
sed -e 's| $(OTOP)| $$(OTOP)|g' >> .depend; \
../tools/depend.sh -name $(CAMLP5N) $$i >> .depend; \
done
promote:
......
......@@ -2,6 +2,8 @@
(* fstream.ml,v *)
(* Copyright (c) INRIA 2007-2017 *)
exception Cut;
type mlazy_c 'a =
[ Lfun of unit -> 'a
| Lval of 'a ]
......