1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
|
host( "working/keller1.rl", 1 ) @{/*
* @@LANG: c++
*/
/*
* Automatically generated by keller. Do not edit.
*
* Parts of this file are copied from Keller source covered by the GNU
* GPL. As a special exception, you may use the parts of this file copied
* from Keller source without restriction. The remainder is derived from
* "tmp.gmr" and inherits the copyright status of that file.
*/
#line 1 "tmp.gmr"
#include <iostream>
using std::cout;
using std::endl;
#line 16 "tmp.rl"
enum token_type_e {
tt_id,
tt_equals,
tt_semi,
tt_pipe,
tt_amp,
tt_minus,
tt_dot,
tt_colon,
tt_percent,
tt_dollar,
tt_plus,
tt_number,
tt_star,
tt_question,
tt_not,
tt_andFSM,
tt_orFSM,
tt_open,
tt_close
};
struct LangEl
{
int line, lineEnd;
int pos;
int type;
int state;
LangEl *prev, *next;
};
struct Token : public LangEl
{
const char *value;
};
struct Lel_start : public LangEl
{
#line 32 "tmp.gmr"
int si;
#line 59 "tmp.rl"
};
struct Lel_M : public LangEl
{
#line 36 "tmp.gmr"
int mi;
#line 67 "tmp.rl"
};
#define l__error 19
#define l_tt_id 0
#define l_tt_equals 1
#define l_tt_semi 2
#define l_tt_pipe 3
#define l_tt_amp 4
#define l_tt_minus 5
#define l_tt_dot 6
#define l_tt_colon 7
#define l_tt_percent 8
#define l_tt_dollar 9
#define l_tt_plus 10
#define l_tt_number 11
#define l_tt_star 12
#define l_tt_question 13
#define l_tt_not 14
#define l_tt_andFSM 15
#define l_tt_orFSM 16
#define l_tt_open 17
#define l_tt_close 18
#define l_start 23
#define l_M 24
#define l_A 25
#define l_E 26
#define l_T 27
#define l_N 28
#define l_K 29
#define l_F 30
#define l__start 31
#define l__eof 20
struct LangEl;
struct Parser
{
Parser();
void parseLangEl( LangEl *langEl );
int done( );
void push( LangEl *lel ) {
lel->prev = stack;
stack = lel;
}
LangEl *pop() {
LangEl *ret = stack;
stack = stack->prev;
return ret;
}
int pop( int n );
void rem( LangEl *lel, int n );
LangEl *stack;
int next;
LangEl *redLel;
LangEl *rhs[10];
int cs;
// Initialize the machine. Invokes any init statement blocks. Returns 0
// if the machine begins in a non-accepting state and 1 if the machine
// begins in an accepting state.
int init( );
// Execute the machine on a block of data. Returns -1 if after processing
// the data, the machine is in the error state and can never accept, 0 if
// the machine is in a non-accepting state and 1 if the machine is in an
// accepting state.
int execute( LangEl *data, int len );
// Indicate that there is no more data. Returns -1 if the machine finishes
// in the error state and does not accept, 0 if the machine finishes
// in any other non-accepting state and 1 if the machine finishes in an
// accepting state.
int finish( );
};
}@
array s8 _Parser_actions( 0, 49 ) = { 0, 1, 0, 4, 1, 5, 17, 13, 4, 1, 6, 19, 13, 4, 1, 8, 24, 13, 4, 1, 9, 27, 13, 4, 1, 10, 37, 13, 4, 1, 11, 41, 13, 4, 1, 12, 46, 13, 4, 1, 12, 47, 13, 4, 1, 12, 48, 13, 4, 2, 6, 18, 14, 4, 2, 9, 26, 14, 4, 2, 11, 38, 14, 4, 2, 11, 39, 14, 4, 2, 11, 40, 14, 4, 2, 11, 45, 14, 4, 3, 8, 21, 15, 4, 3, 8, 22, 15, 4, 3, 8, 23, 15, 4, 3, 9, 25, 15, 4, 3, 10, 28, 15, 4, 3, 10, 29, 15, 4, 3, 10, 30, 15, 4, 3, 11, 42, 15, 4, 3, 11, 43, 15, 4, 3, 11, 44, 15, 4, 3, 12, 49, 15, 4, 4, 7, 20, 16, 4, 4, 10, 31, 16, 4, 4, 10, 32, 16, 4, 4, 10, 33, 16, 4, 4, 10, 34, 16, 4, 4, 10, 35, 16, 4, 4, 10, 36, 16, 0 };
array char _Parser_trans_keys( 0, 28 ) = { 1, 0, 0, 23, 1, 1, 0, 28, 0, 18, 0, 28, 0, 18, 0, 18, 0, 28, 3, 18, 0, 28, 0, 28, 0, 28, 0, 18, 0, 10, 0, 18, 11, 11, 0, 18, 11, 11, 0, 18, 0, 10, 0, 18, 11, 11, 0, 18, 11, 11, 0, 18, 0, 10, 0, 18, 11, 11, 0, 18, 11, 11, 0, 18, 0, 18, 0, 18, 0, 18, 0, 18, 0, 18, 0, 18, 0, 18, 0, 28, 0, 28, 0, 28, 0, 28, 0, 18, 0, 28, 0, 18, 0, 18, 0, 18, 0, 18, 2, 5, 0, 20, 20, 20, 0, 23, 0, 20, 0, 20, 1, 0, 0 };
array s8 _Parser_char_class( 0, 28 ) = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 19, 21, 22, 23, 24, 25, 26, 27, 28, 0 };
array s16 _Parser_index_offsets( 0, 966 ) = { 0, 0, 24, 25, 54, 73, 102, 121, 140, 169, 185, 214, 243, 272, 291, 302, 321, 322, 341, 342, 361, 372, 391, 392, 411, 412, 431, 442, 461, 462, 481, 482, 501, 520, 539, 558, 577, 596, 615, 634, 663, 692, 721, 750, 769, 798, 817, 836, 855, 874, 878, 899, 900, 924, 945, 966, 0 };
array s8 _Parser_indices( 0, 87 ) = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 7, 8, 9, 10, 1, 1, 1, 1, 1, 1, 11, 12, 13, 14, 15, 16, 1, 16, 16, 16, 16, 16, 16, 16, 16, 16, 1, 16, 16, 16, 16, 16, 16, 16, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8, 9, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 17, 18, 1, 18, 18, 18, 18, 18, 18, 18, 18, 18, 1, 18, 18, 18, 18, 18, 18, 18, 19, 1, 19, 19, 19, 19, 19, 19, 19, 19, 19, 1, 19, 19, 19, 19, 19, 19, 19, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 7, 8, 9, 10, 1, 1, 1, 1, 1, 1, 20, 12, 13, 14, 15, 21, 22, 23, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 24, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 7, 8, 9, 10, 1, 1, 1, 1, 1, 1, 1, 25, 13, 14, 15, 6, 1, 26, 26, 26, 26, 27, 1, 1, 1, 1, 1, 1, 1, 7, 8, 9, 10, 26, 1, 1, 1, 1, 1, 1, 1, 28, 14, 15, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 7, 8, 9, 10, 1, 1, 1, 1, 1, 1, 1, 1, 29, 14, 15, 30, 1, 30, 30, 30, 30, 30, 31, 32, 33, 1, 1, 1, 1, 30, 30, 30, 30, 30, 34, 1, 1, 1, 1, 35, 1, 1, 1, 1, 36, 37, 1, 37, 37, 37, 37, 37, 37, 37, 37, 1, 1, 1, 1, 37, 37, 37, 37, 37, 38, 39, 1, 39, 39, 39, 39, 39, 39, 39, 39, 1, 1, 1, 1, 39, 39, 39, 39, 39, 40, 41, 1, 41, 41, 41, 41, 41, 41, 41, 41, 1, 1, 1, 1, 41, 41, 41, 41, 41, 42, 1, 1, 1, 1, 43, 1, 1, 1, 1, 44, 45, 1, 45, 45, 45, 45, 45, 45, 45, 45, 1, 1, 1, 1, 45, 45, 45, 45, 45, 46, 47, 1, 47, 47, 47, 47, 47, 47, 47, 47, 1, 1, 1, 1, 47, 47, 47, 47, 47, 48, 49, 1, 49, 49, 49, 49, 49, 49, 49, 49, 1, 1, 1, 1, 49, 49, 49, 49, 49, 50, 1, 1, 1, 1, 51, 1, 1, 1, 1, 52, 53, 1, 53, 53, 53, 53, 53, 53, 53, 53, 1, 1, 1, 1, 53, 53, 53, 53, 53, 54, 55, 1, 55, 55, 55, 55, 55, 55, 55, 55, 1, 1, 1, 1, 55, 55, 55, 55, 55, 56, 57, 1, 57, 57, 57, 57, 57, 57, 57, 57, 1, 1, 1, 1, 57, 57, 57, 57, 57, 58, 1, 58, 58, 58, 58, 58, 58, 58, 58, 1, 1, 1, 1, 58, 58, 58, 58, 58, 59, 1, 59, 59, 59, 59, 59, 59, 59, 59, 60, 1, 61, 62, 59, 59, 59, 59, 59, 63, 1, 63, 63, 63, 63, 63, 63, 63, 63, 1, 1, 1, 1, 63, 63, 63, 63, 63, 64, 1, 64, 64, 64, 64, 64, 64, 64, 64, 1, 1, 1, 1, 64, 64, 64, 64, 64, 65, 1, 65, 65, 65, 65, 65, 65, 65, 65, 1, 1, 1, 1, 65, 65, 65, 65, 65, 66, 1, 66, 66, 66, 66, 66, 31, 32, 33, 1, 1, 1, 1, 66, 66, 66, 66, 66, 67, 1, 67, 67, 67, 67, 67, 31, 32, 33, 1, 1, 1, 1, 67, 67, 67, 67, 67, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 7, 8, 9, 10, 1, 1, 1, 1, 1, 1, 1, 68, 13, 14, 15, 6, 1, 69, 69, 69, 69, 27, 1, 1, 1, 1, 1, 1, 1, 7, 8, 9, 10, 69, 1, 1, 1, 1, 1, 1, 1, 28, 14, 15, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 7, 8, 9, 10, 1, 1, 1, 1, 1, 1, 1, 70, 13, 14, 15, 6, 1, 71, 71, 71, 71, 27, 1, 1, 1, 1, 1, 1, 1, 7, 8, 9, 10, 71, 1, 1, 1, 1, 1, 1, 1, 28, 14, 15, 72, 1, 72, 72, 72, 72, 72, 72, 72, 72, 72, 1, 72, 72, 72, 72, 72, 72, 72, 6, 1, 73, 73, 73, 73, 27, 1, 1, 1, 1, 1, 1, 1, 7, 8, 9, 10, 73, 1, 1, 1, 1, 1, 1, 1, 28, 14, 15, 74, 1, 74, 74, 74, 74, 74, 74, 74, 74, 75, 1, 76, 77, 74, 74, 74, 74, 74, 78, 1, 78, 78, 78, 78, 78, 78, 78, 78, 1, 1, 1, 1, 78, 78, 78, 78, 78, 79, 1, 79, 79, 79, 79, 79, 79, 79, 79, 1, 1, 1, 1, 79, 79, 79, 79, 79, 80, 1, 80, 80, 80, 80, 80, 80, 80, 80, 1, 1, 1, 1, 80, 80, 80, 80, 80, 81, 21, 22, 23, 82, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 82, 83, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 84, 1, 1, 85, 86, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 86, 87, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 87, 0 };
array s8 _Parser_index_defaults( 0, 1 ) = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 };
array s8 _Parser_trans_cond_spaces( -1, 0 ) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0 };
array s8 _Parser_cond_targs( 0, 55 ) = { 2, 0, 51, 52, 54, 3, 4, 5, 6, 7, 8, 49, 44, 38, 32, 33, 55, 45, 55, 55, 9, 10, 39, 41, 43, 11, 55, 12, 37, 13, 55, 14, 20, 26, 15, 16, 18, 55, 17, 55, 19, 55, 21, 22, 24, 55, 23, 55, 25, 55, 27, 28, 30, 55, 29, 55, 31, 55, 55, 55, 34, 35, 36, 55, 55, 55, 55, 55, 40, 55, 42, 55, 55, 55, 55, 46, 47, 48, 55, 55, 55, 50, 55, 55, 55, 53, 55, 55, 0 };
array s16 _Parser_cond_actions( 0, 163 ) = { 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 43, 1, 33, 38, 1, 1, 1, 1, 1, 1, 78, 1, 1, 1, 93, 1, 1, 1, 1, 1, 1, 98, 1, 143, 1, 138, 1, 1, 1, 103, 1, 153, 1, 148, 1, 1, 1, 108, 1, 163, 1, 158, 23, 28, 1, 1, 1, 68, 58, 63, 53, 18, 1, 83, 1, 88, 128, 13, 73, 1, 1, 1, 123, 113, 118, 1, 133, 1, 3, 1, 48, 8, 0 };
array s8 _Parser_nfa_targs( 0, 0 ) = { 0, 0 };
array s8 _Parser_nfa_offsets( 0, 0 ) = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
array s8 _Parser_nfa_push_actions( 0, 0 ) = { 0, 0 };
array s8 _Parser_nfa_pop_trans( 0, 0 ) = { 0, 0 };
value int Parser_start = 1;
value int Parser_first_final = 55;
value int Parser_error = 0;
value int Parser_en_main = 1;
host( "working/keller1.rl", 756 ) @{
Parser::Parser( )
{ }
int Parser::init( )
{
}@
{
cs = cast(int)Parser_start;
}
host( "working/keller1.rl", 763 ) @{
return 0;
}
int Parser::execute( LangEl *_data, int _len )
{
LangEl *p = _data;
LangEl *pe = _data+_len;
}@
{
int _ps;
int _trans = 0;
index s8 _acts;
uint _nacts;
index char _keys;
index s8 _inds;
entry {
if ( p == pe )
goto _test_eof;
if ( cs == 0 )
goto _out;
label _resume {
_keys = offset( _Parser_trans_keys, (cs<<1) );
_inds = offset( _Parser_indices, _Parser_index_offsets[cs] );
if ( host( "-", 1 ) ={p->type}= <= 30 && host( "-", 1 ) ={p->type}= >= 0 )
{
int _ic = cast(int)_Parser_char_class[cast(int)host( "-", 1 ) ={p->type}= - 0];
if ( _ic <= cast(int)deref( _Parser_trans_keys, _keys+1 ) && _ic >= cast(int)deref( _Parser_trans_keys, _keys ) )
_trans = cast(int)deref( _Parser_indices, _inds + cast(int)( _ic - cast(int)deref( _Parser_trans_keys, _keys ) ) );
else
_trans = cast(int)_Parser_index_defaults[cs];
}
else {
_trans = cast(int)_Parser_index_defaults[cs];
}
goto _match_cond;
}
label _match_cond {
_ps = cs;
cs = cast(int)_Parser_cond_targs[_trans];
if ( _Parser_cond_actions[_trans] == 0 )
goto _again;
_acts = offset( _Parser_actions, _Parser_cond_actions[_trans] );
_nacts = cast(uint)deref( _Parser_actions, _acts );
_acts += 1;
while ( _nacts > 0 ) {
switch ( deref( _Parser_actions, _acts ) )
{
case 0 {
host( "working/keller1.rl", 156 ) ${
p->state = ={_ps}=;
push( p );
}$
}
case 1 {
host( "working/keller1.rl", 161 ) ${ ${cs = host( "-", 1 ) ={pop(1)}=;}$ }$
}
case 2 {
host( "working/keller1.rl", 162 ) ${ ${cs = host( "-", 1 ) ={pop(2)}=;}$ }$
}
case 3 {
host( "working/keller1.rl", 163 ) ${ ${cs = host( "-", 1 ) ={pop(3)}=;}$ }$
}
case 4 {
host( "working/keller1.rl", 164 ) ${ ${cs = host( "-", 1 ) ={pop(4)}=;}$ }$
}
case 5 {
host( "working/keller1.rl", 171 ) ${
redLel = new Lel_start();
redLel->type = 23;
}$
}
case 6 {
host( "working/keller1.rl", 176 ) ${
redLel = new Lel_M();
redLel->type = 24;
}$
}
case 7 {
host( "working/keller1.rl", 181 ) ${
redLel = new LangEl();
redLel->type = 25;
}$
}
case 8 {
host( "working/keller1.rl", 186 ) ${
redLel = new LangEl();
redLel->type = 26;
}$
}
case 9 {
host( "working/keller1.rl", 191 ) ${
redLel = new LangEl();
redLel->type = 27;
}$
}
case 10 {
host( "working/keller1.rl", 196 ) ${
redLel = new LangEl();
redLel->type = 28;
}$
}
case 11 {
host( "working/keller1.rl", 201 ) ${
redLel = new LangEl();
redLel->type = 29;
}$
}
case 12 {
host( "working/keller1.rl", 206 ) ${
redLel = new LangEl();
redLel->type = 30;
}$
}
case 13 {
host( "working/keller1.rl", 226 ) ${ rem(p, 1); }$
}
case 14 {
host( "working/keller1.rl", 227 ) ${ rem(p, 2); }$
}
case 15 {
host( "working/keller1.rl", 228 ) ${ rem(p, 3); }$
}
case 16 {
host( "working/keller1.rl", 229 ) ${ rem(p, 4); }$
}
case 17 {
host( "working/keller1.rl", 232 ) ${
#line 41 "tmp.gmr"
cout << "start = M;" << endl;
static_cast<Lel_start*>(redLel)->si = static_cast<Lel_M*>(rhs[0])->mi;
#line 214 "tmp.rl"
}$
}
case 18 {
host( "working/keller1.rl", 242 ) ${
#line 44 "tmp.gmr"
cout << "M = M A;" << endl;
#line 221 "tmp.rl"
}$
}
case 19 {
host( "working/keller1.rl", 249 ) ${
#line 45 "tmp.gmr"
cout << "M = A;" << endl;
#line 228 "tmp.rl"
}$
}
case 20 {
host( "working/keller1.rl", 256 ) ${
#line 46 "tmp.gmr"
cout << "A = tt_id tt_equals E tt_semi;" << endl;
#line 235 "tmp.rl"
}$
}
case 21 {
host( "working/keller1.rl", 263 ) ${
#line 47 "tmp.gmr"
cout << "E = E tt_pipe T;" << endl;
#line 242 "tmp.rl"
}$
}
case 22 {
host( "working/keller1.rl", 270 ) ${
#line 48 "tmp.gmr"
cout << "E = E tt_amp T;" << endl;
#line 249 "tmp.rl"
}$
}
case 23 {
host( "working/keller1.rl", 277 ) ${
#line 49 "tmp.gmr"
cout << "E = E tt_minus T;" << endl;
#line 256 "tmp.rl"
}$
}
case 24 {
host( "working/keller1.rl", 284 ) ${
#line 50 "tmp.gmr"
cout << "E = T;" << endl;
#line 263 "tmp.rl"
}$
}
case 25 {
host( "working/keller1.rl", 291 ) ${
#line 51 "tmp.gmr"
cout << "T = T tt_dot N;" << endl;
#line 270 "tmp.rl"
}$
}
case 26 {
host( "working/keller1.rl", 298 ) ${
#line 52 "tmp.gmr"
cout << "T = T N;" << endl;
#line 277 "tmp.rl"
}$
}
case 27 {
host( "working/keller1.rl", 305 ) ${
#line 53 "tmp.gmr"
cout << "T = N;" << endl;
#line 284 "tmp.rl"
}$
}
case 28 {
host( "working/keller1.rl", 312 ) ${
#line 54 "tmp.gmr"
cout << "N = N tt_colon tt_id;" << endl;
#line 291 "tmp.rl"
}$
}
case 29 {
host( "working/keller1.rl", 319 ) ${
#line 55 "tmp.gmr"
cout << "N = N tt_percent tt_id;" << endl;
#line 298 "tmp.rl"
}$
}
case 30 {
host( "working/keller1.rl", 326 ) ${
#line 56 "tmp.gmr"
cout << "N = N tt_dollar tt_id;" << endl;
#line 305 "tmp.rl"
}$
}
case 31 {
host( "working/keller1.rl", 333 ) ${
#line 57 "tmp.gmr"
cout << "N = N tt_colon tt_plus tt_number;" << endl;
#line 312 "tmp.rl"
}$
}
case 32 {
host( "working/keller1.rl", 340 ) ${
#line 58 "tmp.gmr"
cout << "N = N tt_colon tt_minus tt_number;" << endl;
#line 319 "tmp.rl"
}$
}
case 33 {
host( "working/keller1.rl", 347 ) ${
#line 59 "tmp.gmr"
cout << "N = N tt_percent tt_plus tt_number;" << endl;
#line 326 "tmp.rl"
}$
}
case 34 {
host( "working/keller1.rl", 354 ) ${
#line 60 "tmp.gmr"
cout << "N = N tt_percent tt_minus tt_number;" << endl;
#line 333 "tmp.rl"
}$
}
case 35 {
host( "working/keller1.rl", 361 ) ${
#line 61 "tmp.gmr"
cout << "N = N tt_dollar tt_plus tt_number;" << endl;
#line 340 "tmp.rl"
}$
}
case 36 {
host( "working/keller1.rl", 368 ) ${
#line 62 "tmp.gmr"
cout << "N = N tt_dollar tt_minus tt_number;" << endl;
#line 347 "tmp.rl"
}$
}
case 37 {
host( "working/keller1.rl", 375 ) ${
#line 63 "tmp.gmr"
cout << "N = K;" << endl;
#line 354 "tmp.rl"
}$
}
case 38 {
host( "working/keller1.rl", 382 ) ${
#line 64 "tmp.gmr"
cout << "K = F tt_star;" << endl;
#line 361 "tmp.rl"
}$
}
case 39 {
host( "working/keller1.rl", 389 ) ${
#line 65 "tmp.gmr"
cout << "K = F tt_question;" << endl;
#line 368 "tmp.rl"
}$
}
case 40 {
host( "working/keller1.rl", 396 ) ${
#line 66 "tmp.gmr"
cout << "K = F tt_plus;" << endl;
#line 375 "tmp.rl"
}$
}
case 41 {
host( "working/keller1.rl", 403 ) ${
#line 67 "tmp.gmr"
cout << "K = F;" << endl;
#line 382 "tmp.rl"
}$
}
case 42 {
host( "working/keller1.rl", 410 ) ${
#line 68 "tmp.gmr"
cout << "K = tt_not F tt_star;" << endl;
#line 389 "tmp.rl"
}$
}
case 43 {
host( "working/keller1.rl", 417 ) ${
#line 69 "tmp.gmr"
cout << "K = tt_not F tt_question;" << endl;
#line 396 "tmp.rl"
}$
}
case 44 {
host( "working/keller1.rl", 424 ) ${
#line 70 "tmp.gmr"
cout << "K = tt_not F tt_plus;" << endl;
#line 403 "tmp.rl"
}$
}
case 45 {
host( "working/keller1.rl", 431 ) ${
#line 71 "tmp.gmr"
cout << "K = tt_not F;" << endl;
#line 410 "tmp.rl"
}$
}
case 46 {
host( "working/keller1.rl", 438 ) ${
#line 72 "tmp.gmr"
cout << "F = tt_andFSM;" << endl;
#line 417 "tmp.rl"
}$
}
case 47 {
host( "working/keller1.rl", 445 ) ${
#line 73 "tmp.gmr"
cout << "F = tt_orFSM;" << endl;
#line 424 "tmp.rl"
}$
}
case 48 {
host( "working/keller1.rl", 452 ) ${
#line 74 "tmp.gmr"
cout << "F = tt_id;" << endl;
#line 431 "tmp.rl"
}$
}
case 49 {
host( "working/keller1.rl", 459 ) ${
#line 75 "tmp.gmr"
cout << "F = tt_open E tt_close;" << endl;
#line 438 "tmp.rl"
}$
}
}
_nacts -= 1;
_acts += 1;
}
}
label _again {
if ( cs == 0 )
goto _out;
p += 1;
if ( p != pe )
goto _resume;
}
label _test_eof { {}
}
label _out { {}
}
}
}
host( "working/keller1.rl", 771 ) @{
if ( cs == Parser_error )
return -1;
if ( cs >= Parser_first_final )
return 1;
return 0;
}
int Parser::finish( )
{
if ( cs == Parser_error )
return -1;
if ( cs >= Parser_first_final )
return 1;
return 0;
}
void Parser::parseLangEl( LangEl *lel )
{
redLel = 0;
execute( lel, 1 );
while ( redLel != 0 ) {
execute( redLel, 1 );
redLel = 0;
execute( lel, 1 );
}
}
int Parser::pop( int n )
{
for ( int i = n-1; i >= 0; i-- )
rhs[i] = pop();
return rhs[0]->state;
}
void Parser::rem( LangEl *lel, int n )
{
for ( int i = n-1; i >= 0; i-- )
delete rhs[i];
}
int Parser::done( )
{
Token *eof = new Token;
eof->type = l__eof;
eof->line = 0;
eof->pos = 0;
parseLangEl( eof );
return finish();
}
#line 77 "tmp.gmr"
#include <assert.h>
#define MAX_TOKS 10000
struct TokList
{
TokList() : numToks(0) { }
void append( int type );
int parse();
Token *toks[MAX_TOKS];
int numToks;
};
void TokList::append( int type )
{
assert( numToks < MAX_TOKS );
toks[numToks] = new Token;
toks[numToks]->type = type;
numToks += 1;
}
int TokList::parse()
{
Parser parser;
parser.init();
for ( int i = 0; i < numToks; i++ )
parser.parseLangEl( toks[i] );
return parser.done();
}
void test0()
{
TokList tokList;
tokList.append( tt_id );
tokList.append( tt_equals );
tokList.append( tt_id );
tokList.append( tt_star );
tokList.append( tt_minus );
tokList.append( tt_andFSM );
tokList.append( tt_dot );
tokList.append( tt_id );
tokList.append( tt_semi );
tokList.append( tt_id );
tokList.append( tt_equals );
tokList.append( tt_id );
tokList.append( tt_andFSM );
tokList.append( tt_id );
tokList.append( tt_semi );
cout << tokList.parse() << endl;
}
void test1()
{
TokList tokList;
tokList.append( tt_id );
tokList.append( tt_equals );
tokList.append( tt_open );
tokList.append( tt_orFSM );
tokList.append( tt_minus );
tokList.append( tt_andFSM );
tokList.append( tt_close );
tokList.append( tt_star );
tokList.append( tt_semi );
cout << tokList.parse() << endl;
}
void test2()
{
TokList tokList;
tokList.append( tt_id );
tokList.append( tt_equals );
tokList.append( tt_not );
tokList.append( tt_open );
tokList.append( tt_orFSM );
tokList.append( tt_minus );
tokList.append( tt_not );
tokList.append( tt_andFSM );
tokList.append( tt_close );
tokList.append( tt_star );
tokList.append( tt_semi );
cout << tokList.parse() << endl;
}
void test3()
{
TokList tokList;
tokList.append( tt_id );
tokList.append( tt_equals );
tokList.append( tt_id );
tokList.append( tt_colon );
tokList.append( tt_minus );
tokList.append( tt_number );
tokList.append( tt_id );
tokList.append( tt_colon );
tokList.append( tt_id );
tokList.append( tt_id );
tokList.append( tt_dollar );
tokList.append( tt_plus );
tokList.append( tt_number );
tokList.append( tt_id );
tokList.append( tt_percent );
tokList.append( tt_minus );
tokList.append( tt_number );
tokList.append( tt_semi );
cout << tokList.parse() << endl;
}
void test4()
{
TokList tokList;
tokList.append( tt_id );
tokList.append( tt_equals );
tokList.append( tt_id );
tokList.append( tt_pipe );
tokList.append( tt_id );
tokList.append( tt_amp );
tokList.append( tt_id );
tokList.append( tt_minus );
tokList.append( tt_id );
tokList.append( tt_semi );
cout << tokList.parse() << endl;
}
int main()
{
test0();
test1();
test2();
test3();
test4();
}
}@
|