Subversion Repositories tendra.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
 * Automatically generated from the files:
6 7u83 3
 *	syntax.sid
2 7u83 4
 * and
6 7u83 5
 *	syntax.act
2 7u83 6
 * by:
7
 *	sid
8
 */
9
 
10
/* BEGINNING OF HEADER */
11
 
12
 
13
/*
14
    		 Crown Copyright (c) 1997
15
 
16
    This TenDRA(r) Computer Program is subject to Copyright
17
    owned by the United Kingdom Secretary of State for Defence
18
    acting through the Defence Evaluation and Research Agency
19
    (DERA).  It is made available to Recipients with a
20
    royalty-free licence for its use, reproduction, transfer
21
    to other parties and amendment for any purpose not excluding
22
    product development provided that any such use et cetera
23
    shall be deemed to be acceptance of the following conditions:-
24
 
25
        (1) Its Recipients shall ensure that this Notice is
26
        reproduced upon any copies or amended versions of it;
27
 
28
        (2) Any amended version of it shall be clearly marked to
29
        show both the nature of and the organisation responsible
30
        for the relevant amendment or amendments;
31
 
32
        (3) Its onward transfer from a recipient to another
33
        party shall be deemed to be that party's acceptance of
34
        these conditions;
35
 
36
        (4) DERA gives no warranty or assurance as to its
37
        quality or suitability for any purpose and DERA accepts
38
        no liability whatsoever in relation to any use to which
39
        it may be put.
40
*/
41
 
42
 
43
#include "config.h"
44
#include "char.h"
45
#include "error.h"
46
#include "lex.h"
47
#include "syntax.h"
48
#include "xalloc.h"
49
 
50
 
51
/*
52
    PARSER TYPES
53
 
54
    These types give the implementation of the types used in the syntax.
55
*/
56
 
57
typedef letter *SID_CHARS ;
58
typedef char *SID_STRING ;
59
 
60
 
61
/*
62
    SID IDENTIFIER PREFIX
63
 
64
    This string is added to the start of each sid identifier.
65
*/
66
 
67
char *sid_prefix = "lex_" ;
68
 
69
 
70
/*
71
    CURRENT CONDITIONAL
72
 
73
    This variable is used to record the current conditional.
74
*/
75
 
76
static char *crt_cond = NULL ;
77
 
78
 
79
/*
80
    COMPILATION MODE
81
 
82
    We allow unreached code in the automatically generated sections.
83
*/
84
 
85
#if FS_TENDRA
86
#pragma TenDRA begin
87
#ifndef OLD_PRODUCER
88
#pragma TenDRA unreachable code allow
89
#endif
90
#endif
91
 
92
 
93
 
94
/* BEGINNING OF FUNCTION DECLARATIONS */
95
 
6 7u83 96
static void ZRstring_Hplus(SID_STRING *);
97
static void ZRchars(SID_CHARS *);
98
static void ZRargs(int *);
99
static void ZRtrigraph_Hdefn(void);
100
static void ZR60(SID_STRING *, int *);
101
extern void read_lex(void);
102
static void ZR68(void);
103
static void ZRcommand_Hlist(void);
104
static void ZRkeyword_Hdefn(void);
105
static void ZRif_Hcommand(void);
106
static void ZRcommand(void);
107
static void ZRtoken_Hdefn(void);
2 7u83 108
 
109
/* BEGINNING OF STATIC VARIABLES */
110
 
111
 
112
/* BEGINNING OF FUNCTION DEFINITIONS */
113
 
