-
Notifications
You must be signed in to change notification settings - Fork 0
/
ast.hpp
715 lines (619 loc) · 20.5 KB
/
ast.hpp
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: ast.hpp
* Author: Andrew
*
* Created on February 9, 2017, 6:34 PM
*/
#ifndef AST_HPP
#define AST_HPP
#include <cassert>
#include "ExceptionHandle.h"
#define Type_Error 0
#define Arithmetic_Error 1
/*
This File Creates the Abstract Syntax Tree for Integers and Boolean values.
* The AST uses the visitor pattern to expand functionality of each expression class
* The base class is a the EXPR class this class holds the implementation of visitor pattern and a destructor.
* It also holds a variable that determines typing which is assigned based on what derived expression it is.
* The Derived class holds the value and creates expressions to hold more expressions.
* Finally There is a function called check which checks the typing for each Subexpression .
* This is to make sure they are well type in a expression .
*/
//Initialize Classes
class Bool_EXPR;
class Not_EXPR;
class Bool_Binary_EXPR;
class Or_EXPR;
class Xor_EXPR;
class And_EXPR;
class Int_EXPR;
class Eq_EXPR;
class Cond_EXPR;
class Neq_EXPR;
class Gt_EXPR;
class Lt_EXPR;
class Gteq_EXPR;
class Lteq_EXPR;
class AndThen_EXPR;
class OrElse_EXPR;
class Add_EXPR;
class Minus_EXPR;
class Mul_EXPR;
class Div_EXPR;
class Mod_EXPR;
class Negation_EXPR;
class Bit_Not_EXPR;
class Bit_And_EXPR;
class Bit_Or_EXPR;
class Var_Int_EXPR;
class Var_Bool_EXPR;
class No_Comp_EXPR;
//Function to check typing before implementation.
bool Check(int input, int EXPR);
//Base Class
//The typing is based on a Enum where Bool_Type=0 and Int_Type=1.
//The EXPR_type is a variable of the Enum which will hold the Enum value to compare in check functions.
class EXPR {
public:
enum Types {
Bool_Type, Int_Type
};
Types EXPR_type;
struct Visitor;
virtual ~EXPR() = default;
virtual void accept(Visitor &v) = 0;
};
//Visitor to implement the visiting pattern
struct EXPR::Visitor {
virtual void visit(Bool_EXPR*) = 0;
virtual void visit(Int_EXPR*) = 0;
virtual void visit(Not_EXPR*) = 0;
virtual void visit (Bit_Not_EXPR*)=0;
virtual void visit(Or_EXPR*) = 0;
virtual void visit (Bit_Or_EXPR*)=0;
virtual void visit(And_EXPR*) = 0;
virtual void visit (Bit_And_EXPR*)=0;
virtual void visit(Xor_EXPR*) = 0;
virtual void visit(Eq_EXPR*) = 0;
virtual void visit(Neq_EXPR*) = 0;
virtual void visit(Cond_EXPR*) = 0;
virtual void visit(Gt_EXPR*) = 0;
virtual void visit(Lt_EXPR*) = 0;
virtual void visit(Gteq_EXPR*) = 0;
virtual void visit(Lteq_EXPR*) = 0;
virtual void visit(AndThen_EXPR*) = 0;
virtual void visit(OrElse_EXPR*) = 0;
virtual void visit(Add_EXPR*) = 0;
virtual void visit(Minus_EXPR*) = 0;
virtual void visit(Mul_EXPR*) = 0;
virtual void visit(Div_EXPR*) = 0;
virtual void visit(Mod_EXPR*) = 0;
virtual void visit(Negation_EXPR*) = 0;
virtual void visit (Var_Int_EXPR*)=0;
virtual void visit (Var_Bool_EXPR*)=0;
virtual void visit (No_Comp_EXPR*)=0;
};
//Bool Expression
//Derived class to hold boolean values and declare the type to bool.
class Bool_EXPR : public EXPR {
public:
bool Value;
Bool_EXPR(bool v1) : Value(v1) {
EXPR_type = Bool_Type;
};
void accept(Visitor& v) {
return v.visit(this);
}
};
class Var_Bool_EXPR : public EXPR {
public:
bool Value;
std::string Name;
Var_Bool_EXPR(std::string N, bool v1) : Value(v1) {
EXPR_type = Bool_Type;
Name=N;
};
void accept(Visitor& v) {
return v.visit(this);
}
};
//Int Expression
//Derived class to hold Integer values and declare the type to Int.
class Int_EXPR : public EXPR {
public:
int Value;
Int_EXPR(int v1) : Value(v1) {
EXPR_type = Int_Type;
};
void accept(Visitor& v) {
return v.visit(this);
}
};
class Var_Int_EXPR : public EXPR {
public:
int Value;
std::string Name;
Var_Int_EXPR(std::string N,int v1) : Value(v1) {
EXPR_type = Int_Type;
Name=N;
};
void accept(Visitor& v) {
return v.visit(this);
}
};
//Not Expression
//The following derived classes boolean expressions values and changes the output in the Eval Function.
class Not_EXPR : public EXPR {
public:
EXPR* e1;
Not_EXPR(EXPR* a) : e1(a) {
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, a->Bool_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST Not Error:Expression is not a Bool");
}
EXPR_type = Bool_Type;
};
void accept(Visitor& v) {
return v.visit(this);
}
};
//Bit Not Expression
//The following derived classes boolean expressions values and changes the output in the Eval Function.
class Bit_Not_EXPR : public EXPR {
public:
EXPR* e1;
Bit_Not_EXPR(EXPR* a) : e1(a) {
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, a->Int_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST Bit Not Error:Expression is not a int");
}
EXPR_type = Int_Type;
};
void accept(Visitor& v) {
return v.visit(this);
}
};
//Intermediate Class to deal modularize code for boolean operators holds both boolean expressions.
class Bool_Binary_EXPR : public EXPR {
public:
EXPR* e1;
EXPR* e2;
Bool_Binary_EXPR(EXPR* a, EXPR* b) : e1(a), e2(b) {
EXPR_type = Bool_Type;
};
};
//And Expression
// The following expressions are boolean operators and check if both expressions are type bool
class And_EXPR : public Bool_Binary_EXPR {
public:
And_EXPR(EXPR* a, EXPR* b) : Bool_Binary_EXPR(a, b) {
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, a->Bool_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST And Error:Expression 1 is not a Bool");
}
Type_Defined = Check(b->EXPR_type, b->Bool_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, " in AST And Error:Expression 2 is not a Bool");
}
}
void accept(Visitor& v) {
return v.visit(this);
}
};
//Bit And Expression
// The following expressions are boolean operators and check if both expressions are type bool
class Bit_And_EXPR : public EXPR {
public:
EXPR* e1;
EXPR* e2;
Bit_And_EXPR(EXPR* a, EXPR* b) {
e1=a;
e2=b;
EXPR_type = Int_Type;
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, b->EXPR_type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST Bit And Error: Types are not the same");
}
}
void accept(Visitor& v) {
return v.visit(this);}
};
//Bit Or Expression
// The following expressions are boolean operators and check if both expressions are type bool
class Bit_Or_EXPR : public EXPR {
public:
EXPR* e1;
EXPR* e2;
Bit_Or_EXPR(EXPR* a, EXPR* b) : e1(a), e2(b) {
bool Type_Defined = true;
EXPR_type = Int_Type;
Type_Defined = Check(a->EXPR_type, b->EXPR_type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST Bit Or Error: Types are not the same");
}
}
void accept(Visitor& v) {
return v.visit(this);
}
};
//Or Expression
// The following expressions are boolean operators and check if both expressions are type bool
class Or_EXPR : public Bool_Binary_EXPR {
public:
Or_EXPR(EXPR* a, EXPR* b) : Bool_Binary_EXPR(a, b) {
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, a->Bool_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST Or Error:Expression 1 is not a Bool");
}
Type_Defined = Check(b->EXPR_type, b->Bool_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, " in AST Or Error:Expression 2 is not a Bool");
}
};
void accept(Visitor& v) {
return v.visit(this);
}
};
//Xor Expression
// The following expressions are boolean operators and check if both expressions are type bool
class Xor_EXPR : public Bool_Binary_EXPR {
public:
Xor_EXPR(EXPR* a, EXPR* b) : Bool_Binary_EXPR(a, b) {
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, b->EXPR_type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST Xor Error:Expression is not the same");
}
};
void accept(Visitor& v) {
return v.visit(this);
}
};
//Equal Expression
// The following expressions are boolean operators and check if both expressions are the same type
class Eq_EXPR : public EXPR {
public:
EXPR* e1;
EXPR* e2;
Eq_EXPR(EXPR* a, EXPR* b) : e1(a), e2(b) {
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, b->EXPR_type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, " in AST EQ Error:Expression are not the same type.");
}
EXPR_type = Bool_Type;
}
void accept(Visitor& v) {
return v.visit(this);
}
};
//Not Equal Expression
// The following expressions are boolean operators and check if both expressions are the same type
class Neq_EXPR : public EXPR {
public:
EXPR* e1;
EXPR* e2;
Neq_EXPR(EXPR* a, EXPR* b) : e1(a), e2(b) {
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, b->EXPR_type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, " in AST NeQ Error:Expression are not the same type.");
}
EXPR_type = Bool_Type;
}
void accept(Visitor& v) {
return v.visit(this);
}
};
//If then Expression
// The following expressions is a boolean operator and checks if the expressions are well typed.
class Cond_EXPR : public EXPR {
public:
EXPR* e1;
EXPR* e2;
EXPR* e3;
Cond_EXPR(EXPR* a, EXPR* b, EXPR* c) : e1(a), e2(b), e3(c) {
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, a->Bool_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST if Cond Error:If condition does not result into a bool");
}
Type_Defined = Check(b->EXPR_type, c->EXPR_type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, " in AST if Cond Error:IF and else Implementation is not the same type.");
}
EXPR_type = b->EXPR_type;
}
void accept(Visitor& v) {
return v.visit(this);
}
};
//Greater Than Expression
// The following expressions are boolean operators and check if both expressions are type Int.
class Gt_EXPR : public EXPR {
public:
EXPR* e1;
EXPR* e2;
Gt_EXPR(EXPR* a, EXPR* b) : e1(a), e2(b) {
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, a->Int_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, " in AST Greater Than Error:Expression 1 is not a Int.");
}
Type_Defined = Check(b->EXPR_type, b->Int_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, " in AST Greater Than Error:Expression 2 is not a Int.");
}
EXPR_type = Bool_Type;
}
void accept(Visitor& v) {
return v.visit(this);
}
};
//Less Than Expression
// The following expressions are boolean operators and check if both expressions are type Int.
class Lt_EXPR : public EXPR {
public:
EXPR* e1;
EXPR* e2;
Lt_EXPR(EXPR* a, EXPR* b) : e1(a), e2(b) {
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, a->Int_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, " in AST Less Than Error:Expression 1 is not a Int.");
}
Type_Defined = Check(b->EXPR_type, b->Int_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, " in AST Less Than Error:Expression 2 is not a Int.");
}
EXPR_type = Bool_Type;
}
void accept(Visitor& v) {
return v.visit(this);
}
};
//Greater Than Equal To Expression
// The following expressions are boolean operators and check if both expressions are type Int.
class Gteq_EXPR : public EXPR {
public:
EXPR* e1;
EXPR* e2;
Gteq_EXPR(EXPR* a, EXPR* b) : e1(a), e2(b) {
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, a->Int_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, " in AST Greater Than or Equal To Error:Expression 1 is not a Int.");
}
Type_Defined = Check(b->EXPR_type, b->Int_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, " in AST Greater Than or Equal To Error:Expression 2 is not a Int.");
}
EXPR_type = Bool_Type;
}
void accept(Visitor& v) {
return v.visit(this);
}
};
//Less Than Equal To Expression
// The following expressions are boolean operators and check if both expressions are type Int.
class Lteq_EXPR : public EXPR {
public:
EXPR* e1;
EXPR* e2;
Lteq_EXPR(EXPR* a, EXPR* b) : e1(a), e2(b) {
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, a->Int_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, " in AST Less Than or Equal To :Expression 1 is not a Int.");
}
Type_Defined = Check(b->EXPR_type, b->Int_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, " in AST Less Than or Equal To Error:Expression 2 is not a Int.");
}
EXPR_type = Bool_Type;
}
void accept(Visitor& v) {
return v.visit(this);
}
};
//And Then Expression
// The following expressions is a boolean operator and checks if the expressions are well typed.
class AndThen_EXPR : public EXPR {
public:
EXPR* e1;
EXPR* e2;
AndThen_EXPR(EXPR* a, EXPR* b) : e1(a), e2(b) {
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, a->Bool_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST And Then Cond Error: If condition does not result into a bool");
}
Type_Defined = Check(b->EXPR_type, b->Bool_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, " in AST And Then Cond Error: Expression 2 is not type bool");
}
EXPR_type = b->Bool_Type;
}
void accept(Visitor& v) {
return v.visit(this);
}
};
//Or Else Expression
// The following expressions is a boolean operator and checks if the expressions are well typed.
class OrElse_EXPR : public EXPR {
public:
EXPR* e1;
EXPR* e2;
OrElse_EXPR(EXPR* a, EXPR* b) : e1(a), e2(b) {
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, a->Bool_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST Or Else Cond Error: If condition does not result into a bool");
}
Type_Defined = Check(b->EXPR_type, b->Bool_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, " in AST Or Else Cond Error: Expression 2 is not type bool");
}
EXPR_type = b->Bool_Type;
}
void accept(Visitor& v) {
return v.visit(this);
}
};
//Addition Expression
// The following expression is a Integer operator and check if both expressions are type Int.
class Add_EXPR : public EXPR {
public:
EXPR* e1;
EXPR* e2;
Add_EXPR(EXPR* a, EXPR* b) : e1(a), e2(b) {
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, a->Int_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST Add Error:Expression 1 is not a Int");
}
Type_Defined = Check(b->EXPR_type, b->Int_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST Add Error:Expression 2 is not a Int");
}
EXPR_type = b->Int_Type;
}
void accept(Visitor& v) {
return v.visit(this);
}
};
//Subtraction Expression
// The following expression is a Integer operator and check if both expressions are type Int.
class Minus_EXPR : public EXPR {
public:
EXPR* e1;
EXPR* e2;
Minus_EXPR(EXPR* a, EXPR* b) : e1(a), e2(b) {
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, a->Int_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST Minus Error:Expression 1 is not a Int");
}
Type_Defined = Check(b->EXPR_type, b->Int_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST Minus Error:Expression 2 is not a Int");
}
EXPR_type = b->Int_Type;
}
void accept(Visitor& v) {
return v.visit(this);
}
};
//Multiplication Expression
// The following expression is a Integer operator and check if both expressions are type Int.
class Mul_EXPR : public EXPR {
public:
EXPR* e1;
EXPR* e2;
Mul_EXPR(EXPR* a, EXPR* b) : e1(a), e2(b) {
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, a->Int_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST Multiply Error:Expression 1 is not a Int");
}
Type_Defined = Check(b->EXPR_type, b->Int_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST Multiply Error:Expression 2 is not a Int");
}
EXPR_type = b->Int_Type;
}
void accept(Visitor& v) {
return v.visit(this);
}
};
//Division Expression
// The following expression is a Integer operator and check if both expressions are type Int.
class Div_EXPR : public EXPR {
public:
EXPR* e1;
EXPR* e2;
Div_EXPR(EXPR* a, EXPR* b) : e1(a), e2(b) {
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, a->Int_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST Divide Error:Expression 1 is not a Int");
}
Type_Defined = Check(b->EXPR_type, b->Int_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST Divide Error:Expression 2 is not a Int");
}
EXPR_type = b->Int_Type;
}
void accept(Visitor& v) {
return v.visit(this);
}
};
//Modulation Expression
// The following expression is a Integer operator and check if both expressions are type Int.
class Mod_EXPR : public EXPR {
public:
EXPR* e1;
EXPR* e2;
Mod_EXPR(EXPR* a, EXPR* b) : e1(a), e2(b) {
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, a->Int_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST Modulus Error:Expression 1 is not a Int");
}
Type_Defined = Check(b->EXPR_type, b->Int_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST Modulus Error:Expression 2 is not a Int");
}
EXPR_type = b->Int_Type;
}
void accept(Visitor& v) {
return v.visit(this);
}
};
//Negation Expression
// The following expression is a Integer operator and check if expression is type Int.
class Negation_EXPR : public EXPR {
public:
EXPR* e1;
Negation_EXPR(EXPR* a) : e1(a) {
bool Type_Defined = true;
Type_Defined = Check(a->EXPR_type, a->Int_Type);
if (Type_Defined != true) {
ExceptionThrow(Type_Error, "in AST Negation Error:Expression is not a Int");
}
EXPR_type = Int_Type;
};
void accept(Visitor& v) {
return v.visit(this);
}
};
class No_Comp_EXPR : public EXPR {
public:
EXPR* e1;
int Value=0;
No_Comp_EXPR() {
EXPR_type = Int_Type;
};
void accept(Visitor& v) {
return v.visit(this);
}
};
//Uses this function to verify if both inputs (in this case type value) is the same.
bool Check(int input, int EXPR) {
if (input == EXPR) {
return true;
} else {
return false;
}
}
#endif /* AST_HPP */