1--  Scanner token definitions.
2--  Copyright (C) 2002-2019 Tristan Gingold
3--
4--  This program is free software: you can redistribute it and/or modify
5--  it under the terms of the GNU General Public License as published by
6--  the Free Software Foundation, either version 2 of the License, or
7--  (at your option) any later version.
8--
9--  This program is distributed in the hope that it will be useful,
10--  but WITHOUT ANY WARRANTY; without even the implied warranty of
11--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12--  GNU General Public License for more details.
13--
14--  You should have received a copy of the GNU General Public License
15--  along with this program.  If not, see <gnu.org/licenses>.
16
17package Vhdl.Tokens is
18   pragma Pure (Vhdl.Tokens);
19
20   type Token_Type is
21     (
22      Tok_Invalid,     -- current_token is not valid.
23
24      Tok_Eof,                 -- End of file.
25      Tok_Newline,
26
27      Tok_Block_Comment_Start, --  Start of a block comment (/*)
28      Tok_Block_Comment_End,   --  End of a block comment (*/)
29
30      Tok_Block_Comment_Text,  --  Text within a block comment (no newline)
31      Tok_Line_Comment,        --  End of line comment (--)
32      Tok_Character,
33      Tok_Identifier,
34      Tok_Integer,
35      Tok_Real,
36      Tok_String,
37
38      --  This token corresponds to a base specifier followed by bit_value.
39      --  The base specifier is stored in Name_Buffer/Name_Length like an
40      --  identifier (in lowercase), the String8_Id contains the expanded bit
41      --  value.
42      Tok_Bit_String,
43
44      --  An integer immediately followed by a letter.  This is used by to
45      --  scan vhdl 2008 (and later) bit string with a length.
46      Tok_Integer_Letter,
47
48      --  Delimiters
49      Tok_Left_Paren,          -- (
50      Tok_Right_Paren,         -- )
51      Tok_Left_Bracket,        -- [
52      Tok_Right_Bracket,       -- ]
53      Tok_Colon,               -- :
54      Tok_Semi_Colon,          -- ;
55      Tok_Comma,               -- ,
56      Tok_Double_Arrow,        -- =>
57      Tok_Tick,                -- '
58      Tok_Double_Star,         -- **
59      Tok_Assign,              -- :=
60      Tok_Bar,                 -- |
61      Tok_Box,                 -- <>
62      Tok_Dot,                 -- .
63
64      Tok_Equal_Equal,         -- == (AMS Vhdl)
65
66   -- relational_operator
67      Tok_Equal,               -- =
68      Tok_Not_Equal,           -- /=
69      Tok_Less,                -- <
70      Tok_Less_Equal,          -- <=
71      Tok_Greater,             -- >
72      Tok_Greater_Equal,       -- >=
73
74      Tok_Match_Equal,         -- ?=
75      Tok_Match_Not_Equal,     -- ?/=
76      Tok_Match_Less,          -- ?<
77      Tok_Match_Less_Equal,    -- ?<=
78      Tok_Match_Greater,       -- ?>
79      Tok_Match_Greater_Equal, -- ?>=
80
81   -- sign token
82      Tok_Plus,                -- +
83      Tok_Minus,               -- -
84   -- and adding_operator
85      Tok_Ampersand,           -- &
86
87   --  VHDL 2008
88      Tok_Condition,           -- ??
89      Tok_Double_Less,         -- <<
90      Tok_Double_Greater,      -- >>
91      Tok_Caret,               -- ^
92
93   --  PSL
94      Tok_And_And,             -- &&
95      Tok_Bar_Bar,             -- ||
96      Tok_Left_Curly,          -- {
97      Tok_Right_Curly,         -- }
98      Tok_Exclam_Mark,         -- !
99      Tok_Brack_Star,          -- [*
100      Tok_Brack_Plus_Brack,    -- [+]
101      Tok_Brack_Arrow,         -- [->
102      Tok_Brack_Equal,         -- [=
103      Tok_Bar_Arrow,           -- |->
104      Tok_Bar_Double_Arrow,    -- |=>
105      Tok_Minus_Greater,       -- ->
106      Tok_Equiv_Arrow,         -- <->
107      Tok_Arobase,             -- @
108
109   -- multiplying operator
110      Tok_Star,                -- *
111      Tok_Slash,               -- /
112      Tok_Mod,                 -- mod
113      Tok_Rem,                 -- rem
114
115   --  miscellaneous operator
116      Tok_Abs,
117      Tok_Not,
118
119   -- Key words
120      Tok_Access,
121      Tok_After,
122      Tok_Alias,
123      Tok_All,
124      Tok_Architecture,
125      Tok_Array,
126      Tok_Assert,
127      Tok_Attribute,
128
129      Tok_Begin,
130      Tok_Block,
131      Tok_Body,
132      Tok_Buffer,
133      Tok_Bus,
134
135      Tok_Case,
136      Tok_Component,
137      Tok_Configuration,
138      Tok_Constant,
139
140      Tok_Disconnect,
141      Tok_Downto,
142
143      Tok_Else,
144      Tok_Elsif,
145      Tok_End,
146      Tok_Entity,
147      Tok_Exit,
148
149      Tok_File,
150      Tok_For,
151      Tok_Function,
152
153      Tok_Generate,
154      Tok_Generic,
155      Tok_Guarded,
156
157      Tok_If,
158      Tok_In,
159      Tok_Inout,
160      Tok_Is,
161
162      Tok_Label,
163      Tok_Library,
164      Tok_Linkage,
165      Tok_Loop,
166
167      Tok_Map,
168
169      Tok_New,
170      Tok_Next,
171      Tok_Null,
172
173      Tok_Of,
174      Tok_On,
175      Tok_Open,
176      Tok_Others,
177      Tok_Out,
178
179      Tok_Package,
180      Tok_Port,
181      Tok_Procedure,
182      Tok_Process,
183
184      Tok_Range,
185      Tok_Record,
186      Tok_Register,
187      Tok_Report,
188      Tok_Return,
189
190      Tok_Select,
191      Tok_Severity,
192      Tok_Signal,
193      Tok_Subtype,
194
195      Tok_Then,
196      Tok_To,
197      Tok_Transport,
198      Tok_Type,
199
200      Tok_Units,
201      Tok_Until,
202      Tok_Use,
203
204      Tok_Variable,
205
206      Tok_Wait,
207      Tok_When,
208      Tok_While,
209      Tok_With,
210
211   -- logical token:
212      Tok_And,
213      Tok_Or,
214      Tok_Xor,
215      Tok_Nand,
216      Tok_Nor,
217
218   --  Tokens below this line are key words in vhdl93 but not in vhdl87
219   --  Note: xnor is the first one, as it is a logical token.
220      Tok_Xnor,
221
222      Tok_Group,
223      Tok_Impure,
224      Tok_Inertial,
225      Tok_Literal,
226      Tok_Postponed,
227      Tok_Pure,
228      Tok_Reject,
229      Tok_Shared,
230      Tok_Unaffected,
231
232   -- shift_operator
233      Tok_Sll,
234      Tok_Sla,
235      Tok_Sra,
236      Tok_Srl,
237      Tok_Rol,
238      Tok_Ror,
239
240   --  Added by Vhdl 2000:
241      Tok_Protected,
242
243   --  Added by vhdl 2008:
244      Tok_Assume,
245      Tok_Context,
246      Tok_Cover,
247      Tok_Default,
248      Tok_Force,
249      Tok_Parameter,
250      Tok_Property,
251      Tok_Release,
252      Tok_Restrict,
253      Tok_Restrict_Guarantee,
254      Tok_Sequence,
255      Tok_Vmode,
256      Tok_Vprop,
257      Tok_Vunit,
258
259   --  AMS reserved words
260      Tok_Across,
261      Tok_Break,
262      Tok_Limit,
263      Tok_Nature,
264      Tok_Noise,
265      Tok_Procedural,
266      Tok_Quantity,
267      Tok_Reference,
268      Tok_Spectrum,
269      Tok_Subnature,
270      Tok_Terminal,
271      Tok_Through,
272      Tok_Tolerance,
273
274   -- PSL words
275      Tok_Psl_Clock,
276      Tok_Psl_Endpoint,
277
278      Tok_Psl_Const,
279      Tok_Psl_Boolean,
280      Tok_Inf,
281
282      Tok_Within,
283      Tok_Abort,
284      Tok_Before,
285      Tok_Before_Em,
286      Tok_Before_Un,
287      Tok_Before_Em_Un,
288      Tok_Always,
289      Tok_Never,
290      Tok_Eventually_Em,
291      Tok_Next_Em,
292      Tok_Next_A,
293      Tok_Next_A_Em,
294      Tok_Next_E,
295      Tok_Next_E_Em,
296      Tok_Next_Event,
297      Tok_Next_Event_Em,
298      Tok_Next_Event_A,
299      Tok_Next_Event_A_Em,
300      Tok_Next_Event_E,
301      Tok_Next_Event_E_Em,
302      Tok_Until_Em,
303      Tok_Until_Un,
304      Tok_Until_Em_Un,
305
306      Tok_Prev,
307      Tok_Stable,
308      Tok_Fell,
309      Tok_Rose
310     );
311
312   --  To ease interfacing
313   pragma Convention (C, Token_Type);
314
315   subtype Token_Logical_Type is Token_Type range
316     Tok_And .. Tok_Xnor;
317
318   subtype Token_Relational_Operator_Type is Token_Type range
319     Tok_Equal .. Tok_Match_Greater_Equal;
320   subtype Token_Shift_Operator_Type is Token_Type range
321     Tok_Sll .. Tok_Ror;
322   subtype Token_Sign_Type is Token_Type range
323     Tok_Plus .. Tok_Minus;
324   subtype Token_Adding_Operator_Type is Token_Type range
325     Tok_Plus .. Tok_Ampersand;
326   subtype Token_Multiplying_Operator_Type is Token_Type range
327     Tok_Star .. Tok_Rem;
328
329   --  These tokens represent text in the source whose exact meaning needs
330   --  extra data (like the value of an integer, the exact identifier...).
331   subtype Token_Source_Type is Token_Type range
332     Tok_Line_Comment ..
333   --Tok_Character
334   --Tok_Identifier
335   --Tok_Integer
336   --Tok_Real
337   --Tok_String
338   --Tok_Bit_String
339     Tok_Integer_Letter;
340
341   Tok_First_Delimiter : constant Token_Type := Tok_Left_Paren;
342   Tok_First_Keyword :   constant Token_Type := Tok_Mod;
343
344   -- Return the name of the token.
345   function Image (Token: Token_Type) return String;
346end Vhdl.Tokens;
347