]>
Commit | Line | Data |
---|---|---|
cacbc350 RK |
1 | ------------------------------------------------------------------------------ |
2 | -- -- | |
fbf5a39b | 3 | -- GNAT COMPILER COMPONENTS -- |
cacbc350 | 4 | -- -- |
fbf5a39b | 5 | -- P R J . E R R -- |
cacbc350 | 6 | -- -- |
fbf5a39b | 7 | -- B o d y -- |
cacbc350 | 8 | -- -- |
3dfe4883 | 9 | -- Copyright (C) 2002-2014, Free Software Foundation, Inc. -- |
cacbc350 RK |
10 | -- -- |
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- -- | |
b5c84c3c | 13 | -- ware Foundation; either version 3, or (at your option) any later ver- -- |
cacbc350 RK |
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 -- | |
b5c84c3c RD |
18 | -- Public License distributed with GNAT; see file COPYING3. If not, go to -- |
19 | -- http://www.gnu.org/licenses for a complete copy of the license. -- | |
cacbc350 | 20 | -- -- |
cacbc350 | 21 | -- GNAT was originally developed by the GNAT team at New York University. -- |
71ff80dc | 22 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- |
cacbc350 RK |
23 | -- -- |
24 | ------------------------------------------------------------------------------ | |
25 | ||
477b99b6 | 26 | with Err_Vars; |
76b84bf0 AC |
27 | with Output; use Output; |
28 | with Stringt; use Stringt; | |
fbf5a39b AC |
29 | |
30 | package body Prj.Err is | |
31 | ||
32 | --------------- | |
33 | -- Post_Scan -- | |
34 | --------------- | |
35 | ||
36 | procedure Post_Scan is | |
37 | Debug_Tokens : constant Boolean := False; | |
38 | ||
39 | begin | |
40 | -- Change operator symbol to literal strings, since that's the way | |
41 | -- we treat all strings in a project file. | |
cacbc350 | 42 | |
fbf5a39b AC |
43 | if Token = Tok_Operator_Symbol |
44 | or else Token = Tok_String_Literal | |
45 | then | |
46 | Token := Tok_String_Literal; | |
47 | String_To_Name_Buffer (String_Literal_Id); | |
48 | Token_Name := Name_Find; | |
49 | end if; | |
cacbc350 | 50 | |
fbf5a39b AC |
51 | if Debug_Tokens then |
52 | Write_Line (Token_Type'Image (Token)); | |
cacbc350 | 53 | |
fbf5a39b AC |
54 | if Token = Tok_Identifier |
55 | or else Token = Tok_String_Literal | |
56 | then | |
57 | Write_Line (" " & Get_Name_String (Token_Name)); | |
58 | end if; | |
59 | end if; | |
60 | end Post_Scan; | |
cacbc350 | 61 | |
e2d9085b EB |
62 | --------------- |
63 | -- Error_Msg -- | |
64 | --------------- | |
65 | ||
66 | procedure Error_Msg | |
67 | (Flags : Processing_Flags; | |
68 | Msg : String; | |
69 | Location : Source_Ptr := No_Location; | |
70 | Project : Project_Id := null) | |
71 | is | |
72 | Real_Location : Source_Ptr := Location; | |
73 | ||
74 | begin | |
3dfe4883 AC |
75 | if Flags.Incomplete_Withs then |
76 | return; | |
77 | end if; | |
78 | ||
e2d9085b EB |
79 | -- Display the error message in the traces so that it appears in the |
80 | -- correct location in the traces (otherwise error messages are only | |
81 | -- displayed at the end and it is difficult to see when they were | |
82 | -- triggered) | |
83 | ||
84 | if Current_Verbosity = High then | |
c4d67e2d | 85 | Debug_Output ("ERROR: " & Msg); |
e2d9085b EB |
86 | end if; |
87 | ||
88 | -- If location of error is unknown, use the location of the project | |
89 | ||
90 | if Real_Location = No_Location | |
91 | and then Project /= null | |
92 | then | |
93 | Real_Location := Project.Location; | |
94 | end if; | |
95 | ||
96 | if Real_Location = No_Location then | |
7b00e31d | 97 | |
e2d9085b EB |
98 | -- If still null, we are parsing a project that was created in-memory |
99 | -- so we shouldn't report errors for projects that the user has no | |
100 | -- access to in any case. | |
7b00e31d | 101 | |
c5be6c3a | 102 | if Current_Verbosity = High then |
c4d67e2d | 103 | Debug_Output ("Error in in-memory project, ignored"); |
c5be6c3a EB |
104 | end if; |
105 | ||
e2d9085b EB |
106 | return; |
107 | end if; | |
108 | ||
109 | -- Report the error through Errutil, so that duplicate errors are | |
110 | -- properly removed, messages are sorted, and correctly interpreted,... | |
111 | ||
112 | Errutil.Error_Msg (Msg, Real_Location); | |
113 | ||
114 | -- Let the application know there was an error | |
115 | ||
116 | if Flags.Report_Error /= null then | |
0e41a941 AC |
117 | Flags.Report_Error |
118 | (Project, | |
76b84bf0 AC |
119 | Is_Warning => |
120 | Msg (Msg'First) = '?' | |
121 | or else (Msg (Msg'First) = '<' | |
122 | and then Err_Vars.Error_Msg_Warn) | |
123 | or else (Msg (Msg'First) = '\' | |
124 | and then Msg (Msg'First + 1) = '<' | |
125 | and then Err_Vars.Error_Msg_Warn)); | |
e2d9085b EB |
126 | end if; |
127 | end Error_Msg; | |
128 | ||
fbf5a39b | 129 | end Prj.Err; |