114
static void
6 7u83 115
ZRstring_Hplus(SID_STRING *ZOs)
2 7u83 116
{
117
    SID_STRING ZIs;
118
 
119
    if ((CURRENT_TERMINAL) == 23) {
120
	return;
121
    }
122
    {
123
	SID_STRING ZIa;
124
 
125
	{
126
	    switch (CURRENT_TERMINAL) {
127
	      case 5:
128
		{
129
		    {
130
 ZIa = "0123456789" ; 
131
		    }
132
		    ADVANCE_LEXER;
133
		}
134
		break;
135
	      case 4:
136
		{
137
		    {
138
 ZIa = "abcdefghijklmnopqrstuvwxyz" ; 
139
		    }
140
		    ADVANCE_LEXER;
141
		}
142
		break;
143
	      case 2:
144
		{
145
		    {
146
 
147
    ZIa = xstrcpy ( token_buff ) ;
148
		    }
149
		    ADVANCE_LEXER;
150
		}
151
		break;
152
	      case 3:
153
		{
154
		    {
155
 ZIa = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; 
156
		    }
157
		    ADVANCE_LEXER;
158
		}
159
		break;
160
	      default:
161
		goto ZL1;
162
	    }
163
	}
164
	{
165
	    switch (CURRENT_TERMINAL) {
166
	      case 20:
167
		{
168
		    SID_STRING ZIb;
169
 
170
		    ADVANCE_LEXER;
171
		    ZRstring_Hplus (&ZIb);
172
		    if ((CURRENT_TERMINAL) == 23) {
173
			RESTORE_LEXER;
174
			goto ZL1;
175
		    }
176
		    {
177
 
178
    (ZIs) = xstrcat ( (ZIa), (ZIb) ) ;
179
		    }
180
		}
181
		break;
182
	      default:
183
		{
184
		    ZIs = ZIa;
185
		}
186
		break;
187
	    }
188
	}
189
    }
190
    goto ZL0;
191
  ZL1:;
192
    SAVE_LEXER (23);
193
    return;
194
  ZL0:;
195
    *ZOs = ZIs;
196
}
197
 
198
static void
6 7u83 199
ZRchars(SID_CHARS *ZOc)
2 7u83 200
{
201
    SID_CHARS ZIc;
202
 
203
    if ((CURRENT_TERMINAL) == 23) {
204
	return;
205
    }
206
    {
207
	SID_STRING ZIs;
208
 
209
	ZRstring_Hplus (&ZIs);
210
	if ((CURRENT_TERMINAL) == 23) {
211
	    RESTORE_LEXER;
212
	    goto ZL1;
213
	}
214
	{
215
 
216
    (ZIc) = make_string ( (ZIs) ) ;
217
	}
218
    }
219
    goto ZL0;
220
  ZL1:;
221
    SAVE_LEXER (23);
222
    return;
223
  ZL0:;
224
    *ZOc = ZIc;
225
}
226
 
227
static void
6 7u83 228
ZRargs(int *ZOa)
2 7u83 229
{
230
    int ZIa;
231
 
232
    switch (CURRENT_TERMINAL) {
233
      case 13:
234
	{
235
	    ADVANCE_LEXER;
236
	    switch (CURRENT_TERMINAL) {
237
	      case 14:
238
		break;
239
	      default:
240
		goto ZL1;
241
	    }
242
	    ADVANCE_LEXER;
243
	    {
244
 (ZIa) = 1 ; 
245
	    }
246
	}
247
	break;
248
      default:
249
	{
250
	    {
251
 (ZIa) = 0 ; 
252
	    }
253
	}
254
	break;
255
      case 23:
256
	return;
257
    }
258
    goto ZL0;
259
  ZL1:;
260
    SAVE_LEXER (23);
261
    return;
262
  ZL0:;
263
    *ZOa = ZIa;
264
}
265
 
