1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2000-2001 Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 -- This package provides a stand alone capability for scanning a gnat.adc
28 -- file for Source_File_Name pragmas. This is for use in tools other than
29 -- the compiler, which want to scan source file name pragmas without the
30 -- overhead of the full compiler scanner and parser.
32 -- Note that neither the package spec, nor the package body, of this
33 -- unit contains any with statements at all. This is a compeltely
34 -- independent package, suitable for incorporation into tools that do
35 -- not access any other units in the GNAT compiler or tools sources.
37 -- This package is NOT task safe, so multiple tasks that may call the
38 -- Scan_SFN_Pragmas procedure at the same time are responsibible for
39 -- avoiding such multiple calls by appropriate synchronization.
43 -- The call to SFN_Scan passes pointers to two procedures that are
44 -- used to store the results of scanning any Source_File_Name pragmas
45 -- that are encountered. The following access types define the form
46 -- of these procedures:
48 type Set_File_Name_Ptr
is access
49 procedure (Typ
: Character; U
: String; F
: String);
50 -- The procedure with this profile is called when a Source_File_Name
51 -- pragma of the form having a unit name parameter. Typ is 'b' for
52 -- a body file name, and 's' for a spec file name. U is a string that
53 -- contains the unit name, exactly as it appeared in the source file,
54 -- and F is the file taken from the second parameter.
56 type Set_File_Name_Pattern_Ptr
is access
57 procedure (Pat
: String; Typ
: Character; Dot
: String; Cas
: Character);
58 -- This is called to process a Source_File_Name pragma whose first
59 -- argument is a file pattern. Pat is this pattern string, which
60 -- contains an asterisk to correspond to the unit. Typ is one of
61 -- ('b'/'s'/'u') for body/spec/subunit, Dot is the separator string
62 -- for child/subunit names (default is "."), and Cas is one of
63 -- ('l'/'u'/'m') indicating the required case for the file name.
64 -- The default setting for Cas is 'l' if no parameter is present.
67 -- Used to record the cursor value if a syntax error is found
69 Syntax_Error_In_GNAT_ADC
: exception;
70 -- Exception raised if a syntax error is found
72 procedure Scan_SFN_Pragmas
74 SFN_Ptr
: Set_File_Name_Ptr
;
75 SFNP_Ptr
: Set_File_Name_Pattern_Ptr
);
76 -- This is the procedure called to scan a gnat.adc file. The Source
77 -- parameter points to the full text of the file, with normal line end
78 -- characters, in the format normally read by the compiler. The two
79 -- parameters SFN_Ptr and SFNP_Ptr point to procedures that will be
80 -- called to register Source_File_Name pragmas as they are found.
82 -- If a syntax error is found, then Syntax_Error_In_GNAT_ADC is raised,
83 -- and the location SFN_Scan.Cursor contains the approximate index of
84 -- the error in the source string.
86 -- The scan assumes that it is dealing with a valid gnat.adc file,
87 -- that includes only pragmas and comments. It does not do a full
88 -- syntax correctness scan by any means, but if it does find anything
89 -- that it can tell is wrong it will immediately raise the exception
90 -- to indicate the aproximate location of the error