13cd29b7fSMasatake YAMATO.. _ctags-optlib(7): 23cd29b7fSMasatake YAMATO 33cd29b7fSMasatake YAMATO============================================================== 4b28d5302SMasatake YAMATOctags-optlib 53cd29b7fSMasatake YAMATO============================================================== 63cd29b7fSMasatake YAMATO-------------------------------------------------------------- 7dccba5efSHiroo HAYASHIUniversal Ctags parser definition language 83cd29b7fSMasatake YAMATO-------------------------------------------------------------- 93cd29b7fSMasatake YAMATO:Version: @VERSION@ 10dccba5efSHiroo HAYASHI:Manual group: Universal Ctags 113cd29b7fSMasatake YAMATO:Manual section: 7 123cd29b7fSMasatake YAMATO 133cd29b7fSMasatake YAMATOSYNOPSIS 143cd29b7fSMasatake YAMATO-------- 153cd29b7fSMasatake YAMATO| **@CTAGS_NAME_EXECUTABLE@** [options] [file(s)] 163cd29b7fSMasatake YAMATO| **@ETAGS_NAME_EXECUTABLE@** [options] [file(s)] 173cd29b7fSMasatake YAMATO 183cd29b7fSMasatake YAMATODESCRIPTION 193cd29b7fSMasatake YAMATO----------- 203cd29b7fSMasatake YAMATO 21185906aaSHiroo HAYASHI*Exuberant Ctags*, the ancestor of *Universal Ctags*, has provided 22dccba5efSHiroo HAYASHIthe way to define a new parser from command line. Universal Ctags 23185906aaSHiroo HAYASHIextends and refines this feature. *optlib parser* is the name for such 24dccba5efSHiroo HAYASHIparser in Universal Ctags. "opt" intends a parser is defined with 25bde6254dSK.Takatacombination of command line options. "lib" intends an optlib parser 26599fcc99SMasatake YAMATOcan be more than ad-hoc personal configuration. 27599fcc99SMasatake YAMATO 2800e59525SMasatake YAMATOThis man page is for people who want to define an optlib parser. The 29185906aaSHiroo HAYASHIreaders should read ctags(1) of Universal Ctags first. 30599fcc99SMasatake YAMATO 31185906aaSHiroo HAYASHIFollowing options are for defining (or customizing) a parser: 32599fcc99SMasatake YAMATO 33185906aaSHiroo HAYASHI* ``--langdef=<name>`` 34185906aaSHiroo HAYASHI* ``--map-<LANG>=[+|-]<extension>|<pattern>`` 35185906aaSHiroo HAYASHI* ``--kinddef-<LANG>=<letter>,<name>,<description>`` 36b01547bcSHiroo HAYASHI* ``--regex-<LANG>=/<line_pattern>/<name_pattern>/<kind-spec>/[<flags>]`` 37b01547bcSHiroo HAYASHI* ``--mline-regex-<LANG>=/<line_pattern>/<name_pattern>/<kind-spec>/[<flags>]`` 38599fcc99SMasatake YAMATO 39185906aaSHiroo HAYASHIFollowing options are for controlling loading parser definition: 40185906aaSHiroo HAYASHI 41185906aaSHiroo HAYASHI* ``--options=<pathname>`` 42185906aaSHiroo HAYASHI* ``--options-maybe=<pathname>`` 43185906aaSHiroo HAYASHI* ``--optlib-dir=[+]<directory>`` 44599fcc99SMasatake YAMATO 45599fcc99SMasatake YAMATOThe design of options and notations for defining a parser in 46bb84f88aSHiroo HAYASHIExuberant Ctags may focus on reducing the number of typing by user. 47599fcc99SMasatake YAMATOReducing the number of typing is important for users who want to 48599fcc99SMasatake YAMATOdefine (or customize) a parser quickly. 49599fcc99SMasatake YAMATO 50dccba5efSHiroo HAYASHIOn the other hand, the design in Universal Ctags focuses on 51dccba5efSHiroo HAYASHImaintainability. The notation of Universal Ctags is redundant than 52bb84f88aSHiroo HAYASHIthat of Exuberant Ctags; the newly introduced kind should be declared 53cd2e08bbSMasatake YAMATOexplicitly, (long) names are approved than one-letter flags 54599fcc99SMasatake YAMATOspecifying kinds, and naming rules are stricter. 55599fcc99SMasatake YAMATO 56dccba5efSHiroo HAYASHIThis man page explains only stable options and flags. Universal Ctags 570b2e105aSMasatake YAMATOalso introduces experimental options and flags which have names starting 580b2e105aSMasatake YAMATOwith ``_``. For documentation on these options and flags, visit 59dccba5efSHiroo HAYASHIUniversal Ctags web site at https://ctags.io/. 604b3c728dSMasatake YAMATO 61599fcc99SMasatake YAMATO 62599fcc99SMasatake YAMATOStoring a parser definition to a file 63599fcc99SMasatake YAMATO~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 64599fcc99SMasatake YAMATOThough it is possible to define a parser from command line, you don't 65599fcc99SMasatake YAMATOwant to type the same command line each time when you need the parser. 66599fcc99SMasatake YAMATOYou can store options for defining a parser into a file. 67599fcc99SMasatake YAMATO 68599fcc99SMasatake YAMATO@CTAGS_NAME_EXECUTABLE@ loads files (preload files) listed in "FILES" 69599fcc99SMasatake YAMATOsection of ctags(1) at program starting up. You can put your parser 70599fcc99SMasatake YAMATOdefinition needed usually to the files. 71599fcc99SMasatake YAMATO 72185906aaSHiroo HAYASHI``--options=<pathname>``, ``--options-maybe=<pathname>``, and 73185906aaSHiroo HAYASHI``--optlib-dir=[+]<directory>`` are for loading optlib files you need 74185906aaSHiroo HAYASHIoccasionally. See "Option File Options" section of ctags(1) for 75599fcc99SMasatake YAMATOthese options. 76599fcc99SMasatake YAMATO 77185906aaSHiroo HAYASHIAs explained in "FILES" section of ctags(1), options for defining a 78599fcc99SMasatake YAMATOparser listed line by line in an optlib file. Prefixed white spaces are 79599fcc99SMasatake YAMATOignored. A line starting with '#' is treated as a comment. Escaping 80599fcc99SMasatake YAMATOshell meta character is not needed. 81599fcc99SMasatake YAMATO 82185906aaSHiroo HAYASHIUse ``.ctags`` as file extension for optlib file. You can define 83599fcc99SMasatake YAMATOmultiple parsers in an optlib file but it is better to make a file for 84599fcc99SMasatake YAMATOeach parser definition. 85599fcc99SMasatake YAMATO 86185906aaSHiroo HAYASHI``--_echo=<msg>`` and ``--_force-quit=<num>`` options are for debugging 87599fcc99SMasatake YAMATOoptlib parser. 88599fcc99SMasatake YAMATO 89599fcc99SMasatake YAMATO 90599fcc99SMasatake YAMATOOverview for defining a parser 91599fcc99SMasatake YAMATO~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 92599fcc99SMasatake YAMATO 93599fcc99SMasatake YAMATO1. Design the parser 94599fcc99SMasatake YAMATO 95599fcc99SMasatake YAMATO You need know both the target language and the ctags' 96599fcc99SMasatake YAMATO concepts (definition, reference, kind, role, field, extra). About 97dccba5efSHiroo HAYASHI the concepts, ctags(1) of Universal Ctags may help you. 98599fcc99SMasatake YAMATO 99d732381dSMasatake YAMATO2. Give a name to the parser 100599fcc99SMasatake YAMATO 101185906aaSHiroo HAYASHI Use ``--langdef=<name>`` option. *<name>* is referred as *<LANG>* in 102599fcc99SMasatake YAMATO the later steps. 103599fcc99SMasatake YAMATO 104d732381dSMasatake YAMATO3. Give a file pattern or file extension for activating the parser 105d732381dSMasatake YAMATO 106185906aaSHiroo HAYASHI Use ``--map-<LANG>=[+|-]<extension>|<pattern>``. 107d732381dSMasatake YAMATO 108599fcc99SMasatake YAMATO4. Define kinds 109599fcc99SMasatake YAMATO 110185906aaSHiroo HAYASHI Use ``--kinddef-<LANG>=<letter>,<name>,<description>`` option. 111bb84f88aSHiroo HAYASHI Universal Ctags introduces this option. Exuberant Ctags doesn't 112bb84f88aSHiroo HAYASHI have. In Exuberant Ctags, a kind is defined as a side effect of 113599fcc99SMasatake YAMATO specifying ``--regex-<LANG>=`` option. So user doesn't have a 114599fcc99SMasatake YAMATO chance to recognize how important the definition of kind. 115599fcc99SMasatake YAMATO 116599fcc99SMasatake YAMATO5. Define patterns 117599fcc99SMasatake YAMATO 118b01547bcSHiroo HAYASHI Use ``--regex-<LANG>=/<line_pattern>/<name_pattern>/<kind-spec>/[<flags>]`` 1198e6f0509SHiroo HAYASHI option for a single-line regular expression. You can also use 120b01547bcSHiroo HAYASHI ``--mline-regex-<LANG>=/<line_pattern>/<name_pattern>/<kind-spec>/[<flags>]`` 1218e6f0509SHiroo HAYASHI option for a multi-line regular expression. 122599fcc99SMasatake YAMATO 123185906aaSHiroo HAYASHI As *<kind-spec>*, you can use the one-letter flag defined with 124185906aaSHiroo HAYASHI ``--kinddef-<LANG>=<letter>,<name>,<description>`` option. 125599fcc99SMasatake YAMATO 1262c6d8896SMasatake YAMATOOPTIONS 127599fcc99SMasatake YAMATO------------ 128599fcc99SMasatake YAMATO 129185906aaSHiroo HAYASHI``--langdef=<name>`` 130185906aaSHiroo HAYASHI Defines a new user-defined language, *<name>*, to be parsed with regular 131185906aaSHiroo HAYASHI expressions. Once defined, *<name>* may be used in other options taking 132599fcc99SMasatake YAMATO language names. 133599fcc99SMasatake YAMATO 134185906aaSHiroo HAYASHI *<name>* must consist of alphanumeric characters, '``#``', or '``+``' 135185906aaSHiroo HAYASHI ('[a-zA-Z0-9#+]+'). The graph characters other than '``#``' and 136185906aaSHiroo HAYASHI '``+``' are disallowed (or reserved). Some of them (``[-=:{.]``) are 1370278c2a1SMasatake YAMATO disallowed because they can make the command line parser of 1380278c2a1SMasatake YAMATO @CTAGS_NAME_EXECUTABLE@ confused. The rest of them are just 1390278c2a1SMasatake YAMATO reserved for future extending @CTAGS_NAME_EXECUTABLE@. 1400278c2a1SMasatake YAMATO 141185906aaSHiroo HAYASHI ``all`` is an exception. ``all`` as *<name>* is not acceptable. It is 1420278c2a1SMasatake YAMATO a reserved word. See the description of 143185906aaSHiroo HAYASHI ``--kinds-(<LANG>|all)=[+|-](<kinds>|*)`` option in ctags(1) about how the 1440278c2a1SMasatake YAMATO reserved word is used. 1452ff65297SMasatake YAMATO 146c9703bd8SMasatake YAMATO The names of built-in parsers are capitalized. When 147c9703bd8SMasatake YAMATO @CTAGS_NAME_EXECUTABLE@ evaluates an option in a command line, and 148c9703bd8SMasatake YAMATO chooses a parser, @CTAGS_NAME_EXECUTABLE@ uses the names of 149c9703bd8SMasatake YAMATO parsers in a case-insensitive way. Therefore, giving a name 150c9703bd8SMasatake YAMATO started from a lowercase character doesn't help you to avoid the 151c9703bd8SMasatake YAMATO parser name confliction. However, in a tags file, 152c9703bd8SMasatake YAMATO @CTAGS_NAME_EXECUTABLE@ prints parser names in a case-sensitive 153185906aaSHiroo HAYASHI way; it prints a parser name as specified in ``--langdef=<name>`` 154c9703bd8SMasatake YAMATO option. Therefore, we recommend you to give a name started from a 155c9703bd8SMasatake YAMATO lowercase character to your private optlib parser. With this 156c9703bd8SMasatake YAMATO convention, people can know where a tag entry in a tag file comes 157c9703bd8SMasatake YAMATO from a built-in parser or a private optlib parser. 158c9703bd8SMasatake YAMATO 159185906aaSHiroo HAYASHI``--kinddef-<LANG>=<letter>,<name>,<description>`` 160599fcc99SMasatake YAMATO Define a kind for *<LANG>*. 161599fcc99SMasatake YAMATO Be not confused this with ``--kinds-<LANG>``. 162599fcc99SMasatake YAMATO 163185906aaSHiroo HAYASHI *<letter>* must be an alphabetical character ('[a-zA-EG-Z]') 164599fcc99SMasatake YAMATO other than "F". "F" has been reserved for representing a file 165bb84f88aSHiroo HAYASHI since Exuberant Ctags. 166599fcc99SMasatake YAMATO 167185906aaSHiroo HAYASHI *<name>* must start with an alphabetic character, and the rest 1682854ad6dSMasatake YAMATO must be alphanumeric ('[a-zA-Z][a-zA-Z0-9]*'). Do not use 169185906aaSHiroo HAYASHI "file" as *<name>*. It has been reserved for representing a file 170bb84f88aSHiroo HAYASHI since Exuberant Ctags. 1712854ad6dSMasatake YAMATO 172185906aaSHiroo HAYASHI Note that using a number character in a *<name>* violates the 173a8356685SMasatake YAMATO version 2 of tags file format though @CTAGS_NAME_EXECUTABLE@ 174a8356685SMasatake YAMATO accepts it. For more detail, see tags(5). 1750f8ba855SMasatake YAMATO 176185906aaSHiroo HAYASHI *<description>* comes from any printable ASCII characters. The 177c45dfbecSK.Takata exception is ``{`` and ``\``. ``{`` is reserved for adding flags 178c45dfbecSK.Takata this option in the future. So put ``\`` before ``{`` to include 179c45dfbecSK.Takata ``{`` to a description. To include ``\`` itself to a description, 180c45dfbecSK.Takata put ``\`` before ``\``. 18196b4483eSMasatake YAMATO 182185906aaSHiroo HAYASHI Both *<letter>*, *<name>* and their combination must be unique in 183599fcc99SMasatake YAMATO a *<LANG>*. 184599fcc99SMasatake YAMATO 185dccba5efSHiroo HAYASHI This option is newly introduced in Universal Ctags. This option 186599fcc99SMasatake YAMATO reduces the typing defining a regex pattern with 187599fcc99SMasatake YAMATO ``--regex-<LANG>=``, and keeps the consistency of kind 188599fcc99SMasatake YAMATO definitions in a language. 189599fcc99SMasatake YAMATO 190185906aaSHiroo HAYASHI The *<letter>* can be used as an argument for ``--kinds-<LANG>`` 191599fcc99SMasatake YAMATO option to enable or disable the kind. Unless ``K`` field is 192185906aaSHiroo HAYASHI enabled, the *<letter>* is used as value in the "kind" extension 193599fcc99SMasatake YAMATO field in tags output. 194599fcc99SMasatake YAMATO 195185906aaSHiroo HAYASHI The *<name>* surrounded by braces can be used as an argument for 196185906aaSHiroo HAYASHI ``--kind-<LANG>`` option. If ``K`` field is enabled, the *<name>* 197599fcc99SMasatake YAMATO is used as value in the "kind" extension field in tags output. 198599fcc99SMasatake YAMATO 199185906aaSHiroo HAYASHI The *<description>* and *<letter>* are listed in ``--list-kinds`` 200b01547bcSHiroo HAYASHI output. All three elements of the kind-spec are listed in 201599fcc99SMasatake YAMATO ``--list-kinds-full`` output. Don't use braces in the 202185906aaSHiroo HAYASHI *<description>*. They will be used meta characters in the future. 203599fcc99SMasatake YAMATO 204b01547bcSHiroo HAYASHI``--regex-<LANG>=/<line_pattern>/<name_pattern>/<kind-spec>/[<flags>]`` 2058e6f0509SHiroo HAYASHI Define a single-line regular expression. 2068e6f0509SHiroo HAYASHI 207185906aaSHiroo HAYASHI The */<line_pattern>/<name_pattern>/* pair defines a regular expression 208185906aaSHiroo HAYASHI replacement pattern, similar in style to ``sed`` substitution 209185906aaSHiroo HAYASHI commands, ``s/regexp/replacement/``, with which to generate tags from source files mapped to 210599fcc99SMasatake YAMATO the named language, *<LANG>*, (case-insensitive; either a built-in 211185906aaSHiroo HAYASHI or user-defined language). 212185906aaSHiroo HAYASHI 213185906aaSHiroo HAYASHI The regular expression, *<line_pattern>*, defines 214599fcc99SMasatake YAMATO an extended regular expression (roughly that used by egrep(1)), 215599fcc99SMasatake YAMATO which is used to locate a single source line containing a tag and 216185906aaSHiroo HAYASHI may specify tab characters using ``\t``. 217185906aaSHiroo HAYASHI 218185906aaSHiroo HAYASHI When a matching line is 219599fcc99SMasatake YAMATO found, a tag will be generated for the name defined by 220185906aaSHiroo HAYASHI *<name_pattern>*, which generally will contain the special 221c45dfbecSK.Takata back-references ``\1`` through ``\9`` to refer to matching sub-expression 222185906aaSHiroo HAYASHI groups within *<line_pattern>*. 223185906aaSHiroo HAYASHI 224185906aaSHiroo HAYASHI The '``/``' separator characters shown in the 225599fcc99SMasatake YAMATO parameter to the option can actually be replaced by any 226599fcc99SMasatake YAMATO character. Note that whichever separator character is used will 227185906aaSHiroo HAYASHI have to be escaped with a backslash ('``\``') character wherever it is 228599fcc99SMasatake YAMATO used in the parameter as something other than a separator. The 229599fcc99SMasatake YAMATO regular expression defined by this option is added to the current 230599fcc99SMasatake YAMATO list of regular expressions for the specified language unless the 231599fcc99SMasatake YAMATO parameter is omitted, in which case the current list is cleared. 232599fcc99SMasatake YAMATO 233185906aaSHiroo HAYASHI Unless modified by *<flags>*, *<line_pattern>* is interpreted as a POSIX 234185906aaSHiroo HAYASHI extended regular expression. The *<name_pattern>* should expand for all 235599fcc99SMasatake YAMATO matching lines to a non-empty string of characters, or a warning 236804d9ea4SMasatake YAMATO message will be reported unless ``{placeholder}`` regex flag is 237185906aaSHiroo HAYASHI specified. 238599fcc99SMasatake YAMATO 239b01547bcSHiroo HAYASHI A kind specifier (*<kind-spec>*) for tags matching regexp may 240185906aaSHiroo HAYASHI follow *<name_pattern>*, which will determine what kind of tag is 241185906aaSHiroo HAYASHI reported in the ``kind`` extension field (see tags(5)). 242185906aaSHiroo HAYASHI 2438e6f0509SHiroo HAYASHI *<kind-spec>* has two forms: *one-letter form* and *full form*. 244599fcc99SMasatake YAMATO 2458e6f0509SHiroo HAYASHI The one-letter form in the form of ``<letter>``. It just refers a kind 2468e6f0509SHiroo HAYASHI *<letter>* defined with ``--kinddef-<LANG>``. This form is recommended in 2478e6f0509SHiroo HAYASHI Universal Ctags. 248599fcc99SMasatake YAMATO 2498e6f0509SHiroo HAYASHI The full form of *<kind-spec>* is in the form of 2508e6f0509SHiroo HAYASHI ``<letter>,<name>,<description>``. Either the kind *<name>* and/or the 2518e6f0509SHiroo HAYASHI *<description>* can be omitted. See the description of 2528e6f0509SHiroo HAYASHI ``--kinddef-<LANG>=<letter>,<name>,<description>`` option about the 2538e6f0509SHiroo HAYASHI elements. 2548e6f0509SHiroo HAYASHI 2558e6f0509SHiroo HAYASHI The full form is supported only for keeping the compatibility with Exuberant 2568e6f0509SHiroo HAYASHI Ctags which does not have ``--kinddef-<LANG>`` option. Supporting the 257185906aaSHiroo HAYASHI form will be removed from Universal Ctags in the future. 258599fcc99SMasatake YAMATO 2598e6f0509SHiroo HAYASHI .. MEMO: the following line is commented out 260185906aaSHiroo HAYASHI If *<kind-spec>* is omitted, it defaults to ``r,regex``. 261185906aaSHiroo HAYASHI 262185906aaSHiroo HAYASHI About *<flags>*, see "FLAGS FOR ``--regex-<LANG>`` OPTION". 263599fcc99SMasatake YAMATO 264a8aa0c2bSMasatake YAMATO For more information on the regular expressions used by 265a8aa0c2bSMasatake YAMATO @CTAGS_NAME_EXECUTABLE@, see either the regex(5,7) man page, or 266185906aaSHiroo HAYASHI the GNU info documentation for regex (e.g. "``info regex``"). 267a8aa0c2bSMasatake YAMATO 2688e6f0509SHiroo HAYASHI``--list-regex-flags`` 2698e6f0509SHiroo HAYASHI Lists the flags that can be used in ``--regex-<LANG>`` option. 2708e6f0509SHiroo HAYASHI 2718e6f0509SHiroo HAYASHI``--list-mline-regex-flags`` 2728e6f0509SHiroo HAYASHI Lists the flags that can be used in ``--mline-regex-<LANG>`` option. 2738e6f0509SHiroo HAYASHI 274b01547bcSHiroo HAYASHI``--mline-regex-<LANG>=/<line_pattern>/<name_pattern>/<kind-spec>/[<flags>]`` 2758e6f0509SHiroo HAYASHI Define a multi-line regular expression. 2768e6f0509SHiroo HAYASHI 2778e6f0509SHiroo HAYASHI This option is similar to ``--regex-<LANG>`` option except the pattern is 2788e6f0509SHiroo HAYASHI applied to the whole file’s contents, not line by line. 2798e6f0509SHiroo HAYASHI 2808e6f0509SHiroo HAYASHI``--_echo=<message>`` 2818e6f0509SHiroo HAYASHI Print *<message>* to the standard error stream. This is helpful to 282dccba5efSHiroo HAYASHI understand (and debug) optlib loading feature of Universal Ctags. 283599fcc99SMasatake YAMATO 284185906aaSHiroo HAYASHI``--_force-quit[=<num>]`` 285185906aaSHiroo HAYASHI Exits immediately when this option is processed. If *<num>* is used 286599fcc99SMasatake YAMATO as exit status. The default is 0. This is helpful to debug optlib 287dccba5efSHiroo HAYASHI loading feature of Universal Ctags. 288599fcc99SMasatake YAMATO 289599fcc99SMasatake YAMATO 290599fcc99SMasatake YAMATOFLAGS FOR ``--regex-<LANG>`` OPTION 2918e6f0509SHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 292599fcc99SMasatake YAMATO 293185906aaSHiroo HAYASHIYou can specify more than one flag, ``<letter>|{<name>}``, at the end of ``--regex-<LANG>`` to 294dccba5efSHiroo HAYASHIcontrol how Universal Ctags uses the pattern. 295599fcc99SMasatake YAMATO 296185906aaSHiroo HAYASHIExuberant Ctags uses a *<letter>* to represent a flag. In 297185906aaSHiroo HAYASHIUniversal Ctags, a *<name>* surrounded by braces (name form) can be used 298185906aaSHiroo HAYASHIin addition to *<letter>*. The name form makes a user reading an optlib 299185906aaSHiroo HAYASHIfile easier. 300185906aaSHiroo HAYASHI 301185906aaSHiroo HAYASHIThe most of all flags newly added in Universal Ctags 302cd2e08bbSMasatake YAMATOdon't have the one-letter representation. All of them have only the name 303599fcc99SMasatake YAMATOrepresentation. ``--list-regex-flags`` lists all the flags. 304599fcc99SMasatake YAMATO 305cd2e08bbSMasatake YAMATO``basic`` (one-letter form ``b``) 306185906aaSHiroo HAYASHI The pattern is interpreted as a POSIX basic regular expression. 307599fcc99SMasatake YAMATO 308cd2e08bbSMasatake YAMATO``exclusive`` (one-letter form ``x``) 309f15ca522SMasatake YAMATO Skip testing the other patterns if a line is matched to this 310599fcc99SMasatake YAMATO pattern. This is useful to avoid using CPU to parse line comments. 311599fcc99SMasatake YAMATO 312cd2e08bbSMasatake YAMATO``extend`` (one-letter form ``e``) 313185906aaSHiroo HAYASHI The pattern is interpreted as a POSIX extended regular 314599fcc99SMasatake YAMATO expression (default). 315599fcc99SMasatake YAMATO 316ea999d80SMasatake YAMATO``pcre2`` (one-letter form ``p``, experimental) 317ea999d80SMasatake YAMATO The pattern is interpreted as a PCRE2 regular expression explained 318ea999d80SMasatake YAMATO in pcre2syntax(3). This flag is available only if the ctags is 319ea999d80SMasatake YAMATO built with ``pcre2`` library. See the output of 320ea999d80SMasatake YAMATO ``--list-features`` option to know whether your ctags is 321ea999d80SMasatake YAMATO built-with ``pcre2`` or not. 322ea999d80SMasatake YAMATO 323cd2e08bbSMasatake YAMATO``icase`` (one-letter form ``i``) 324599fcc99SMasatake YAMATO The regular expression is to be applied in a case-insensitive 325599fcc99SMasatake YAMATO manner. 326599fcc99SMasatake YAMATO 327599fcc99SMasatake YAMATO``placeholder`` 328804d9ea4SMasatake YAMATO Don't emit a tag captured with a regex pattern. The replacement 329804d9ea4SMasatake YAMATO can be an empty string. See the following description of 330804d9ea4SMasatake YAMATO ``scope=...`` flag about how this is useful. 331599fcc99SMasatake YAMATO 332*f998e51dSMasatake YAMATO``scope=(ref|push|pop|clear|set|replace)`` 333804d9ea4SMasatake YAMATO 334804d9ea4SMasatake YAMATO Specify what to do with the internal scope stack. 335804d9ea4SMasatake YAMATO 336804d9ea4SMasatake YAMATO A parser programmed with ``--regex-<LANG>`` has a stack (scope 337804d9ea4SMasatake YAMATO stack) internally. You can use it for tracking scope 338804d9ea4SMasatake YAMATO information. The ``scope=...`` flag is for manipulating and 339804d9ea4SMasatake YAMATO utilizing the scope stack. 340804d9ea4SMasatake YAMATO 341804d9ea4SMasatake YAMATO If ``{scope=push}`` is specified, a tag captured with 342804d9ea4SMasatake YAMATO ``--regex-<LANG>`` is pushed to the stack. ``{scope=push}`` 343804d9ea4SMasatake YAMATO implies ``{scope=ref}``. 344804d9ea4SMasatake YAMATO 345*f998e51dSMasatake YAMATO You can fill the scope field (``scope:``) of captured tag with 346804d9ea4SMasatake YAMATO ``{scope=ref}``. If ``{scope=ref}`` flag is given, 347804d9ea4SMasatake YAMATO @CTAGS_NAME_EXECUTABLE@ attaches the tag at the top to the tag 348804d9ea4SMasatake YAMATO captured with ``--regex-<LANG>`` as the value for the ``scope:`` 349804d9ea4SMasatake YAMATO field. 350804d9ea4SMasatake YAMATO 351804d9ea4SMasatake YAMATO @CTAGS_NAME_EXECUTABLE@ pops the tag at the top of the stack when 352804d9ea4SMasatake YAMATO ``--regex-<LANG>`` with ``{scope=pop}`` is matched to the input 353804d9ea4SMasatake YAMATO line. 354804d9ea4SMasatake YAMATO 355804d9ea4SMasatake YAMATO Specifying ``{scope=clear}`` removes all the tags in the scope. 356804d9ea4SMasatake YAMATO Specifying ``{scope=set}`` removes all the tags in the scope, and 357804d9ea4SMasatake YAMATO then pushes the captured tag as ``{scope=push}`` does. 358804d9ea4SMasatake YAMATO 359*f998e51dSMasatake YAMATO ``{scope=replace}`` does the three things sequentially. First it 360*f998e51dSMasatake YAMATO does the same as ``{scope=pop}``, then fills the ``scope:`` field 361*f998e51dSMasatake YAMATO of the tag captured with ``--regex-<LANG>``, and pushes the tag to 362*f998e51dSMasatake YAMATO the scope stack as if ``{scope=push}`` was given finally. 363*f998e51dSMasatake YAMATO You cannot specify another scope action together with 364*f998e51dSMasatake YAMATO ``{scope=replace}``. 365*f998e51dSMasatake YAMATO 366*f998e51dSMasatake YAMATO You don't want to specify ``{scope=pop}{scope=push}`` as an 367*f998e51dSMasatake YAMATO alternative to ``{scope=replace}``; ``{scope=pop}{scope=push}`` 368*f998e51dSMasatake YAMATO fills the ``scope:`` field of the tag captured with ``--regex-<LANG>`` 369*f998e51dSMasatake YAMATO first, then pops the tag at the top of the stack, and pushes 370*f998e51dSMasatake YAMATO the captured tag to the scope stack finally. The timing when 371*f998e51dSMasatake YAMATO filling the end field is different between ``{scope=replace}`` and 372*f998e51dSMasatake YAMATO ``{scope=pop}{scope=push}``. 373*f998e51dSMasatake YAMATO 3740b2e105aSMasatake YAMATO In some cases, you may want to use ``--regex-<LANG>`` only for its 3750b2e105aSMasatake YAMATO side effects: using it only to manipulate the stack but not for 376185906aaSHiroo HAYASHI capturing a tag. In such a case, make *<name_pattern>* component of 3770b2e105aSMasatake YAMATO ``--regex-<LANG>`` option empty while specifying ``{placeholder}`` 3780b2e105aSMasatake YAMATO as a regex flag. For example, a non-named tag can be put on 379185906aaSHiroo HAYASHI the stack by giving a regex flag "``{scope=push}{placeholder}``". 380804d9ea4SMasatake YAMATO 3810b2e105aSMasatake YAMATO You may wonder what happens if a regex pattern with 382804d9ea4SMasatake YAMATO ``{scope=ref}`` flag matches an input line but the stack is empty, 3830b2e105aSMasatake YAMATO or a non-named tag is at the top. If the regex pattern contains a 3840b2e105aSMasatake YAMATO ``{scope=ref}`` flag and the stack is empty, the ``{scope=ref}`` 3850b2e105aSMasatake YAMATO flag is ignored and nothing is attached to the ``scope:`` field. 3860b2e105aSMasatake YAMATO 3870b2e105aSMasatake YAMATO If the top of the stack contains an unnamed tag, 3880b2e105aSMasatake YAMATO @CTAGS_NAME_EXECUTABLE@ searches deeper into the stack to find the 3890b2e105aSMasatake YAMATO top-most named tag. If it reaches the bottom of the stack without 3900b2e105aSMasatake YAMATO finding a named tag, the ``{scope=ref}`` flag is ignored and 3910b2e105aSMasatake YAMATO nothing is attached to the ``scope:`` field. 392804d9ea4SMasatake YAMATO 393804d9ea4SMasatake YAMATO When a named tag on the stack is popped or cleared as the side 394804d9ea4SMasatake YAMATO effect of a pattern matching, @CTAGS_NAME_EXECUTABLE@ attaches the 3950b2e105aSMasatake YAMATO line number of the match to the ``end:`` field of 396804d9ea4SMasatake YAMATO the named tag. 397804d9ea4SMasatake YAMATO 3980b2e105aSMasatake YAMATO @CTAGS_NAME_EXECUTABLE@ clears all of the tags on the stack when it 3990b2e105aSMasatake YAMATO reaches the end of the input source file. The line number of the 4000b2e105aSMasatake YAMATO end is attached to the ``end:`` field of the cleared tags. 401599fcc99SMasatake YAMATO 4028e6f0509SHiroo HAYASHI``warning=<message>`` 4038e6f0509SHiroo HAYASHI print the given *<message>* at WARNING level 404599fcc99SMasatake YAMATO 4058e6f0509SHiroo HAYASHI``fatal=<message>`` 4068e6f0509SHiroo HAYASHI print the given *<message>* and exit 4078e6f0509SHiroo HAYASHI 4088e6f0509SHiroo HAYASHIEXAMPLES 409bced791fSMasatake YAMATO------------- 410bced791fSMasatake YAMATO 4118e6f0509SHiroo HAYASHIPerl Pod 4128e6f0509SHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 413bced791fSMasatake YAMATO 4148e6f0509SHiroo HAYASHIThis is the definition (pod.ctags) used in ctags for parsing Pod 4158e6f0509SHiroo HAYASHI(https://perldoc.perl.org/perlpod.html) file. 4168e6f0509SHiroo HAYASHI 417d14dd918SMasatake YAMATO.. code-block:: ctags 4188e6f0509SHiroo HAYASHI 4198e6f0509SHiroo HAYASHI --langdef=pod 4208e6f0509SHiroo HAYASHI --map-pod=+.pod 4218e6f0509SHiroo HAYASHI 4228e6f0509SHiroo HAYASHI --kinddef-pod=c,chapter,chapters 4238e6f0509SHiroo HAYASHI --kinddef-pod=s,section,sections 4248e6f0509SHiroo HAYASHI --kinddef-pod=S,subsection,subsections 4258e6f0509SHiroo HAYASHI --kinddef-pod=t,subsubsection,subsubsections 4268e6f0509SHiroo HAYASHI 4278e6f0509SHiroo HAYASHI --regex-pod=/^=head1[ \t]+(.+)/\1/c/ 4288e6f0509SHiroo HAYASHI --regex-pod=/^=head2[ \t]+(.+)/\1/s/ 4298e6f0509SHiroo HAYASHI --regex-pod=/^=head3[ \t]+(.+)/\1/S/ 4308e6f0509SHiroo HAYASHI --regex-pod=/^=head4[ \t]+(.+)/\1/t/ 431bced791fSMasatake YAMATO 432bced791fSMasatake YAMATOUsing scope regex flags 433bced791fSMasatake YAMATO~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 434bced791fSMasatake YAMATO 4350b2e105aSMasatake YAMATOLet's think about writing a parser for a very small subset of the Ruby 4360b2e105aSMasatake YAMATOlanguage. 437bced791fSMasatake YAMATO 438185906aaSHiroo HAYASHIinput source file (``input.srb``):: 439bced791fSMasatake YAMATO 440bced791fSMasatake YAMATO class Example 441bced791fSMasatake YAMATO def methodA 442bced791fSMasatake YAMATO puts "in class_method" 443bced791fSMasatake YAMATO end 444bced791fSMasatake YAMATO def methodB 445bced791fSMasatake YAMATO puts "in class_method" 446bced791fSMasatake YAMATO end 447bced791fSMasatake YAMATO end 448bced791fSMasatake YAMATO 449185906aaSHiroo HAYASHIThe parser for the input should capture ``Example`` with ``class`` kind, 450185906aaSHiroo HAYASHI``methodA``, and ``methodB`` with ``method`` kind. ``methodA`` and ``methodB`` 451185906aaSHiroo HAYASHIshould have ``Example`` as their scope. ``end:`` fields of each tag 4520b2e105aSMasatake YAMATOshould have proper values. 453bced791fSMasatake YAMATO 454d14dd918SMasatake YAMATOoptlib file (``sub-ruby.ctags``): 455d14dd918SMasatake YAMATO 456d14dd918SMasatake YAMATO.. code-block:: ctags 457bced791fSMasatake YAMATO 458bced791fSMasatake YAMATO --langdef=subRuby 459bced791fSMasatake YAMATO --map-subRuby=.srb 460bced791fSMasatake YAMATO --kinddef-subRuby=c,class,classes 461bced791fSMasatake YAMATO --kinddef-subRuby=m,method,methods 462bced791fSMasatake YAMATO --regex-subRuby=/^class[ \t]+([a-zA-Z][a-zA-Z0-9]+)/\1/c/{scope=push} 463bced791fSMasatake YAMATO --regex-subRuby=/^end///{scope=pop}{placeholder} 464bced791fSMasatake YAMATO --regex-subRuby=/^[ \t]+def[ \t]+([a-zA-Z][a-zA-Z0-9_]+)/\1/m/{scope=push} 465bced791fSMasatake YAMATO --regex-subRuby=/^[ \t]+end///{scope=pop}{placeholder} 466bced791fSMasatake YAMATO 467bced791fSMasatake YAMATOcommand line and output:: 468bced791fSMasatake YAMATO 46945e335abSHiroo HAYASHI $ ctags --quiet --fields=+eK \ 470bced791fSMasatake YAMATO --options=./sub-ruby.ctags -o - input.srb 471bced791fSMasatake YAMATO Example input.srb /^class Example$/;" class end:8 472bced791fSMasatake YAMATO methodA input.srb /^ def methodA$/;" method class:Example end:4 473bced791fSMasatake YAMATO methodB input.srb /^ def methodB$/;" method class:Example end:7 474bced791fSMasatake YAMATO 475bced791fSMasatake YAMATO 476599fcc99SMasatake YAMATOSEE ALSO 477599fcc99SMasatake YAMATO-------- 478599fcc99SMasatake YAMATO 479dccba5efSHiroo HAYASHIThe official Universal Ctags web site at: 480599fcc99SMasatake YAMATO 481599fcc99SMasatake YAMATOhttps://ctags.io/ 482599fcc99SMasatake YAMATO 483ea999d80SMasatake YAMATOctags(1), tags(5), regex(3), regex(7), egrep(1), pcre2syntax(3) 484599fcc99SMasatake YAMATO 485599fcc99SMasatake YAMATOAUTHOR 486599fcc99SMasatake YAMATO------ 487599fcc99SMasatake YAMATO 488dccba5efSHiroo HAYASHIUniversal Ctags project 4892b8661bbSK.Takatahttps://ctags.io/ 490599fcc99SMasatake YAMATO(This man page partially derived from ctags(1) of 491599fcc99SMasatake YAMATOExecutable-ctags) 492599fcc99SMasatake YAMATO 493599fcc99SMasatake YAMATODarren Hiebert <dhiebert@users.sourceforge.net> 494599fcc99SMasatake YAMATOhttp://DarrenHiebert.com/ 495