OTAGS

Section: User Manuals (1)
Updated: August 2010
Index Return to Main Contents
 

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 those 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 the sources files. The advantage are more complete TAGS files (in comparison with regular expression based tagging) and that also sources with camlp4 syntax extensions can be tagged. The disadvantage is that the source files must be syntactically correct for tagging.

otags can tag all files that camlp4 can parse. Internally otags keeps a current parser list that can be modified with the options -pc, -pa and -pr. 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.  

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).
-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.
-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 otherwise the revised syntax would be loaded on top of the standard syntax with probably strange results.

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_type_conv.cmo 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 syntas 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.
 

DIAGNOSTICS

Parse errors are reported with the normal camlp4 error message. No tags are generated for files that produce errors. Tagging continues with the next file, in this case.  

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
MISSING FEATURES
CREDITS
AUTHOR
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 07:22:57 GMT, August 25, 2010