]>
Commit | Line | Data |
---|---|---|
fbd2eda1 GM |
1 | /* do not edit automatically generated by mc from bnflex. */ |
2 | /* bnflex.mod provides a simple lexical package for pg. | |
3 | ||
4 | Copyright (C) 2001-2023 Free Software Foundation, Inc. | |
5 | Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>. | |
6 | ||
7 | This file is part of GNU Modula-2. | |
8 | ||
9 | GNU Modula-2 is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation; either version 3, or (at your option) | |
12 | any later version. | |
13 | ||
14 | GNU Modula-2 is distributed in the hope that it will be useful, but | |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with GNU Modula-2; see the file COPYING3. If not see | |
21 | <http://www.gnu.org/licenses/>. */ | |
22 | ||
23 | # if !defined (PROC_D) | |
24 | # define PROC_D | |
25 | typedef void (*PROC_t) (void); | |
26 | typedef struct { PROC_t proc; } PROC; | |
27 | # endif | |
28 | ||
29 | # if !defined (TRUE) | |
30 | # define TRUE (1==1) | |
31 | # endif | |
32 | ||
33 | # if !defined (FALSE) | |
34 | # define FALSE (1==0) | |
35 | # endif | |
36 | ||
37 | #include <string.h> | |
38 | #include <limits.h> | |
39 | #define _bnflex_H | |
40 | #define _bnflex_C | |
41 | ||
42 | # include "GPushBackInput.h" | |
43 | # include "GSymbolKey.h" | |
44 | # include "GASCII.h" | |
45 | # include "GDebug.h" | |
46 | # include "GNameKey.h" | |
47 | # include "GStrLib.h" | |
48 | # include "GFIO.h" | |
49 | # include "GStrCase.h" | |
50 | # include "GStdIO.h" | |
51 | ||
52 | # define MaxNameLength 8192 | |
53 | typedef enum {bnflex_identtok, bnflex_literaltok, bnflex_codetok, bnflex_lbecomestok, bnflex_rbecomestok, bnflex_bartok, bnflex_lsparatok, bnflex_rsparatok, bnflex_lcparatok, bnflex_rcparatok, bnflex_lparatok, bnflex_rparatok, bnflex_errortok, bnflex_tfunctok, bnflex_symfunctok, bnflex_squotetok, bnflex_dquotetok, bnflex_moduletok, bnflex_begintok, bnflex_rulestok, bnflex_endtok, bnflex_lesstok, bnflex_gretok, bnflex_tokentok, bnflex_specialtok, bnflex_firsttok, bnflex_followtok, bnflex_BNFtok, bnflex_FNBtok, bnflex_declarationtok, bnflex_epsilontok, bnflex_eoftok} bnflex_TokenType; | |
54 | ||
55 | static FIO_File f; | |
56 | static SymbolKey_SymbolTree ReservedWords; | |
57 | static NameKey_Name CurrentToken; | |
58 | static bnflex_TokenType CurrentType; | |
59 | static unsigned int Debugging; | |
60 | static unsigned int InQuote; | |
61 | static char QuoteChar; | |
62 | ||
63 | /* | |
64 | OpenSource - Attempts to open the source file, a. | |
65 | The success of the operation is returned. | |
66 | */ | |
67 | ||
68 | extern "C" unsigned int bnflex_OpenSource (const char *a_, unsigned int _a_high); | |
69 | ||
70 | /* | |
71 | CloseSource - Closes the current open file. | |
72 | */ | |
73 | ||
74 | extern "C" void bnflex_CloseSource (void); | |
75 | ||
76 | /* | |
77 | GetChar - returns the current character on the input stream. | |
78 | */ | |
79 | ||
80 | extern "C" char bnflex_GetChar (void); | |
81 | ||
82 | /* | |
83 | PutChar - pushes a character onto the push back stack, it also | |
84 | returns the character which has been pushed. | |
85 | */ | |
86 | ||
87 | extern "C" char bnflex_PutChar (char ch); | |
88 | ||
89 | /* | |
90 | SymIs - if t is equal to the current token the next token is read | |
91 | and true is returned, otherwise false is returned. | |
92 | */ | |
93 | ||
94 | extern "C" unsigned int bnflex_SymIs (bnflex_TokenType t); | |
95 | ||
96 | /* | |
97 | IsSym - returns the result of the comparison between the current token | |
98 | type and t. | |
99 | */ | |
100 | ||
101 | extern "C" unsigned int bnflex_IsSym (bnflex_TokenType t); | |
102 | ||
103 | /* | |
104 | GetCurrentTokenType - returns the type of current token. | |
105 | */ | |
106 | ||
107 | extern "C" bnflex_TokenType bnflex_GetCurrentTokenType (void); | |
108 | ||
109 | /* | |
110 | GetCurrentToken - returns the NameKey of the current token. | |
111 | */ | |
112 | ||
113 | extern "C" NameKey_Name bnflex_GetCurrentToken (void); | |
114 | ||
115 | /* | |
116 | SkipUntilWhite - skips all characters until white space is seen. | |
117 | */ | |
118 | ||
119 | extern "C" void bnflex_SkipUntilWhite (void); | |
120 | ||
121 | /* | |
122 | SkipWhite - skips all white space. | |
123 | */ | |
124 | ||
125 | extern "C" void bnflex_SkipWhite (void); | |
126 | ||
127 | /* | |
128 | SkipUntilEoln - skips until a lf is seen. It consumes the lf. | |
129 | */ | |
130 | ||
131 | extern "C" void bnflex_SkipUntilEoln (void); | |
132 | ||
133 | /* | |
134 | AdvanceToken - advances to the next token. | |
135 | */ | |
136 | ||
137 | extern "C" void bnflex_AdvanceToken (void); | |
138 | ||
139 | /* | |
140 | IsReserved - returns TRUE if the name is a reserved word. | |
141 | */ | |
142 | ||
143 | extern "C" unsigned int bnflex_IsReserved (NameKey_Name name); | |
144 | ||
145 | /* | |
146 | PushBackToken - pushes a token back onto input. | |
147 | */ | |
148 | ||
149 | extern "C" void bnflex_PushBackToken (NameKey_Name t); | |
150 | ||
151 | /* | |
152 | SetDebugging - sets the debugging flag. | |
153 | */ | |
154 | ||
155 | extern "C" void bnflex_SetDebugging (unsigned int flag); | |
156 | ||
157 | /* | |
158 | EatChar - consumes the next character in the input. | |
159 | */ | |
160 | ||
161 | static void EatChar (void); | |
162 | ||
163 | /* | |
164 | IsWhite - returns TRUE if, ch, is a space or a tab. | |
165 | */ | |
166 | ||
167 | static unsigned int IsWhite (char ch); | |
168 | ||
169 | /* | |
170 | SkipComments - consumes comments. | |
171 | */ | |
172 | ||
173 | static void SkipComments (void); | |
174 | ||
175 | /* | |
176 | WriteToken - | |
177 | */ | |
178 | ||
179 | static void WriteToken (void); | |
180 | ||
181 | /* | |
182 | Init - initialize the modules global variables. | |
183 | */ | |
184 | ||
185 | static void Init (void); | |
186 | ||
187 | ||
188 | /* | |
189 | EatChar - consumes the next character in the input. | |
190 | */ | |
191 | ||
192 | static void EatChar (void) | |
193 | { | |
194 | if ((PushBackInput_GetCh (f)) == ASCII_nul) | |
195 | {} /* empty. */ | |
196 | } | |
197 | ||
198 | ||
199 | /* | |
200 | IsWhite - returns TRUE if, ch, is a space or a tab. | |
201 | */ | |
202 | ||
203 | static unsigned int IsWhite (char ch) | |
204 | { | |
205 | return ((ch == ' ') || (ch == ASCII_tab)) || (ch == ASCII_lf); | |
206 | /* static analysis guarentees a RETURN statement will be used before here. */ | |
207 | __builtin_unreachable (); | |
208 | } | |
209 | ||
210 | ||
211 | /* | |
212 | SkipComments - consumes comments. | |
213 | */ | |
214 | ||
215 | static void SkipComments (void) | |
216 | { | |
217 | bnflex_SkipWhite (); | |
218 | while ((bnflex_PutChar (bnflex_GetChar ())) == '-') | |
219 | { | |
220 | if (((bnflex_GetChar ()) == '-') && ((bnflex_PutChar (bnflex_GetChar ())) == '-')) | |
221 | { | |
222 | /* found comment, skip it */ | |
223 | bnflex_SkipUntilEoln (); | |
224 | bnflex_SkipWhite (); | |
225 | } | |
226 | else | |
227 | { | |
228 | /* no second '-' found thus restore first '-' */ | |
229 | if ((bnflex_PutChar ('-')) == '-') | |
230 | {} /* empty. */ | |
231 | return ; | |
232 | } | |
233 | } | |
234 | } | |
235 | ||
236 | ||
237 | /* | |
238 | WriteToken - | |
239 | */ | |
240 | ||
241 | static void WriteToken (void) | |
242 | { | |
243 | NameKey_WriteKey (CurrentToken); | |
244 | StdIO_Write (' '); | |
245 | } | |
246 | ||
247 | ||
248 | /* | |
249 | Init - initialize the modules global variables. | |
250 | */ | |
251 | ||
252 | static void Init (void) | |
253 | { | |
254 | typedef struct Init__T1_a Init__T1; | |
255 | ||
256 | struct Init__T1_a { char array[1+1]; }; | |
257 | Init__T1 a; | |
258 | ||
259 | SymbolKey_InitTree (&ReservedWords); | |
260 | Debugging = FALSE; | |
261 | a.array[0] = ASCII_nul; | |
262 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) &a.array[0], 1), ((unsigned int) (bnflex_eoftok))); | |
263 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "%", 1), ((unsigned int) (bnflex_codetok))); | |
264 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) ":=", 2), ((unsigned int) (bnflex_lbecomestok))); | |
265 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "=:", 2), ((unsigned int) (bnflex_rbecomestok))); | |
266 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "|", 1), ((unsigned int) (bnflex_bartok))); | |
267 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "[", 1), ((unsigned int) (bnflex_lsparatok))); | |
268 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "]", 1), ((unsigned int) (bnflex_rsparatok))); | |
269 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "{", 1), ((unsigned int) (bnflex_lcparatok))); | |
270 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "}", 1), ((unsigned int) (bnflex_rcparatok))); | |
271 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "(", 1), ((unsigned int) (bnflex_lparatok))); | |
272 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) ")", 1), ((unsigned int) (bnflex_rparatok))); | |
273 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "<", 1), ((unsigned int) (bnflex_lesstok))); | |
274 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) ">", 1), ((unsigned int) (bnflex_gretok))); | |
275 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "error", 5), ((unsigned int) (bnflex_errortok))); | |
276 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "tokenfunc", 9), ((unsigned int) (bnflex_tfunctok))); | |
277 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "symfunc", 7), ((unsigned int) (bnflex_symfunctok))); | |
278 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "'", 1), ((unsigned int) (bnflex_squotetok))); | |
279 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "\"", 1), ((unsigned int) (bnflex_dquotetok))); | |
280 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "module", 6), ((unsigned int) (bnflex_moduletok))); | |
281 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "begin", 5), ((unsigned int) (bnflex_begintok))); | |
282 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "rules", 5), ((unsigned int) (bnflex_rulestok))); | |
283 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "end", 3), ((unsigned int) (bnflex_endtok))); | |
284 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "declaration", 11), ((unsigned int) (bnflex_declarationtok))); | |
285 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "token", 5), ((unsigned int) (bnflex_tokentok))); | |
286 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "special", 7), ((unsigned int) (bnflex_specialtok))); | |
287 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "first", 5), ((unsigned int) (bnflex_firsttok))); | |
288 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "follow", 6), ((unsigned int) (bnflex_followtok))); | |
289 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "epsilon", 7), ((unsigned int) (bnflex_epsilontok))); | |
290 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "BNF", 3), ((unsigned int) (bnflex_BNFtok))); | |
291 | SymbolKey_PutSymKey (ReservedWords, NameKey_MakeKey ((const char *) "FNB", 3), ((unsigned int) (bnflex_FNBtok))); | |
292 | CurrentToken = NameKey_NulName; | |
293 | CurrentType = bnflex_identtok; | |
294 | InQuote = FALSE; | |
295 | } | |
296 | ||
297 | ||
298 | /* | |
299 | OpenSource - Attempts to open the source file, a. | |
300 | The success of the operation is returned. | |
301 | */ | |
302 | ||
303 | extern "C" unsigned int bnflex_OpenSource (const char *a_, unsigned int _a_high) | |
304 | { | |
305 | char a[_a_high+1]; | |
306 | ||
307 | /* make a local copy of each unbounded array. */ | |
308 | memcpy (a, a_, _a_high+1); | |
309 | ||
310 | f = PushBackInput_Open ((const char *) a, _a_high); | |
311 | return FIO_IsNoError (f); | |
312 | /* static analysis guarentees a RETURN statement will be used before here. */ | |
313 | __builtin_unreachable (); | |
314 | } | |
315 | ||
316 | ||
317 | /* | |
318 | CloseSource - Closes the current open file. | |
319 | */ | |
320 | ||
321 | extern "C" void bnflex_CloseSource (void) | |
322 | { | |
323 | PushBackInput_Close (f); | |
324 | } | |
325 | ||
326 | ||
327 | /* | |
328 | GetChar - returns the current character on the input stream. | |
329 | */ | |
330 | ||
331 | extern "C" char bnflex_GetChar (void) | |
332 | { | |
333 | return PushBackInput_GetCh (f); | |
334 | /* static analysis guarentees a RETURN statement will be used before here. */ | |
335 | __builtin_unreachable (); | |
336 | } | |
337 | ||
338 | ||
339 | /* | |
340 | PutChar - pushes a character onto the push back stack, it also | |
341 | returns the character which has been pushed. | |
342 | */ | |
343 | ||
344 | extern "C" char bnflex_PutChar (char ch) | |
345 | { | |
346 | return PushBackInput_PutCh (ch); | |
347 | /* static analysis guarentees a RETURN statement will be used before here. */ | |
348 | __builtin_unreachable (); | |
349 | } | |
350 | ||
351 | ||
352 | /* | |
353 | SymIs - if t is equal to the current token the next token is read | |
354 | and true is returned, otherwise false is returned. | |
355 | */ | |
356 | ||
357 | extern "C" unsigned int bnflex_SymIs (bnflex_TokenType t) | |
358 | { | |
359 | if (CurrentType == t) | |
360 | { | |
361 | bnflex_AdvanceToken (); | |
362 | return TRUE; | |
363 | } | |
364 | else | |
365 | { | |
366 | return FALSE; | |
367 | } | |
368 | /* static analysis guarentees a RETURN statement will be used before here. */ | |
369 | __builtin_unreachable (); | |
370 | } | |
371 | ||
372 | ||
373 | /* | |
374 | IsSym - returns the result of the comparison between the current token | |
375 | type and t. | |
376 | */ | |
377 | ||
378 | extern "C" unsigned int bnflex_IsSym (bnflex_TokenType t) | |
379 | { | |
380 | return t == CurrentType; | |
381 | /* static analysis guarentees a RETURN statement will be used before here. */ | |
382 | __builtin_unreachable (); | |
383 | } | |
384 | ||
385 | ||
386 | /* | |
387 | GetCurrentTokenType - returns the type of current token. | |
388 | */ | |
389 | ||
390 | extern "C" bnflex_TokenType bnflex_GetCurrentTokenType (void) | |
391 | { | |
392 | return CurrentType; | |
393 | /* static analysis guarentees a RETURN statement will be used before here. */ | |
394 | __builtin_unreachable (); | |
395 | } | |
396 | ||
397 | ||
398 | /* | |
399 | GetCurrentToken - returns the NameKey of the current token. | |
400 | */ | |
401 | ||
402 | extern "C" NameKey_Name bnflex_GetCurrentToken (void) | |
403 | { | |
404 | return CurrentToken; | |
405 | /* static analysis guarentees a RETURN statement will be used before here. */ | |
406 | __builtin_unreachable (); | |
407 | } | |
408 | ||
409 | ||
410 | /* | |
411 | SkipUntilWhite - skips all characters until white space is seen. | |
412 | */ | |
413 | ||
414 | extern "C" void bnflex_SkipUntilWhite (void) | |
415 | { | |
416 | while (((! (IsWhite (bnflex_PutChar (bnflex_GetChar ())))) && ((bnflex_PutChar (bnflex_GetChar ())) != ASCII_nul)) || ((bnflex_PutChar (bnflex_GetChar ())) == ASCII_lf)) | |
417 | { | |
418 | EatChar (); | |
419 | } | |
420 | } | |
421 | ||
422 | ||
423 | /* | |
424 | SkipWhite - skips all white space. | |
425 | */ | |
426 | ||
427 | extern "C" void bnflex_SkipWhite (void) | |
428 | { | |
429 | while (IsWhite (bnflex_PutChar (bnflex_GetChar ()))) | |
430 | { | |
431 | EatChar (); | |
432 | } | |
433 | } | |
434 | ||
435 | ||
436 | /* | |
437 | SkipUntilEoln - skips until a lf is seen. It consumes the lf. | |
438 | */ | |
439 | ||
440 | extern "C" void bnflex_SkipUntilEoln (void) | |
441 | { | |
442 | while (((bnflex_PutChar (bnflex_GetChar ())) != ASCII_lf) && ((bnflex_PutChar (bnflex_GetChar ())) != ASCII_nul)) | |
443 | { | |
444 | EatChar (); | |
445 | } | |
446 | if ((bnflex_PutChar (bnflex_GetChar ())) == ASCII_lf) | |
447 | { | |
448 | EatChar (); | |
449 | } | |
450 | } | |
451 | ||
452 | ||
453 | /* | |
454 | AdvanceToken - advances to the next token. | |
455 | */ | |
456 | ||
457 | extern "C" void bnflex_AdvanceToken (void) | |
458 | { | |
459 | typedef struct AdvanceToken__T2_a AdvanceToken__T2; | |
460 | ||
461 | struct AdvanceToken__T2_a { char array[MaxNameLength+1]; }; | |
462 | AdvanceToken__T2 a; | |
463 | unsigned int i; | |
464 | ||
465 | i = 0; | |
466 | if (InQuote) | |
467 | { | |
468 | if (CurrentType == bnflex_literaltok) | |
469 | { | |
470 | if ((bnflex_PutChar (bnflex_GetChar ())) == QuoteChar) | |
471 | { | |
472 | a.array[i] = bnflex_GetChar (); | |
473 | InQuote = FALSE; | |
474 | i += 1; | |
475 | a.array[i] = ASCII_nul; | |
476 | CurrentToken = NameKey_MakeKey ((const char *) &a.array[0], MaxNameLength); | |
477 | CurrentType = (bnflex_TokenType) (SymbolKey_GetSymKey (ReservedWords, CurrentToken)); | |
478 | } | |
479 | else | |
480 | { | |
481 | if (QuoteChar == '"') | |
482 | { | |
483 | PushBackInput_WarnError ((const char *) "missing \" at the end of a literal", 33); | |
484 | } | |
485 | else | |
486 | { | |
487 | PushBackInput_WarnError ((const char *) "missing ' at the end of a literal", 33); | |
488 | } | |
489 | InQuote = FALSE; /* to avoid a contineous list of the same error message */ | |
490 | } | |
491 | } | |
492 | else | |
493 | { | |
494 | while ((((i < MaxNameLength) && ((bnflex_PutChar (bnflex_GetChar ())) != ASCII_nul)) && ((bnflex_PutChar (bnflex_GetChar ())) != ASCII_lf)) && ((bnflex_PutChar (bnflex_GetChar ())) != QuoteChar)) | |
495 | { | |
496 | a.array[i] = bnflex_GetChar (); | |
497 | i += 1; | |
498 | } | |
499 | if ((bnflex_PutChar (bnflex_GetChar ())) == QuoteChar) | |
500 | { | |
501 | CurrentType = bnflex_literaltok; | |
502 | a.array[i] = ASCII_nul; | |
503 | CurrentToken = NameKey_MakeKey ((const char *) &a.array[0], MaxNameLength); | |
504 | } | |
505 | else | |
506 | { | |
507 | if (QuoteChar == '"') | |
508 | { | |
509 | PushBackInput_WarnError ((const char *) "missing \" at the end of a literal", 33); | |
510 | } | |
511 | else | |
512 | { | |
513 | PushBackInput_WarnError ((const char *) "missing ' at the end of a literal", 33); | |
514 | } | |
515 | InQuote = FALSE; /* to avoid a contineous list of the same error message */ | |
516 | } | |
517 | } | |
518 | } | |
519 | else | |
520 | { | |
521 | SkipComments (); | |
522 | if (((bnflex_PutChar (bnflex_GetChar ())) == '"') || ((bnflex_PutChar (bnflex_GetChar ())) == '\'')) | |
523 | { | |
524 | a.array[i] = bnflex_GetChar (); | |
525 | QuoteChar = a.array[i]; | |
526 | i += 1; | |
527 | InQuote = TRUE; | |
528 | a.array[i] = ASCII_nul; | |
529 | CurrentToken = NameKey_MakeKey ((const char *) &a.array[0], MaxNameLength); | |
530 | CurrentType = (bnflex_TokenType) (SymbolKey_GetSymKey (ReservedWords, CurrentToken)); | |
531 | } | |
532 | else | |
533 | { | |
534 | while (((((i < MaxNameLength) && ((bnflex_PutChar (bnflex_GetChar ())) != ASCII_nul)) && ((bnflex_PutChar (bnflex_GetChar ())) != ASCII_lf)) && ((bnflex_PutChar (bnflex_GetChar ())) != QuoteChar)) && (! (IsWhite (bnflex_PutChar (bnflex_GetChar ()))))) | |
535 | { | |
536 | a.array[i] = bnflex_GetChar (); | |
537 | i += 1; | |
538 | } | |
539 | a.array[i] = ASCII_nul; | |
540 | CurrentToken = NameKey_MakeKey ((const char *) &a.array[0], MaxNameLength); | |
541 | if ((SymbolKey_GetSymKey (ReservedWords, CurrentToken)) == 0) | |
542 | { | |
543 | CurrentType = bnflex_identtok; | |
544 | } | |
545 | else | |
546 | { | |
547 | CurrentType = (bnflex_TokenType) (SymbolKey_GetSymKey (ReservedWords, CurrentToken)); | |
548 | } | |
549 | } | |
550 | } | |
551 | if (Debugging) | |
552 | { | |
553 | WriteToken (); | |
554 | } | |
555 | } | |
556 | ||
557 | ||
558 | /* | |
559 | IsReserved - returns TRUE if the name is a reserved word. | |
560 | */ | |
561 | ||
562 | extern "C" unsigned int bnflex_IsReserved (NameKey_Name name) | |
563 | { | |
564 | return (SymbolKey_GetSymKey (ReservedWords, name)) != 0; | |
565 | /* static analysis guarentees a RETURN statement will be used before here. */ | |
566 | __builtin_unreachable (); | |
567 | } | |
568 | ||
569 | ||
570 | /* | |
571 | PushBackToken - pushes a token back onto input. | |
572 | */ | |
573 | ||
574 | extern "C" void bnflex_PushBackToken (NameKey_Name t) | |
575 | { | |
576 | typedef struct PushBackToken__T3_a PushBackToken__T3; | |
577 | ||
578 | struct PushBackToken__T3_a { char array[MaxNameLength+1]; }; | |
579 | PushBackToken__T3 a; | |
580 | ||
581 | NameKey_GetKey (t, (char *) &a.array[0], MaxNameLength); | |
582 | PushBackInput_PutString ((const char *) &a.array[0], MaxNameLength); | |
583 | } | |
584 | ||
585 | ||
586 | /* | |
587 | SetDebugging - sets the debugging flag. | |
588 | */ | |
589 | ||
590 | extern "C" void bnflex_SetDebugging (unsigned int flag) | |
591 | { | |
592 | Debugging = flag; | |
593 | } | |
594 | ||
595 | extern "C" void _M2_bnflex_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) | |
596 | { | |
597 | Init (); | |
598 | } | |
599 | ||
600 | extern "C" void _M2_bnflex_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) | |
601 | { | |
602 | } |