-
Notifications
You must be signed in to change notification settings - Fork 0
/
ParserGenerator.cs
2403 lines (2306 loc) · 65.5 KB
/
ParserGenerator.cs
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
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// This code was generated by the Gardens Point Parser Generator
// Copyright (c) Wayne Kelly, QUT 2005-2010
// (see accompanying GPPGcopyright.rtf)
// GPPG version 1.5.0
// Machine: KYLE-PC
// DateTime: 9/2/2013 3:07:52 PM
// UserName: Kyle
// Input file <ParserGenerator.y - 9/2/2013 3:07:49 PM>
// options: lines
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using QUT.Gppg;
internal enum Tokens {error=94,EOF=95,NUMBER=96,
STRING=97,GREATER=98,GREATEREQ=99,EQUAL=100,LESS=101,LESSEQ=102,
AND=103,OR=104,WHILE=105,PIECE=106,START=107,END=108,
THIS=109,IF=110,ELSE=111,BOARD=112,EOT=113,WIN=114,
DIRECTION=115,X=116,Y=117,REPLACE=118,TYPE=119,HASMOVED=120,
PIECEDEF=121};
internal struct ValueType
#line 18 "ParserGenerator.y"
{ public string sVal;
#line 19 "ParserGenerator.y"
public Stmt stmtVal;
#line 20 "ParserGenerator.y"
public Piece pVal;
#line 21 "ParserGenerator.y"
public Pieces psVal;
#line 22 "ParserGenerator.y"
public PieceDef pdVal;
#line 23 "ParserGenerator.y"
public ImportedFile ifVal;
#line 24 "ParserGenerator.y"
public Win wVal;
#line 25 "ParserGenerator.y"
public Eot eVal;
#line 26 "ParserGenerator.y"
public Move mVal;
#line 27 "ParserGenerator.y"
public int iVal; }
internal class Parser: ShiftReduceParser<ValueType, LexLocation>
{
// Verbatim content from ParserGenerator.y - 9/2/2013 3:07:49 PM
#line 2 "ParserGenerator.y"
Dictionary nt = new Dictionary<string,int>();
// End verbatim content from ParserGenerator.y - 9/2/2013 3:07:49 PM
#pragma warning disable 649
private static Dictionary<int, string> aliasses;
#pragma warning restore 649
private static Rule[] rules = new Rule[51];
private static State[] states = new State[139];
private static string[] nonTerms = new string[] {
"file", "element", "expr", "term", "fact", "strcmp", "while", "if", "assign",
"piece", "stmt", "stmtlist", "piecedef", "move", "eot", "win", "$accept",
"pieces", "startingposlist", "startingpos", };
static Parser() {
states[0] = new State(new int[]{121,131},new int[]{-1,1,-18,3,-13,138});
states[1] = new State(new int[]{95,2});
states[2] = new State(-1);
states[3] = new State(new int[]{58,4});
states[4] = new State(new int[]{96,120,121,131},new int[]{-19,5,-13,128,-20,130});
states[5] = new State(new int[]{58,6,96,120},new int[]{-20,119});
states[6] = new State(new int[]{113,115},new int[]{-15,7});
states[7] = new State(new int[]{58,8});
states[8] = new State(new int[]{114,11},new int[]{-16,9});
states[9] = new State(new int[]{58,10});
states[10] = new State(-2);
states[11] = new State(new int[]{58,12});
states[12] = new State(new int[]{105,18,110,26,97,38,112,64,109,76},new int[]{-12,13,-11,15,-7,17,-8,25,-9,36,-10,108});
states[13] = new State(new int[]{58,14});
states[14] = new State(-11);
states[15] = new State(new int[]{105,18,110,26,97,38,112,64,109,76,58,-19,108,-19,111,-19},new int[]{-12,16,-11,15,-7,17,-8,25,-9,36,-10,108});
states[16] = new State(-18);
states[17] = new State(-20);
states[18] = new State(new int[]{40,19});
states[19] = new State(new int[]{40,47,97,56,96,57,112,64,109,76,34,98},new int[]{-3,20,-2,86,-4,73,-5,77,-10,87,-6,97});
states[20] = new State(new int[]{41,21,104,41,103,50,98,71,101,78,100,80,99,82,102,84});
states[21] = new State(new int[]{107,22});
states[22] = new State(new int[]{105,18,110,26,97,38,112,64,109,76},new int[]{-12,23,-11,15,-7,17,-8,25,-9,36,-10,108});
states[23] = new State(new int[]{108,24});
states[24] = new State(-14);
states[25] = new State(-21);
states[26] = new State(new int[]{40,27});
states[27] = new State(new int[]{40,47,97,56,96,57,112,64,109,76,34,98},new int[]{-3,28,-2,86,-4,73,-5,77,-10,87,-6,97});
states[28] = new State(new int[]{41,29,104,41,103,50,98,71,101,78,100,80,99,82,102,84});
states[29] = new State(new int[]{107,30});
states[30] = new State(new int[]{105,18,110,26,97,38,112,64,109,76},new int[]{-12,31,-11,15,-7,17,-8,25,-9,36,-10,108});
states[31] = new State(new int[]{108,32,111,33});
states[32] = new State(-16);
states[33] = new State(new int[]{105,18,110,26,97,38,112,64,109,76},new int[]{-12,34,-11,15,-7,17,-8,25,-9,36,-10,108});
states[34] = new State(new int[]{108,35});
states[35] = new State(-17);
states[36] = new State(new int[]{59,37});
states[37] = new State(-22);
states[38] = new State(new int[]{61,39});
states[39] = new State(new int[]{40,47,97,56,96,57,112,64,109,76,34,98},new int[]{-3,40,-2,86,-4,73,-5,77,-10,87,-6,97});
states[40] = new State(new int[]{104,41,103,50,98,71,101,78,100,80,99,82,102,84,59,-15});
states[41] = new State(new int[]{40,47,97,56,96,57,112,64,109,76},new int[]{-2,42,-4,73,-5,77,-10,58});
states[42] = new State(new int[]{43,43,45,52,41,-24,104,-24,103,-24,98,-24,101,-24,100,-24,99,-24,102,-24,59,-24,93,-24});
states[43] = new State(new int[]{40,47,97,56,96,57,112,64,109,76},new int[]{-4,44,-5,77,-10,58});
states[44] = new State(new int[]{42,45,47,54,37,74,43,-33,45,-33,41,-33,104,-33,103,-33,98,-33,101,-33,100,-33,99,-33,102,-33,59,-33,93,-33});
states[45] = new State(new int[]{40,47,97,56,96,57,112,64,109,76},new int[]{-5,46,-10,58});
states[46] = new State(-36);
states[47] = new State(new int[]{40,47,97,56,96,57,112,64,109,76,34,98},new int[]{-3,48,-2,86,-4,73,-5,77,-10,87,-6,97});
states[48] = new State(new int[]{41,49,104,41,103,50,98,71,101,78,100,80,99,82,102,84});
states[49] = new State(-40);
states[50] = new State(new int[]{40,47,97,56,96,57,112,64,109,76},new int[]{-2,51,-4,73,-5,77,-10,58});
states[51] = new State(new int[]{43,43,45,52,41,-25,104,-25,103,-25,98,-25,101,-25,100,-25,99,-25,102,-25,59,-25,93,-25});
states[52] = new State(new int[]{40,47,97,56,96,57,112,64,109,76},new int[]{-4,53,-5,77,-10,58});
states[53] = new State(new int[]{42,45,47,54,37,74,43,-34,45,-34,41,-34,104,-34,103,-34,98,-34,101,-34,100,-34,99,-34,102,-34,59,-34,93,-34});
states[54] = new State(new int[]{40,47,97,56,96,57,112,64,109,76},new int[]{-5,55,-10,58});
states[55] = new State(-37);
states[56] = new State(-41);
states[57] = new State(-42);
states[58] = new State(new int[]{46,59});
states[59] = new State(new int[]{116,60,117,61,115,62,120,63});
states[60] = new State(-43);
states[61] = new State(-44);
states[62] = new State(-45);
states[63] = new State(-46);
states[64] = new State(new int[]{91,65});
states[65] = new State(new int[]{40,47,97,56,96,57,112,64,109,76,34,98},new int[]{-3,66,-2,86,-4,73,-5,77,-10,87,-6,97});
states[66] = new State(new int[]{93,67,104,41,103,50,98,71,101,78,100,80,99,82,102,84});
states[67] = new State(new int[]{91,68});
states[68] = new State(new int[]{40,47,97,56,96,57,112,64,109,76,34,98},new int[]{-3,69,-2,86,-4,73,-5,77,-10,87,-6,97});
states[69] = new State(new int[]{93,70,104,41,103,50,98,71,101,78,100,80,99,82,102,84});
states[70] = new State(-12);
states[71] = new State(new int[]{40,47,97,56,96,57,112,64,109,76},new int[]{-2,72,-4,73,-5,77,-10,58});
states[72] = new State(new int[]{43,43,45,52,41,-26,104,-26,103,-26,98,-26,101,-26,100,-26,99,-26,102,-26,59,-26,93,-26});
states[73] = new State(new int[]{42,45,47,54,37,74,43,-35,45,-35,41,-35,104,-35,103,-35,98,-35,101,-35,100,-35,99,-35,102,-35,59,-35,93,-35});
states[74] = new State(new int[]{40,47,97,56,96,57,112,64,109,76},new int[]{-5,75,-10,58});
states[75] = new State(-38);
states[76] = new State(-13);
states[77] = new State(-39);
states[78] = new State(new int[]{40,47,97,56,96,57,112,64,109,76},new int[]{-2,79,-4,73,-5,77,-10,58});
states[79] = new State(new int[]{43,43,45,52,41,-27,104,-27,103,-27,98,-27,101,-27,100,-27,99,-27,102,-27,59,-27,93,-27});
states[80] = new State(new int[]{40,47,97,56,96,57,112,64,109,76},new int[]{-2,81,-4,73,-5,77,-10,58});
states[81] = new State(new int[]{43,43,45,52,41,-28,104,-28,103,-28,98,-28,101,-28,100,-28,99,-28,102,-28,59,-28,93,-28});
states[82] = new State(new int[]{40,47,97,56,96,57,112,64,109,76},new int[]{-2,83,-4,73,-5,77,-10,58});
states[83] = new State(new int[]{43,43,45,52,41,-29,104,-29,103,-29,98,-29,101,-29,100,-29,99,-29,102,-29,59,-29,93,-29});
states[84] = new State(new int[]{40,47,97,56,96,57,112,64,109,76},new int[]{-2,85,-4,73,-5,77,-10,58});
states[85] = new State(new int[]{43,43,45,52,41,-30,104,-30,103,-30,98,-30,101,-30,100,-30,99,-30,102,-30,59,-30,93,-30});
states[86] = new State(new int[]{43,43,45,52,41,-31,104,-31,103,-31,98,-31,101,-31,100,-31,99,-31,102,-31,59,-31,93,-31});
states[87] = new State(new int[]{46,88});
states[88] = new State(new int[]{116,60,117,61,115,62,120,63,119,89});
states[89] = new State(new int[]{100,90});
states[90] = new State(new int[]{34,94,112,64,109,76},new int[]{-10,91});
states[91] = new State(new int[]{46,92});
states[92] = new State(new int[]{119,93});
states[93] = new State(-47);
states[94] = new State(new int[]{97,95});
states[95] = new State(new int[]{34,96});
states[96] = new State(-48);
states[97] = new State(-32);
states[98] = new State(new int[]{97,99});
states[99] = new State(new int[]{34,100});
states[100] = new State(new int[]{100,101});
states[101] = new State(new int[]{34,105,112,64,109,76},new int[]{-10,102});
states[102] = new State(new int[]{46,103});
states[103] = new State(new int[]{119,104});
states[104] = new State(-49);
states[105] = new State(new int[]{97,106});
states[106] = new State(new int[]{34,107});
states[107] = new State(-50);
states[108] = new State(new int[]{46,109});
states[109] = new State(new int[]{118,110});
states[110] = new State(new int[]{40,111});
states[111] = new State(new int[]{97,112});
states[112] = new State(new int[]{41,113});
states[113] = new State(new int[]{59,114});
states[114] = new State(-23);
states[115] = new State(new int[]{58,116});
states[116] = new State(new int[]{105,18,110,26,97,38,112,64,109,76},new int[]{-12,117,-11,15,-7,17,-8,25,-9,36,-10,108});
states[117] = new State(new int[]{58,118});
states[118] = new State(-10);
states[119] = new State(-4);
states[120] = new State(new int[]{58,121});
states[121] = new State(new int[]{96,122});
states[122] = new State(new int[]{58,123});
states[123] = new State(new int[]{97,124});
states[124] = new State(new int[]{58,125});
states[125] = new State(new int[]{96,126});
states[126] = new State(new int[]{58,127});
states[127] = new State(-5);
states[128] = new State(new int[]{58,129});
states[129] = new State(-7);
states[130] = new State(-3);
states[131] = new State(new int[]{58,132});
states[132] = new State(new int[]{97,133});
states[133] = new State(new int[]{58,134});
states[134] = new State(new int[]{105,18,110,26,97,38,112,64,109,76},new int[]{-14,135,-12,137,-11,15,-7,17,-8,25,-9,36,-10,108});
states[135] = new State(new int[]{58,136});
states[136] = new State(-8);
states[137] = new State(-9);
states[138] = new State(-6);
for (int sNo = 0; sNo < states.Length; sNo++) states[sNo].number = sNo;
rules[1] = new Rule(-17, new int[]{-1,95});
rules[2] = new Rule(-1, new int[]{-18,58,-19,58,-15,58,-16,58});
rules[3] = new Rule(-19, new int[]{-20});
rules[4] = new Rule(-19, new int[]{-19,-20});
rules[5] = new Rule(-20, new int[]{96,58,96,58,97,58,96,58});
rules[6] = new Rule(-18, new int[]{-13});
rules[7] = new Rule(-18, new int[]{-18,58,-13,58});
rules[8] = new Rule(-13, new int[]{121,58,97,58,-14,58});
rules[9] = new Rule(-14, new int[]{-12});
rules[10] = new Rule(-15, new int[]{113,58,-12,58});
rules[11] = new Rule(-16, new int[]{114,58,-12,58});
rules[12] = new Rule(-10, new int[]{112,91,-3,93,91,-3,93});
rules[13] = new Rule(-10, new int[]{109});
rules[14] = new Rule(-7, new int[]{105,40,-3,41,107,-12,108});
rules[15] = new Rule(-9, new int[]{97,61,-3});
rules[16] = new Rule(-8, new int[]{110,40,-3,41,107,-12,108});
rules[17] = new Rule(-8, new int[]{110,40,-3,41,107,-12,111,-12,108});
rules[18] = new Rule(-12, new int[]{-11,-12});
rules[19] = new Rule(-12, new int[]{-11});
rules[20] = new Rule(-11, new int[]{-7});
rules[21] = new Rule(-11, new int[]{-8});
rules[22] = new Rule(-11, new int[]{-9,59});
rules[23] = new Rule(-11, new int[]{-10,46,118,40,97,41,59});
rules[24] = new Rule(-3, new int[]{-3,104,-2});
rules[25] = new Rule(-3, new int[]{-3,103,-2});
rules[26] = new Rule(-3, new int[]{-3,98,-2});
rules[27] = new Rule(-3, new int[]{-3,101,-2});
rules[28] = new Rule(-3, new int[]{-3,100,-2});
rules[29] = new Rule(-3, new int[]{-3,99,-2});
rules[30] = new Rule(-3, new int[]{-3,102,-2});
rules[31] = new Rule(-3, new int[]{-2});
rules[32] = new Rule(-3, new int[]{-6});
rules[33] = new Rule(-2, new int[]{-2,43,-4});
rules[34] = new Rule(-2, new int[]{-2,45,-4});
rules[35] = new Rule(-2, new int[]{-4});
rules[36] = new Rule(-4, new int[]{-4,42,-5});
rules[37] = new Rule(-4, new int[]{-4,47,-5});
rules[38] = new Rule(-4, new int[]{-4,37,-5});
rules[39] = new Rule(-4, new int[]{-5});
rules[40] = new Rule(-5, new int[]{40,-3,41});
rules[41] = new Rule(-5, new int[]{97});
rules[42] = new Rule(-5, new int[]{96});
rules[43] = new Rule(-5, new int[]{-10,46,116});
rules[44] = new Rule(-5, new int[]{-10,46,117});
rules[45] = new Rule(-5, new int[]{-10,46,115});
rules[46] = new Rule(-5, new int[]{-10,46,120});
rules[47] = new Rule(-6, new int[]{-10,46,119,100,-10,46,119});
rules[48] = new Rule(-6, new int[]{-10,46,119,100,34,97,34});
rules[49] = new Rule(-6, new int[]{34,97,34,100,-10,46,119});
rules[50] = new Rule(-6, new int[]{34,97,34,100,34,97,34});
}
protected override void Initialize() {
this.InitSpecialTokens((int)Tokens.error, (int)Tokens.EOF);
this.InitStates(states);
this.InitRules(rules);
this.InitNonTerminals(nonTerms);
}
protected override void DoAction(int action)
{
#pragma warning disable 162, 1522
switch (action)
{
case 2: // file -> pieces, ':', startingposlist, ':', eot, ':', win, ':'
#line 80 "ParserGenerator.y"
{
#line 81 "ParserGenerator.y"
CurrentSemanticValue.ifVal=new ImportedFile(ValueStack[ValueStack.Depth-8],ValueStack[ValueStack.Depth-6],ValueStack[ValueStack.Depth-4].eVal,ValueStack[ValueStack.Depth-2].wVal);
#line 82 "ParserGenerator.y"
}
break;
case 3: // startingposlist -> startingpos
#line 85 "ParserGenerator.y"
{
#line 86 "ParserGenerator.y"
StartingPosList spl=new StartingPosList();
#line 87 "ParserGenerator.y"
spl.add(ValueStack[ValueStack.Depth-1]);
#line 88 "ParserGenerator.y"
CurrentSemanticValue=spl;
#line 89 "ParserGenerator.y"
}
break;
case 4: // startingposlist -> startingposlist, startingpos
#line 91 "ParserGenerator.y"
{
#line 92 "ParserGenerator.y"
ValueStack[ValueStack.Depth-2].add(ValueStack[ValueStack.Depth-1]);
#line 93 "ParserGenerator.y"
CurrentSemanticValue=ValueStack[ValueStack.Depth-2];
#line 94 "ParserGenerator.y"
}
break;
case 5: // startingpos -> NUMBER, ':', NUMBER, ':', STRING, ':', NUMBER, ':'
#line 97 "ParserGenerator.y"
{
#line 98 "ParserGenerator.y"
CurrentSemanticValue=new StartingPos(ValueStack[ValueStack.Depth-8].iVal,ValueStack[ValueStack.Depth-6].iVal,ValueStack[ValueStack.Depth-4].sVal,ValueStack[ValueStack.Depth-2].iVal);
#line 99 "ParserGenerator.y"
}
break;
case 6: // pieces -> piecedef
#line 102 "ParserGenerator.y"
{
#line 103 "ParserGenerator.y"
Pieces p = new Pieces();
#line 104 "ParserGenerator.y"
p.add(ValueStack[ValueStack.Depth-1].pdVal);
#line 105 "ParserGenerator.y"
CurrentSemanticValue=p;
#line 106 "ParserGenerator.y"
}
break;
case 7: // pieces -> pieces, ':', piecedef, ':'
#line 108 "ParserGenerator.y"
{
#line 109 "ParserGenerator.y"
ValueStack[ValueStack.Depth-4].add(ValueStack[ValueStack.Depth-2].pdVal);
#line 110 "ParserGenerator.y"
CurrentSemanticValue=ValueStack[ValueStack.Depth-4];
#line 111 "ParserGenerator.y"
}
break;
case 8: // piecedef -> PIECEDEF, ':', STRING, ':', move, ':'
#line 114 "ParserGenerator.y"
{
#line 115 "ParserGenerator.y"
CurrentSemanticValue.pdVal=new PieceDef(ValueStack[ValueStack.Depth-4].sVal,ValueStack[ValueStack.Depth-2].mVal);
#line 116 "ParserGenerator.y"
}
break;
case 9: // move -> stmtlist
#line 119 "ParserGenerator.y"
{
#line 120 "ParserGenerator.y"
CurrentSemanticValue.mVal=new Move(ValueStack[ValueStack.Depth-1].stmtlistVal);
#line 121 "ParserGenerator.y"
}
break;
case 10: // eot -> EOT, ':', stmtlist, ':'
#line 124 "ParserGenerator.y"
{
#line 125 "ParserGenerator.y"
CurrentSemanticValue.eVal=new Eot(ValueStack[ValueStack.Depth-2].stmtlistVal);
#line 126 "ParserGenerator.y"
}
break;
case 11: // win -> WIN, ':', stmtlist, ':'
#line 129 "ParserGenerator.y"
{
#line 130 "ParserGenerator.y"
CurrentSemanticValue.wVal=new Win(ValueStack[ValueStack.Depth-2].stmtlistVal);
#line 131 "ParserGenerator.y"
}
break;
case 12: // piece -> BOARD, '[', expr, ']', '[', expr, ']'
#line 134 "ParserGenerator.y"
{
#line 135 "ParserGenerator.y"
CurrentSemanticValue.psVal=new BoardElement(ValueStack[ValueStack.Depth-5].Expr,ValueStack[ValueStack.Depth-2].Expr);
#line 136 "ParserGenerator.y"
}
break;
case 13: // piece -> THIS
#line 138 "ParserGenerator.y"
{
#line 139 "ParserGenerator.y"
CurrentSemanticValue.psVal=new This();
#line 140 "ParserGenerator.y"
}
break;
case 14: // while -> WHILE, '(', expr, ')', START, stmtlist, END
#line 144 "ParserGenerator.y"
{
#line 145 "ParserGenerator.y"
CurrentSemanticValue.stmtVal=new WhileStmt(ValueStack[ValueStack.Depth-5].Expr,ValueStack[ValueStack.Depth-2].stmtlistVal);
#line 146 "ParserGenerator.y"
}
break;
case 15: // assign -> STRING, '=', expr
#line 149 "ParserGenerator.y"
{
#line 150 "ParserGenerator.y"
CurrentSemanticValue.stmtVal=new AssignStmt(ValueStack[ValueStack.Depth-3].sVal,ValueStack[ValueStack.Depth-1].Expr);
#line 151 "ParserGenerator.y"
}
break;
case 16: // if -> IF, '(', expr, ')', START, stmtlist, END
#line 154 "ParserGenerator.y"
{
#line 155 "ParserGenerator.y"
CurrentSemanticValue.stmtVal=new IfStmt(ValueStack[ValueStack.Depth-5].Expr,ValueStack[ValueStack.Depth-2].stmtlistVal,new StmtList());
#line 156 "ParserGenerator.y"
}
break;
case 17: // if -> IF, '(', expr, ')', START, stmtlist, ELSE, stmtlist, END
#line 159 "ParserGenerator.y"
{
#line 160 "ParserGenerator.y"
CurrentSemanticValue.stmtVal=new IfStmt(ValueStack[ValueStack.Depth-7].Expr,ValueStack[ValueStack.Depth-4].stmtlistVal,ValueStack[ValueStack.Depth-2].stmtlistVal);
#line 161 "ParserGenerator.y"
}
break;
case 18: // stmtlist -> stmt, stmtlist
#line 164 "ParserGenerator.y"
{
#line 165 "ParserGenerator.y"
ValueStack[ValueStack.Depth-1].stmtlistVal.insert(ValueStack[ValueStack.Depth-2].stmtVal);
#line 166 "ParserGenerator.y"
CurrentSemanticValue.stmtlistVal=ValueStack[ValueStack.Depth-1].stmtlistVal;
#line 167 "ParserGenerator.y"
}
break;
case 19: // stmtlist -> stmt
#line 169 "ParserGenerator.y"
{
#line 170 "ParserGenerator.y"
StmtList sl=new StmtList();
#line 171 "ParserGenerator.y"
sl.insert(ValueStack[ValueStack.Depth-1].stmtVal);
#line 172 "ParserGenerator.y"
CurrentSemanticValue.stmtlistVal=sl;
#line 173 "ParserGenerator.y"
}
break;
case 20: // stmt -> while
#line 177 "ParserGenerator.y"
{
#line 178 "ParserGenerator.y"
CurrentSemanticValue.stmtVal=ValueStack[ValueStack.Depth-1].stmtVal;
#line 179 "ParserGenerator.y"
}
break;
case 21: // stmt -> if
#line 181 "ParserGenerator.y"
{
#line 182 "ParserGenerator.y"
CurrentSemanticValue.stmtVal=ValueStack[ValueStack.Depth-1].stmtVal;
#line 183 "ParserGenerator.y"
}
break;
case 22: // stmt -> assign, ';'
#line 185 "ParserGenerator.y"
{
#line 186 "ParserGenerator.y"
CurrentSemanticValue.stmtVal=ValueStack[ValueStack.Depth-2].stmtVal;
#line 187 "ParserGenerator.y"
}
break;
case 23: // stmt -> piece, '.', REPLACE, '(', STRING, ')', ';'
#line 189 "ParserGenerator.y"
{
#line 190 "ParserGenerator.y"
CurrentSemanticValue.stmtVal=new ReplaceStmt(ValueStack[ValueStack.Depth-7].psVal,ValueStack[ValueStack.Depth-3].sVal);
#line 191 "ParserGenerator.y"
}
break;
case 24: // expr -> expr, OR, element
#line 194 "ParserGenerator.y"
{
#line 195 "ParserGenerator.y"
CurrentSemanticValue.Expr=new Or(ValueStack[ValueStack.Depth-3].Expr,ValueStack[ValueStack.Depth-1].Expr);
#line 196 "ParserGenerator.y"
}
break;
case 25: // expr -> expr, AND, element
#line 198 "ParserGenerator.y"
{
#line 199 "ParserGenerator.y"
CurrentSemanticValue.Expr=new And(ValueStack[ValueStack.Depth-3].Expr,ValueStack[ValueStack.Depth-1].Expr);
#line 200 "ParserGenerator.y"
}
break;
case 26: // expr -> expr, GREATER, element
#line 202 "ParserGenerator.y"
{
#line 203 "ParserGenerator.y"
CurrentSemanticValue.Expr=new Greater(ValueStack[ValueStack.Depth-3].Expr,ValueStack[ValueStack.Depth-1].Expr);
#line 204 "ParserGenerator.y"
}
break;
case 27: // expr -> expr, LESS, element
#line 206 "ParserGenerator.y"
{
#line 207 "ParserGenerator.y"
CurrentSemanticValue.Expr=new Less(ValueStack[ValueStack.Depth-3].Expr,ValueStack[ValueStack.Depth-1].Expr);
#line 208 "ParserGenerator.y"
}
break;
case 28: // expr -> expr, EQUAL, element
#line 210 "ParserGenerator.y"
{
#line 211 "ParserGenerator.y"
CurrentSemanticValue.Expr=new Equ(ValueStack[ValueStack.Depth-3].Expr,ValueStack[ValueStack.Depth-1].Expr);
#line 212 "ParserGenerator.y"
}
break;
case 29: // expr -> expr, GREATEREQ, element
#line 214 "ParserGenerator.y"
{
#line 215 "ParserGenerator.y"
CurrentSemanticValue.Expr=new GreaterEq(ValueStack[ValueStack.Depth-3].Expr,ValueStack[ValueStack.Depth-1].Expr);
#line 216 "ParserGenerator.y"
}
break;
case 30: // expr -> expr, LESSEQ, element
#line 218 "ParserGenerator.y"
{
#line 219 "ParserGenerator.y"
CurrentSemanticValue.Expr=new LessEq(ValueStack[ValueStack.Depth-3].Expr,ValueStack[ValueStack.Depth-1].Expr);
#line 220 "ParserGenerator.y"
}
break;
case 31: // expr -> element
#line 222 "ParserGenerator.y"
{
#line 223 "ParserGenerator.y"
CurrentSemanticValue.Expr = ValueStack[ValueStack.Depth-1].Expr;
#line 224 "ParserGenerator.y"
}
break;
case 32: // expr -> strcmp
#line 226 "ParserGenerator.y"
{
#line 227 "ParserGenerator.y"
CurrentSemanticValue.Expr = ValueStack[ValueStack.Depth-1].Expr;
#line 228 "ParserGenerator.y"
}
break;
case 33: // element -> element, '+', term
#line 231 "ParserGenerator.y"
{
#line 232 "ParserGenerator.y"
CurrentSemanticValue.Expr=new Plus(ValueStack[ValueStack.Depth-3].Expr,ValueStack[ValueStack.Depth-1].Expr);
#line 233 "ParserGenerator.y"
}
break;
case 34: // element -> element, '-', term
#line 236 "ParserGenerator.y"
{
#line 237 "ParserGenerator.y"
CurrentSemanticValue.Expr=new Minus(ValueStack[ValueStack.Depth-3].Expr,ValueStack[ValueStack.Depth-1].Expr);
#line 238 "ParserGenerator.y"
}
break;
case 35: // element -> term
#line 240 "ParserGenerator.y"
{
#line 241 "ParserGenerator.y"
CurrentSemanticValue.Expr=ValueStack[ValueStack.Depth-1].Expr;
#line 242 "ParserGenerator.y"
}
break;
case 36: // term -> term, '*', fact
#line 246 "ParserGenerator.y"
{
#line 247 "ParserGenerator.y"
CurrentSemanticValue.Expr=new Times(ValueStack[ValueStack.Depth-3].Expr,ValueStack[ValueStack.Depth-1].Expr);
#line 248 "ParserGenerator.y"
}
break;
case 37: // term -> term, '/', fact
#line 251 "ParserGenerator.y"
{
#line 252 "ParserGenerator.y"
CurrentSemanticValue.Expr=new Divide(ValueStack[ValueStack.Depth-3].Expr,ValueStack[ValueStack.Depth-1].Expr);
#line 253 "ParserGenerator.y"
}
break;
case 38: // term -> term, '%', fact
#line 256 "ParserGenerator.y"
{
#line 257 "ParserGenerator.y"
CurrentSemanticValue.Expr=new Mod(ValueStack[ValueStack.Depth-3].Expr,ValueStack[ValueStack.Depth-1].Expr);
#line 258 "ParserGenerator.y"
}
break;
case 39: // term -> fact
#line 261 "ParserGenerator.y"
{
#line 262 "ParserGenerator.y"
CurrentSemanticValue.Expr=ValueStack[ValueStack.Depth-1].Expr;
#line 263 "ParserGenerator.y"
}
break;
case 40: // fact -> '(', expr, ')'
#line 266 "ParserGenerator.y"
{
#line 267 "ParserGenerator.y"
CurrentSemanticValue.Expr=ValueStack[ValueStack.Depth-2].Expr;
#line 268 "ParserGenerator.y"
}
break;
case 41: // fact -> STRING
#line 271 "ParserGenerator.y"
{
#line 272 "ParserGenerator.y"
CurrentSemanticValue.Expr=new Ident(ValueStack[ValueStack.Depth-1].sVal);
#line 273 "ParserGenerator.y"
}
break;
case 42: // fact -> NUMBER
#line 276 "ParserGenerator.y"
{
#line 277 "ParserGenerator.y"
CurrentSemanticValue.Expr=new Number(ValueStack[ValueStack.Depth-1].iVal);
#line 278 "ParserGenerator.y"
}
break;
case 43: // fact -> piece, '.', X
#line 280 "ParserGenerator.y"
{
#line 281 "ParserGenerator.y"
CurrentSemanticValue.Expr=new XVal(ValueStack[ValueStack.Depth-3].psVal,ValueStack[ValueStack.Depth-1].sVal);
#line 282 "ParserGenerator.y"
}
break;
case 44: // fact -> piece, '.', Y
#line 284 "ParserGenerator.y"
{
#line 285 "ParserGenerator.y"
CurrentSemanticValue.Expr=new YVal(ValueStack[ValueStack.Depth-3].psVal,ValueStack[ValueStack.Depth-1].sVal);
#line 286 "ParserGenerator.y"
}
break;
case 45: // fact -> piece, '.', DIRECTION
#line 288 "ParserGenerator.y"
{
#line 289 "ParserGenerator.y"
CurrentSemanticValue.Expr=new Direction(ValueStack[ValueStack.Depth-3].psVal,ValueStack[ValueStack.Depth-1].sVal);
#line 290 "ParserGenerator.y"
}
break;
case 46: // fact -> piece, '.', HASMOVED
#line 292 "ParserGenerator.y"
{
#line 293 "ParserGenerator.y"
CurrentSemanticValue.Expr=new HASMOVED(ValueStack[ValueStack.Depth-3].psVal);
#line 294 "ParserGenerator.y"
}
break;
case 47: // strcmp -> piece, '.', TYPE, EQUAL, piece, '.', TYPE
#line 297 "ParserGenerator.y"
{
#line 298 "ParserGenerator.y"
CurrentSemanticValue.Expr=new StrCmp(new Type(ValueStack[ValueStack.Depth-7].psVal),new Type(ValueStack[ValueStack.Depth-3].psVal));
#line 299 "ParserGenerator.y"
}
break;
case 48: // strcmp -> piece, '.', TYPE, EQUAL, '"', STRING, '"'
#line 301 "ParserGenerator.y"
{
#line 302 "ParserGenerator.y"
CurrentSemanticValue.Expr=new StrCmp(new Type(ValueStack[ValueStack.Depth-7].psVal),ValueStack[ValueStack.Depth-2].sVal);
#line 303 "ParserGenerator.y"
}
break;
case 49: // strcmp -> '"', STRING, '"', EQUAL, piece, '.', TYPE
#line 305 "ParserGenerator.y"
{
#line 306 "ParserGenerator.y"
CurrentSemanticValue.Expr=new StrCmp(ValueStack[ValueStack.Depth-6].sVal,new Type(ValueStack[ValueStack.Depth-3].psVal));
#line 307 "ParserGenerator.y"
}
break;
case 50: // strcmp -> '"', STRING, '"', EQUAL, '"', STRING, '"'
#line 309 "ParserGenerator.y"
{
#line 310 "ParserGenerator.y"
CurrentSemanticValue.Expr=new StrCmp(ValueStack[ValueStack.Depth-6].sVal,ValueStack[ValueStack.Depth-2].sVal);
#line 311 "ParserGenerator.y"
}
break;
}
#pragma warning restore 162, 1522
}
protected override string TerminalToString(int terminal)
{
if (aliasses != null && aliasses.ContainsKey(terminal))
return aliasses[terminal];
else if (((Tokens)terminal).ToString() != terminal.ToString(CultureInfo.InvariantCulture))
return ((Tokens)terminal).ToString();
else
return CharToString((char)terminal);
}
#line 314 "ParserGenerator.y"
#line 315 "ParserGenerator.y"
#line 316 "ParserGenerator.y"
class ImportedFile
#line 317 "ParserGenerator.y"
{
#line 318 "ParserGenerator.y"
public Pieces _p;
#line 319 "ParserGenerator.y"
public StartingPos _sp;
#line 320 "ParserGenerator.y"
public Eot _eot;
#line 321 "ParserGenerator.y"
public Win _win;
#line 322 "ParserGenerator.y"
public ImportedFile(Pieces p, StartingPos sp, Eot eot, Win win)
#line 323 "ParserGenerator.y"
{
#line 324 "ParserGenerator.y"
_p=p;
#line 325 "ParserGenerator.y"
_sp=sp;
#line 326 "ParserGenerator.y"
_eot=eot;
#line 327 "ParserGenerator.y"
_win=win;
#line 328 "ParserGenerator.y"
}
#line 329 "ParserGenerator.y"
#line 330 "ParserGenerator.y"
}
#line 331 "ParserGenerator.y"
class StartingPosList
#line 332 "ParserGenerator.y"
{
#line 333 "ParserGenerator.y"
List<StartingPos> _pos;
#line 334 "ParserGenerator.y"
#line 335 "ParserGenerator.y"
public StartingPosList()
#line 336 "ParserGenerator.y"
{
#line 337 "ParserGenerator.y"
_pos=new List<StartingPos>();
#line 338 "ParserGenerator.y"
}
#line 339 "ParserGenerator.y"
#line 340 "ParserGenerator.y"
public void add(StartingPos s)
#line 341 "ParserGenerator.y"
{
#line 342 "ParserGenerator.y"
_pos.Add(s);
#line 343 "ParserGenerator.y"
}
#line 344 "ParserGenerator.y"
#line 345 "ParserGenerator.y"
public getPieces()
#line 346 "ParserGenerator.y"
{
#line 347 "ParserGenerator.y"
return _pos;
#line 348 "ParserGenerator.y"
}
#line 349 "ParserGenerator.y"
#line 350 "ParserGenerator.y"
}
#line 351 "ParserGenerator.y"
class StartingPos
#line 352 "ParserGenerator.y"
{
#line 353 "ParserGenerator.y"
public int _x;
#line 354 "ParserGenerator.y"
public int _y;
#line 355 "ParserGenerator.y"
public string _type;
#line 356 "ParserGenerator.y"
public int _direction;
#line 357 "ParserGenerator.y"
public starting(int x, int y, string type, int direction)
#line 358 "ParserGenerator.y"
{
#line 359 "ParserGenerator.y"
_x=x;
#line 360 "ParserGenerator.y"
_y=y;
#line 361 "ParserGenerator.y"
_type=type;
#line 362 "ParserGenerator.y"
_direction=direction;
#line 363 "ParserGenerator.y"
}
#line 364 "ParserGenerator.y"
}
#line 365 "ParserGenerator.y"
class Pieces
#line 366 "ParserGenerator.y"
{
#line 367 "ParserGenerator.y"
List<subPiece> _pieces;
#line 368 "ParserGenerator.y"
#line 369 "ParserGenerator.y"
public Pieces()
#line 370 "ParserGenerator.y"
{
#line 371 "ParserGenerator.y"
_pieces=new List<subPiece>();
#line 372 "ParserGenerator.y"
}
#line 373 "ParserGenerator.y"
#line 374 "ParserGenerator.y"
public void add(subPiece s)
#line 375 "ParserGenerator.y"
{
#line 376 "ParserGenerator.y"
_pieces.Add(s);
#line 377 "ParserGenerator.y"
}
#line 378 "ParserGenerator.y"
#line 379 "ParserGenerator.y"
public getPieces()
#line 380 "ParserGenerator.y"
{
#line 381 "ParserGenerator.y"
return _pieces;
#line 382 "ParserGenerator.y"
}
#line 383 "ParserGenerator.y"
#line 384 "ParserGenerator.y"
}
#line 385 "ParserGenerator.y"
#line 386 "ParserGenerator.y"
class subPiece
#line 387 "ParserGenerator.y"
{
#line 388 "ParserGenerator.y"
string _type;
#line 389 "ParserGenerator.y"
Move _move;
#line 390 "ParserGenerator.y"
public subPieces(string type, Move move)
#line 391 "ParserGenerator.y"
{
#line 392 "ParserGenerator.y"
_type=type;
#line 393 "ParserGenerator.y"
_move=move;
#line 394 "ParserGenerator.y"
}
#line 395 "ParserGenerator.y"
public getType()
#line 396 "ParserGenerator.y"
{
#line 397 "ParserGenerator.y"
return _type;
#line 398 "ParserGenerator.y"
}
#line 399 "ParserGenerator.y"
public getMove()
#line 400 "ParserGenerator.y"
{
#line 401 "ParserGenerator.y"
return _move;
#line 402 "ParserGenerator.y"
}
#line 403 "ParserGenerator.y"
}
#line 404 "ParserGenerator.y"
#line 405 "ParserGenerator.y"
class Eot
#line 406 "ParserGenerator.y"
{
#line 407 "ParserGenerator.y"
StmtList _sl;
#line 408 "ParserGenerator.y"
#line 409 "ParserGenerator.y"
public Eot(StmtList sl)
#line 410 "ParserGenerator.y"
{
#line 411 "ParserGenerator.y"
_sl=sl;
#line 412 "ParserGenerator.y"
}
#line 413 "ParserGenerator.y"
public bool eval(Board board,Dictionary nt)
#line 414 "ParserGenerator.y"
{
#line 415 "ParserGenerator.y"
sl.eval(board,nt);
#line 416 "ParserGenerator.y"
if(nt.Containskey("return") && nt["return"]==1){
#line 417 "ParserGenerator.y"
return true;
#line 418 "ParserGenerator.y"
}
#line 419 "ParserGenerator.y"
return false;
#line 420 "ParserGenerator.y"
}
#line 421 "ParserGenerator.y"
}
#line 422 "ParserGenerator.y"
#line 423 "ParserGenerator.y"
class Move
#line 424 "ParserGenerator.y"
{
#line 425 "ParserGenerator.y"
StmtList _sl;
#line 426 "ParserGenerator.y"
#line 427 "ParserGenerator.y"
public Move(StmtList sl)
#line 428 "ParserGenerator.y"
{
#line 429 "ParserGenerator.y"
_sl=sl;
#line 430 "ParserGenerator.y"
}
#line 431 "ParserGenerator.y"
public bool eval(Board board,Dictionary nt,Piece t,int x, int y)
#line 432 "ParserGenerator.y"
{
#line 433 "ParserGenerator.y"
nt["movex"]=x;
#line 434 "ParserGenerator.y"
nt["movey"]=y;
#line 435 "ParserGenerator.y"
sl.eval(board,nt,t);
#line 436 "ParserGenerator.y"
if(nt.Containskey("return") && nt["return"]==1){
#line 437 "ParserGenerator.y"
return true;
#line 438 "ParserGenerator.y"
}
#line 439 "ParserGenerator.y"
return false;
#line 440 "ParserGenerator.y"
}
#line 441 "ParserGenerator.y"
}
#line 442 "ParserGenerator.y"
#line 443 "ParserGenerator.y"
class Win
#line 444 "ParserGenerator.y"
{
#line 445 "ParserGenerator.y"
StmtList _sl;
#line 446 "ParserGenerator.y"
#line 447 "ParserGenerator.y"
public Win(StmtList sl)
#line 448 "ParserGenerator.y"
{
#line 449 "ParserGenerator.y"
_sl=sl;
#line 450 "ParserGenerator.y"
}
#line 451 "ParserGenerator.y"
public int eval(Board board,Dictionary nt)
#line 452 "ParserGenerator.y"
{
#line 453 "ParserGenerator.y"
sl.eval(board,nt);
#line 454 "ParserGenerator.y"
if(nt.Containskey("winner")){
#line 455 "ParserGenerator.y"
return nt["winner"];
#line 456 "ParserGenerator.y"
}
#line 457 "ParserGenerator.y"
return 0;
#line 458 "ParserGenerator.y"
}
#line 459 "ParserGenerator.y"
}
#line 460 "ParserGenerator.y"
#line 461 "ParserGenerator.y"
abstract class Expr
#line 462 "ParserGenerator.y"
{
#line 463 "ParserGenerator.y"
abstract public int eval(Board board,Dictionary nt,Piece t);
#line 464 "ParserGenerator.y"
}
#line 465 "ParserGenerator.y"
#line 466 "ParserGenerator.y"
class Equ : Expr