ETAGS.EBNF 4.04 KB
Newer Older
1
-*- mode: indented-text; coding: utf-8 -*-
2

3 4
See the end of this file for copyright information.

5 6
This file contains two sections:

7
1) An EBNF (Extended Backus-Naur Form) description of the format of
8 9
    the tags file created by etags.c and interpreted by etags.el;
2) A discussion of tag names and implicit tag names.
10

11
====================== 1) EBNF tag file description =====================
Francesco Potortì's avatar
Francesco Potortì committed
12

13
Productions created from current behavior to aid extensions
Paul Eggert's avatar
Paul Eggert committed
14
Francesco Potortì <pot@gnu.org> 2002
15
----------------
16

Francesco Potortì's avatar
Francesco Potortì committed
17
FF ::= #x0c				   /* tag section starter */
18

Francesco Potortì's avatar
Francesco Potortì committed
19
LF ::= #x0a				   /* line terminator */
20

21
DEL ::= #x7f				   /* pattern terminator */
22

23
SOH ::= #x01				   /* name terminator */
24

25
regchar ::= [^#x0a#x0c#x7f]		   /* regular character */
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42

regstring ::= { regchar }		   /* regular string */

unsint ::= [0-9] { [0-9] }		   /* non-negative integer */



tagfile ::= { tagsection }		   /* a tags file */

tagsection ::= FF LF ( includesec | regularsec ) LF

includesec ::= filename ",include" [ LF fileprop ]

regularsec ::= filename "," [ unsint ] [ LF fileprop ] { LF tag }

filename ::= regchar regstring		   /* a file name */

Francesco Potortì's avatar
Francesco Potortì committed
43
fileprop ::= "(" regstring ")"		   /* an elisp alist */
44 45 46

tag ::= directtag | patterntag

Francesco Potortì's avatar
Francesco Potortì committed
47
directtag ::= DEL realposition		   /* no pattern */
48

49
patterntag ::= pattern DEL [ tagname SOH ] position
50 51 52 53 54

pattern ::= regstring			   /* a tag pattern */

tagname ::= regchar regstring		   /* a tag name */

Francesco Potortì's avatar
Francesco Potortì committed
55
position ::= realposition | "," 	   /* charpos,linepos */
56 57

realposition ::= "," unsint | unsint "," | unsint "," unsint
58 59 60 61 62

==================== end of EBNF tag file description ====================



63
======================= 2) discussion of tag names =======================
64

65
- WHAT ARE TAG NAMES
66 67 68 69
Tag lines in a tags file are usually made from the above defined pattern
and by an optional tag name.  The pattern is a string that is searched
in the source file to find the tagged line.

70
- WHY TAG NAMES ARE GOOD
71 72 73 74 75 76 77
When a user looks for a tag, Emacs first compares the tag with the tag
names contained in the tags file.  If no match is found, Emacs compares
the tag with the patterns.  The tag name is then the preferred way to
look for tags in the tags file, because when the tag name is present
Emacs can find a tag faster and more accurately.  These tag names are
part of tag lines in the tags file, so we call them "explicit".

78
- WHY IMPLICIT TAG NAMES ARE EVEN BETTER
79
When a tag line has no name, but a name can be deduced from the pattern,
80 81 82 83 84
we say that the tag line has an implicit tag name.  Often tag names are
redundant; this happens when the name of a tag is an easily guessable
substring of the tag pattern.  We define a set of rules to decide
whether it is possible to deduce the tag name from the pattern, and make
an unnamed tag in those cases.  The name deduced from the pattern of an
85
unnamed tag is the implicit name of that tag.
Francesco Potortì's avatar
Francesco Potortì committed
86
  When the user looks for a tag, and Emacs finds no explicit tag names
87
that match it, Emacs then looks for a tag whose implicit tag name
88 89
matches the request.  etags.c uses implicit tag names when possible, in
order to reduce the size of the tags file.
90
  An implicit tag name is deduced from the pattern by discarding the
91
last character if it is one of ' \f\t\n\r()=,;', then taking all the
92 93 94 95
rightmost consecutive characters in the pattern which are not one of
those.

===================== end of discussion of tag names =====================
96

97
Copyright (C) 2002-2019 Free Software Foundation, Inc.
98 99 100

COPYING PERMISSIONS:

101
    This document is free software: you can redistribute it and/or modify
102
    it under the terms of the GNU General Public License as published by
103 104
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
105 106 107 108 109 110 111

    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
112
    along with this program.  If not, see <https://www.gnu.org/licenses/>.