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