266
static void
6 7u83 267
ZRtrigraph_Hdefn(void)
2 7u83 268
{
269
    if ((CURRENT_TERMINAL) == 23) {
270
	return;
271
    }
272
    {
273
	SID_CHARS ZIs;
274
	SID_STRING ZIt;
275
 
276
	switch (CURRENT_TERMINAL) {
277
	  case 8:
278
	    break;
279
	  default:
280
	    goto ZL1;
281
	}
282
	ADVANCE_LEXER;
283
	ZRchars (&ZIs);
284
	switch (CURRENT_TERMINAL) {
285
	  case 17:
286
	    break;
287
	  case 23:
288
	    RESTORE_LEXER;
289
	    goto ZL1;
290
	  default:
291
	    goto ZL1;
292
	}
293
	ADVANCE_LEXER;
294
	ZRstring_Hplus (&ZIt);
295
	if ((CURRENT_TERMINAL) == 23) {
296
	    RESTORE_LEXER;
297
	    goto ZL1;
298
	}
299
	{
300
 
301
    char *data [3] ;
302
    data [0] = (ZIt) ;
303
    data [1] = NULL ;
304
    data [2] = crt_cond ;
305
    add_char ( pre_pass, (ZIs), data ) ;
306
	}
307
    }
308
    return;
309
  ZL1:;
310
    SAVE_LEXER (23);
311
    return;
312
}
313
 
314
static void
6 7u83 315
ZR60(SID_STRING *ZOi, int *ZOa)
2 7u83 316
{
317
    SID_STRING ZIi;
318
    int ZIa;
319
 
320
    switch (CURRENT_TERMINAL) {
321
      case 0:
322
	{
323
	    {
324
 
325
    ZIi = xstrcpy ( token_buff ) ;
326
	    }
327
	    ADVANCE_LEXER;
328
	    ZRargs (&ZIa);
329
	    if ((CURRENT_TERMINAL) == 23) {
330
		RESTORE_LEXER;
331
		goto ZL1;
332
	    }
333
	}
334
	break;
335
      case 1:
336
	{
337
	    {
338
 
339
    int n ;
340
    char *s ;
341
    char buff [1000] ;
342
    strcpy_v ( buff, sid_prefix ) ;
343
    n = ( int ) strlen ( buff ) ;
344
    for ( s = token_buff ; *s ; s++ ) {
345
	if ( *s == '-' ) {
346
	    buff [ n++ ] = '_' ;
347
	    buff [ n++ ] = 'H' ;
348
	} else if ( *s == '_' ) {
349
	    buff [ n++ ] = '_' ;
350
	    buff [ n++ ] = '_' ;
351
	} else {
352
	    buff [ n++ ] = *s ;
353
	}
354
	if ( n >= 900 ) {
355
	    error ( ERROR_SERIOUS, "Identifier too long" ) ;
356
	    break ;
357
	}
358
    }
359
    buff [n] = 0 ;
360
    ZIi = xstrcpy ( buff ) ;
361
	    }
362
	    ADVANCE_LEXER;
363
	    {
364
 (ZIa) = 0 ; 
365
	    }
366
	}
367
	break;
368
      case 23:
369
	return;
370
      default:
371
	goto ZL1;
372
    }
373
    goto ZL0;
374
  ZL1:;
375
    SAVE_LEXER (23);
376
    return;
377
  ZL0:;
378
    *ZOi = ZIi;
379
    *ZOa = ZIa;
380
}
381
 
382
void
6 7u83 383
read_lex(void)
2 7u83 384
{
385
    if ((CURRENT_TERMINAL) == 23) {
386
	return;
387
    }
388
    {
389
	ZRcommand_Hlist ();
390
	{
391
	    if ((CURRENT_TERMINAL) == 23) {
392
		RESTORE_LEXER;
393
		goto ZL1;
394
	    }
395
	    {
396
		switch (CURRENT_TERMINAL) {
397
		  case 18:
398
		    break;
399
		  default:
400
		    goto ZL3;
401
		}
402
		ADVANCE_LEXER;
403
	    }
404
	    goto ZL2;
405
	  ZL3:;
406
	    {
407
		{
408
 
409
    error ( ERROR_SERIOUS, "Syntax error" ) ;
410
		}
411
	    }
412
	  ZL2:;
413
	}
414
    }
415
    return;
416
  ZL1:;
417
    SAVE_LEXER (23);
418
    return;
419
}
420
 
