Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / behvhdl / vhd_bcomp.lex
1 %{
2 #include <stdio.h>
3 #include <string.h>
4 #include <stdlib.h>
5 #include MUT_H
6 #include BEH_H
7
8 #define yylval vhd_bcomplval
9 #define YY_NO_UNPUT
10
11 #include "bvl_byacc.h"
12 #include "vhd_bcomp.tab.h"
13 #include "bvl_blex.h"
14
15 %}
16
17 upper_case_letter [A-Z]
18 digit [0-9]
19 special_character [\#\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\_\|]
20 space_character [ \t]
21 format_effector [\t\v\r\l\f]
22 end_of_line \n
23 lower_case_letter [a-z]
24 other_special_character [\!\$\@\?\[\\\]\^\`\{\}\~]
25
26 graphic_character ({basic_graphic_character}|{lower_case_letter}|{other_special_character})
27 basic_graphic_character ({upper_case_letter}|{digit}|{special_character}|{space_character})
28 letter ({upper_case_letter}|{lower_case_letter})
29 letter_or_digit ({letter}|{digit})
30 decimal_literal {integer}(\.{integer})?({exponent})?
31 integer {digit}(_?{digit})*
32 exponent ([eE][-+]?{integer})
33 base {integer}
34 based_integer {extended_digit}(_?{extended_digit})*
35 extended_digit ({digit}|[a-fA-F])
36 base_specifier (B|b|O|o|X|x)
37
38 %%
39 \n {
40 /*printf ("Newline\n");*/
41 BEH_LINNUM++;
42 }
43 [ \t] {
44 /*printf ("space\n");*/
45 }
46 \& {
47 /*printf ("Ampersand\n");*/
48 return(Ampersand);
49 }
50 \' {
51 /*printf ("Apostrophe\n");*/
52 return(Apostrophe);
53 }
54 \( {
55 /*printf ("LeftParen\n");*/
56 return(LeftParen);
57 }
58 \) {
59 /*printf ("RightParen\n");*/
60 return(RightParen);
61 }
62 "**" {
63 /*printf ("DoubleStar\n");*/
64 return(DoubleStar);
65 }
66 \* {
67 /*printf ("Star\n");*/
68 return(Star);
69 }
70 \+ {
71 /*printf ("Plus\n");*/
72 return(Plus);
73 }
74 \, {
75 /*printf ("Comma\n");*/
76 return(Comma);
77 }
78 \- {
79 /*printf ("Minus\n");*/
80 return(Minus);
81 }
82 ":=" {
83 /*printf ("VarAsgn\n");*/
84 return(VarAsgn);
85 }
86 \: {
87 /*printf ("Colon\n");*/
88 return(Colon);
89 }
90 \; {
91 /*printf ("Semicolon\n");*/
92 return(Semicolon);
93 }
94 "<=" {
95 /*printf ("_LESym\n");*/
96 return(_LESym);
97 }
98 ">=" {
99 /*printf ("_GESym\n");*/
100 return(_GESym);
101 }
102 \< {
103 /*printf ("_LTSym\n");*/
104 return(_LTSym);
105 }
106 \> {
107 /*printf ("_GTSym\n");*/
108 return(_GTSym);
109 }
110 = {
111 /*printf ("_EQSym\n");*/
112 return(_EQSym);
113 }
114 \/= {
115 /*printf ("_NESym\n");*/
116 return(_NESym);
117 }
118 "=>" {
119 /*printf ("Arrow\n");*/
120 return(Arrow);
121 }
122 "<>" {
123 /*printf ("Box\n");*/
124 return(Box);
125 }
126 \| {
127 /*printf ("Bar\n");*/
128 return(Bar);
129 }
130 ! {
131 /*printf ("Bar\n");*/
132 return(Bar);
133 }
134 \. {
135 /*printf ("Dot\n");*/
136 return(Dot);
137 }
138 \/ {
139 /*printf ("Slash\n");*/
140 return(Slash);
141 }
142
143 {letter_or_digit}+("."(_?{letter_or_digit})*)+ {
144 /* printf("pointed name : %s\n",yytext);*/
145 yylval.text = namealloc (yytext);
146 return (Pointed_name);
147 }
148
149 {letter}(_?{letter_or_digit})* {
150 int itoken;
151
152 itoken = search (yytext);
153 if (itoken == EMPTYHT)
154 {
155 yylval.text = namealloc (yytext);
156 /*printf ("Identifier : %s\n", yytext);*/
157 return (Identifier);
158 }
159 else
160 {
161 /*printf ("Key word : %s\n", yytext);*/
162 return (itoken);
163 }
164 }
165 ({decimal_literal})|({base}#{based_integer}(\.{based_integer})?#({exponent})?)|({base}:{based_integer}(\.{based_integer})?:({exponent})?) {
166 yylval.text = mbkalloc ((unsigned int)strlen(yytext)+1);
167 strcpy (yylval.text, yytext);
168 return (AbstractLit);
169 }
170 '({graphic_character}|\"|\%)' {
171 yylval.text = namealloc (yytext);
172 return (CharacterLit);
173 }
174 (\"({graphic_character}|(\"\")|\%)*\")|(\%({graphic_character}|(\%\%)|\")*\%) {
175 yylval.text = namealloc (yytext);
176 return (StringLit);
177 }
178 {base_specifier}((\"{extended_digit}(_?{extended_digit})*\")|(\%{extended_digit}(_?{extended_digit})*\%)) {
179 yylval.text = namealloc (yytext);
180 return (BitStringLit);
181 }
182 \-\-.*$ {
183 }
184 . {
185 return (*yytext);
186 }
187 %%
188
189 /* ###--------------------------------------------------------------### */
190 /* function : yywrap */
191 /* description : return 1 */
192 /* called func. : none */
193 /* ###--------------------------------------------------------------### */
194
195 int yywrap ()
196 {
197 return (1);
198 }
199
200 /* ###--------------------------------------------------------------### */
201 /* function : search */
202 /* description : check that an identifier is a reserved word or not */
203 /* called func. : addht, addhtitem, gethtitem, namealloc */
204 /* ###--------------------------------------------------------------### */
205
206 static int search (key)
207
208 char *key;
209
210 {
211 static ht *pt_hash = NULL;
212 char keyd[128] ;
213
214 if (pt_hash == NULL)
215 {
216 pt_hash = addht (107);
217
218 addhtitem (pt_hash, namealloc("abs") , ABS );
219 addhtitem (pt_hash, namealloc("access") , ACCESS );
220 addhtitem (pt_hash, namealloc("after") , AFTER );
221 addhtitem (pt_hash, namealloc("alias") , ALIAS );
222 addhtitem (pt_hash, namealloc("all") , ALL );
223 addhtitem (pt_hash, namealloc("and") , VHD_AND );
224 addhtitem (pt_hash, namealloc("architecture") , ARCHITECTURE );
225 addhtitem (pt_hash, namealloc("array") , ARRAY );
226 addhtitem (pt_hash, namealloc("assert") , ASSERT );
227 addhtitem (pt_hash, namealloc("attribute") , ATTRIBUTE );
228
229 addhtitem (pt_hash, namealloc("begin") , _BEGIN );
230 addhtitem (pt_hash, namealloc("bit") , BIT );
231 addhtitem (pt_hash, namealloc("bit_vector") , BIT_VECTOR );
232 addhtitem (pt_hash, namealloc("block") , BLOCK );
233 addhtitem (pt_hash, namealloc("body") , BODY );
234 addhtitem (pt_hash, namealloc("buffer") , BUFFER );
235 addhtitem (pt_hash, namealloc("bus") , BUS );
236
237 addhtitem (pt_hash, namealloc("case") , CASE );
238 addhtitem (pt_hash, namealloc("component") , COMPONENT );
239 addhtitem (pt_hash, namealloc("configuration"), CONFIGURATION);
240 addhtitem (pt_hash, namealloc("constant") , CONSTANT );
241
242 addhtitem (pt_hash, namealloc("disconnect") , DISCONNECT );
243 addhtitem (pt_hash, namealloc("downto") , DOWNTO );
244
245 addhtitem (pt_hash, namealloc("event") , EVENT );
246 addhtitem (pt_hash, namealloc("else") , ELSE );
247 addhtitem (pt_hash, namealloc("elsif") , ELSIF );
248 addhtitem (pt_hash, namealloc("end") , _END );
249 addhtitem (pt_hash, namealloc("entity") , ENTITY );
250 addhtitem (pt_hash, namealloc("error") , ERROR );
251 addhtitem (pt_hash, namealloc("exit") , _EXIT );
252
253 addhtitem (pt_hash, namealloc("file") , _FILE );
254 addhtitem (pt_hash, namealloc("for") , FOR );
255 addhtitem (pt_hash, namealloc("function") , FUNCTION );
256
257 addhtitem (pt_hash, namealloc("generate") , GENERATE );
258 addhtitem (pt_hash, namealloc("generic") , GENERIC );
259 addhtitem (pt_hash, namealloc("guarded") , GUARDED );
260
261 addhtitem (pt_hash, namealloc("if") , IF );
262 addhtitem (pt_hash, namealloc("in") , _IN );
263 addhtitem (pt_hash, namealloc("inout") , _INOUT );
264 addhtitem (pt_hash, namealloc("is") , IS );
265
266 addhtitem (pt_hash, namealloc("label") , _LABEL );
267 addhtitem (pt_hash, namealloc("library") , LIBRARY );
268 addhtitem (pt_hash, namealloc("linkage") , _LINKAGE );
269 addhtitem (pt_hash, namealloc("loop") , T_LOOP );
270
271 addhtitem (pt_hash, namealloc("map") , MAP );
272 addhtitem (pt_hash, namealloc("mod") , MOD );
273 addhtitem (pt_hash, namealloc("ms") , MS );
274 addhtitem (pt_hash, namealloc("mux_bit") , MUX_BIT );
275 addhtitem (pt_hash, namealloc("mux_vector") , MUX_VECTOR );
276
277 addhtitem (pt_hash, namealloc("nand") , _NAND );
278 addhtitem (pt_hash, namealloc("natural") , NATURAL );
279 addhtitem (pt_hash, namealloc("new") , NEW );
280 addhtitem (pt_hash, namealloc("next") , _NEXT );
281 addhtitem (pt_hash, namealloc("nor") , _NOR );
282 addhtitem (pt_hash, namealloc("not") , _NOT );
283 addhtitem (pt_hash, namealloc("ns") , NS );
284 addhtitem (pt_hash, namealloc("null") , VHD_NULL );
285
286 addhtitem (pt_hash, namealloc("of") , OF );
287 addhtitem (pt_hash, namealloc("on") , ON );
288 addhtitem (pt_hash, namealloc("open") , OPEN );
289 addhtitem (pt_hash, namealloc("or") , _OR );
290 addhtitem (pt_hash, namealloc("others") , OTHERS );
291 addhtitem (pt_hash, namealloc("out") , _OUT );
292
293 addhtitem (pt_hash, namealloc("package") , PACKAGE );
294 addhtitem (pt_hash, namealloc("port") , PORT );
295 addhtitem (pt_hash, namealloc("procedure") , PROCEDURE );
296 addhtitem (pt_hash, namealloc("process") , PROCESS );
297 addhtitem (pt_hash, namealloc("ps") , PS );
298
299 addhtitem (pt_hash, namealloc("range") , RANGE );
300 addhtitem (pt_hash, namealloc("record") , RECORD );
301 addhtitem (pt_hash, namealloc("reg_bit") , REG_BIT );
302 addhtitem (pt_hash, namealloc("reg_vector") , REG_VECTOR );
303 addhtitem (pt_hash, namealloc("register") , REGISTER );
304 addhtitem (pt_hash, namealloc("rem") , REM );
305 addhtitem (pt_hash, namealloc("report") , REPORT );
306 addhtitem (pt_hash, namealloc("return") , RETURN );
307
308 addhtitem (pt_hash, namealloc("select") , SELECT );
309 addhtitem (pt_hash, namealloc("severity") , SEVERITY );
310 addhtitem (pt_hash, namealloc("signal") , SIGNAL );
311 addhtitem (pt_hash, namealloc("stable") , _STABLE );
312 addhtitem (pt_hash, namealloc("std_logic") , STD_LOGIC );
313 addhtitem (pt_hash, namealloc("std_logic_vector") , STD_LOGIC_VECTOR );
314 addhtitem (pt_hash, namealloc("subtype") , SUBTYPE );
315
316 addhtitem (pt_hash, namealloc("then") , THEN );
317 addhtitem (pt_hash, namealloc("to") , TO );
318 addhtitem (pt_hash, namealloc("transport") , TRANSPORT );
319 addhtitem (pt_hash, namealloc("type") , _TYPE );
320
321 addhtitem (pt_hash, namealloc("units") , UNITS );
322 addhtitem (pt_hash, namealloc("until") , UNTIL );
323 addhtitem (pt_hash, namealloc("us") , US );
324 addhtitem (pt_hash, namealloc("use") , USE );
325
326 addhtitem (pt_hash, namealloc("variable") , VARIABLE );
327
328 addhtitem (pt_hash, namealloc("wait") , WAIT );
329 addhtitem (pt_hash, namealloc("warning") , WARNING );
330 addhtitem (pt_hash, namealloc("when") , WHEN );
331 addhtitem (pt_hash, namealloc("while") , WHILE );
332 addhtitem (pt_hash, namealloc("with") , WITH );
333 addhtitem (pt_hash, namealloc("wor_bit") , WOR_BIT );
334 addhtitem (pt_hash, namealloc("wor_vector") , WOR_VECTOR );
335
336 addhtitem (pt_hash, namealloc("xor") , _XOR );
337 }
338
339 downstr(key,keyd) ;
340 return (gethtitem (pt_hash, namealloc(keyd)));
341 }