annotate gcc/ada/sfn_scan.ads @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S F N _ S C A N --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
kono
parents:
diff changeset
9 -- Copyright (C) 2000-2017, Free Software Foundation, Inc. --
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 -- This package provides a stand alone capability for scanning a gnat.adc
kono
parents:
diff changeset
27 -- file for Source_File_Name pragmas. This is for use in tools other than
kono
parents:
diff changeset
28 -- the compiler, which want to scan source file name pragmas without the
kono
parents:
diff changeset
29 -- overhead of the full compiler scanner and parser.
kono
parents:
diff changeset
30
kono
parents:
diff changeset
31 -- Note that neither the package spec, nor the package body, of this
kono
parents:
diff changeset
32 -- unit contains any with statements at all. This is a completely
kono
parents:
diff changeset
33 -- independent package, suitable for incorporation into tools that do
kono
parents:
diff changeset
34 -- not access any other units in the GNAT compiler or tools sources.
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 -- This package is NOT task safe, so multiple tasks that may call the
kono
parents:
diff changeset
37 -- Scan_SFN_Pragmas procedure at the same time are responsible for
kono
parents:
diff changeset
38 -- avoiding such multiple calls by appropriate synchronization.
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 package SFN_Scan is
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 -- The call to SFN_Scan passes pointers to two procedures that are
kono
parents:
diff changeset
43 -- used to store the results of scanning any Source_File_Name pragmas
kono
parents:
diff changeset
44 -- that are encountered. The following access types define the form
kono
parents:
diff changeset
45 -- of these procedures:
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 type Set_File_Name_Ptr is access
kono
parents:
diff changeset
48 procedure
kono
parents:
diff changeset
49 (Typ : Character;
kono
parents:
diff changeset
50 U : String;
kono
parents:
diff changeset
51 F : String;
kono
parents:
diff changeset
52 Index : Natural);
kono
parents:
diff changeset
53 -- The procedure with this profile is called when a Source_File_Name
kono
parents:
diff changeset
54 -- pragma of the form having a unit name parameter. Typ is 'b' for
kono
parents:
diff changeset
55 -- a body file name, and 's' for a spec file name. U is a string that
kono
parents:
diff changeset
56 -- contains the unit name, exactly as it appeared in the source file,
kono
parents:
diff changeset
57 -- and F is the file taken from the second parameter. Index is taken
kono
parents:
diff changeset
58 -- from the third parameter, or is set to zero if no third parameter.
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 type Set_File_Name_Pattern_Ptr is access
kono
parents:
diff changeset
61 procedure (Pat : String; Typ : Character; Dot : String; Cas : Character);
kono
parents:
diff changeset
62 -- This is called to process a Source_File_Name pragma whose first
kono
parents:
diff changeset
63 -- argument is a file pattern. Pat is this pattern string, which
kono
parents:
diff changeset
64 -- contains an asterisk to correspond to the unit. Typ is one of
kono
parents:
diff changeset
65 -- ('b'/'s'/'u') for body/spec/subunit, Dot is the separator string
kono
parents:
diff changeset
66 -- for child/subunit names (default is "."), and Cas is one of
kono
parents:
diff changeset
67 -- ('l'/'u'/'m') indicating the required case for the file name.
kono
parents:
diff changeset
68 -- The default setting for Cas is 'l' if no parameter is present.
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 Cursor : Natural;
kono
parents:
diff changeset
71 -- Used to record the cursor value if a syntax error is found
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 Syntax_Error_In_GNAT_ADC : exception;
kono
parents:
diff changeset
74 -- Exception raised if a syntax error is found
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 procedure Scan_SFN_Pragmas
kono
parents:
diff changeset
77 (Source : String;
kono
parents:
diff changeset
78 SFN_Ptr : Set_File_Name_Ptr;
kono
parents:
diff changeset
79 SFNP_Ptr : Set_File_Name_Pattern_Ptr);
kono
parents:
diff changeset
80 -- This is the procedure called to scan a gnat.adc file. The Source
kono
parents:
diff changeset
81 -- parameter contains the full text of the file, with normal line end
kono
parents:
diff changeset
82 -- characters, in the format normally read by the compiler. The two
kono
parents:
diff changeset
83 -- parameters SFN_Ptr and SFNP_Ptr point to procedures that will be
kono
parents:
diff changeset
84 -- called to register Source_File_Name pragmas as they are found.
kono
parents:
diff changeset
85 --
kono
parents:
diff changeset
86 -- If a syntax error is found, then Syntax_Error_In_GNAT_ADC is raised,
kono
parents:
diff changeset
87 -- and the location SFN_Scan.Cursor contains the approximate index of
kono
parents:
diff changeset
88 -- the error in the source string.
kono
parents:
diff changeset
89 --
kono
parents:
diff changeset
90 -- The scan assumes that it is dealing with a valid gnat.adc file,
kono
parents:
diff changeset
91 -- that includes only pragmas and comments. It does not do a full
kono
parents:
diff changeset
92 -- syntax correctness scan by any means, but if it does find anything
kono
parents:
diff changeset
93 -- that it can tell is wrong it will immediately raise the exception
kono
parents:
diff changeset
94 -- to indicate the approximate location of the error.
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 end SFN_Scan;