6.3. Command Line of gnatfind

The gnatfind command line is of the following form:


$ prefix-gnatfind pattern[:sourcefile[:line[:column]]] [files]

where

pattern

An entity will be output only if it matches the regular expression found in pattern (See Section 6.3.1).

Omitting the pattern is equivalent to specifying *, which will match any entity. Note that if you do not provide a pattern, you have to provide both a sourcefile and a line.

Entity names are given in Latin-1, with upper-lower case equivalence for matching purposes. At the current time there is no support for 8-bit codes other than Latin-1, or for wide characters in identifiers.

sourcefile

gnatfind will look for references, bodies or declarations of symbols referenced in sourcefile, at line line and column column. See examples of gnatfind usage, for syntax examples.

line

is a decimal integer identifying the line number containing the reference to the entity (or entities) to be located.

column

is a decimal integer identifying the exact location on the line of the first character of the identifier for the entity reference. Columns are numbered from 1.

files

The search will be restricted to these files. If none are given, then the search will be done for every library file in the search path. These file must appear only after the pattern or sourcefile.

At least one of sourcefile or pattern has to be present on the command line.

6.3.1. Regular expressions in gnatfind and gnatxref

As specified in the section about gnatfind, the pattern can be a regular expression. Actually, there are to set of regular expressions which are recognized by the program :

globbing patterns

These are the most usual regular expression. They are the same that you generally used in a UNIX shell command line, or in a DOS session.

Here is a more formal grammar :


 regexp ::= term
 term   ::= elmt            -- matches elmt
 term   ::= elmt elmt       -- concatenation (elmt then elmt)
 term   ::= *               -- any string of 0 or more characters
 term   ::= ?               -- matches any character
 term   ::= [char {char}]   -- matches any character listed
 term   ::= [char - char]   -- matches any character in range
full regular expression

The second set of regular expressions is much more powerful. This is the type of regular expressions recognized by utilities such a grep.

The following is the form of a regular expression, expressed in Ada reference manual style BNF is as follows:


  regexp ::= term {| term} -- alternation (term or term ...)

  term ::= item {item}     -- concatenation (item then item)

  item ::= elmt              -- match elmt
  item ::= elmt *            -- zero or more elmt's
  item ::= elmt +            -- one or more elmt's
  item ::= elmt ?            -- matches elmt or nothing

  elmt ::= nschar            -- matches given character
  elmt ::= [nschar {nschar}]   -- matches any character listed
  elmt ::= [^ nschar {nschar}] -- matches any character not listed
  elmt ::= [char - char]     -- matches chars in given range
  elmt ::= \ char            -- matches given character
  elmt ::= . -- matches any single character
  elmt ::= ( regexp )        -- parens used for grouping

  char ::= any character, including special characters
  nschar ::= any character except ()[].*+?^

Following are a few examples :

abcde|fghi

will match any of the two strings "abcde" and "fghi".

abc*d

will match any string like "abd", "abcd", "abccd", "abcccd", and so on

[a-z]+

will match any string which has only lower-case characters in it (and at least one character