-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSkeleton.C
805 lines (544 loc) · 15 KB
/
Skeleton.C
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
/* File generated by the BNF Converter (bnfc 2.9.4). */
/*** Visitor Design Pattern Skeleton. ***/
/* This implements the common visitor design pattern.
Note that this method uses Visitor-traversal of lists, so
List->accept() does NOT traverse the list. This allows different
algorithms to use context information differently. */
#include "Skeleton.H"
void Skeleton::visitProg(Prog *t) {} //abstract class
void Skeleton::visitTopDef(TopDef *t) {} //abstract class
void Skeleton::visitFnDef(FnDef *t) {} //abstract class
void Skeleton::visitEVal(EVal *t) {} //abstract class
void Skeleton::visitArg(Arg *t) {} //abstract class
void Skeleton::visitBType(BType *t) {} //abstract class
void Skeleton::visitOType(OType *t) {} //abstract class
void Skeleton::visitAType(AType *t) {} //abstract class
void Skeleton::visitType(Type *t) {} //abstract class
void Skeleton::visitBracketsOpt(BracketsOpt *t) {} //abstract class
void Skeleton::visitSBlk(SBlk *t) {} //abstract class
void Skeleton::visitCBlk(CBlk *t) {} //abstract class
void Skeleton::visitMemItem(MemItem *t) {} //abstract class
void Skeleton::visitMemdef(Memdef *t) {} //abstract class
void Skeleton::visitCMemdef(CMemdef *t) {} //abstract class
void Skeleton::visitBlk(Blk *t) {} //abstract class
void Skeleton::visitStmt(Stmt *t) {} //abstract class
void Skeleton::visitItem(Item *t) {} //abstract class
void Skeleton::visitExpr(Expr *t) {} //abstract class
void Skeleton::visitDimExpr(DimExpr *t) {} //abstract class
void Skeleton::visitAddOp(AddOp *t) {} //abstract class
void Skeleton::visitMulOp(MulOp *t) {} //abstract class
void Skeleton::visitRelOp(RelOp *t) {} //abstract class
void Skeleton::visitProgram(Program *program)
{
/* Code For Program Goes Here */
if (program->listtopdef_) program->listtopdef_->accept(this);
}
void Skeleton::visitStruct(Struct *struct_)
{
/* Code For Struct Goes Here */
visitIdent(struct_->ident_);
if (struct_->sblk_) struct_->sblk_->accept(this);
}
void Skeleton::visitTypeDef(TypeDef *type_def)
{
/* Code For TypeDef Goes Here */
visitIdent(type_def->ident_1);
visitIdent(type_def->ident_2);
}
void Skeleton::visitTypeDefWS(TypeDefWS *type_def_ws)
{
/* Code For TypeDefWS Goes Here */
visitIdent(type_def_ws->ident_1);
if (type_def_ws->sblk_) type_def_ws->sblk_->accept(this);
visitIdent(type_def_ws->ident_2);
}
void Skeleton::visitEnum(Enum *enum_)
{
/* Code For Enum Goes Here */
visitIdent(enum_->ident_);
if (enum_->listeval_) enum_->listeval_->accept(this);
}
void Skeleton::visitClass(Class *class_)
{
/* Code For Class Goes Here */
visitIdent(class_->ident_);
if (class_->cblk_) class_->cblk_->accept(this);
}
void Skeleton::visitClassWE(ClassWE *class_we)
{
/* Code For ClassWE Goes Here */
visitIdent(class_we->ident_1);
visitIdent(class_we->ident_2);
if (class_we->cblk_) class_we->cblk_->accept(this);
}
void Skeleton::visitGFuncDef(GFuncDef *g_func_def)
{
/* Code For GFuncDef Goes Here */
if (g_func_def->fndef_) g_func_def->fndef_->accept(this);
}
void Skeleton::visitFuncDef(FuncDef *func_def)
{
/* Code For FuncDef Goes Here */
if (func_def->type_) func_def->type_->accept(this);
visitIdent(func_def->ident_);
if (func_def->listarg_) func_def->listarg_->accept(this);
if (func_def->blk_) func_def->blk_->accept(this);
}
void Skeleton::visitEnumValue(EnumValue *enum_value)
{
/* Code For EnumValue Goes Here */
visitIdent(enum_value->ident_);
}
void Skeleton::visitArgument(Argument *argument)
{
/* Code For Argument Goes Here */
if (argument->type_) argument->type_->accept(this);
visitIdent(argument->ident_);
}
void Skeleton::visitInt(Int *int_)
{
/* Code For Int Goes Here */
}
void Skeleton::visitDoub(Doub *doub)
{
/* Code For Doub Goes Here */
}
void Skeleton::visitBool(Bool *bool_)
{
/* Code For Bool Goes Here */
}
void Skeleton::visitVoid(Void *void_)
{
/* Code For Void Goes Here */
}
void Skeleton::visitObjT(ObjT *obj_t)
{
/* Code For ObjT Goes Here */
visitIdent(obj_t->ident_);
}
void Skeleton::visitArray(Array *array)
{
/* Code For Array Goes Here */
if (array->type_) array->type_->accept(this);
if (array->bracketsopt_) array->bracketsopt_->accept(this);
}
void Skeleton::visitBaseType(BaseType *base_type)
{
/* Code For BaseType Goes Here */
if (base_type->btype_) base_type->btype_->accept(this);
}
void Skeleton::visitObjType(ObjType *obj_type)
{
/* Code For ObjType Goes Here */
if (obj_type->otype_) obj_type->otype_->accept(this);
}
void Skeleton::visitArrType(ArrType *arr_type)
{
/* Code For ArrType Goes Here */
if (arr_type->atype_) arr_type->atype_->accept(this);
}
void Skeleton::visitBracketsEmpty(BracketsEmpty *brackets_empty)
{
/* Code For BracketsEmpty Goes Here */
}
void Skeleton::visitSBlock(SBlock *s_block)
{
/* Code For SBlock Goes Here */
if (s_block->listmemdef_) s_block->listmemdef_->accept(this);
}
void Skeleton::visitCBlock(CBlock *c_block)
{
/* Code For CBlock Goes Here */
if (c_block->listcmemdef_) c_block->listcmemdef_->accept(this);
}
void Skeleton::visitMemberItem(MemberItem *member_item)
{
/* Code For MemberItem Goes Here */
visitIdent(member_item->ident_);
}
void Skeleton::visitMemberDef(MemberDef *member_def)
{
/* Code For MemberDef Goes Here */
if (member_def->type_) member_def->type_->accept(this);
if (member_def->listmemitem_) member_def->listmemitem_->accept(this);
}
void Skeleton::visitCVarDef(CVarDef *c_var_def)
{
/* Code For CVarDef Goes Here */
if (c_var_def->memdef_) c_var_def->memdef_->accept(this);
}
void Skeleton::visitCFuncDef(CFuncDef *c_func_def)
{
/* Code For CFuncDef Goes Here */
if (c_func_def->fndef_) c_func_def->fndef_->accept(this);
}
void Skeleton::visitBlock(Block *block)
{
/* Code For Block Goes Here */
if (block->liststmt_) block->liststmt_->accept(this);
}
void Skeleton::visitEmpty(Empty *empty)
{
/* Code For Empty Goes Here */
}
void Skeleton::visitBStmt(BStmt *b_stmt)
{
/* Code For BStmt Goes Here */
if (b_stmt->blk_) b_stmt->blk_->accept(this);
}
void Skeleton::visitDecl(Decl *decl)
{
/* Code For Decl Goes Here */
if (decl->type_) decl->type_->accept(this);
if (decl->listitem_) decl->listitem_->accept(this);
}
void Skeleton::visitSExp(SExp *s_exp)
{
/* Code For SExp Goes Here */
if (s_exp->expr_) s_exp->expr_->accept(this);
}
void Skeleton::visitAss(Ass *ass)
{
/* Code For Ass Goes Here */
if (ass->expr_1) ass->expr_1->accept(this);
if (ass->expr_2) ass->expr_2->accept(this);
}
void Skeleton::visitRet(Ret *ret)
{
/* Code For Ret Goes Here */
if (ret->expr_) ret->expr_->accept(this);
}
void Skeleton::visitVRet(VRet *v_ret)
{
/* Code For VRet Goes Here */
}
void Skeleton::visitCond(Cond *cond)
{
/* Code For Cond Goes Here */
if (cond->expr_) cond->expr_->accept(this);
if (cond->stmt_) cond->stmt_->accept(this);
}
void Skeleton::visitCondElse(CondElse *cond_else)
{
/* Code For CondElse Goes Here */
if (cond_else->expr_) cond_else->expr_->accept(this);
if (cond_else->stmt_1) cond_else->stmt_1->accept(this);
if (cond_else->stmt_2) cond_else->stmt_2->accept(this);
}
void Skeleton::visitWhile(While *while_)
{
/* Code For While Goes Here */
if (while_->expr_) while_->expr_->accept(this);
if (while_->stmt_) while_->stmt_->accept(this);
}
void Skeleton::visitForLoop(ForLoop *for_loop)
{
/* Code For ForLoop Goes Here */
if (for_loop->type_) for_loop->type_->accept(this);
visitIdent(for_loop->ident_);
if (for_loop->expr_) for_loop->expr_->accept(this);
if (for_loop->stmt_) for_loop->stmt_->accept(this);
}
void Skeleton::visitNoInit(NoInit *no_init)
{
/* Code For NoInit Goes Here */
visitIdent(no_init->ident_);
}
void Skeleton::visitInit(Init *init)
{
/* Code For Init Goes Here */
visitIdent(init->ident_);
if (init->expr_) init->expr_->accept(this);
}
void Skeleton::visitEcast(Ecast *ecast)
{
/* Code For Ecast Goes Here */
if (ecast->type_) ecast->type_->accept(this);
if (ecast->expr_) ecast->expr_->accept(this);
}
void Skeleton::visitELitNull(ELitNull *e_lit_null)
{
/* Code For ELitNull Goes Here */
}
void Skeleton::visitELitInt(ELitInt *e_lit_int)
{
/* Code For ELitInt Goes Here */
visitInteger(e_lit_int->integer_);
}
void Skeleton::visitELitDoub(ELitDoub *e_lit_doub)
{
/* Code For ELitDoub Goes Here */
visitDouble(e_lit_doub->double_);
}
void Skeleton::visitELitTrue(ELitTrue *e_lit_true)
{
/* Code For ELitTrue Goes Here */
}
void Skeleton::visitELitFalse(ELitFalse *e_lit_false)
{
/* Code For ELitFalse Goes Here */
}
void Skeleton::visitEString(EString *e_string)
{
/* Code For EString Goes Here */
visitString(e_string->string_);
}
void Skeleton::visitEVar(EVar *e_var)
{
/* Code For EVar Goes Here */
visitIdent(e_var->ident_);
}
void Skeleton::visitEApp(EApp *e_app)
{
/* Code For EApp Goes Here */
visitIdent(e_app->ident_);
if (e_app->listexpr_) e_app->listexpr_->accept(this);
}
void Skeleton::visitENewObj(ENewObj *e_new_obj)
{
/* Code For ENewObj Goes Here */
if (e_new_obj->otype_) e_new_obj->otype_->accept(this);
}
void Skeleton::visitEArrow(EArrow *e_arrow)
{
/* Code For EArrow Goes Here */
if (e_arrow->expr_) e_arrow->expr_->accept(this);
visitIdent(e_arrow->ident_);
}
void Skeleton::visitEpropety(Epropety *epropety)
{
/* Code For Epropety Goes Here */
if (epropety->expr_) epropety->expr_->accept(this);
visitIdent(epropety->ident_);
}
void Skeleton::visitEFunc(EFunc *e_func)
{
/* Code For EFunc Goes Here */
if (e_func->expr_) e_func->expr_->accept(this);
visitIdent(e_func->ident_);
if (e_func->listexpr_) e_func->listexpr_->accept(this);
}
void Skeleton::visitENewBArr(ENewBArr *e_new_b_arr)
{
/* Code For ENewBArr Goes Here */
if (e_new_b_arr->btype_) e_new_b_arr->btype_->accept(this);
if (e_new_b_arr->listdimexpr_) e_new_b_arr->listdimexpr_->accept(this);
}
void Skeleton::visitENewOArr(ENewOArr *e_new_o_arr)
{
/* Code For ENewOArr Goes Here */
if (e_new_o_arr->otype_) e_new_o_arr->otype_->accept(this);
if (e_new_o_arr->listdimexpr_) e_new_o_arr->listdimexpr_->accept(this);
}
void Skeleton::visitEAcc(EAcc *e_acc)
{
/* Code For EAcc Goes Here */
if (e_acc->expr_) e_acc->expr_->accept(this);
if (e_acc->listdimexpr_) e_acc->listdimexpr_->accept(this);
}
void Skeleton::visitEInc(EInc *e_inc)
{
/* Code For EInc Goes Here */
if (e_inc->expr_) e_inc->expr_->accept(this);
}
void Skeleton::visitEDecr(EDecr *e_decr)
{
/* Code For EDecr Goes Here */
if (e_decr->expr_) e_decr->expr_->accept(this);
}
void Skeleton::visitENeg(ENeg *e_neg)
{
/* Code For ENeg Goes Here */
if (e_neg->expr_) e_neg->expr_->accept(this);
}
void Skeleton::visitENot(ENot *e_not)
{
/* Code For ENot Goes Here */
if (e_not->expr_) e_not->expr_->accept(this);
}
void Skeleton::visitEMul(EMul *e_mul)
{
/* Code For EMul Goes Here */
if (e_mul->expr_1) e_mul->expr_1->accept(this);
if (e_mul->mulop_) e_mul->mulop_->accept(this);
if (e_mul->expr_2) e_mul->expr_2->accept(this);
}
void Skeleton::visitEAdd(EAdd *e_add)
{
/* Code For EAdd Goes Here */
if (e_add->expr_1) e_add->expr_1->accept(this);
if (e_add->addop_) e_add->addop_->accept(this);
if (e_add->expr_2) e_add->expr_2->accept(this);
}
void Skeleton::visitERel(ERel *e_rel)
{
/* Code For ERel Goes Here */
if (e_rel->expr_1) e_rel->expr_1->accept(this);
if (e_rel->relop_) e_rel->relop_->accept(this);
if (e_rel->expr_2) e_rel->expr_2->accept(this);
}
void Skeleton::visitEAnd(EAnd *e_and)
{
/* Code For EAnd Goes Here */
if (e_and->expr_1) e_and->expr_1->accept(this);
if (e_and->expr_2) e_and->expr_2->accept(this);
}
void Skeleton::visitEOr(EOr *e_or)
{
/* Code For EOr Goes Here */
if (e_or->expr_1) e_or->expr_1->accept(this);
if (e_or->expr_2) e_or->expr_2->accept(this);
}
void Skeleton::visitDim(Dim *dim)
{
/* Code For Dim Goes Here */
if (dim->expr_) dim->expr_->accept(this);
}
void Skeleton::visitPlus(Plus *plus)
{
/* Code For Plus Goes Here */
}
void Skeleton::visitMinus(Minus *minus)
{
/* Code For Minus Goes Here */
}
void Skeleton::visitTimes(Times *times)
{
/* Code For Times Goes Here */
}
void Skeleton::visitDiv(Div *div)
{
/* Code For Div Goes Here */
}
void Skeleton::visitMod(Mod *mod)
{
/* Code For Mod Goes Here */
}
void Skeleton::visitLTH(LTH *lth)
{
/* Code For LTH Goes Here */
}
void Skeleton::visitLE(LE *le)
{
/* Code For LE Goes Here */
}
void Skeleton::visitGTH(GTH *gth)
{
/* Code For GTH Goes Here */
}
void Skeleton::visitGE(GE *ge)
{
/* Code For GE Goes Here */
}
void Skeleton::visitEQU(EQU *equ)
{
/* Code For EQU Goes Here */
}
void Skeleton::visitNE(NE *ne)
{
/* Code For NE Goes Here */
}
void Skeleton::visitListEVal(ListEVal *list_e_val)
{
for (ListEVal::iterator i = list_e_val->begin() ; i != list_e_val->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListArg(ListArg *list_arg)
{
for (ListArg::iterator i = list_arg->begin() ; i != list_arg->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListTopDef(ListTopDef *list_top_def)
{
for (ListTopDef::iterator i = list_top_def->begin() ; i != list_top_def->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListBracketsOpt(ListBracketsOpt *list_brackets_opt)
{
for (ListBracketsOpt::iterator i = list_brackets_opt->begin() ; i != list_brackets_opt->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListType(ListType *list_type)
{
for (ListType::iterator i = list_type->begin() ; i != list_type->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListMemItem(ListMemItem *list_mem_item)
{
for (ListMemItem::iterator i = list_mem_item->begin() ; i != list_mem_item->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListMemdef(ListMemdef *list_memdef)
{
for (ListMemdef::iterator i = list_memdef->begin() ; i != list_memdef->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListCMemdef(ListCMemdef *list_c_memdef)
{
for (ListCMemdef::iterator i = list_c_memdef->begin() ; i != list_c_memdef->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListStmt(ListStmt *list_stmt)
{
for (ListStmt::iterator i = list_stmt->begin() ; i != list_stmt->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListItem(ListItem *list_item)
{
for (ListItem::iterator i = list_item->begin() ; i != list_item->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListDimExpr(ListDimExpr *list_dim_expr)
{
for (ListDimExpr::iterator i = list_dim_expr->begin() ; i != list_dim_expr->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitListExpr(ListExpr *list_expr)
{
for (ListExpr::iterator i = list_expr->begin() ; i != list_expr->end() ; ++i)
{
(*i)->accept(this);
}
}
void Skeleton::visitInteger(Integer x)
{
/* Code for Integer Goes Here */
}
void Skeleton::visitChar(Char x)
{
/* Code for Char Goes Here */
}
void Skeleton::visitDouble(Double x)
{
/* Code for Double Goes Here */
}
void Skeleton::visitString(String x)
{
/* Code for String Goes Here */
}
void Skeleton::visitIdent(Ident x)
{
/* Code for Ident Goes Here */
}