Added upstream from http://ftp.icm.edu.pl/pub/loglan/
[loglan.git] / loglan96 / loglan93 / lex.l
1 %{
2
3 //****************************************************************
4 //*                                                              *
5 //*    Lex.l : Reg. Exp. for the LOGLAN-82 and the LOGLAN-93     *
6 //*            languages.                                        *
7 //*                                                              *
8 //* (c) LITA, university of PAU (France), summer 1993.           *
9 //****************************************************************
10
11 #ifdef TOKENS_DEBUG
12 #define TOKENS_ERROR
13 #define TOKENS_DEBUG_printf(a)    fprintf(stderr,a)
14 #define TOKENS_DEBUG_printf2(a,b) fprintf(stderr,a,b)
15 #else
16 #define TOKENS_DEBUG_printf(a)
17 #define TOKENS_DEBUG_printf2(a,b)
18 #endif
19
20 #ifdef TOKENS_ERROR
21 #define TOKENS_ERROR_printf(a)  fprintf(stderr,a)
22 #else
23 #define TOKENS_ERROR_printf(a)
24 #endif
25
26 #ifdef SYNTAX_ONLY
27 #define SEMANTIC(a)
28 #else
29 #define SEMANTIC(a) a
30 #endif
31
32 #ifndef SYNTAX_ONLY
33
34 #include <String.h>
35 #include <iostream.h>
36 #include "Objects.h"
37 #include "Expr.h"
38 #include "Instr.h"
39
40 #endif
41
42 #include "syntax.h"
43
44 int line_number=1;
45
46 #ifndef SYNTAX_ONLY
47 void LexAdvanceCursor( int length );
48
49 Location ThisPlace;
50 int      BeginningOfLine;
51
52 #endif
53
54 %}
55
56 %x CondComment CondLineComment
57 %x CondString
58
59 Letter          [A-Za-z]
60 IdLetter        {Letter}|[_0-9]
61 Digit           [0-9]
62
63 Identifier      {Letter}({IdLetter}*)
64 A               [Aa]
65 B               [Bb]
66 C               [Cc]
67 D               [Dd]
68 E               [Ee]
69 F               [Ff]
70 G               [Gg]
71 H               [Hh]
72 I               [Ii]
73 J               [Jj]
74 K               [Kk]
75 L               [Ll]
76 M               [Mm]
77 N               [Nn]
78 O               [Oo]
79 P               [Pp]
80 Q               [Qq]
81 R               [Rr]
82 S               [Ss]
83 T               [Tt]
84 U               [Uu]
85 V               [Vv]
86 W               [Ww]
87 X               [Xx]
88 Y               [Yy]
89 Z               [Zz]
90
91 %%
92
93 {B}{E}{G}{I}{N} {
94                   TOKENS_DEBUG_printf2("%s.\n",yytext);
95                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
96                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
97                   return(Begin);
98                 }
99
100 {E}{N}{D}       { 
101                   TOKENS_DEBUG_printf2("%s.\n",yytext);
102                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
103                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
104                   return(END);
105                 }
106
107 {P}{R}{O}{G}{R}{A}{M}   { 
108                   TOKENS_DEBUG_printf2("%s.\n",yytext);
109                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
110                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
111                   return(PROGRAM);
112                 }
113
114 {U}{N}{I}{T}    { 
115                   TOKENS_DEBUG_printf2("%s.\n",yytext);
116                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
117                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
118                   return(UNIT);
119                 }
120
121 {C}{L}{A}{S}{S} {
122                   TOKENS_DEBUG_printf2("%s.\n",yytext);
123                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
124                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
125                   return(CLASS);
126                 }
127
128 {P}{R}{O}{C}{E}{D}{U}{R}{E}     {
129                   TOKENS_DEBUG_printf2("%s.\n",yytext);
130                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
131                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
132                   return(PROCEDURE);
133                 }
134
135 {F}{U}{N}{C}{T}{I}{O}{N}        { 
136                   TOKENS_DEBUG_printf2("%s.\n",yytext);
137                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
138                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
139                   return(FUNCTION);
140                 }
141
142 {C}{O}{R}{O}{U}{T}{I}{N}{E}     {
143                   TOKENS_DEBUG_printf2("%s.\n",yytext);
144                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
145                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
146                   return(COROUTINE);
147                 }
148 {P}{R}{O}{C}{E}{S}{S}   {
149                   TOKENS_DEBUG_printf2("%s.\n",yytext);
150                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
151                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
152                   return(PROCESS);
153                 }
154
155 {B}{L}{O}{C}{K} {
156                   TOKENS_DEBUG_printf2("%s.\n",yytext);
157                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
158                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
159                   return(BLOCK);
160                 }
161
162 {T}{Y}{P}{E}    {
163                   TOKENS_DEBUG_printf2("%s.\n",yytext);
164                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
165                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
166                   return(TYPE);
167                 }
168
169 {H}{A}{N}{D}{L}{E}{R}{S}        {
170                   TOKENS_DEBUG_printf2("%s.\n",yytext);
171                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
172                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
173                   return(HANDLERS);
174                 }
175
176 {I}{N}{P}{U}{T} {
177                   TOKENS_DEBUG_printf2("%s.\n",yytext);
178                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
179                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
180                   return(INPUT);
181                 }
182
183 {O}{U}{T}{P}{U}{T}      {  
184                   TOKENS_DEBUG_printf2("%s.\n",yytext);
185                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
186                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
187                   return(OUTPUT);
188                 }
189
190 {I}{N}{O}{U}{T} {  
191                   TOKENS_DEBUG_printf2("%s.\n",yytext);
192                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
193                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
194                   return(INOUT);
195                 }
196
197 {V}{I}{R}{T}{U}{A}{L}   {
198                   TOKENS_DEBUG_printf2("%s.\n",yytext);
199                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
200                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
201                   return(VIRTUAL);
202                 }
203
204 {W}{H}{E}{N}    {
205                   TOKENS_DEBUG_printf2("%s.\n",yytext);
206                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
207                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
208                   return(WHEN);
209                 }
210
211 {O}{T}{H}{E}{R}{W}{I}{S}{E}     {
212                   TOKENS_DEBUG_printf2("%s.\n",yytext);
213                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
214                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
215                   return(OTHERWISE);
216                 }
217
218 {C}{O}{N}{S}{T} {
219                   TOKENS_DEBUG_printf2("%s.\n",yytext);
220                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
221                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
222                   return(CONST);
223                 }
224
225 {V}{A}{R}       {
226                   TOKENS_DEBUG_printf2("%s.\n",yytext);
227                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
228                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
229                   return(VAR);
230                 }
231
232 {S}{I}{G}{N}{A}{L}      {
233                   TOKENS_DEBUG_printf2("%s.\n",yytext);
234                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
235                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
236                   return(SIGNAL);
237                 }
238
239 {O}{T}{H}{E}{R}{W}{I}{S}{E}     {
240                   TOKENS_DEBUG_printf2("%s.\n",yytext);
241                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
242                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
243                   return(OTHERWISE);
244                 }
245
246 {I}{N}{T}{E}{G}{E}{R}   {
247                   TOKENS_DEBUG_printf2("%s.\n",yytext);
248                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
249                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
250                   return(INTEGER);
251                 }
252
253 {R}{E}{A}{L}    {
254                   TOKENS_DEBUG_printf2("%s.\n",yytext);
255                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
256                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
257                   return(REAL);
258                 }
259
260 {B}{O}{O}{L}{E}{A}{N}   {
261                   TOKENS_DEBUG_printf2("%s.\n",yytext);
262                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
263                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
264                   return(BOOLEAN);
265                 }
266
267 {C}{H}{A}{R}{A}{C}{T}{E}{R}     {
268                   TOKENS_DEBUG_printf2("%s.\n",yytext);
269                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
270                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
271                   return(CHARACTER);
272                 }
273
274 {S}{T}{R}{I}{N}{G}      {
275                   TOKENS_DEBUG_printf2("%s.\n",yytext);
276                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
277                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
278                   return(STRING);
279                 }
280
281 {F}{I}{L}{E}    {
282                   TOKENS_DEBUG_printf2("%s.\n",yytext);
283                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
284                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
285                   return(File);
286                 }
287
288 {P}{R}{O}{C}{E}{S}{S}   {
289                   TOKENS_DEBUG_printf2("%s.\n",yytext);
290                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
291                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
292                   return(PROCESS);
293                 }
294
295 {C}{O}{R}{O}{U}{T}{I}{N}{E}     {
296                   TOKENS_DEBUG_printf2("%s.\n",yytext);
297                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
298                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
299                   return(COROUTINE);
300                 }
301
302 {A}{R}{R}{A}{Y}{O}{F}   {
303                   TOKENS_DEBUG_printf2("%s.\n",yytext);
304                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
305                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
306                   return(ARRAY_OF);
307                 }
308
309 {N}{O}{N}{E}    {
310                   TOKENS_DEBUG_printf2("%s.\n",yytext);
311                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
312                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
313                   return(NONE);
314                 }
315
316 {T}{H}{I}{S}    {
317                   TOKENS_DEBUG_printf2("%s.\n",yytext);
318                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
319                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
320                   return(THIS);
321                 }
322
323 {D}{I}{V}       {
324                   TOKENS_DEBUG_printf2("%s.\n",yytext);
325                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
326                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
327                   return(DIV);
328                 }
329
330 {M}{O}{D}       {
331                   TOKENS_DEBUG_printf2("%s.\n",yytext);
332                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
333                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
334                   return(MOD);
335                 }
336
337 {I}{S}          {
338                   TOKENS_DEBUG_printf2("%s.\n",yytext);
339                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
340                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
341                   return(IS);
342                 }
343
344 {I}{N}          {
345                   TOKENS_DEBUG_printf2("%s.\n",yytext);
346                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
347                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
348                   return(IN);
349                 }
350
351 {O}{R}          {
352                   TOKENS_DEBUG_printf2("%s.\n",yytext);
353                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
354                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
355                   return(OR);
356                 }
357
358 {A}{N}{D}       {
359                   TOKENS_DEBUG_printf2("%s.\n",yytext);
360                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
361                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
362                   return(AND);
363                 }
364
365 {N}{O}{T}       {
366                   TOKENS_DEBUG_printf2("%s.\n",yytext);
367                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
368                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
369                   return(NOT);
370                 }
371
372 {Q}{U}{A}       {
373                   TOKENS_DEBUG_printf2("%s.\n",yytext);
374                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
375                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
376                   return(QUA);
377                 }
378
379 {R}{E}{S}{U}{L}{T}      {
380                   TOKENS_DEBUG_printf2("%s.\n",yytext);
381                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
382                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
383                   return(RESULT);
384                 }
385
386 {N}{E}{W}       {
387                   TOKENS_DEBUG_printf2("%s.\n",yytext);
388                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
389                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
390                   return(NEW);
391                 }
392
393 {C}{O}{P}{Y}    {
394                   TOKENS_DEBUG_printf2("%s.\n",yytext);
395                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
396                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
397                   return(COPY);
398                 }
399
400 {A}{T}{T}{A}{C}{H}      {
401                   TOKENS_DEBUG_printf2("%s.\n",yytext);
402                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
403                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
404                   return(ATTACH);
405                 }
406
407 {D}{E}{T}{A}{C}{H}      {
408                   TOKENS_DEBUG_printf2("%s.\n",yytext);
409                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
410                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
411                   return(DETACH);
412                 }
413
414 {S}{T}{O}{P}    {
415                   TOKENS_DEBUG_printf2("%s.\n",yytext);
416                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
417                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
418                   return(STOP);
419                 }
420
421 {R}{E}{S}{U}{M}{E}      {
422                   TOKENS_DEBUG_printf2("%s.\n",yytext);
423                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
424                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
425                   return(RESUME);
426                 }
427
428 {T}{E}{R}{M}{I}{N}{A}{T}{E}     {
429                   TOKENS_DEBUG_printf2("%s.\n",yytext);
430                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
431                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
432                   return(TERMINATE);
433                 }
434
435 {P}{U}{T}       {
436                   TOKENS_DEBUG_printf2("%s.\n",yytext);
437                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
438                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
439                   return(PUT);
440                 }
441
442 {G}{E}{T}       {
443                   TOKENS_DEBUG_printf2("%s.\n",yytext);
444                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
445                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
446                   return(GET);
447                 }
448
449 {R}{E}{A}{D}    {
450                   TOKENS_DEBUG_printf2("%s.\n",yytext);
451                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
452                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
453                   return(READ);
454                 }
455
456 {R}{E}{A}{D}{L}{N}      {
457                   TOKENS_DEBUG_printf2("%s.\n",yytext);
458                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
459                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
460                   return(READLN);
461                 }
462
463 {W}{R}{I}{T}{E} {
464                   TOKENS_DEBUG_printf2("%s.\n",yytext);
465                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
466                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
467                   return(WRITE);
468                 }
469
470 {W}{R}{I}{T}{E}{L}{N}   {
471                   TOKENS_DEBUG_printf2("%s.\n",yytext);
472                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
473                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
474                   return(WRITELN);
475                 }
476
477 {C}{A}{L}{L}    {
478                   TOKENS_DEBUG_printf2("%s.\n",yytext);
479                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
480                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
481                   return(CALL);
482                 }
483
484 {K}{I}{L}{L}    {
485                   TOKENS_DEBUG_printf2("%s.\n",yytext);
486                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
487                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
488                   return(KILL);
489                 }
490
491 {E}{X}{I}{T}    {
492                   TOKENS_DEBUG_printf2("%s.\n",yytext);
493                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
494                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
495                   return(EXIT);
496                 }
497
498 {R}{E}{P}{E}{A}{T}      {
499                   TOKENS_DEBUG_printf2("%s.\n",yytext);
500                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
501                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
502                   return(REPEAT);
503                 }
504
505 {I}{N}{N}{E}{R} {
506                   TOKENS_DEBUG_printf2("%s.\n",yytext);
507                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
508                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
509                   return(INNER);
510                 }
511
512 {W}{I}{N}{D}    {
513                   TOKENS_DEBUG_printf2("%s.\n",yytext);
514                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
515                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
516                   return(WIND);
517                 }
518
519 {R}{A}{I}{S}{E} {
520                   TOKENS_DEBUG_printf2("%s.\n",yytext);
521                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
522                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
523                   return(RAISE);
524                 }
525
526 {A}{R}{R}{A}{Y} {
527                   TOKENS_DEBUG_printf2("%s.\n",yytext);
528                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
529                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
530                   return(ARRAY);
531                 }
532
533 {D}{I}{M}       {
534                   TOKENS_DEBUG_printf2("%s.\n",yytext);
535                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
536                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
537                   return(DIM);
538                 }
539
540 {D}{O}          {
541                   TOKENS_DEBUG_printf2("%s.\n",yytext);
542                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
543                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
544                   return(DO);
545                 }
546
547 {O}{D}          {
548                   TOKENS_DEBUG_printf2("%s.\n",yytext);
549                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
550                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
551                   return(OD);
552                 }
553
554 {W}{H}{I}{L}{E} {
555                   TOKENS_DEBUG_printf2("%s.\n",yytext);
556                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
557                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
558                   return(WHILE);
559                 }
560
561 {F}{O}{R}       {
562                   TOKENS_DEBUG_printf2("%s.\n",yytext);
563                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
564                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
565                   return(FOR);
566                 }
567
568 {S}{T}{E}{P}    {
569                   TOKENS_DEBUG_printf2("%s.\n",yytext);
570                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
571                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
572                   return(STEP);
573                 }
574
575 {T}{O}          {
576                   TOKENS_DEBUG_printf2("%s.\n",yytext);
577                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
578                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
579                   return(TO);
580                 }
581
582 {D}{O}{W}{N}{T}{O}      {
583                   TOKENS_DEBUG_printf2("%s.\n",yytext);
584                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
585                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
586                   return(DOWNTO);
587                 }
588
589 {I}{F}          {
590                   TOKENS_DEBUG_printf2("%s.\n",yytext);
591                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
592                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
593                   return(IF);
594                 }
595
596 {T}{H}{E}{N}    {
597                   TOKENS_DEBUG_printf2("%s.\n",yytext);
598                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
599                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
600                   return(THEN);
601                 }
602
603 {E}{L}{S}{E}    {
604                   TOKENS_DEBUG_printf2("%s.\n",yytext);
605                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
606                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
607                   return(ELSE);
608                 }
609
610 {F}{I}          {
611                   TOKENS_DEBUG_printf2("%s.\n",yytext);
612                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
613                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
614                   return(FI);
615                 }
616
617 {A}{N}{D}{I}{F} {
618                   TOKENS_DEBUG_printf2("%s.\n",yytext);
619                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
620                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
621                   return(ANDIF);
622                 }
623
624 {O}{R}{I}{F}    {
625                   TOKENS_DEBUG_printf2("%s.\n",yytext);
626                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
627                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
628                   return(ORIF);
629                 }
630
631 {C}{A}{S}{E}    {
632                   TOKENS_DEBUG_printf2("%s.\n",yytext);
633                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
634                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
635                   return(CASE);
636                 }
637
638 {E}{S}{A}{C}    {
639                   TOKENS_DEBUG_printf2("%s.\n",yytext);
640                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
641                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
642                   return(ESAC);
643                 }
644
645 {P}{R}{E}{F}    {
646                   TOKENS_DEBUG_printf2("%s.\n",yytext);
647                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
648                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
649                   return(PREF);
650                 }
651
652 {S}{H}{A}{R}{E}{D} {
653                   TOKENS_DEBUG_printf2("%s.\n",yytext);
654                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
655                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
656                   return(SHARED);
657                 }
658
659 {E}{N}{U}{M}    {
660                   TOKENS_DEBUG_printf2("%s.\n",yytext);
661                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
662                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
663                   return(ENUM);
664                 }
665
666 {T}{R}{U}{E}    {
667                   TOKENS_DEBUG_printf2("%s.\n",yytext);
668                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
669                   SEMANTIC(( yylval.ThisBool.Bool = 1 ));
670                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
671                   return(BOOLCONST);
672                 }
673
674 {F}{A}{L}{S}{E} {
675                   TOKENS_DEBUG_printf2("%s.\n",yytext);
676                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
677                   SEMANTIC(( yylval.ThisBool.Bool = 0 ));
678                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
679                   return(BOOLCONST);
680                 }
681
682 \*              {
683                   TOKENS_DEBUG_printf2("%s.\n",yytext);
684                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
685                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
686                   return(STAR);
687                 }
688
689 \/              {
690                   TOKENS_DEBUG_printf2("%s.\n",yytext);
691                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
692                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
693                   return(DIVIDE);
694                 }
695
696 \+              {
697                   TOKENS_DEBUG_printf2("%s.\n",yytext);
698                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
699                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
700                   return(PLUS);
701                 }
702
703 \-              {
704                   TOKENS_DEBUG_printf2("%s.\n",yytext);
705                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
706                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
707                   return(MINUS);
708                 }
709
710 \=              {
711                   TOKENS_DEBUG_printf2("%s.\n",yytext);
712                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
713                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
714                   return(EQUAL);
715                 }
716
717 ("<>")|("=/=")  {
718                   TOKENS_DEBUG_printf2("%s.\n",yytext);
719                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
720                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
721                   return(NEQUAL);
722                 }
723
724 "<"             {
725                   TOKENS_DEBUG_printf2("%s.\n",yytext);
726                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
727                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
728                   return(LESS);
729                 }
730
731 ">"             {
732                   TOKENS_DEBUG_printf2("%s.\n",yytext);
733                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
734                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
735                   return(GREATER);
736                 }
737
738 (">=")|("=>")   {
739                   TOKENS_DEBUG_printf2("%s.\n",yytext);
740                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
741                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
742                   return(GREATEROREQUAL);
743                 }
744
745 ("<=")|("=<")   {
746                   TOKENS_DEBUG_printf2("%s.\n",yytext);
747                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
748                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
749                   return(LESSOREQUAL);
750                 }
751
752 \(              {  
753                   TOKENS_DEBUG_printf2("%s.\n",yytext);
754                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
755                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
756                   return(OPENINGBRACKET);
757                 }
758
759 \)              {  
760                   TOKENS_DEBUG_printf2("%s.\n",yytext);
761                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
762                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
763                   return(CLOSINGBRACKET);
764                 }
765
766 \,              {  
767                   TOKENS_DEBUG_printf2("%s.\n",yytext);
768                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
769                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
770                   return(LIST_SEPARATOR);
771                 }
772
773 :               {  
774                   TOKENS_DEBUG_printf2("%s.\n",yytext);
775                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
776                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
777                   return(VARSEPARATOR);
778                 }
779
780 \;              {  
781                   TOKENS_DEBUG_printf2("%s.\n",yytext);
782                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
783                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
784                   return(ENDSENTENCE);
785                 }
786
787 \.              {  
788                   TOKENS_DEBUG_printf2("%s.\n",yytext);
789                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
790                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
791                   return(POINT);
792                 }
793
794 ":="            {
795                   TOKENS_DEBUG_printf2("%s.\n",yytext);
796                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
797                   SEMANTIC(( yylval.ThisLoc = new Location( ThisPlace ) ));
798                   return(AFFECTATION);
799                 }
800
801 " "             {
802                   SEMANTIC(( ThisPlace.Tab(1) ));
803                 }
804
805 \n              {
806                   SEMANTIC(( BeginningOfLine = 1 ));
807                   SEMANTIC(( ThisPlace.Cr() ));
808                   line_number++;
809                 }
810
811 {Identifier}    {
812                   TOKENS_DEBUG_printf2("%s.\n",yytext);
813                   SEMANTIC(( yylval.ThisString.Str = new String ( yytext ) ));
814                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
815                   SEMANTIC(( yylval.ThisString.Loc = new Location( ThisPlace ) ));
816                   return(IDENTIFIER);
817                 }
818
819 {Digit}+        {
820                   TOKENS_DEBUG_printf("DigitSequence.\n");
821                   SEMANTIC(( yylval.ThisInt.Int = atoi(yytext) ));
822                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
823                   SEMANTIC(( yylval.ThisInt.Loc = new Location( ThisPlace ) ));
824                   return(DIGITSEQUENCE);
825                 }
826
827 \'.?\'          {
828                   TOKENS_DEBUG_printf("CharConst.\n");
829                   SEMANTIC(( yylval.ThisChar.Char = yytext[1]  ));
830                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
831                   SEMANTIC(( yylval.ThisChar.Loc = new Location( ThisPlace ) ));
832                   return(CHARCONST);
833                 }
834
835 \'[^\'\n]*\'    {
836                   TOKENS_ERROR_printf("Error : Multiple Character constant.\n");
837                   SEMANTIC(( yylval.ThisChar.Char = yytext[1]  ));
838                   SEMANTIC(( LexAdvanceCursor( strlen(yytext) ) ));
839                   SEMANTIC(( yylval.ThisChar.Loc = new Location( ThisPlace ) ));
840                   return(CHARCONST);
841                 }
842
843 \"              {
844                   BEGIN(CondString);
845                   SEMANTIC(( ThisPlace.Tab( 1 ) ));
846                   yymore();
847                 }
848
849 "(*"            {
850                   BEGIN(CondComment);
851                   SEMANTIC(( ThisPlace.Tab( 2 ) ));
852                   yymore();
853                 }
854
855 .               {
856                   TOKENS_ERROR_printf("Erreur d'entree.\n");
857                   SEMANTIC(( ThisPlace.Select( 1 ) ));
858                 }
859
860 "//"            {
861                   BEGIN(CondLineComment);
862                   SEMANTIC(( ThisPlace.Tab( 2 ) ));
863                   yymore();
864                 }
865
866 <CondLineComment>.*\n {
867                   BEGIN(INITIAL);
868                   SEMANTIC(( ThisPlace.Cr() ));
869                   SEMANTIC(( BeginningOfLine = 1 ));
870                   line_number++;
871                 }
872
873 <CondString>\"  {
874                   TOKENS_DEBUG_printf2("String :%s\n",yytext);
875                   BEGIN(INITIAL);
876                   SEMANTIC(
877                   {
878                     yylval.ThisString.Str = new String(yytext);
879                     ThisPlace.Select( strlen(yytext) );
880                     yylval.ThisString.Loc = new Location( ThisPlace );
881                   });
882                   return(TEXTCONST);
883                 }
884
885 <CondString>\\\" {
886                   yymore();
887                 }
888
889 <CondString>\n {
890                   TOKENS_ERROR_printf("Error : Unterminated String.\n");
891                   line_number++;
892                   BEGIN(INITIAL);
893                   SEMANTIC(( ThisPlace.Cr() ));
894                   SEMANTIC(( BeginningOfLine = 1 ));
895                   return(TEXTCONST);
896                 }
897
898 <CondString>.  {
899                   yymore();
900                 }
901
902 <CondComment>"(*"       {
903                   SEMANTIC(( ThisPlace.Tab( 2 ) ));
904                 }
905
906 <CondComment>"*)"       {
907                   BEGIN(INITIAL);
908                   SEMANTIC(( ThisPlace.Select( 2 ) ));
909                 }
910
911 <CondComment>.  {
912                   SEMANTIC(( ThisPlace.Tab( 1 ) ));
913                 }
914
915 %%
916 #ifndef SYNTAX_ONLY
917 void LexAdvanceCursor( int length )
918 {
919
920   if ( !BeginningOfLine )
921     ThisPlace.Advance();
922   ThisPlace.Select( length );
923   BeginningOfLine = 0;
924   ThisPlace;
925 }
926 #endif /* SYNTAX_ONLY */