ocaml-tools-20120103/0000755000175000017500000000000011230634277013140 5ustar mehdimehdiocaml-tools-20120103/autoconf/0000755000175000017500000000000011230640770014751 5ustar mehdimehdiocaml-tools-20120103/autoconf/Makefile.in0000644000175000017500000001132511230640770017020 0ustar mehdimehdi # WARNING: THIS EXAMPLE IS BASED ON OBSOLETE AUTOCONF MACROS # More up to date autoconf macros for OCaml are now available under # the name of ocaml-autoconf at: http://ocaml-autoconf.forge.ocamlcore.org/ # In Debian, they are shipped by the ocaml-tools package. # Just type "man ocaml.m4" to discover how to user them. # # sample Makefile for Objective Caml # Copyright (C) 2001 Jean-Christophe FILLIATRE # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License version 2, as published by the Free Software Foundation. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # See the GNU Library General Public License version 2 for more details # (enclosed in the file LGPL). # where to install the binaries prefix=@prefix@ exec_prefix=@exec_prefix@ BINDIR=@bindir@ # where to install the man page MANDIR=@mandir@ # other variables set by ./configure OCAMLC = @OCAMLC@ OCAMLOPT = @OCAMLOPT@ OCAMLDEP = @OCAMLDEP@ OCAMLLEX = @OCAMLLEX@ OCAMLYACC= @OCAMLYACC@ OCAMLLIB = @OCAMLLIB@ OCAMLBEST= @OCAMLBEST@ OCAMLVERSION = @OCAMLVERSION@ OCAMLWEB = @OCAMLWEB@ OCAMLWIN32 = @OCAMLWIN32@ EXE = @EXE@ INCLUDES = BFLAGS = -g $(INCLUDES) OFLAGS = $(INCLUDES) # main target ############# NAME = project all: $(OCAMLBEST) # bytecode and native-code compilation ###################################### CMO = CMX = $(CMO:.cmo=.cmx) GENERATED = version.ml byte: $(NAME).byte opt: $(NAME).opt $(NAME).byte: $(CMO) $(OCAMLC) $(BFLAGS) -o $@ $^ $(NAME).opt: $(CMX) $(OCAMLOPT) $(OFLAGS) -o $@ $^ VERSION=0.1 version.ml: Makefile echo "let version = \""$(VERSION)"\"" > version.ml echo "let date = \""`date`"\"" >> version.ml # installation ############## install-indep: mkdir -p $(BINDIR) mkdir -p $(MANDIR)/man1 cp -f $(NAME).1 $(MANDIR)/man1 install: install-indep cp -f $(NAME).$(OCAMLBEST) $(BINDIR)/$(NAME)$(EXE) install-byte: install-indep cp -f $(NAME).byte $(BINDIR)/$(NAME)$(EXE) install-opt: install-indep cp -f $(NAME).opt $(BINDIR)/$(NAME)$(EXE) # documentation ############### DOCFILES=manual.ps manual.html doc: $(DOCFILES) # export ######## EXPORTDIR=$(NAME)-$(VERSION) TAR=$(EXPORTDIR).tar FTP = $$HOME/ftp/$(NAME) WWW = $$HOME/WWW/$(NAME) FILES = *.ml* $(NAME).1 manual.tex \ Makefile.in configure configure.in \ .depend README INSTALL COPYING GPL CHANGES export: source binary export-doc cp README COPYING GPL CHANGES $(FTP) source: mkdir -p export/$(EXPORTDIR) cp $(FILES) export/$(EXPORTDIR) cd export ; tar cf $(TAR) $(EXPORTDIR) ; gzip -f --best $(TAR) cp export/$(TAR).gz $(FTP) export-doc: $(DOCFILES) gzip -c manual.ps > $(FTP)/manual.ps.gz cp manual.html $(WWW) BINARY = $(EXPORTDIR)-$(OSTYPE) BINARYTAR=$(BINARY).tar BINARYFILES = README INSTALL COPYING GPL $(NAME).1 binary: $(NAME).$(OCAMLBEST) $(DOCFILES) mkdir -p export/$(BINARY) cp $(BINARYFILES) $(DOCFILES) export/$(BINARY) cp $(NAME).$(OCAMLBEST) export/$(BINARY)/$(NAME) (cd export; tar czf $(BINARY).tar.gz $(BINARY)) cp export/$(BINARY).tar.gz $(FTP) # literate programming ###################### SOURCES = $(NAME).tex: $(SOURCES) $(OCAMLWEB) -o $@ $^ # generic rules ############### .SUFFIXES: .mli .ml .cmi .cmo .cmx .mll .mly .tex .dvi .ps .html .mli.cmi: $(OCAMLC) -c $(BFLAGS) $< .ml.cmo: $(OCAMLC) -c $(BFLAGS) $< .ml.o: $(OCAMLOPT) -c $(OFLAGS) $< .ml.cmx: $(OCAMLOPT) -c $(OFLAGS) $< .mll.ml: $(OCAMLLEX) $< .mly.ml: $(OCAMLYACC) -v $< .mly.mli: $(OCAMLYACC) -v $< .tex.dvi: latex $< && latex $< .dvi.ps: dvips $< -o $@ .tex.html: hevea $< # Emacs tags ############ tags: find . -name "*.ml*" | sort -r | xargs \ etags "--regex=/let[ \t]+\([^ \t]+\)/\1/" \ "--regex=/let[ \t]+rec[ \t]+\([^ \t]+\)/\1/" \ "--regex=/and[ \t]+\([^ \t]+\)/\1/" \ "--regex=/type[ \t]+\([^ \t]+\)/\1/" \ "--regex=/exception[ \t]+\([^ \t]+\)/\1/" \ "--regex=/val[ \t]+\([^ \t]+\)/\1/" \ "--regex=/module[ \t]+\([^ \t]+\)/\1/" # Makefile is rebuilt whenever Makefile.in or configure.in is modified ###################################################################### Makefile: Makefile.in config.status ./config.status config.status: configure ./config.status --recheck configure: configure.in autoconf # clean ####### clean:: rm -f *.cm[iox] *.o *~ rm -f $(GENERATED) parser.output rm -f $(NAME).byte $(NAME).opt rm -f *.aux *.log $(NAME).tex $(NAME).dvi $(NAME).ps dist-clean distclean:: clean rm -f Makefile config.cache config.log config.status # depend ######## .depend depend:: $(GENERATED) rm -f .depend $(OCAMLDEP) $(INCLUDES) *.ml *.mli > .depend include .depend ocaml-tools-20120103/autoconf/configure.in0000644000175000017500000001145211230640534017263 0ustar mehdimehdi # WARNING: THESE MACROS ARE OBSOLETE # More up to date autoconf macros for OCaml are now available under # the name of ocaml-autoconf at: http://ocaml-autoconf.forge.ocamlcore.org/ # In Debian, they are shipped by the ocaml-tools package. # Just type "man ocaml.m4" to discover how to user them. # autoconf input for Objective Caml programs # Copyright (C) 2001 Jean-Christophe Filliâtre # from a first script by Georges Mariano # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License version 2, as published by the Free Software Foundation. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # See the GNU Library General Public License version 2 for more details # (enclosed in the file LGPL). # the script generated by autoconf from this input will set the following # variables: # OCAMLC "ocamlc" if present in the path, or a failure # or "ocamlc.opt" if present with same version number as ocamlc # OCAMLOPT "ocamlopt" (or "ocamlopt.opt" if present), or "no" # OCAMLBEST either "byte" if no native compiler was found, # or "opt" otherwise # OCAMLDEP "ocamldep" # OCAMLLEX "ocamllex" (or "ocamllex.opt" if present) # OCAMLYACC "ocamlyac" # OCAMLLIB the path to the ocaml standard library # OCAMLVERSION the ocaml version number # OCAMLWEB "ocamlweb" (not mandatory) # OCAMLWIN32 "yes"/"no" depending on Sys.os_type = "Win32" # EXE ".exe" if OCAMLWIN32=yes, "" otherwise # check for one particular file of the sources # ADAPT THE FOLLOWING LINE TO YOUR SOURCES! AC_INIT(web.mli) # Check for Ocaml compilers # we first look for ocamlc in the path; if not present, we fail AC_CHECK_PROG(OCAMLC,ocamlc,ocamlc,no) if test "$OCAMLC" = no ; then AC_MSG_ERROR(Cannot find ocamlc.) fi # we extract Ocaml version number and library path OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version *\(.*\)$|\1|p' ` echo "ocaml version is $OCAMLVERSION" OCAMLLIB=`$OCAMLC -v | tail -1 | cut -f 4 -d " "` echo "ocaml library path is $OCAMLLIB" # then we look for ocamlopt; if not present, we issue a warning # if the version is not the same, we also discard it # we set OCAMLBEST to "opt" or "byte", whether ocamlopt is available or not AC_CHECK_PROG(OCAMLOPT,ocamlopt,ocamlopt,no) OCAMLBEST=byte if test "$OCAMLOPT" = no ; then AC_MSG_WARN(Cannot find ocamlopt; bytecode compilation only.) else AC_MSG_CHECKING(ocamlopt version) TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version *\(.*\)$|\1|p' ` if test "$TMPVERSION" != "$OCAMLVERSION" ; then AC_MSG_RESULT(differs from ocamlc; ocamlopt discarded.) OCAMLOPT=no else AC_MSG_RESULT(ok) OCAMLBEST=opt fi fi # checking for ocamlc.opt AC_CHECK_PROG(OCAMLCDOTOPT,ocamlc.opt,ocamlc.opt,no) if test "$OCAMLCDOTOPT" != no ; then AC_MSG_CHECKING(ocamlc.opt version) TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version *\(.*\)$|\1|p' ` if test "$TMPVERSION" != "$OCAMLVERSION" ; then AC_MSG_RESULT(differs from ocamlc; ocamlc.opt discarded.) else AC_MSG_RESULT(ok) OCAMLC=$OCAMLCDOTOPT fi fi # checking for ocamlopt.opt if test "$OCAMLOPT" != no ; then AC_CHECK_PROG(OCAMLOPTDOTOPT,ocamlopt.opt,ocamlopt.opt,no) if test "$OCAMLOPTDOTOPT" != no ; then AC_MSG_CHECKING(ocamlc.opt version) TMPVER=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version *\(.*\)$|\1|p' ` if test "$TMPVER" != "$OCAMLVERSION" ; then AC_MSG_RESULT(differs from ocamlc; ocamlopt.opt discarded.) else AC_MSG_RESULT(ok) OCAMLOPT=$OCAMLOPTDOTOPT fi fi fi # ocamldep, ocamllex and ocamlyacc should also be present in the path AC_CHECK_PROG(OCAMLDEP,ocamldep,ocamldep,no) if test "$OCAMLDEP" = no ; then AC_MSG_ERROR(Cannot find ocamldep.) fi AC_CHECK_PROG(OCAMLLEX,ocamllex,ocamllex,no) if test "$OCAMLLEX" = no ; then AC_MSG_ERROR(Cannot find ocamllex.) else AC_CHECK_PROG(OCAMLLEXDOTOPT,ocamllex.opt,ocamllex.opt,no) if test "$OCAMLLEXDOTOPT" != no ; then OCAMLLEX=$OCAMLLEXDOTOPT fi fi AC_CHECK_PROG(OCAMLYACC,ocamlyacc,ocamlyacc,no) if test "$OCAMLYACC" = no ; then AC_MSG_ERROR(Cannot find ocamlyacc.) fi AC_CHECK_PROG(OCAMLWEB,ocamlweb,ocamlweb,true) # platform AC_MSG_CHECKING(platform) if echo "let _ = Sys.os_type" | ocaml | grep -q Win32; then AC_MSG_RESULT(Win32) OCAMLWIN32=yes EXE=.exe else OCAMLWIN32=no EXE= fi # substitutions to perform AC_SUBST(OCAMLC) AC_SUBST(OCAMLOPT) AC_SUBST(OCAMLDEP) AC_SUBST(OCAMLLEX) AC_SUBST(OCAMLYACC) AC_SUBST(OCAMLBEST) AC_SUBST(OCAMLVERSION) AC_SUBST(OCAMLLIB) AC_SUBST(OCAMLWEB) AC_SUBST(OCAMLWIN32) AC_SUBST(EXE) # Finally create the Makefile from Makefile.in AC_OUTPUT(Makefile) chmod a-w Makefile ocaml-tools-20120103/ocaml-autoconf/0000755000175000017500000000000011230634364016044 5ustar mehdimehdiocaml-tools-20120103/ocaml-autoconf/LICENSE0000644000175000017500000000305211230634327017050 0ustar mehdimehdiCopyright © 2009 Richard W.M. Jones Copyright © 2009 Stefano Zacchiroli Copyright © 2000-2005 Olivier Andrieu Copyright © 2000-2005 Jean-Christophe Filliâtre Copyright © 2000-2005 Georges Mariano Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ocaml-tools-20120103/ocaml-autoconf/Makefile0000644000175000017500000000211211230634327017477 0ustar mehdimehdiPACKAGE = ocaml-autoconf VERSION = 1.0 prefix = /usr/local datadir = $(prefix)/share mandir = $(datadir)/man INSTALL = install MKDIR_P = mkdir -p all: man ocaml.m4.txt doc: man ocaml.m4.txt ocaml.m4.html man: ocaml.m4.1 ocaml.m4.1: ocaml.m4.pod pod2man -c "Autoconf macros" --release "$(PACKAGE)-$(VERSION)" $< > $@ ocaml.m4.txt: ocaml.m4.pod pod2text $< > $@ ocaml.m4.html: ocaml.m4.pod pod2html $< > $@ clean: rm -f *~ ocaml.m4.1 ocaml.m4.txt dist: ocaml.m4.1 ocaml.m4.txt rm -rf $(PACKAGE)-$(VERSION) mkdir $(PACKAGE)-$(VERSION) install -m 0644 \ LICENSE README \ Makefile \ ocaml.m4 \ ocaml.m4.1 ocaml.m4.pod ocaml.m4.txt \ $(PACKAGE)-$(VERSION)/ tar -cf - $(PACKAGE)-$(VERSION) | \ gzip --best > $(PACKAGE)-$(VERSION).tar.gz rm -rf $(PACKAGE)-$(VERSION) install: install-macro install-man install-macro: $(MKDIR_P) $(DESTDIR)$(datadir)/aclocal/ $(INSTALL) -m 0644 ocaml.m4 $(DESTDIR)$(datadir)/aclocal/ install-man: $(MKDIR_P) $(DESTDIR)$(mandir)/man1/ $(INSTALL) -m 0644 ocaml.m4.1 $(DESTDIR)$(mandir)/man1/ .PHONY: man install-macro install-man ocaml-tools-20120103/ocaml-autoconf/README0000644000175000017500000000165411230634327016731 0ustar mehdimehdiThis archive contains standard, useful autoconf macros for detecting OCaml, findlib, OCaml packages, etc. http://forge.ocamlcore.org/projects/ocaml-autoconf/ Authors ---------------------------------------------------------------------- * Olivier Andrieu * Jean-Christophe Filliâtre * Richard W.M. Jones * Georges Mariano * Stefano Zacchiroli Requirements ---------------------------------------------------------------------- To build the manual page, you'll need 'perldoc' (part of Perl). Building ---------------------------------------------------------------------- To build the manual page, etc., do: make To install the manual page and macro centrally, do: make install Using ---------------------------------------------------------------------- Copy ocaml.m4 into the autoconf macros directory (usually m4/) of your project. Read the ocaml.m4 manual page for the details of how to use the macros. man ocaml.m4 ocaml-tools-20120103/ocaml-autoconf/ocaml.m40000644000175000017500000001345011230634327017403 0ustar mehdimehdidnl autoconf macros for OCaml dnl dnl Copyright © 2009 Richard W.M. Jones dnl Copyright © 2009 Stefano Zacchiroli dnl Copyright © 2000-2005 Olivier Andrieu dnl Copyright © 2000-2005 Jean-Christophe Filliâtre dnl Copyright © 2000-2005 Georges Mariano dnl dnl For documentation, please read the ocaml.m4 man page. AC_DEFUN([AC_PROG_OCAML], [dnl # checking for ocamlc AC_CHECK_TOOL([OCAMLC],[ocamlc],[no]) if test "$OCAMLC" != "no"; then OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p'` AC_MSG_RESULT([OCaml version is $OCAMLVERSION]) # If OCAMLLIB is set, use it if test "$OCAMLLIB" = ""; then OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4` else AC_MSG_RESULT([OCAMLLIB previously set; preserving it.]) fi AC_MSG_RESULT([OCaml library path is $OCAMLLIB]) AC_SUBST([OCAMLVERSION]) AC_SUBST([OCAMLLIB]) # checking for ocamlopt AC_CHECK_TOOL([OCAMLOPT],[ocamlopt],[no]) OCAMLBEST=byte if test "$OCAMLOPT" = "no"; then AC_MSG_WARN([Cannot find ocamlopt; bytecode compilation only.]) else TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` if test "$TMPVERSION" != "$OCAMLVERSION" ; then AC_MSG_RESULT([versions differs from ocamlc; ocamlopt discarded.]) OCAMLOPT=no else OCAMLBEST=opt fi fi AC_SUBST([OCAMLBEST]) # checking for ocamlc.opt AC_CHECK_TOOL([OCAMLCDOTOPT],[ocamlc.opt],[no]) if test "$OCAMLCDOTOPT" != "no"; then TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` if test "$TMPVERSION" != "$OCAMLVERSION" ; then AC_MSG_RESULT([versions differs from ocamlc; ocamlc.opt discarded.]) else OCAMLC=$OCAMLCDOTOPT fi fi # checking for ocamlopt.opt if test "$OCAMLOPT" != "no" ; then AC_CHECK_TOOL([OCAMLOPTDOTOPT],[ocamlopt.opt],[no]) if test "$OCAMLOPTDOTOPT" != "no"; then TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` if test "$TMPVERSION" != "$OCAMLVERSION" ; then AC_MSG_RESULT([version differs from ocamlc; ocamlopt.opt discarded.]) else OCAMLOPT=$OCAMLOPTDOTOPT fi fi fi AC_SUBST([OCAMLOPT]) fi AC_SUBST([OCAMLC]) # checking for ocaml toplevel AC_CHECK_TOOL([OCAML],[ocaml],[no]) # checking for ocamldep AC_CHECK_TOOL([OCAMLDEP],[ocamldep],[no]) # checking for ocamlmktop AC_CHECK_TOOL([OCAMLMKTOP],[ocamlmktop],[no]) # checking for ocamlmklib AC_CHECK_TOOL([OCAMLMKLIB],[ocamlmklib],[no]) # checking for ocamldoc AC_CHECK_TOOL([OCAMLDOC],[ocamldoc],[no]) # checking for ocamlbuild AC_CHECK_TOOL([OCAMLBUILD],[ocamlbuild],[no]) ]) AC_DEFUN([AC_PROG_OCAMLLEX], [dnl # checking for ocamllex AC_CHECK_TOOL([OCAMLLEX],[ocamllex],[no]) if test "$OCAMLLEX" != "no"; then AC_CHECK_TOOL([OCAMLLEXDOTOPT],[ocamllex.opt],[no]) if test "$OCAMLLEXDOTOPT" != "no"; then OCAMLLEX=$OCAMLLEXDOTOPT fi fi AC_SUBST([OCAMLLEX]) ]) AC_DEFUN([AC_PROG_OCAMLYACC], [dnl AC_CHECK_TOOL([OCAMLYACC],[ocamlyacc],[no]) AC_SUBST([OCAMLYACC]) ]) AC_DEFUN([AC_PROG_CAMLP4], [dnl AC_REQUIRE([AC_PROG_OCAML])dnl # checking for camlp4 AC_CHECK_TOOL([CAMLP4],[camlp4],[no]) if test "$CAMLP4" != "no"; then TMPVERSION=`$CAMLP4 -v 2>&1| sed -n -e 's|.*version *\(.*\)$|\1|p'` if test "$TMPVERSION" != "$OCAMLVERSION" ; then AC_MSG_RESULT([versions differs from ocamlc]) CAMLP4=no fi fi AC_SUBST([CAMLP4]) # checking for companion tools AC_CHECK_TOOL([CAMLP4BOOT],[camlp4boot],[no]) AC_CHECK_TOOL([CAMLP4O],[camlp4o],[no]) AC_CHECK_TOOL([CAMLP4OF],[camlp4of],[no]) AC_CHECK_TOOL([CAMLP4OOF],[camlp4oof],[no]) AC_CHECK_TOOL([CAMLP4ORF],[camlp4orf],[no]) AC_CHECK_TOOL([CAMLP4PROF],[camlp4prof],[no]) AC_CHECK_TOOL([CAMLP4R],[camlp4r],[no]) AC_CHECK_TOOL([CAMLP4RF],[camlp4rf],[no]) AC_SUBST([CAMLP4BOOT]) AC_SUBST([CAMLP4O]) AC_SUBST([CAMLP4OF]) AC_SUBST([CAMLP4OOF]) AC_SUBST([CAMLP4ORF]) AC_SUBST([CAMLP4PROF]) AC_SUBST([CAMLP4R]) AC_SUBST([CAMLP4RF]) ]) AC_DEFUN([AC_PROG_FINDLIB], [dnl AC_REQUIRE([AC_PROG_OCAML])dnl # checking for ocamlfind AC_CHECK_TOOL([OCAMLFIND],[ocamlfind],[no]) AC_SUBST([OCAMLFIND]) ]) dnl Thanks to Jim Meyering for working this next bit out for us. dnl XXX We should define AS_TR_SH if it's not defined already dnl (eg. for old autoconf). AC_DEFUN([AC_CHECK_OCAML_PKG], [dnl AC_REQUIRE([AC_PROG_FINDLIB])dnl AC_MSG_CHECKING([for OCaml findlib package $1]) unset found unset pkg found=no for pkg in $1 $2 ; do if $OCAMLFIND query $pkg >/dev/null 2>/dev/null; then AC_MSG_RESULT([found]) AS_TR_SH([OCAML_PKG_$1])=$pkg found=yes break fi done if test "$found" = "no" ; then AC_MSG_RESULT([not found]) AS_TR_SH([OCAML_PKG_$1])=no fi AC_SUBST(AS_TR_SH([OCAML_PKG_$1])) ]) AC_DEFUN([AC_CHECK_OCAML_MODULE], [dnl AC_MSG_CHECKING([for OCaml module $2]) cat > conftest.ml <&5 2>&5 ; then found=yes break fi done if test "$found" ; then AC_MSG_RESULT([$$1]) else AC_MSG_RESULT([not found]) $1=no fi AC_SUBST([$1]) ]) dnl XXX Cross-compiling AC_DEFUN([AC_CHECK_OCAML_WORD_SIZE], [dnl AC_REQUIRE([AC_PROG_OCAML])dnl AC_MSG_CHECKING([for OCaml compiler word size]) cat > conftest.ml < conftest.ml < is a file containing standard, useful autoconf macros for detecting the OCaml, findlib, OCaml packages, and so on in your autoconf-generated ./configure scripts. To begin using these macros, you will need to copy the C file (usually located at C) to the autoconf macros directory in your project. Normally this is the C directory in your project, but the directory can be changed using the C directive. If you have just created the C directory, then you may also need to do: aclocal -I m4 You can then add any of the macros described below to your C (or C). Almost every OCaml project should use C first and probably C right after it. This manual page does not describe how to use autoconf. For that you should read the detailed autoconf info file (C). =head1 AC_PROG_OCAML This macro detects which tools of the usual OCaml toolchain are available. It defines and substitutes the following variables: OCAMLC set to the name of the bytecode compiler (eg. "ocamlc" or "ocamlc.opt"), or "no" if no OCaml installation was found OCAMLOPT the name of the native-code compiler, eg. "ocamlopt", "ocamlopt.opt" or "no" OCAMLBEST "byte" (if only the bytecode compiler is available) or "opt" (if both bytecode and native code compilers are available) OCAMLDEP the name of the dependency resolver, eg. "ocamldep" OCAMLMKTOP the name of ocamlmktop OCAMLMKLIB the name of ocamlmklib OCAMLDOC the name of ocamldoc OCAMLBUILD the name of ocamlbuild OCAMLLIB the OCaml library path (eg. C) OCAMLVERSION the compiler version (eg. C<3.11.0>) =head2 Detecting if OCaml is installed Unlike old versions of these macros, C does I exit if no OCaml installation is detected. Therefore if you want to detect if OCaml is installed you have to do something like this: AC_PROG_OCAML if test "$OCAMLC" = "no"; then AC_MSG_ERROR([You must install the OCaml compiler]) fi This behaviour and usage pattern are consistent with other macros of the C) family. =head2 Cross-compiling If the configure script is invoked for cross-compiling then C will detect the cross-compiler versions of the OCaml compiler, eg. C etc. This happens automatically, and for most purposes you don't need to worry about it. =head1 AC_PROG_FINDLIB This macro checks for the presence of the ocamlfind program (part of findlib). It defines and substitutes C to the name of the ocamlfind program, or C if not found. Note that this macro does not fail if ocamlfind is not found. If you want to force the user to install findlib, you should do: AC_PROG_FINDLIB if test "$OCAMLFIND" = "no"; then AC_MSG_ERROR([You must install OCaml findlib (the ocamlfind command)]) fi See also C. =head1 AC_PROG_OCAMLLEX This checks for the ocamllex program and sets C to the name of the program (eg. C or C), or C if not found. =head1 AC_PROG_OCAMLYACC This checks for the ocamlyacc program and sets C to the name of the program, or C if not found. =head1 AC_PROG_CAMLP4 This checks for camlp4, and checks that the version matches the compiler version found previously. It sets C to the name of the basic camlp4 program, or C if not found. The macro also checks for other tools of the camlp4 suite like camlp4o, camlp4orf, etc. For each of them, a fully capitalized variable is set to the tool name (or C if not found); all variable are substituted for when filling .in files. The full list of tools and respective variable names is as follows: camlp4 CAMLP4 camlp4boot CAMLP4BOOT camlp4o CAMLP4O camlp4of CAMLP4OF camlp4oof CAMLP4OOF camlp4orf CAMLP4ORF camlp4prof CAMLP4PROF camlp4r CAMLP4R camlp4rf CAMLP4RF =head1 AC_CHECK_OCAML_PKG This is the main macro that can be used to detect the presence of OCaml findlib packages. This macro uses ocamlfind to look up findlib packages (and thus requires that findlib itself has been installed, and that the package has been properly packaged with a META file etc.) If you want to find an OCaml findlib package which hasn't been installed with findlib then you should try using C instead. AC_CHECK_OCAML_PKG([name]) checks for an OCaml findlib package with the given name. If found, it defines and substitutes the variable C where the C part is substituted for the package name by replacing all dashes with underscores. For example, AC_CHECK_OCAML_PKG([xml-light]) will set C to either C or C. To have the configure script fail if a package is not installed, do: AC_CHECK_OCAML_PKG([foo]) if test "$OCAML_PKG_foo" = "no"; then AC_MSG_ERROR([Please install OCaml findlib module 'foo'.]) fi In your Makefile.in, use the substitution variable in conjunction with ocamlfind, eg: .ml.cmo: $(OCAMLFIND) ocamlc -package @OCAML_PKG_foo@ -c $< -o $@ Note that also in the substitution variable dashes are replaced with underscores. =head2 Checking for alternative findlib package names In the (unlikely) case where the same library corresponds to different findlib package names on different systems, you can improve portability by checking for the alternative names passing a second argument to C: AC_CHECK_OCAML_PKG(PKGNAME,ALTERNATIVE-NAMES) The behaviour is the same as before if C is found. Otherwise all names in C are tested in turn as findlib package names. If one is found, it is set as the value set by the macro and substituted in .in files; otherwise C is set. Note that the variable name is determined by C, while the value depends on the actual alternative name found. For example, to detect the camlzip findlib package, either called C or C, and to store the found value in the C variable you can do in your configure.ac: AC_CHECK_OCAML_PKG(zip,camlzip) and have a portable Makefile.in build line such as: .ml.cmo: $(OCAMLFIND) ocamlc -package @OCAML_PKG_zip@ -c $< -o $@ =head1 AC_CHECK_OCAML_MODULE(VARIABLE,NAME,MODULE,INCLUDE-PATHS) C is the hairier alternative to C. You should always use C and ocamlfind/findlib if possible. The parameters are: =over =item VARIABLE This is the environment variable that is set. It will either be set to the include path, or to C if the module was not found. =item NAME This is the name of the module we are looking for. This parameter is just used for printing messages, and does not affect how the module is found. =item MODULE This should be an OCaml module name, representing the module name being looked up. You can put sub-modules here, eg. C =item INCLUDE-PATHS This is the default list of include directories to search, eg. C<+calendar> =back For example, the following code will check for the OCaml Calendar module, and will distinguish between version 1 and version 2 of this module (which have incompatible APIs). AC_CHECK_OCAML_PKG(calendar) AC_CHECK_OCAML_MODULE(is_calendar2,calendar,[CalendarLib.Date],[+calendar]) After the above code has run, variables C and C will be set as follows: OCAML_PKG_calendar is_calendar2 Result yes +calendar Calendar v2 is installed yes no Calendar v1 is installed no no No Calendar module installed =head1 AC_CHECK_OCAML_WORD_SIZE This checks the word size of the OCaml compiler, and sets C to either C<32> or C<64>. =head1 SEE ALSO L, L, L =head1 FILES =over =item * /usr/share/aclocal/ocaml.m4 =back =head1 AUTHORS Various people have contributed to these macros over many years: =over =item * Olivier Andrieu =item * Jean-Christophe Filliâtre =item * Richard W.M. Jones =item * Georges Mariano =item * Jim Meyering =item * Stefano Zacchiroli =back =head1 LICENSE Copyright © 2009 Richard W.M. Jones Copyright © 2009 Stefano Zacchiroli Copyright © 2000-2005 Olivier Andrieu Copyright © 2000-2005 Jean-Christophe Filliâtre Copyright © 2000-2005 Georges Mariano All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =head1 REPORTING BUGS Please report bugs to the authors at the project page: L, using the forge bug tracker L. ocaml-tools-20120103/omlet-0.13/0000755000175000017500000000000011230634221014624 5ustar mehdimehdiocaml-tools-20120103/omlet-0.13/ChangeLog0000644000175000017500000000170211230634221016376 0ustar mehdimehdi ChangeLog for OMLet, the better OCaml mode for VIm Copyright (c) 2005 David Baelde 2005/04/08 (0.13) * Comments are now always aligned on the next block * Corrected a bug related to comment un-skipping * Added 'c', "=" and [|...|] handling. Sorry for the delay :) 2005/03/25 (0.12) * OMLet now overrides OCaml correctly. That's ugly but needed, because OCaml is installed with VIm. * Added OCaml modeline support * Prevented a few abusive autoindentation, when atoms begin like keywords ("incr"...) * Multiple comments are now aligned on the next real block * New option omlet_middle_comment, still has pb with autoindent * Corrected the parsing return value, indentation of "and" is OK now * Indentation code for ";" handles "bla ; bla ;\nbla" better * Added "mod" 2005/03/14 (0.11) * Enhanced a lot the expression backward parsing, including many infix operators, which are now well considered regarding their binding power * s:indent() was enhanced a lot ocaml-tools-20120103/omlet-0.13/INSTALL0000644000175000017500000000030511230634221015653 0ustar mehdimehdi To install omlet, run "make install". It will put the files in your home directory, and won't overwrite anything but omlet.vim files, creating and filling filetype.vim only if it does not exist. ocaml-tools-20120103/omlet-0.13/LICENSE0000644000175000017500000004327611230634221015645 0ustar mehdimehdi GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. ocaml-tools-20120103/omlet-0.13/Makefile0000644000175000017500000000162011230634221016263 0ustar mehdimehdi.PHONY: install dist VERSION=0.13 install: BASE=$(HOME)/.vim make install-aux install-sys: BASE=/usr/share/vim/vimfiles make install-aux install-aux: for i in indent syntax ftplugin ftdetect ; do \ mkdir -p $(BASE)/$$i ; \ cp -f $$i/omlet.vim $(BASE)/$$i ; \ done @echo Installation done. @echo @echo Add lines like \"filetype plugin on\", \"filetype indent on\" to your .vimrc @echo in order to enable OMLet. @echo See README for other useful information. V=omlet-$(shell date +%y%m%d) D=/home/httpd/htdocs/david.baelde/productions/POOL dist: rm -rf omlet-$(VERSION) mkdir omlet-$(VERSION) cp LICENSE README INSTALL ChangeLog Makefile omlet-$(VERSION) for i in indent syntax ftplugin ftdetect ; do \ mkdir omlet-$(VERSION)/$$i ; \ cp $$i/omlet.vim omlet-$(VERSION)/$$i ; \ done tar czvf $(V).tar.gz omlet-$(VERSION) rm -rf omlet-$(VERSION) cp $(V).tar.gz omlet-$(VERSION).tar.gz ocaml-tools-20120103/omlet-0.13/README0000644000175000017500000000053011230634221015502 0ustar mehdimehdi omlet.vim -- filetype OCaml for VIm Copyright (c) 2005 David Baelde OMLet includes: - A slightly modified syntax file; - A much better indentation, which aims at becoming as good as Tuareg; - A plugin which performs folding, plus the official features For customization & tips: http://perso.ens-lyon.fr/david.baelde/productions/omlet.php ocaml-tools-20120103/omlet-0.13/ftdetect/0000755000175000017500000000000011230634221016426 5ustar mehdimehdiocaml-tools-20120103/omlet-0.13/ftdetect/omlet.vim0000644000175000017500000000036111230634221020263 0ustar mehdimehdiau BufRead,BufNewFile *.ml,*.mli set ft=omlet " setf omlet would result in having omlet not loaded cause system's " filetype.vim defines ocaml.vim for .ml files. " This is quite ugly, but we have to do this until ocaml.vim becomes omlet... ocaml-tools-20120103/omlet-0.13/ftplugin/0000755000175000017500000000000011230634221016454 5ustar mehdimehdiocaml-tools-20120103/omlet-0.13/ftplugin/omlet.vim0000644000175000017500000003331411230634221020315 0ustar mehdimehdi" Language: OCaml " Maintainer: David Baelde " Mike Leary " Markus Mottl " Stefano Zacchiroli " URL: http://www.ocaml.info/vim/ftplugin/ocaml.vim " Last Change: 2005 March 25 " Changelog: " 0.12 - Modeline support " - Folding now works also when indent_struct != 2 " - Changed folding customization variable, default is off " - Made folding settings local to the buffer " - Included the official ftplugin ocaml.vim, except " annotations stuff, and parenthesis around assert false " abbreviation " - Corrected toplevel let folding " - Made the file reloading correctly " " omlet.vim plugins -- utilities for working on OCaml files with VIm " Copyright (C) 2005 D. Baelde, M. Leary, M. Mottl, S. Zacchiroli " " This program is free software; you can redistribute it and/or modify " it under the terms of the GNU General Public License as published by " the Free Software Foundation; either version 2 of the License, or " (at your option) any later version. " " This program is distributed in the hope that it will be useful, " but WITHOUT ANY WARRANTY; without even the implied warranty of " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " GNU General Public License for more details. " " You should have received a copy of the GNU General Public License " along with this program; if not, write to the Free Software " Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA " Folding is activated if ocaml_folding is set " Do these settings once per buffer " if exists("b:did_ftplugin") " finish " endif let b:did_ftplugin=1 " Error handling -- helps moving where the compiler wants you to go set cpo-=C setlocal efm= \%EFile\ \"%f\"\\,\ line\ %l\\,\ characters\ %c-%*\\d:, \%EFile\ \"%f\"\\,\ line\ %l\\,\ character\ %c:%m, \%+EReference\ to\ unbound\ regexp\ name\ %m, \%Eocamlyacc:\ e\ -\ line\ %l\ of\ \"%f\"\\,\ %m, \%Wocamlyacc:\ w\ -\ %m, \%-Zmake%.%#, \%C%m " Add mappings, unless the user didn't want this. if !exists("no_plugin_maps") && !exists("no_ocaml_maps") " (un)commenting if !hasmapto('Comment') nmap c LUncomOn vmap c BUncomOn nmap C LUncomOff vmap C BUncomOff endif nnoremap LUncomOn mz0i(* $A *)`z nnoremap LUncomOff :s/^(\* \(.*\) \*)/\1/ vnoremap BUncomOn :'<,'>`0i(*`>o0i*)`< vnoremap BUncomOff :'<,'>`dd`< if !hasmapto('Abbrev') iabbrev ASS (assert false) endif endif " Let % jump between structure elements (due to Issac Trotts) let b:mw='\:\:\(\\|;;\),' let b:mw=b:mw . '\:\:\,\:\,' let b:mw=b:mw . '\<\(object\|sig\|struct\|begin\)\>:\' let b:match_words=b:mw " switching between interfaces (.mli) and implementations (.ml) if !exists("g:did_ocaml_switch") let g:did_ocaml_switch = 1 map s :call OCaml_switch(0) map S :call OCaml_switch(1) fun OCaml_switch(newwin) if (match(bufname(""), "\\.mli$") >= 0) let fname = substitute(bufname(""), "\\.mli$", ".ml", "") if (a:newwin == 1) exec "new " . fname else exec "arge " . fname endif elseif (match(bufname(""), "\\.ml$") >= 0) let fname = bufname("") . "i" if (a:newwin == 1) exec "new " . fname else exec "arge " . fname endif endif endfun endif " Folding support " Get the modeline because folding depends on indentation let s:s = line2byte(line('.'))+col('.')-1 if search('^\s*(\*:o\?caml:') let s:modeline = getline(".") else let s:modeline = "" endif if s:s > 0 exe 'goto' s:s endif " Get the indentation params let s:m = matchstr(s:modeline,'default\s*=\s*\d\+') if s:m != "" let s:idef = matchstr(s:m,'\d\+') elseif exists("g:omlet_indent") let s:idef = g:omlet_indent else let s:idef = 2 endif let s:m = matchstr(s:modeline,'struct\s*=\s*\d\+') if s:m != "" let s:i = matchstr(s:m,'\d\+') elseif exists("g:omlet_indent_struct") let s:i = g:omlet_indent_struct else let s:i = s:idef endif " Set the folding method if exists("g:ocaml_folding") setlocal foldmethod=expr setlocal foldexpr=OMLetFoldLevel(v:lnum) endif " - Only definitions below, executed once ------------------------------------- if exists("*OMLetFoldLevel") finish endif function s:topindent(lnum) let l = a:lnum while l > 0 if getline(l) =~ '\s*\%(\\|\\|\\)' return indent(l) endif let l = l-1 endwhile return -s:i endfunction function OMLetFoldLevel(l) " This is for not merging blank lines around folds to them if getline(a:l) !~ '\S' return -1 endif " We start folds for modules, classes, and every toplevel definition if getline(a:l) =~ '^\s*\%(\\|\\|\\|\\|\\|\\|\\|\\|\\)' exe 'return ">' (indent(a:l)/s:i)+1 '"' endif " Toplevel let are detected thanks to the indentation if getline(a:l) =~ '^\s*let\>' && indent(a:l) == s:i+s:topindent(a:l) exe 'return ">' (indent(a:l)/s:i)+1 '"' endif " We close fold on end which are associated to struct, sig or object. " We use syntax information to do that. if getline(a:l) =~ '^\s*end\>' && synIDattr(synID(a:l, indent(a:l)+1, 0), "name") != "ocamlKeyword" return (indent(a:l)/s:i)+1 endif " Folds end on ;; if getline(a:l) =~ '^\s*;;' exe 'return "<' (indent(a:l)/s:i)+1 '"' endif " Comments around folds aren't merged to them. if synIDattr(synID(a:l, indent(a:l)+1, 0), "name") == "ocamlComment" return -1 endif return '=' endfunction " Vim support for OCaml .annot files (requires Vim with python support) " " Executing OCamlPrintType() function will display in the Vim bottom " line(s) the type of an ocaml value getting it from the corresponding .annot " file (if any). If Vim is in visual mode, should be "visual" and the " selected ocaml value correspond to the highlighted text, otherwise ( " can be anything else) it corresponds to the literal found at the current " cursor position. " " .annot files are parsed lazily the first time OCamlPrintType is invoked; is " also possible to force the parsing using the OCamlParseAnnot() function. " " Typing ',3' will cause OCamlPrintType function to be invoked with " the right argument depending on the current mode (visual or not). " " Copyright (C) <2003-2004> Stefano Zacchiroli " " Created: Wed, 01 Oct 2003 18:16:22 +0200 zack " LastModified: Wed, 25 Aug 2004 18:28:39 +0200 zack " " " This program is free software; you can redistribute it and/or modify " it under the terms of the GNU General Public License as published by " the Free Software Foundation; either version 2 of the License, or " (at your option) any later version. " " This program is distributed in the hope that it will be useful, " but WITHOUT ANY WARRANTY; without even the implied warranty of " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " GNU General Public License for more details. " " You should have received a copy of the GNU General Public License " along with this program; if not, write to the Free Software " Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA if !has("python") finish endif python << EOF import re import os import string import time import vim debug = False class AnnExc(Exception): def __init__(self, reason): self.reason = reason no_annotations = AnnExc("No type annotations (.annot) file found") annotation_not_found = AnnExc("No type annotation found for the given text") def malformed_annotations(lineno): return AnnExc("Malformed .annot file (line = %d)" % lineno) class Annotations: """ .annot ocaml file representation File format (copied verbatim from caml-types.el) file ::= block * block ::= position position annotation * position ::= filename num num num annotation ::= keyword open-paren data close-paren is a space character (ASCII 0x20) is a line-feed character (ASCII 0x0A) num is a sequence of decimal digits filename is a string with the lexical conventions of O'Caml open-paren is an open parenthesis (ASCII 0x28) close-paren is a closed parenthesis (ASCII 0x29) data is any sequence of characters where is always followed by at least two space characters. - in each block, the two positions are respectively the start and the end of the range described by the block. - in a position, the filename is the name of the file, the first num is the line number, the second num is the offset of the beginning of the line, the third num is the offset of the position itself. - the char number within the line is the difference between the third and second nums. For the moment, the only possible keyword is \"type\"." """ def __init__(self): self.__filename = None # last .annot parsed file self.__ml_filename = None # as above but s/.annot/.ml/ self.__timestamp = None # last parse action timestamp self.__annot = {} self.__re = re.compile( '^"[^"]*"\s+(\d+)\s+(\d+)\s+(\d+)\s+"[^"]*"\s+(\d+)\s+(\d+)\s+(\d+)$') def __parse(self, fname): try: f = open(fname) line = f.readline() # position line lineno = 1 while (line != ""): m = self.__re.search(line) if (not m): raise malformed_annotations(lineno) line1 = int(m.group(1)) col1 = int(m.group(3)) - int(m.group(2)) line2 = int(m.group(4)) col2 = int(m.group(6)) - int(m.group(5)) line = f.readline() # "type(" string lineno += 1 if (line == ""): raise malformed_annotations(lineno) type = [] line = f.readline() # type description lineno += 1 if (line == ""): raise malformed_annotations(lineno) while line != ")\n": type.append(string.strip(line)) line = f.readline() lineno += 1 if (line == ""): raise malformed_annotations(lineno) type = string.join(type, "\n") key = ((line1, col1), (line2, col2)) if not self.__annot.has_key(key): self.__annot[key] = type line = f.readline() # position line f.close() self.__filename = fname self.__ml_filename = re.sub("\.annot$", ".ml", fname) self.__timestamp = int(time.time()) except IOError: raise no_annotations def parse(self): annot_file = re.sub("\.ml$", ".annot", vim.current.buffer.name) self.__parse(annot_file) def get_type(self, (line1, col1), (line2, col2)): if debug: print line1, col1, line2, col2 if vim.current.buffer.name == None: raise no_annotations if vim.current.buffer.name != self.__ml_filename or \ os.stat(self.__filename).st_mtime > self.__timestamp: self.parse() try: return self.__annot[(line1, col1), (line2, col2)] except KeyError: raise annotation_not_found word_char_RE = re.compile("^[\w.]$") # TODO this function should recognize ocaml literals, actually it's just an # hack that recognize continuous sequences of word_char_RE above def findBoundaries(line, col): """ given a cursor position (as returned by vim.current.window.cursor) return two integers identify the beggining and end column of the word at cursor position, if any. If no word is at the cursor position return the column cursor position twice """ left, right = col, col line = line - 1 # mismatch vim/python line indexes (begin_col, end_col) = (0, len(vim.current.buffer[line]) - 1) try: while word_char_RE.search(vim.current.buffer[line][left - 1]): left = left - 1 except IndexError: pass try: while word_char_RE.search(vim.current.buffer[line][right + 1]): right = right + 1 except IndexError: pass return (left, right) annot = Annotations() # global annotation object def printOCamlType(mode): try: if mode == "visual": # visual mode: lookup highlighted text (line1, col1) = vim.current.buffer.mark("<") (line2, col2) = vim.current.buffer.mark(">") else: # any other mode: lookup word at cursor position (line, col) = vim.current.window.cursor (col1, col2) = findBoundaries(line, col) (line1, line2) = (line, line) begin_mark = (line1, col1) end_mark = (line2, col2 + 1) print annot.get_type(begin_mark, end_mark) except AnnExc, exc: print exc.reason def parseOCamlAnnot(): try: annot.parse() except AnnExc, exc: print exc.reason EOF fun! OCamlPrintType(current_mode) if (a:current_mode == "visual") python printOCamlType("visual") else python printOCamlType("normal") endif endfun fun! OCamlParseAnnot() python parseOCamlAnnot() endfun map ,t :call OCamlPrintType("normal") vmap ,t :call OCamlPrintType("visual") ocaml-tools-20120103/omlet-0.13/indent/0000755000175000017500000000000011230634221016105 5ustar mehdimehdiocaml-tools-20120103/omlet-0.13/indent/omlet.vim0000644000175000017500000004543511230634221017755 0ustar mehdimehdi" Vim indent file " Language: OCaml " Maintainer: David Baelde " URL: http://ocaml.info/vim/indent/omlet.vim " Last Change: 2005 Apr 08 " Changelog: " 0.13 - Comments are now always aligned on the next block " - Corrected a bug related to comment un-skipping " - Added 'c', "=" and [|...|] handling. Sorry for the delay :) " 0.12 - Added OCaml modeline support " - Prevented a few abusive autoindentation, when atoms begin " like keywords ("incr"...) " - Multiple comments are now aligned on the next real block " - New option omlet_middle_comment, still has pb with autoindent " - Corrected the parsing return value -- indentation of "and" " - Indentation code for ";" handles "bla ; bla ;\nbla" better " - Added "mod" " 0.11 - Enhanced a lot the expression backward parsing, including " many infix operators, which are now well considered regarding " their binding power " - s:indent() was enhanced a lot " omlet.vim -- a set of files for working on OCaml code with VIm " Copyright (C) 2005 David Baelde " " This program is free software; you can redistribute it and/or modify " it under the terms of the GNU General Public License as published by " the Free Software Foundation; either version 2 of the License, or " (at your option) any later version. " " This program is distributed in the hope that it will be useful, " but WITHOUT ANY WARRANTY; without even the implied warranty of " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " GNU General Public License for more details. " " You should have received a copy of the GNU General Public License " along with this program; if not, write to the Free Software " Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA " TODO cannot re-indent when || is typed at begining of line " Only load this indent file when no other was loaded. if exists("b:did_indent") finish endif let b:did_indent = 1 setlocal expandtab setlocal fo=croq syntax enable setlocal indentexpr=GetOMLetIndent(v:lnum) setlocal indentkeys=0{,0},!^F,o,O,0=let\ ,0=and,0=in,0=end,0),0],0=\|],0=do,0=done,0=then,0=else,0=with,0\|,0=->,0=;;,0=module,0=struct,0=sig,0=class,0=object,0=val,0=method,0=initializer,0=inherit,0=open,0=include,0=exception,0=external,0=type,0=&&,0^,0*,0\,,0=::,0@,0+,0/,0- " Get the modeline let s:s = line2byte(line('.'))+col('.')-1 if search('^\s*(\*:o\?caml:') let s:modeline = getline(".") else let s:modeline = "" endif if s:s > 0 exe 'goto' s:s endif " P is a modeline param name, S a global variable name, V the default value function! s:default(p,s,v) let m = matchstr(s:modeline,a:p.'\s*=\s*\d\+') if m != "" return matchstr(m,'\d\+') elseif exists(a:s) exe "return" a:s else return a:v endif endfunction let b:i = s:default("default","g:omlet_indent",2) let b:i_struct = s:default("struct","g:omlet_indent_struct",b:i) let b:i_match = s:default("match","g:omlet_indent_match",b:i) let b:i_function = s:default("fun","g:omlet_indent_function",b:i) let b:i_let = s:default("let","g:omlet_indent_let",b:i) let b:mb = s:default("xxx","g:omlet_middle_comment",1) if b:mb != 0 let b:mb = 1 endif if b:mb == 1 setlocal comments=s1l:(*,mb:*,ex:*) else setlocal comments=s1l:(*,ex:*) endif " Do not define our functions twice if exists("*GetOMLetIndent") finish endif let b:did_indent = 1 " {{{ A few utils function s:save() return line2byte(line('.'))+col('.')-1 endfunction function s:restore(v) execute 'goto ' a:v endfunction " Same as searchpair() but skips comments and strings function s:searchpair(beg,mid,end,flags) return searchpair(a:beg,a:mid,a:end,a:flags,'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"') endfunction " Same as search(_,'bW') but skips comments function s:search(re) let p = s:save() while search('\*)\_s*\%#','bW') call searchpair('(\*','','\*)','bW') endwhile if search(a:re,'bW') return 1 else call s:restore(p) endif endfunction " Goes back to the beginning of an "end", whatever its opening keyword is let s:begend = '\%(\\|\\|\\|\\)' function OMLetBegendBackward() return s:searchpair(s:begend,'','\','bW') endfunction " }}} " {{{ Jumping " We separated expressions in three classes: " A: The applications " E: A + closure by infix operators which bind tighter than ";" " We ignore the aggregating "let" and the special "then" operator " Block: Full expressions, it's a mess... " "then", "match", "patterns"... " Goes to the beginning of the previous (exclusive) block. " It is stopped by any non-trivial syntax. " The block moves are really the heart of omlet! let s:blockstop = '\(\%^\|(\|{\|\[\|\[|\|\\|;\|,\|&&\|||\|\\|\\|\\||\|->\|\\|\\|\\|\\|=\|\\|\\|\\|\\|\\|\\|\\|\\|\\|\\|\\|\\)\_s*\%#' let s:binop_core = '\%(\\|\\|\\|\\|\\|\\|\\|,\|::\|@\|\^\|||\|&&\|\.\|<-\|:=\|+\|\*\|/\|-\)' " Thanks to ".", floating point arith operators are included... let s:binop = s:binop_core.'\_s*\%#' function OMLetAtomBackward() let s = s:save() if search('\*)\_s*\%#','bW') call searchpair('(\*','','\*)','bW') return OMLetAtomBackward() elseif search(')\_s*\%#','bW') return s:searchpair('(','',')','bW') elseif search('\]\_s*\%#','bW') return s:searchpair('\[','','\]','bW') elseif search('}\_s*\%#','bW') return s:searchpair('{','','}','bW') elseif search("'\\_s*\\%#",'bW') while search("\\_.'",'bW') if synIDattr(synID(line("."), col("."), 0), "name") != "ocamlCharacter" call search("'") return 1 endif endwhile throw "Couldn't find beginning of character" elseif search('"\_s*\%#','bW') while search('\_."','bW') if synIDattr(synID(line("."), col("."), 0), "name") != "ocamlString" call search('"') return 1 endif endwhile throw "Couldn't find beginning of string" elseif search('\\_s*\%#','bW') call s:searchpair('\','','\','bW') return s:searchpair('\%(\\|\\)','','\','bW') elseif search('\\_s*\%#','bW') if synIDattr(synID(line("."), col("."), 0), "name") == "ocamlKeyword" call s:searchpair('\','','\','bW') return 1 else call s:restore(s) endif elseif search('\%(!\|`\|#\|\.\)\_s*\%#','bW') " Ignore some atom prefixes return OMLetAtomBackward() elseif search(s:binop,'bW') || search(s:blockstop,'bW') " Stop moving in front of those block delimiters call s:restore(s) return 0 else " Otherwise, move backward, skipping a variable name or constant... return search('\<','bW') endif endfunction function OMLetABackward() if OMLetAtomBackward() while OMLetAtomBackward() endwhile return 1 else return 0 endif endfunction function OMLetEBackward() if OMLetABackward() call OMLetEBackward() return 1 endif if s:search(s:binop) call OMLetEBackward() return 1 endif let s = s:save() if search('=\_s*\%#','bW') if search('\%(\\|\\|\\|\\)[^=]\+\%#','bW') call s:restore(s) return 0 else call OMLetEBackward() return 1 endif endif endfunction " }}} " {{{ Complex jumping " We still have problems with "match", and "else", " which have no closing keyword. function OMLetMatchHeadBackward() if s:search('\\_s*\%#') call s:searchpair('\%(\\|\\)','','\','bW') return 1 elseif s:search('\\_s*\%#') return 1 elseif s:search('\\_s*\%#') return 1 elseif s:search('\\_[^=]\+=\_s*\%#') return 1 else return 0 endif endfunction function OMLetIfHeadBackward() if search('\','','\','bW') else throw "Indentation failed!" endif endfunction function OMLetBlockBackward(lf,gbg) if search('\','','\','bW') call OMLetBlockBackward(a:lf,a:gbg) return 1 elseif a:lf == ';' return 0 elseif search('\\_s*\%#','bW') call s:searchpair('\','','\','bW') call OMLetBlockBackward(a:lf, 0) " [let ... in] eats the garbage return 1 elseif search(';\_s*\%#','bW') call OMLetBlockBackward(a:lf,1) " sequence is the garbage return 1 elseif search('\\|\\)\_s*\%#','bW') call OMLetPatternBackward() call OMLetBlockBackward('match',0) if a:lf != 'match' call OMLetMatchHeadBackward() call OMLetBlockBackward(a:lf,0) " match has eaten the garbage endif return 1 endif return 0 endfunction function OMLetPatternBackward() call OMLetBlockBackward('',0) call search('|\_s*\%#','bW') " allow failure endfunction " }}} " {{{ Indentation function " The goal is to return a 'correct' indentation, " assuming that the previous lines are well indented. function s:indent(...) " The optionnal argument avoids ignoring leading "| " " If there's a hard delimiter like "{","(","[", its position is " used as the reference for the indentation let p = s:save() let l = line(".") if !search('\%#[{(\[]') && s:searchpair('[\[{(]','','[)}\]]','bW') && line(".") == l call search('\S') return col('.')-1 else call s:restore(p) endif if a:0==0 && search('^\s*\%(|.*\%#\|\%#|\)','bW') " We consider leading "|" as whitespace call search('|') call search('\S') return col('.')-1 endif return indent('.') endfunction function s:topindent(lnum) let l = a:lnum while l > 0 if getline(l) =~ '\s*\%(\\|\\|\\)' return b:i_struct+indent(l) endif let l = l-1 endwhile return 0 endfunction function GetOMLetIndent(l) " Go to the first non-blank char on the line to be indented. exe a:l " {{{ Comments " Inside comments -- needs the comment to be closed! if synIDattr(synID(line("."), col("."), 0), "name") == 'ocamlComment' " TODO the first line inside the comment isn't autoindented correctly if searchpair('(\*','','\*)','bW') " We were strictly inside the comment, and we are now at its beginning " Let's jump to the last * call search('\*\_[^\*]') if b:mb == 0 && getline(a:l) !~ '^\s*\*)' return col('.')+1 else return col('.')-1 endif endif " No need to restore, there was no move endif " Comments with a blank line before them are indented as the next block if getline(a:l) =~ '^\s*(\*' let ok = 1 while ok == 1 call searchpair('(\*','','\*)') " TODO this would be better : /\%#\*)\_s*(/e if getline(line('.')+1) =~ '^\s*(\*' exe line('.')+1 else let ok = 0 endtry endwhile let new = nextnonblank(line('.')+1) if new == 0 || new == a:l return -1 else return GetOMLetIndent(new) endif endif " }}} " {{{ Keyword alignments " How to indent a line starting with a keyword " Parenthesis-like closing if getline(a:l) =~ '^\s*\' && s:searchpair(s:begend,'','\','bW') return s:indent() endif if getline(a:l) =~ '^\s*}' call s:searchpair('{','','}','bW') return s:indent() endif if getline(a:l) =~ '^\s*)' call s:searchpair('(','',')','bW') return s:indent() endif if getline(a:l) =~ '^\s*\]' call s:searchpair('\[','','\]','bW') return s:indent() endif if getline(a:l) =~ '^\s*|\]' call s:searchpair('\[|','','|\]','bW') return s:indent() endif " WHILE and FOR if getline(a:l) =~ '^\s*\' && s:searchpair('\','','\','bW') call s:searchpair('\%(\\|\\)','','\','bW') return s:indent() endif if getline(a:l) =~ '^\s*\' && s:searchpair('\<\(while\|for\)\>','','\','bW') return s:indent() endif " PATTERNS if getline(a:l) =~ '^\s*\' && s:searchpair('\%(\\|\\)','','\','bW') return s:indent() endif if getline(a:l) =~ '^\s*->' call OMLetPatternBackward() if search('\%#|') return s:indent(1)+2 else return s:indent() endif endif if getline(a:l) =~ '^\s*|' call OMLetBlockBackward('match',0) if s:search('|\_s*\%#') " We are stuck on a 0-ary constructor return s:indent(1) elseif s:search('\[\_s*\%#') " Polymorphic variant return col(".")-1 elseif s:search('function\_s*\%#') return s:indent()+b:i_function else call OMLetMatchHeadBackward() return s:indent()+b:i_match endif endif " INFIX "&&", "||", "^", ... if getline(a:l) =~ '^\s*'.s:binop_core call OMLetEBackward() return s:indent() endif " IF/THEN/ELSE if getline(a:l) =~ '^\s*\' && s:searchpair('\','','\','bW') return s:indent() endif if getline(a:l) =~ '^\s*\' call OMLetBlockBackward('then',0) if s:search('\','','\','bW') endif return s:indent() endif " ;; alone is indented as toplevel defs if getline(a:l) =~ '^\s*;;' if OMLetBegendBackward() return s:indent()+b:i_struct else return 0 endif endif " { and [ may need to be reindented in type definitions, where they don't " really deserve the default +4 indentation " if getline(a:l) =~ '^\s*{' " return s:indent(a:l-1)+2 " But that's weak ! " endif " Easy toplevel definitions if getline(a:l) =~ '^\s*\%(\\|\\|\\|\\|\\|\\|\\|\\|\\|\\|\\|\\|\\|\\)' if s:searchpair(s:begend,'','\','bW') return s:indent()+b:i_struct else return 0 endif endif " The next three tests are for indenting toplevel let " let after a high-level end (not matching a begin) if getline(a:l) =~ '^\s*let\>' && s:search('\\_s*\%#') && synIDattr(synID(line('.'),col('.'),0),'name') != 'ocamlKeyword' call OMLetBegendBackward() return s:indent() else exe a:l endif " let at the beginning of a structure if getline(a:l) =~ '^\s*let\>' && s:search('\\_s*\%#') return s:indent()+b:i_struct endif " let after another value-level construct if getline(a:l) =~ '^\s*let\>' && (OMLetAtomBackward() || search(';;\_s*\%#')) if OMLetBegendBackward() return s:indent()+b:i_struct else return 0 endif else exe a:l " That was undoing the AtomBackward endif " let/and if getline(a:l) =~ '^\s*and\>' && OMLetBlockBackward('',0) if s:search('\%(\\|\\)\_[^=]\+=\_s*\%#') return s:indent() else exe a:l endif endif " Now we deal with let/in if getline(a:l) =~ '^\s*in\>' && s:searchpair('\','','\','bW') " Check that we don't have a toplevel let if s:indent() == s:topindent('.') exe a:l else return s:indent() endif endif " let after let isn't indented if getline(a:l) =~ '^\s*\' && s:search('\\_s*\%#') call s:searchpair('\','','\','bW') return s:indent() endif " }}} " {{{ Beginning of blocks " Howto indent a line after some keyword " Basic case if s:search('\(\\|\\|\\)\_s*\%#') return s:indent()+b:i_struct endif if s:search('\(\\|\\|\\|\\|\\|\\|(\|{\|\[\|\[|\|\\)\_s*\%#') return s:indent()+b:i endif if s:search('\%(\\|\\|\\|\\|\\)\_[^=]\+=\_s*\%#') return s:indent()+b:i endif " PATTERNS if s:search('\\_s*\%#') return s:indent()+2+b:i_function endif if s:search('\\_s*\%#') call s:searchpair('\%(\\|\\)','','\','bW') return s:indent()+2+b:i_match endif if s:search('\\_[^=]\+=\_s*\%#') return s:indent()+2+b:i endif if s:search('\\_s*\%#') return s:indent()+b:i endif " Sometimes you increment according to a master keyword " IF if s:search('\\_s*\%#') call s:searchpair('\','','\','bW') return s:indent()+b:i endif if s:search('\\_s*\%#') call OMLetBlockBackward('then',0) call OMLetIfHeadBackward() return s:indent()+b:i endif " MATCH if s:search('\\_s*\%#') call OMLetPatternBackward() if search('\%#|') return s:indent(1)+2+b:i else " First pattern can have no | return s:indent()+b:i endif endif if s:search('->\_s*\%#') call OMLetPatternBackward() if s:search('fun\>\s*\%#') return s:indent()+b:i elseif search('\%#|') return s:indent(1)+2+b:i else " First pattern can have no | return s:indent()+b:i endif endif " WHILE/DO if s:search('\\_s*\%#') call s:searchpair('\%(\\|\\)','','\','bW') return s:indent()+b:i endif " LET if s:search('\\_s*\%#') call s:searchpair('\','','\','bW') return s:indent()+b:i_let endif " }}} " Sequence: find previous instruction's base indentation if s:search(';;\_s*\%#') if OMLetBegendBackward() return s:indent()+b:i_struct else return 0 endif endif if s:search(';\_s*\%#') " Flexible indentation using s:indent() would be nice, " but I would actually need to return the identation " that *would have had* the previous expr in the sequence " if it has been alone on a line. " s/col(".")-1/s:indent()/ leads to bad things like: " > let x = bla ; " > bla call OMLetBlockBackward(';',0) while s:search(';\s*\%#') call OMLetBlockBackward(';',0) endwhile return col(".")-1 endif if s:search(s:binop) call OMLetEBackward() return col(".")-1 endif " = is a special binop if s:search('=\_s*\%#') call OMLetEBackward() return s:indent()+b:i endif " Application: indentation between a function and its arguments if OMLetAtomBackward() " I think s:indent() is ugly here... call OMLetABackward() return col('.')-1+b:i endif " This shouldn't happen return 0 endfunction " }}} ocaml-tools-20120103/omlet-0.13/syntax/0000755000175000017500000000000011230634221016152 5ustar mehdimehdiocaml-tools-20120103/omlet-0.13/syntax/omlet.vim0000644000175000017500000003172311230634221020015 0ustar mehdimehdi" Vim syntax file " Language: OCaml " Filenames: *.ml *.mli *.mll *.mly " Maintainers: Markus Mottl " Karl-Heinz Sylla " Issac Trotts " URL: http://www.ocaml.info/vim/syntax/ocaml.vim " Last Change: 2004 Aug 13 - Added new type keywords (MM) " 2004 Jul 30 - Added script keyword "thread" (MM) " 2004 May 15 - Added keyword "format4" (MM) " 2003 Jan 19 - Added script keyword "require" (MM) " A minor patch was applied to the official version so that object/end " can be distinguished from begin/end, which is used for indentation, " and folding. (David Baelde) " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded if version < 600 syntax clear elseif exists("b:current_syntax") && b:current_syntax != "ocaml" finish endif " OCaml is case sensitive. syn case match " Script headers highlighted like comments syn match ocamlComment "^#!.*" " Scripting directives syn match ocamlScript "^#\<\(quit\|labels\|warnings\|directory\|cd\|load\|use\|install_printer\|remove_printer\|require\|thread\|trace\|untrace\|untrace_all\|print_depth\|print_length\)\>" " lowercase identifier - the standard way to match syn match ocamlLCIdentifier /\<\(\l\|_\)\(\w\|'\)*\>/ syn match ocamlKeyChar "|" " Errors syn match ocamlBraceErr "}" syn match ocamlBrackErr "\]" syn match ocamlParenErr ")" syn match ocamlArrErr "|]" syn match ocamlCommentErr "\*)" syn match ocamlCountErr "\" syn match ocamlCountErr "\" if !exists("ocaml_revised") syn match ocamlDoErr "\" endif syn match ocamlDoneErr "\" syn match ocamlThenErr "\" " Error-highlighting of "end" without synchronization: " as keyword or as error (default) if exists("ocaml_noend_error") syn match ocamlKeyword "\" else syn match ocamlEndErr "\" endif " Some convenient clusters syn cluster ocamlAllErrs contains=ocamlBraceErr,ocamlBrackErr,ocamlParenErr,ocamlCommentErr,ocamlCountErr,ocamlDoErr,ocamlDoneErr,ocamlEndErr,ocamlThenErr syn cluster ocamlAENoParen contains=ocamlBraceErr,ocamlBrackErr,ocamlCommentErr,ocamlCountErr,ocamlDoErr,ocamlDoneErr,ocamlEndErr,ocamlThenErr syn cluster ocamlContained contains=ocamlTodo,ocamlPreDef,ocamlModParam,ocamlModParam1,ocamlPreMPRestr,ocamlMPRestr,ocamlMPRestr1,ocamlMPRestr2,ocamlMPRestr3,ocamlModRHS,ocamlFuncWith,ocamlFuncStruct,ocamlModTypeRestr,ocamlModTRWith,ocamlWith,ocamlWithRest,ocamlModType,ocamlFullMod " Enclosing delimiters syn region ocamlEncl transparent matchgroup=ocamlKeyword start="(" matchgroup=ocamlKeyword end=")" contains=ALLBUT,@ocamlContained,ocamlParenErr syn region ocamlEncl transparent matchgroup=ocamlKeyword start="{" matchgroup=ocamlKeyword end="}" contains=ALLBUT,@ocamlContained,ocamlBraceErr syn region ocamlEncl transparent matchgroup=ocamlKeyword start="\[" matchgroup=ocamlKeyword end="\]" contains=ALLBUT,@ocamlContained,ocamlBrackErr syn region ocamlEncl transparent matchgroup=ocamlKeyword start="\[|" matchgroup=ocamlKeyword end="|\]" contains=ALLBUT,@ocamlContained,ocamlArrErr " Comments syn region ocamlComment start="(\*" end="\*)" contains=ocamlComment,ocamlTodo syn keyword ocamlTodo contained TODO FIXME XXX " Objects syn region ocamlEnd matchgroup=ocamlObject start="\" matchgroup=ocamlObject end="\" contains=ALLBUT,@ocamlContained,ocamlEndErr " Blocks if !exists("ocaml_revised") syn region ocamlEnd matchgroup=ocamlKeyword start="\" matchgroup=ocamlKeyword end="\" contains=ALLBUT,@ocamlContained,ocamlEndErr endif " "for" syn region ocamlNone matchgroup=ocamlKeyword start="\" matchgroup=ocamlKeyword end="\<\(to\|downto\)\>" contains=ALLBUT,@ocamlContained,ocamlCountErr " "do" if !exists("ocaml_revised") syn region ocamlDo matchgroup=ocamlKeyword start="\" matchgroup=ocamlKeyword end="\" contains=ALLBUT,@ocamlContained,ocamlDoneErr endif " "if" syn region ocamlNone matchgroup=ocamlKeyword start="\" matchgroup=ocamlKeyword end="\" contains=ALLBUT,@ocamlContained,ocamlThenErr "" Modules " "struct" syn region ocamlStruct matchgroup=ocamlModule start="\" matchgroup=ocamlModule end="\" contains=ALLBUT,@ocamlContained,ocamlEndErr " "sig" syn region ocamlSig matchgroup=ocamlModule start="\" matchgroup=ocamlModule end="\" contains=ALLBUT,@ocamlContained,ocamlEndErr,ocamlModule syn region ocamlModSpec matchgroup=ocamlKeyword start="\" matchgroup=ocamlModule end="\<\u\(\w\|'\)*\>" contained contains=@ocamlAllErrs,ocamlComment skipwhite skipempty nextgroup=ocamlModTRWith,ocamlMPRestr " "open" syn region ocamlNone matchgroup=ocamlKeyword start="\" matchgroup=ocamlModule end="\<\u\(\w\|'\)*\(\.\u\(\w\|'\)*\)*\>" contains=@ocamlAllErrs,ocamlComment " "include" syn match ocamlKeyword "\" contained skipwhite skipempty nextgroup=ocamlModParam,ocamlFullMod " "module" - somewhat complicated stuff ;-) syn region ocamlModule matchgroup=ocamlKeyword start="\" matchgroup=ocamlModule end="\<\u\(\w\|'\)*\>" contains=@ocamlAllErrs,ocamlComment skipwhite skipempty nextgroup=ocamlPreDef syn region ocamlPreDef start="."me=e-1 matchgroup=ocamlKeyword end="\l\|="me=e-1 contained contains=@ocamlAllErrs,ocamlComment,ocamlModParam,ocamlModTypeRestr,ocamlModTRWith nextgroup=ocamlModPreRHS syn region ocamlModParam start="([^*]" end=")" contained contains=@ocamlAENoParen,ocamlModParam1 syn match ocamlModParam1 "\<\u\(\w\|'\)*\>" contained skipwhite skipempty nextgroup=ocamlPreMPRestr syn region ocamlPreMPRestr start="."me=e-1 end=")"me=e-1 contained contains=@ocamlAllErrs,ocamlComment,ocamlMPRestr,ocamlModTypeRestr syn region ocamlMPRestr start=":" end="."me=e-1 contained contains=@ocamlComment skipwhite skipempty nextgroup=ocamlMPRestr1,ocamlMPRestr2,ocamlMPRestr3 syn region ocamlMPRestr1 matchgroup=ocamlModule start="\ssig\s\=" matchgroup=ocamlModule end="\" contained contains=ALLBUT,@ocamlContained,ocamlEndErr,ocamlModule syn region ocamlMPRestr2 start="\sfunctor\(\s\|(\)\="me=e-1 matchgroup=ocamlKeyword end="->" contained contains=@ocamlAllErrs,ocamlComment,ocamlModParam skipwhite skipempty nextgroup=ocamlFuncWith,ocamlMPRestr2 syn match ocamlMPRestr3 "\w\(\w\|'\)*\(\.\w\(\w\|'\)*\)*" contained syn match ocamlModPreRHS "=" contained skipwhite skipempty nextgroup=ocamlModParam,ocamlFullMod syn region ocamlModRHS start="." end=".\w\|([^*]"me=e-2 contained contains=ocamlComment skipwhite skipempty nextgroup=ocamlModParam,ocamlFullMod syn match ocamlFullMod "\<\u\(\w\|'\)*\(\.\u\(\w\|'\)*\)*" contained skipwhite skipempty nextgroup=ocamlFuncWith syn region ocamlFuncWith start="([^*]"me=e-1 end=")" contained contains=ocamlComment,ocamlWith,ocamlFuncStruct skipwhite skipempty nextgroup=ocamlFuncWith syn region ocamlFuncStruct matchgroup=ocamlModule start="[^a-zA-Z]struct\>"hs=s+1 matchgroup=ocamlModule end="\" contains=ALLBUT,@ocamlContained,ocamlEndErr syn match ocamlModTypeRestr "\<\w\(\w\|'\)*\(\.\w\(\w\|'\)*\)*\>" contained syn region ocamlModTRWith start=":\s*("hs=s+1 end=")" contained contains=@ocamlAENoParen,ocamlWith syn match ocamlWith "\<\(\u\(\w\|'\)*\.\)*\w\(\w\|'\)*\>" contained skipwhite skipempty nextgroup=ocamlWithRest syn region ocamlWithRest start="[^)]" end=")"me=e-1 contained contains=ALLBUT,@ocamlContained " "module type" syn region ocamlKeyword start="\\s*\" matchgroup=ocamlModule end="\<\w\(\w\|'\)*\>" contains=ocamlComment skipwhite skipempty nextgroup=ocamlMTDef syn match ocamlMTDef "=\s*\w\(\w\|'\)*\>"hs=s+1,me=s syn keyword ocamlKeyword and as assert class syn keyword ocamlKeyword constraint else syn keyword ocamlKeyword exception external fun syn keyword ocamlKeyword in inherit initializer syn keyword ocamlKeyword land lazy let match syn keyword ocamlKeyword method mutable new of syn keyword ocamlKeyword parser private raise rec syn keyword ocamlKeyword try type syn keyword ocamlKeyword val virtual when while with if exists("ocaml_revised") syn keyword ocamlKeyword do value syn keyword ocamlBoolean True False else syn keyword ocamlKeyword function syn keyword ocamlBoolean true false syn match ocamlKeyChar "!" endif syn keyword ocamlType array bool char exn float format format4 syn keyword ocamlType int int32 int64 lazy_t list nativeint option syn keyword ocamlType string unit syn keyword ocamlOperator asr lor lsl lsr lxor mod not syn match ocamlConstructor "(\s*)" syn match ocamlConstructor "\[\s*\]" syn match ocamlConstructor "\[|\s*>|]" syn match ocamlConstructor "\[<\s*>\]" syn match ocamlConstructor "\u\(\w\|'\)*\>" " Polymorphic variants syn match ocamlConstructor "`\w\(\w\|'\)*\>" " Module prefix syn match ocamlModPath "\u\(\w\|'\)*\."he=e-1 syn match ocamlCharacter "'\\\d\d\d'\|'\\[\'ntbr]'\|'.'" syn match ocamlCharErr "'\\\d\d'\|'\\\d'" syn match ocamlCharErr "'\\[^\'ntbr]'" syn region ocamlString start=+"+ skip=+\\\\\|\\"+ end=+"+ syn match ocamlFunDef "->" syn match ocamlRefAssign ":=" syn match ocamlTopStop ";;" syn match ocamlOperator "\^" syn match ocamlOperator "::" syn match ocamlOperator "&&" syn match ocamlOperator "<" syn match ocamlOperator ">" syn match ocamlAnyVar "\<_\>" syn match ocamlKeyChar "|[^\]]"me=e-1 syn match ocamlKeyChar ";" syn match ocamlKeyChar "\~" syn match ocamlKeyChar "?" syn match ocamlKeyChar "\*" syn match ocamlKeyChar "=" if exists("ocaml_revised") syn match ocamlErr "<-" else syn match ocamlOperator "<-" endif syn match ocamlNumber "\<-\=\d\+\>" syn match ocamlNumber "\<-\=0[x|X]\x\+\>" syn match ocamlNumber "\<-\=0[o|O]\o\+\>" syn match ocamlNumber "\<-\=0[b|B][01]\+\>" syn match ocamlFloat "\<-\=\d\+\.\d*\([eE][-+]\=\d\+\)\=[fl]\=\>" " Labels syn match ocamlLabel "\~\(\l\|_\)\(\w\|'\)*"lc=1 syn match ocamlLabel "?\(\l\|_\)\(\w\|'\)*"lc=1 syn region ocamlLabel transparent matchgroup=ocamlLabel start="?(\(\l\|_\)\(\w\|'\)*"lc=2 end=")"me=e-1 contains=ALLBUT,@ocamlContained,ocamlParenErr " Synchronization syn sync minlines=50 syn sync maxlines=500 if !exists("ocaml_revised") syn sync match ocamlDoSync grouphere ocamlDo "\" syn sync match ocamlDoSync groupthere ocamlDo "\" endif if exists("ocaml_revised") syn sync match ocamlEndSync grouphere ocamlEnd "\<\(object\)\>" else syn sync match ocamlEndSync grouphere ocamlEnd "\<\(begin\|object\)\>" endif syn sync match ocamlEndSync groupthere ocamlEnd "\" syn sync match ocamlStructSync grouphere ocamlStruct "\" syn sync match ocamlStructSync groupthere ocamlStruct "\" syn sync match ocamlSigSync grouphere ocamlSig "\" syn sync match ocamlSigSync groupthere ocamlSig "\" " Define the default highlighting. " For version 5.7 and earlier: only when not done already " For version 5.8 and later: only when an item doesn't have highlighting yet if version >= 508 || !exists("did_ocaml_syntax_inits") if version < 508 let did_ocaml_syntax_inits = 1 command -nargs=+ HiLink hi link else command -nargs=+ HiLink hi def link endif HiLink ocamlBraceErr Error HiLink ocamlBrackErr Error HiLink ocamlParenErr Error HiLink ocamlArrErr Error HiLink ocamlCommentErr Error HiLink ocamlCountErr Error HiLink ocamlDoErr Error HiLink ocamlDoneErr Error HiLink ocamlEndErr Error HiLink ocamlThenErr Error HiLink ocamlCharErr Error HiLink ocamlErr Error HiLink ocamlComment Comment HiLink ocamlModPath Include HiLink ocamlObject Include HiLink ocamlModule Include HiLink ocamlModParam1 Include HiLink ocamlModType Include HiLink ocamlMPRestr3 Include HiLink ocamlFullMod Include HiLink ocamlModTypeRestr Include HiLink ocamlWith Include HiLink ocamlMTDef Include HiLink ocamlScript Include HiLink ocamlConstructor Constant HiLink ocamlModPreRHS Keyword HiLink ocamlMPRestr2 Keyword HiLink ocamlKeyword Keyword HiLink ocamlFunDef Keyword HiLink ocamlRefAssign Keyword HiLink ocamlKeyChar Keyword HiLink ocamlAnyVar Keyword HiLink ocamlTopStop Keyword HiLink ocamlOperator Keyword HiLink ocamlBoolean Boolean HiLink ocamlCharacter Character HiLink ocamlNumber Number HiLink ocamlFloat Float HiLink ocamlString String HiLink ocamlLabel Identifier HiLink ocamlType Type HiLink ocamlTodo Todo HiLink ocamlEncl Keyword delcommand HiLink endif let b:current_syntax = "ocaml" " vim: ts=8 ocaml-tools-20120103/ocamldot/README0000444000175000017500000000213407145037644015625 0ustar mehdimehdiOcamldot generates program dependency graphs for ocaml programs. The dependency graph output by ocamldot can be rendered by a separate program, dot. Dot is freely available from http://www.research.att.com/sw/tools/graphviz/ Ocamldot is designed to process the output of ocamldep. A typical use would be ocamldep *.ml | ocamldot > dep.dot or ocamldep *.ml > .depend ocamldot .depend > dep.dot This will output a dot graph into the file dep.dot. You can then use the program dotty to view, edit, and print the graph. Ocamldot has the following options: -fullgraph draw the full graph (default is to draw only the kernel) -landscape output in landscape format (default is portrait) -lr draw graph from left to right (default is top to bottom) -r use as a root in the graph; nodes reachable from will be shown (The transitive kernel of a dag is the smallest subset of the dag whose transitive closure is the same as the transitive closure of the dag. For example, the kernel of A->B, A->C, B->C is just the two edges A->B, B->C.) -Trevor Jim ocaml-tools-20120103/ocamldot/ocamldot.mll0000444000175000017500000002643607145037645017271 0ustar mehdimehdi(* ocamldot.mll, July 1999, Trevor Jim *) { module StringSet = Set.Make(struct type t = string let compare = compare end) let dependencies = ref [] let currentSource = ref "" let addDepend t = let s = !currentSource in if s<>t then dependencies := (s,t)::(!dependencies) } rule processSource = parse ['.' '-' '/' 'A'-'Z' 'a'-'z' '_' '\192'-'\214' '\216'-'\246' '\248'-'\255' '\'' '0'-'9' ]+ '.' ['A'-'Z' 'a'-'z']+ [' ' '\009']* ':' { let s = Lexing.lexeme lexbuf in let i = String.rindex s '.' in let s = String.sub s 0 i in let s = Filename.basename s in let s = String.capitalize s in currentSource := s; processTargets lexbuf } | eof { () } | _ { processSource lexbuf } and processTargets = parse [' ' '\009']+ { processTargets lexbuf } | '\\' [' ' '\009']* ['\010' '\013']+ [' ' '\009']+ { processTargets lexbuf } | ['.' '/' 'A'-'Z' 'a'-'z' '_' '\192'-'\214' '\216'-'\246' '\248'-'\255' '\'' '0'-'9' ]+ '.' ['A'-'Z' 'a'-'z']+ { let t = Lexing.lexeme lexbuf in let i = String.rindex t '.' in let t = String.sub t 0 i in let t = Filename.basename t in let t = String.capitalize t in addDepend t; processTargets lexbuf } | eof { () } | _ { processSource lexbuf } { (********************************) (* Utility functions for graphs *) (********************************) (**********************************************************************) (* A graph is represented by a (string * StringSet) list, *) (* that is, a list of (source,targets) pairs. *) (**********************************************************************) let emptyGraph = [] (**********************************************************************) (* divideGraph graph source = (sourceTargets, graphWithoutSource) *) (* *) (* Return the targets of a source in a graph and the graph with the *) (* source substracted from the sources. GraphWithoutSources may *) (* still contain source as a target. *) (**********************************************************************) let divideGraph graph source = let rec aux l = match l with [] -> (StringSet.empty,[]) | (s,ts)::tl -> if s=source then (ts,tl) else let (sourceTargets,tlWithoutSource) = aux tl in (sourceTargets,(s,ts)::tlWithoutSource) in aux graph (*********************************************) (* Add the edge (source,target) to the graph *) (*********************************************) let addEdge graph source target = let (sourceTargets,graphWithoutSource) = divideGraph graph source in (source,StringSet.add target sourceTargets)::graphWithoutSource (************************************************************) (* Add the edges { (source,t) | t in targets } to the graph *) (************************************************************) let addEdges graph source targets = let (sourceTargets,graphWithoutSource) = divideGraph graph source in (source,StringSet.union targets sourceTargets)::graphWithoutSource (**************************************************) (* Remove the edge (source,target) from the graph *) (**************************************************) let removeEdge graph source target = let rec loop l = match l with [] -> [] | (s,ts)::tl -> if s=source then (s,StringSet.remove target ts)::tl else (s,ts)::(loop tl) in loop graph (*****************************************************************) (* Remove the edges { (source,t) | t in targets } from the graph *) (*****************************************************************) let removeEdges graph source targets = let rec loop l = match l with [] -> [] | (s,ts)::tl -> if s=source then (s,StringSet.diff ts targets)::tl else (s,ts)::(loop tl) in loop graph (**********************************************************************) (* Convert between an edge-list representation of graphs and our *) (* representation. *) (**********************************************************************) let edgesOfGraph graph = List.concat (List.map (fun (s,ts) -> List.map (fun t -> (s,t)) (StringSet.elements ts)) graph) let graphOfEdges edges = List.fold_left (fun g (s,t) -> addEdge g s t) emptyGraph edges (****************************) (* Is an edge in the graph? *) (****************************) let isEdge graph source target = try let sourceTargets = List.assoc source graph in StringSet.mem target sourceTargets with Not_found -> false (*****************) (* Print a graph *) (*****************) let printGraph graph = let printEdges(source,targets) = StringSet.iter (fun t -> Printf.printf " \"%s\" -> \"%s\" ;\n" source t) targets in List.iter printEdges graph (********************************) (* Targets of a node in a graph *) (********************************) let targetsOf graph node = (* A set of nodes *) try List.assoc node graph with Not_found -> StringSet.empty (*****************************************) (* Sources that target a node in a graph *) (*****************************************) let sourcesOf graph node = (* A list of nodes *) let rec aux l = match l with [] -> [] | (s,ts)::tl -> if StringSet.mem node ts then s::(aux tl) else aux tl in aux graph (******************************************************************) (* Add an edge to a transitively closed graph, and return the new *) (* transitive closure. *) (******************************************************************) let addEdgeTc graph source target = let targetTargets = targetsOf graph target in let (sourceTargets,graphWithoutSource) = divideGraph graph source in let sourceSources = sourcesOf graphWithoutSource source in let newSourceTargets = StringSet.add target (StringSet.union sourceTargets targetTargets) in (source,newSourceTargets):: (List.fold_right (fun s g -> addEdges g s newSourceTargets) sourceSources graphWithoutSource) (**********************************************************) (* Compute the transitive closure of a graph from scratch *) (**********************************************************) let tc graph = let loop graph (source,targets) = let reachableFromSource = List.fold_left (fun r (s,ts) -> if StringSet.mem s r then StringSet.union r ts else r) targets graph in (source,reachableFromSource):: (List.map (fun (s,ts) -> if StringSet.mem source ts then (s,StringSet.union ts reachableFromSource) else (s,ts)) graph) in List.fold_left loop [] graph (************************************************************************) (* The transitive kernel (tk) of a dag is a subset of the dag whose *) (* transitive closure is the same as the transitive closure of the dag. *) (* *) (* IF THE GRAPH IS NOT A DAG, THIS CODE WON'T WORK PROPERLY!!! *) (************************************************************************) (************************************************************************) (* Add an edge to a kernel dag and return the new kernel and transitive *) (* closure of the new kernel. Requires the transitive closure of the *) (* old kernel. *) (************************************************************************) let addEdgeTk kernel tcKernel source target = if isEdge tcKernel source target then (kernel,tcKernel) else if source=target then (addEdge kernel source target,tcKernel) else begin let (sourceTargets,kernelWithoutSource) = divideGraph kernel source in let targetTargets = StringSet.add target (targetsOf tcKernel target) in let sourceSources = sourcesOf tcKernel source in let kernelWithoutSource = List.fold_left (fun kws s -> removeEdges kws s targetTargets) kernelWithoutSource sourceSources in ((source, StringSet.add target (StringSet.diff sourceTargets targetTargets)) ::kernelWithoutSource, addEdgeTc tcKernel source target) end (**********************************) (* The transitive kernel of a dag *) (**********************************) let tk dag = let edges = edgesOfGraph dag in let (kernel,tcKernel) = List.fold_left (fun (k,tck) (s,t) -> addEdgeTk k tck s t) (emptyGraph,emptyGraph) edges in kernel (**************************) (* Print the dependencies *) (**************************) let doKernel = ref true let printDepend graph = if (!doKernel) then printGraph (tk graph) else printGraph graph let calledOnFile = ref false let getDependFromFile file = calledOnFile := true; try let ic = open_in file in let lexbuf = Lexing.from_channel ic in processSource lexbuf; close_in ic with Sys_error msg -> () | Exit -> () let getDependFromStdin () = try let lexbuf = Lexing.from_channel stdin in processSource lexbuf with Sys_error msg -> () | Exit -> () (***************) (* Entry point *) (***************) let usage = "Usage: ocamldot [options] " let leftToRight = ref false let landscape = ref false let roots = ref [] ;; Arg.parse [ ("-fullgraph", Arg.Clear doKernel, " draw the full graph (default is to draw only the kernel)"); ("-landscape", Arg.Set landscape, " output in landscape format (default is portrait)"); ("-lr", Arg.Set leftToRight, " draw graph from left to right (default is top to bottom)"); ("-r", Arg.String(fun s -> roots := s::!roots), " use as a root in the graph; nodes reachable from \n will be shown") ] getDependFromFile usage; if not(!calledOnFile) then getDependFromStdin(); print_string "digraph G {\n"; if !landscape then print_string " size=\"10,7.5\" ;\n rotate=90 ;\n" else print_string " size=\"7.5,10\" ;\n"; if (!leftToRight) then print_string " rankdir = LR ;\n" else print_string " rankdir = TB ;\n"; let graph = graphOfEdges(!dependencies) in begin match !roots with [] -> printDepend graph | roots -> (* Set up the graph so that the roots are printed at the same level *) print_string " { rank=same ;\n"; List.iter (fun r -> print_string " "; print_string r; print_string " ;\n") roots; print_string " };\n"; (* Find the graph reachable from the roots *) let tcGraph = tc graph in let reachable node = (List.exists (fun r -> r=node) roots) or (List.exists (fun r -> isEdge tcGraph r node) roots) in let reachableFromRoots = List.concat (List.map (fun (source,targets) -> if reachable source then [(source,targets)] else []) graph) in printDepend reachableFromRoots end; print_string "}\n"; exit 0 ;; } ocaml-tools-20120103/ocamldot/ocamldot.10000444000175000017500000000245707261155523016635 0ustar mehdimehdi.TH OCAMLDOT 1 .SH NAME ocamldot \- generate dependency graphs of ocaml programs .SH SYNOPSIS .B ocamldot .I .RI "[options] " .SH "DESCRIPTION" This manual page documents briefly the .BR ocamldot command. .PP .B ocamldot generates program dependency graphs for ocaml programs. The dependency graph output by ocamldot can be rendered by a separate program, \fIdot\fR. .P Ocamldot is designed to process the output of ocamldep. A typical use would be .P ocamldep *.ml | ocamldot > dep.dot .P or .P ocamldep *.ml > .depend .br ocamldot .depend > dep.dot .SH OPTIONS .TP .B \-fullgraph Draw the full graph (default is to draw only the kernel) .TP .B \-landscape Output in landscape format (default is portrait) .TP .B \-lr Draw graph from left to right (default is top to bottom) .TP .B \-r Use \fI\fR as a root in the graph; nodes reachable from \fI\fR will be shown. .P The transitive kernel of a dag is the smallest subset of the dag whose transitive closure is the same as the transitive closure of the dag. For example, the kernel of A->B, A->C, B->C is just the two edges A->B, B->C. .SH SEE ALSO .BR ocamldep (1), .BR dot(1) .P \fIhttp://www.research.att.com/~trevor/ocamldot\fR. .SH AUTHOR Trevor Jim ocaml-tools-20120103/ocamldot/Makefile0000444000175000017500000000066207145037644016411 0ustar mehdimehdi# Try to automatically guess whether we are running under Windows. # Set WIN32=true manually if this doesn't work. # ifeq (${OSTYPE},cygwin32) # Cygwin Beta 19 WIN32=true else ifeq (${OSTYPE},cygwin) # Cygwin Beta 20 WIN32=true endif endif ifdef WIN32 EXE=.exe else # UNIX EXE= endif ocamldot$(EXE): ocamldot.mll ocamllex ocamldot.mll ocamlc -o $@ ocamldot.ml clean: $(RM) ocamldot$(EXE) ocamldot.ml *.cmi *.cmo *.o *.obj ocaml-tools-20120103/ocamldot/LICENSE0000444000175000017500000000015407257665565015767 0ustar mehdimehdiOcamldot was written by Trevor Jim. It is in the public domain; use it however you like, at your own risk.