File: error_types.ads

package info (click to toggle)
spark 2012.0.deb-9
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 29,260 kB
  • ctags: 3,098
  • sloc: ada: 186,243; cpp: 13,497; makefile: 685; yacc: 440; lex: 176; ansic: 119; sh: 16
file content (143 lines) | stat: -rw-r--r-- 5,739 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
-------------------------------------------------------------------------------
-- (C) Altran Praxis Limited
-------------------------------------------------------------------------------
--
-- The SPARK toolset is free software; you can redistribute it and/or modify it
-- under terms of the GNU General Public License as published by the Free
-- Software Foundation; either version 3, or (at your option) any later
-- version. The SPARK toolset is distributed in the hope that it will be
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-- Public License for more details. You should have received a copy of the GNU
-- General Public License distributed with the SPARK toolset; see file
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy of
-- the license.
--
--=============================================================================

with LexTokenManager;
with E_Strings;
with Dictionary;

--# inherit Dictionary,
--#         E_Strings,
--#         LexTokenManager;
package Error_Types is

   --------------------------------------------------------
   -- Types common to ErrorHandler and Error_IO packages --
   --------------------------------------------------------

   type Error_Class is (
                        LexErr,
                        SyntaxErr,
                        SyntaxRec,
                        UncondFlowErr,
                        CondlFlowErr,
                        UncondDependencyErr,
                        CondlDependencyErr,
                        SemanticErr,
                        DepSemanticErr,
                        WarningWithPosition,
                        WarningWithoutPosition,
                        Note,
                        ControlFlowErr,
                        IneffectiveStat,
                        StabilityErr,
                        UsageErr,
                        NoErr);

   type NameSorts is (
                      None,
                      Symbol,
                      Entity,
                      LexString,
                      ParserSymbol,
                      StabilityIndex,
                      ThePartition);

   -- a "Name" is a kind of variant record, storing one of various NameSorts is numerical form
   type Names is record
      Name_Sort : NameSorts;
      -- case Name_Sort is
      --    when ???    =>
      Name_Sym : Dictionary.Symbol;
      --    when ???    =>
      Name_Str : LexTokenManager.Lex_String;
      --    when others =>
      Pos : Natural;
      -- end case;
   end record;
   NoName : constant Names :=
     Names'(Name_Sort => None,
            Name_Sym  => Dictionary.NullSymbol,
            Name_Str  => LexTokenManager.Null_String,
            Pos       => 0);

   ThePartitionName : constant Names :=
     Names'(Name_Sort => ThePartition,
            Name_Sym  => Dictionary.NullSymbol,
            Name_Str  => LexTokenManager.Null_String,
            Pos       => 0);

   -- error messages have a number, curently in the range 0 .. 999;
   subtype ErrNumRange is Integer range 0 .. 999;

   -- Error messages are handled in 2 forms.  The NumericError form is space efficient
   -- and is used for adding and sorting messages into line number order; that is the work
   -- of ErrorBuffer

   type NumericError is record
      ErrorType           : Error_Class;
      Position            : LexTokenManager.Token_Position;
      Scope               : Dictionary.Scopes;
      ErrorNum            : ErrNumRange;
      Reference           : Natural;
      Name1, Name2, Name3 : Names;
   end record;

   Empty_NumericError : constant NumericError :=
     NumericError'
     (NoErr,
      LexTokenManager.Token_Position'(Start_Line_No => 0,
                                      Start_Pos     => 0),
      Dictionary.NullScope,
      0,
      0,
      NoName,
      NoName,
      NoName);

   -- The StringError form includes a conversion of the message into string form and is therefore not
   -- space efficient but is suitable for printing; that is the work of ConvertToString as called
   -- by PrintErrors and AppendErrors (and also as a sid effect of Add).

   type StringError is record
      MessageId : ErrNumRange;
      ErrorType : Error_Class;
      Position  : LexTokenManager.Token_Position;
      Message   : E_Strings.T;
   end record;

   Empty_StringError : constant StringError :=
     StringError'(0, NoErr, LexTokenManager.Token_Position'(Start_Line_No => 0,
                                                            Start_Pos     => 0), E_Strings.Empty_String);

   -- constants used as offsets to 'val/'pos of various error kind enumerations
   --     so as to ensure that they all have unique error numbers
   UncondFlowErrorOffset       : constant ErrNumRange := 20;
   UncondDependencyErrorOffset : constant ErrNumRange := 50;
   StabilityErrOffset          : constant ErrNumRange := 40;
   UsageErrOffset              : constant ErrNumRange := 30;
   ControlFlowErrOffset        : constant ErrNumRange := 1;
   CondFlowErrorOffset         : constant ErrNumRange := 500;
   CondDependencyErrorOffset   : constant ErrNumRange := 600;

   -- To track when explanations have been given, so that we can restrict such explanations
   -- to the first occurrence of each error number, we need to know whether the conversion
   -- of a numeric error to a string error is being made for one of the three following
   -- purposes.
   type ConversionRequestSource is (ForScreen, ForReportSelectedFiles, ForReportIndexedFiles, ForListing);
   subtype ForReport is ConversionRequestSource range ForReportSelectedFiles .. ForReportIndexedFiles;

end Error_Types;