421
static void
6 7u83 422
ZR68(void)
2 7u83 423
{
424
    switch (CURRENT_TERMINAL) {
425
      case 0:
426
	{
427
	    SID_STRING ZIi;
428
	    SID_CHARS ZIs;
429
 
430
	    {
431
 
432
    ZIi = xstrcpy ( token_buff ) ;
433
	    }
434
	    ADVANCE_LEXER;
435
	    switch (CURRENT_TERMINAL) {
436
	      case 19:
437
		break;
438
	      default:
439
		goto ZL1;
440
	    }
441
	    ADVANCE_LEXER;
442
	    ZRchars (&ZIs);
443
	    if ((CURRENT_TERMINAL) == 23) {
444
		RESTORE_LEXER;
445
		goto ZL1;
446
	    }
447
	    {
448
 
449
    make_group ( (ZIi), (ZIs) ) ;
450
	    }
451
	    switch (CURRENT_TERMINAL) {
452
	      case 21:
453
		break;
454
	      default:
455
		goto ZL1;
456
	    }
457
	    ADVANCE_LEXER;
458
	}
459
	break;
460
      case 10:
461
	{
462
	    SID_CHARS ZIs;
463
 
464
	    ADVANCE_LEXER;
465
	    switch (CURRENT_TERMINAL) {
466
	      case 19:
467
		break;
468
	      default:
469
		goto ZL1;
470
	    }
471
	    ADVANCE_LEXER;
472
	    ZRchars (&ZIs);
473
	    if ((CURRENT_TERMINAL) == 23) {
474
		RESTORE_LEXER;
475
		goto ZL1;
476
	    }
477
	    {
478
 
479
    if ( white_space ) {
480
	error ( ERROR_SERIOUS, "White space group already defined" ) ;
481
    }
482
    white_space = (ZIs) ;
483
	    }
484
	    switch (CURRENT_TERMINAL) {
485
	      case 21:
486
		break;
487
	      default:
488
		goto ZL1;
489
	    }
490
	    ADVANCE_LEXER;
491
	}
492
	break;
493
      case 23:
494
	return;
495
      default:
496
	goto ZL1;
497
    }
498
    return;
499
  ZL1:;
500
    SAVE_LEXER (23);
501
    return;
502
}
503
 
504
static void
6 7u83 505
ZRcommand_Hlist(void)
2 7u83 506
{
507
  ZL2_command_Hlist:;
508
    switch (CURRENT_TERMINAL) {
509
      case 6: case 7: case 8: case 9: case 11:
510
      case 15: case 21:
511
	{
512
	    ZRcommand ();
513
	    if ((CURRENT_TERMINAL) == 23) {
514
		RESTORE_LEXER;
515
		goto ZL1;
516
	    } else {
517
		goto ZL2_command_Hlist;
518
	    }
519
	}
520
	/*UNREACHED*/
521
      case 23:
522
	return;
523
      default:
524
	break;
525
    }
526
    return;
527
  ZL1:;
528
    {
529
	{
530
 
531
    error ( ERROR_SERIOUS, "Syntax error" ) ;
532
	}
533
    }
534
}
535
 
