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