OTAGS
Section: User Manuals (1)
Updated: August 2010
Index
NAME
otags - generate tags files for emacs and vi/vim from OCaml sources
SYNOPSIS
otags
[STATIC-OPTION] ... [FILE] ... [DYNAMIC-OPTION] ... [FILE] ...
DESCRIPTION
otags
generates
TAGS
files for
emacs
and
tags
files for
vi/vim
to give these editors the ability to directly jump to function
and value definitions (use
M-.
<identifier>
in emacs and
:tag
<identifier>
in vim).
otags
uses
camlp4
for parsing. This is more precise than regular expression based
tagging. On the downside,
otags
can only tag syntactically correct files. Furthermore,
otags
is
OCaml
version specific: Sources to be compiled with
OCaml
version
X.Y
can, in general, only be tagged with
otags
version
X.Y.
otags
can tag all files that
camlp4
can parse. Internally
otags
keeps a
current parser list
that can be modified with the options
-pc
(clear list),
-pa
(add to list), and
-pr
(reset to default).
The default value of the
current parser list
corresponds to standard
OCaml
syntax (containing the parsers
r, o, rp, and op, see
STANDARD CAMLP4 PARSING EXTENSIONS below).
Each source file is parsed with a
camlp4
parser into which all parsing extensions from the
current parser list
have been loaded. The
camlp4
standard parsers are linked into
otags
and if the
current parser list
contains only such parsers then the parsing module is build
internally. Otherwise an external
camlp4
process is started.
otags
tags all toplevel items in structures and signatures, including
infix operators and nested modules and signatures. It also tags
instance variables and methods in classes and class-types.
Filenames
FILE
on the command line are parsed as interfaces if they have a
.mli
suffix and as implementations if they have a
.ml
suffix. (See also the dynamic options
-intf
and
-impl.)
otags
can tag all files in a directory tree (if option
-r
is given). Files that are generated by
ocamllex
or
ocamlyacc
or that require preprocessing with the
camlp4 macro
parser must, however, be tagged in the same directory as these
tools are run. This is because the line directives that
ocamllex
and
ocamlyacc
put into generated files are relative to the current working
directory of the generating process. For the
camlp4 macro
parser an
INCLUDE
directive may be resolved relative to the current working
directory of the
camlp4
process. Therefore, if you tag such files from a different
directory you will get an error message.
STATIC OPTIONS
Static options take effect on the whole program run, regardless
of their position in the command line.
- -r
-
Descend into directories. With this option, if one of the
FILE
arguments is a directory
otags
will recursively tag all files in this whole directory tree.
- -o file
-
Write tags to
file.
The default is
TAGS
(for
emacs)
and
tags
for
vi
(if the
-vi
option is given) in the current directory.
- -a
-
Append to an existing TAGS file (does only work for emacs TAGS files).
- -vi
-
Generate tags for
vi
and change the default output file into
tags.
- -I dir
-
Add directory dir to the
camlp4
search path for object files for
external
camlp4
parsing calls.
- -version
-
Print version and exit.
- -v
-
Verbose. Print file names as they are parsed and the command
lines for externally started
camlp4
parsing processes (if any). If
-v
is the first command line argument backtraces for exceptions are
enabled and printed if an exception escapes and terminates
otags
(which is considered as a bug about which I would appreciate a
bug report).
- -q
-
Be quiet.
- -help
-
Print the option list.
- --help
-
Alias for
-help
DYNAMIC OPTIONS
Dynamic options do only affect arguments that follow them on the
command line.
- -intf FILE
-
Parse and tag
FILE
as an interface.
- -impl FILE
-
Parse and tag
FILE
as implementation.
- -pc
-
Clear the
current parser list.
- -pa parser
-
Add
parser
to the
current parser list.
If
parser
is not one of the
standard parsers that are distributed with
camlp4
then the following file(s) are parsed in separate
camlp4
process(es).
parser
must be accepted by
camlp4 -parser,
that is, it must be a standard camlp4 parser name or a bytecode file
(.cmo) or library (.cma).
- -pr
-
Reset the
current parser list
to its default value (parse standard OCaml
without extensions).
- -pp
-
Print the
current parser list.
- -extern
-
Force
otags
to parse all the following files with an external
camlp4
process.
- -intern
-
Switch back to (default) internal parsing.
EXAMPLES
Tag some files in the original and some in the revised syntax:
-
otags
original.ml
-pc -pa r
revised.ml
-pr
original.ml
The
-pc
is necessary because, for
camlp4,
the original
OCaml
syntax is an extension of the revised syntax. Therefore, the
default
current parser list
contains the parser
r
already and adding
r
would not change the
current parser list.
Tag files with quotations
(original host syntax and revised quotation syntax):
-
otags -pa rq
qotation.ml
Tag files that use the sexplib extension:
-
otags -I
/usr/lib/ocaml/type-conv
-I
/usr/lib/ocaml/sexplib
-pa
pa_type_conv.cmo
-pa
pa_sexp_conv.cmo
use_sexp.ml
The
-I
options specify the directories where
pa_type_conv.cmo
and
pa_sexp_conv.cmo
are located on the system.
STANDARD CAMLP4 PARSING EXTENSIONS
There is currently no documentation on the names and aliases that
refer to standard
camlp4
parsing modules. Also the dependencies among those modules is
mostly undocumented. The only source for information is the file
camlp4/Camlp4Bin.ml
in the
OCaml
distribution.
The following list describes the identifiers that
camlp4 -parser
treats specifically. This is therefore the list of standard
camlp4
parsers. For these identifiers case is not significant (they are
piped through
String.lowercase
before matching). The dependencies listed here are treated
auto-magically by
camlp4
and
otags.
- r, ocamlr, ocamlrevised, pa_r.cmo, camlp4ocamlrevisedparser.cmo
-
Revised syntax without stream parsers.
- rr, reloaded, ocamlreloaded, camlp4ocamlreloadedparser.cmo
-
Variant of the revised syntax (usage unknown).
- o, ocaml, pa_o.cmo, camlp4ocamlparser.cmo
-
Original syntax without stream parsers. Depends on parser
r.
- rp, rparser, pa_rp.cmo, camlp4ocamlrevisedparserparser.cmo
-
Meaning unclear. (Should probably be revised syntax with stream
parsers but it loads
Camlp4OCamlParser,
see bug #5134).
Depends on parser
r, o.
- op, parser, pa_op.cmo, camlp4ocamlparserparser.cmo
-
Original syntax with stream parsers. Depends on parser
r, o, rp
- g, grammar, pa_extend.cmo, pa_extend_m.cmo, camlp4grammarparser.cmo
-
Grammar extensions.
- m, macro, pa_macro.cmo, camlp4macroparser.cmo
-
Macros and conditionals.
- q, camlp4quotationexpander.cmo
-
Reflective Quotations. This parsing extension takes the current
host syntax and adds quotation expanders using that current
syntax such that the resulting grammar is reflective: Changing
the host syntax afterwards does also affect the quotation syntax.
Depends on module
Camlp4QuotationCommon
(common quotation infrastructure).
- rq, q_mlast.cmo, camlp4ocamlrevisedquotationexpander.cmo
-
Revised Quotations. Adds quotations in the revised syntax. Host
and quotation parsing remain independent. Depends on module
Camlp4QuotationCommon
(common quotation infrastructure).
- oq, camlp4ocamloriginalquotationexpander.cmo
-
Original OCaml with original quotations. Loads original OCaml
(without stream parsers) as host syntax and as quotation syntax.
Host and quotation syntax are independent (not reflective).
Depends on parser
ocamlr, ocaml and module Camlp4QuotationCommon
- rf
-
Full revised. Sets up revised syntax with stream parsers, grammar
extensions, list comprehensions and macros and adds reflective
quotations. Depends on parsers/modules
r, rp, Camlp4QuotationCommon, q, g, comp, m.
- of
-
Original full. Sets up original OCaml with stream parsers, list
comprehensions and macros and adds quotations in the revised
syntax. (Note that this is
camlp4 -parser of
which is different from
camlp4of,
see bug #5129.) Depends on parsers/modules
r, o, rp, op, Camlp4QuotationCommon, rq, g, comp and m.
- comp, camlp4listcomprehension.cmo
-
List comprehensions.
- debug, camlp4debugparser, camlp4debugparser.cmo
-
Debugging statements
debug
and
camlp4_debug.
The expansion of those statements depends on the value of the
environment variable
STATIC_CAMLP4_DEBUG
such that also the produced tag entries might depend on this variable.
DIAGNOSTICS
Parse errors are reported with normal
camlp4
error messages. No tags are generated for files that produce
errors. Tagging continues with the next file, in this case.
The error "Original source not available" is reported if the file
to which a line directive refers cannot be found. This may happen
if
otags
is started in a different directory than the program that
generated the faulting file.
Escaping exceptions and assertions that terminate
otags
are considered as bugs. If they occur please use option
-v
as
first
command line switch to obtain an exception backtrace and submit this
with all relevant information as bug report.
BUGS
Material following a line directive (for instance in
ocamlyacc
generated files) is parsed with completely wrong location
information (see
OCaml
bug #5159). Therefore the tags generated for such material are
essentially garbage.
MISSING FEATURES
Appending to vi tags files requires to reread the existing tags
file, because vi tags files are sorted.
CREDITS
Cuihtlauac Alvarado and Jean-Francois Monin were the first to
exploit
camlp4
for tagging
OCaml
files. This version is a complete rewrite,
based on the new
camlp4
from
OCaml
version 3.10 and onwards.
AUTHOR
Hendrik Tews <otags at askra.de>
SEE ALSO
etags(1),
ctags(1)
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- STATIC OPTIONS
-
- DYNAMIC OPTIONS
-
- EXAMPLES
-
- STANDARD CAMLP4 PARSING EXTENSIONS
-
- DIAGNOSTICS
-
- BUGS
-
- MISSING FEATURES
-
- CREDITS
-
- AUTHOR
-
- SEE ALSO
-
This document was created by
man2html,
using the manual pages.
Time: 21:39:29 GMT, January 14, 2012