536
static void
6 7u83 537
ZRkeyword_Hdefn(void)
2 7u83 538
{
539
    if ((CURRENT_TERMINAL) == 23) {
540
	return;
541
    }
542
    {
543
	SID_STRING ZIs;
544
	SID_STRING ZIi;
545
	int ZIa;
546
 
547
	switch (CURRENT_TERMINAL) {
548
	  case 7:
549
	    break;
550
	  default:
551
	    goto ZL1;
552
	}
553
	ADVANCE_LEXER;
554
	switch (CURRENT_TERMINAL) {
555
	  case 2:
556
	    {
557
 
558
    ZIs = xstrcpy ( token_buff ) ;
559
	    }
560
	    break;
561
	  default:
562
	    goto ZL1;
563
	}
564
	ADVANCE_LEXER;
565
	switch (CURRENT_TERMINAL) {
566
	  case 17:
567
	    break;
568
	  default:
569
	    goto ZL1;
570
	}
571
	ADVANCE_LEXER;
572
	ZR60 (&ZIi, &ZIa);
573
	if ((CURRENT_TERMINAL) == 23) {
574
	    RESTORE_LEXER;
575
	    goto ZL1;
576
	}
577
	{
578
 
579
    char *data [3] ;
580
    data [0] = (ZIi) ;
581
    data [1] = ( (ZIa) ? "()" : NULL ) ;
582
    data [2] = crt_cond ;
583
    add_keyword ( (ZIs), data ) ;
584
	}
585
    }
586
    return;
587
  ZL1:;
588
    SAVE_LEXER (23);
589
    return;
590
}
591
 
592
static void
6 7u83 593
ZRif_Hcommand(void)
2 7u83 594
{
595
    if ((CURRENT_TERMINAL) == 23) {
596
	return;
597
    }
598
    {
599
	SID_STRING ZIi;
600
	SID_STRING ZIj;
601
 
602
	switch (CURRENT_TERMINAL) {
603
	  case 11:
604
	    break;
605
	  default:
606
	    goto ZL1;
607
	}
608
	ADVANCE_LEXER;
609
	switch (CURRENT_TERMINAL) {
610
	  case 13:
611
	    break;
612
	  default:
613
	    goto ZL1;
614
	}
615
	ADVANCE_LEXER;
616
	switch (CURRENT_TERMINAL) {
617
	  case 0:
618
	    {
619
 
620
    ZIi = xstrcpy ( token_buff ) ;
621
	    }
622
	    break;
623
	  default:
624
	    goto ZL1;
625
	}
626
	ADVANCE_LEXER;
627
	switch (CURRENT_TERMINAL) {
628
	  case 14:
629
	    break;
630
	  default:
631
	    goto ZL1;
632
	}
633
	ADVANCE_LEXER;
634
	{
635
 
636
    (ZIj) = crt_cond ;
637
	}
638
	{
639
 
640
    if ( crt_cond ) {
641
	crt_cond = xstrcat ( crt_cond, xstrcat ( " && ", (ZIi) ) ) ;
642
    } else {
643
	crt_cond = (ZIi) ;
644
    }
645
	}
646
	ZRcommand ();
647
	{
648
	    if ((CURRENT_TERMINAL) == 23) {
649
		RESTORE_LEXER;
650
		goto ZL1;
651
	    }
652
	    {
653
		switch (CURRENT_TERMINAL) {
654
		  case 12:
655
		    break;
656
		  default:
657
		    goto ZL3;
658
		}
659
		ADVANCE_LEXER;
660
		{
661
 
662
    if ( crt_cond ) {
663
	if ( strchr ( crt_cond, '&' ) ) {
664
	    crt_cond = xstrcat ( xstrcat ( "!( ", crt_cond ), " )" ) ;
665
	} else {
666
	    crt_cond = xstrcat ( "!", crt_cond ) ;
667
	}
668
    }
669
		}
670
		ZRcommand ();
671
		if ((CURRENT_TERMINAL) == 23) {
672
		    RESTORE_LEXER;
673
		    goto ZL3;
674
		}
675
		{
676
 
677
    crt_cond = (ZIj) ;
678
		}
679
	    }
680
	    goto ZL2;
681
	  ZL3:;
682
	    {
683
		{
684
 
685
    crt_cond = (ZIj) ;
686
		}
687
	    }
688
	  ZL2:;
689
	}
690
    }
691
    return;
692
  ZL1:;
693
    SAVE_LEXER (23);
694
    return;
695
}
696
 
697
static void
6 7u83 698
ZRcommand(void)
2 7u83 699
{
700
    switch (CURRENT_TERMINAL) {
701
      case 6:
702
	{
703
	    ADVANCE_LEXER;
704
	    ZR68 ();
705
	    if ((CURRENT_TERMINAL) == 23) {
706
		RESTORE_LEXER;
707
		goto ZL1;
708
	    }
709
	}
710
	break;
711
      case 15:
712
	{
713
	    ADVANCE_LEXER;
714
	    ZRcommand_Hlist ();
715
	    switch (CURRENT_TERMINAL) {
716
	      case 16:
717
		break;
718
	      case 23:
719
		RESTORE_LEXER;
720
		goto ZL1;
721
	      default:
722
		goto ZL1;
723
	    }
724
	    ADVANCE_LEXER;
725
	}
726
	break;
727
      case 21:
728
	{
729
	    ADVANCE_LEXER;
730
	}
731
	break;
732
      case 11:
733
	{
734
	    ZRif_Hcommand ();
735
	    if ((CURRENT_TERMINAL) == 23) {
736
		RESTORE_LEXER;
737
		goto ZL1;
738
	    }
739
	}
740
	break;
741
      case 7:
742
	{
743
	    ZRkeyword_Hdefn ();
744
	    switch (CURRENT_TERMINAL) {
745
	      case 21:
746
		break;
747
	      case 23:
748
		RESTORE_LEXER;
749
		goto ZL1;
750
	      default:
751
		goto ZL1;
752
	    }
753
	    ADVANCE_LEXER;
754
	}
755
	break;
756
      case 9:
757
	{
758
	    ZRtoken_Hdefn ();
759
	    switch (CURRENT_TERMINAL) {
760
	      case 21:
761
		break;
762
	      case 23:
763
		RESTORE_LEXER;
764
		goto ZL1;
765
	      default:
766
		goto ZL1;
767
	    }
768
	    ADVANCE_LEXER;
769
	}
770
	break;
771
      case 8:
772
	{
773
	    ZRtrigraph_Hdefn ();
774
	    switch (CURRENT_TERMINAL) {
775
	      case 21:
776
		break;
777
	      case 23:
778
		RESTORE_LEXER;
779
		goto ZL1;
780
	      default:
781
		goto ZL1;
782
	    }
783
	    ADVANCE_LEXER;
784
	}
785
	break;
786
      case 23:
787
	return;
788
      default:
789
	goto ZL1;
790
    }
791
    return;
792
  ZL1:;
793
    SAVE_LEXER (23);
794
    return;
795
}
796
 
797
static void
6 7u83 798
ZRtoken_Hdefn(void)
2 7u83 799
{
800
    if ((CURRENT_TERMINAL) == 23) {
801
	return;
802
    }
803
    {
804
	SID_CHARS ZIs;
805
	SID_STRING ZIi;
806
	int ZIa;
807
 
808
	switch (CURRENT_TERMINAL) {
809
	  case 9:
810
	    break;
811
	  default:
812
	    goto ZL1;
813
	}
814
	ADVANCE_LEXER;
815
	ZRchars (&ZIs);
816
	switch (CURRENT_TERMINAL) {
817
	  case 17:
818
	    break;
819
	  case 23:
820
	    RESTORE_LEXER;
821
	    goto ZL1;
822
	  default:
823
	    goto ZL1;
824
	}
825
	ADVANCE_LEXER;
826
	ZR60 (&ZIi, &ZIa);
827
	if ((CURRENT_TERMINAL) == 23) {
828
	    RESTORE_LEXER;
829
	    goto ZL1;
830
	}
831
	{
832
 
833
    char *data [3] ;
834
    data [0] = (ZIi) ;
835
    data [1] = ( (ZIa) ? "()" : NULL ) ;
836
    data [2] = crt_cond ;
837
    add_char ( main_pass, (ZIs), data ) ;
838
	}
839
    }
840
    return;
841
  ZL1:;
842
    SAVE_LEXER (23);
843
    return;
844
}
845
 
846
/* BEGINNING OF TRAILER */
847
 
848
 
849
 
850
/* END OF FILE */