-
Notifications
You must be signed in to change notification settings - Fork 1
/
E--_parser.y++
619 lines (470 loc) · 26.2 KB
/
E--_parser.y++
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
%{
#include "Ast.h"
#include "ParserUtil.h"
#include "Error.h"
#include "log.h"
using namespace std;
extern int verbosity;
extern int yylex();
extern void yyerror(const char *s);
int offSet;
extern const OpNode::OpInfo opInfo[];
/* Global variables for inherited attributes */
Type *var_type;
Type *fun_ret_type;
RuleBlockEntry* rbe = NULL;
int start_rule_scope = 0;
WhileNode* Globwhile;
%}
%union{
unsigned int uVal;
double dVal;
char* cVal;
vector<string>* strVector;
Value* valVal;
ExprNode* exprVal;
vector<ExprNode*>* exprList;
RefExprNode* refexpVal;
ClassEntry* classEntry;
Type* typeVal;
vector<Type*>* typeList;
EventEntry* eventEntry;
VariableEntry* variableEntry;
FunctionEntry* functionEntry;
vector<VariableEntry*>* variableEntries;
BasePatNode* patVal;
PrimitivePatNode* primPatVal;
StmtNode* stmtVal;
list<StmtNode*>* stmtList;
IfNode* ifVal;
WhileNode* whileVal;
CompoundStmtNode* compoundStmtVal;
RuleNode* ruleNode;
vector<RuleNode*>* transList;
vector<Type*>* formalTypeVal;
const OpNode::OpInfo* funIval;
};
/* Operators */
%token TOK_LEX_ERROR TOK_PAT_STAR TOK_PAT_OR TOK_PAT_NOT
%token TOK_PLUS TOK_MINUS TOK_UMINUS TOK_MULT TOK_DIV TOK_MOD
%token TOK_BITAND TOK_BITOR TOK_BITNOT TOK_BITXOR TOK_SHL TOK_SHR
%token TOK_GT TOK_LT TOK_GE TOK_LE TOK_EQ TOK_NE TOK_AND TOK_OR TOK_NOT
%token TOK_COMMA TOK_ASSIGN TOK_SEMICOLON TOK_COLON TOK_ARROW
%token TOK_LBRACE TOK_RBRACE TOK_LPAREN TOK_RPAREN
/* Key words */
%token TOK_IF TOK_ELSE TOK_CLASS TOK_RETURN TOK_EVENT TOK_ANY TOK_PRINT
%token TOK_UINTNUM TOK_DOUBLENUM TOK_VOID TOK_STRING TOK_STRCONST
%token TOK_INT TOK_UNSIGNED TOK_BOOL TOK_BYTE TOK_DOUBLE TOK_SHORT
%token TOK_TRUE TOK_FALSE TOK_IDENT
%token TOK_WHILE TOK_BREAK
%token TOK_RBRACK TOK_QMARK TOK_LONG TOK_BIT TOK_ENUM
/******************************** Type Info ********************************/
%type <typeVal> type baseType
%type <valVal> literal
%type <uVal> TOK_UINTNUM
%type <dVal> TOK_DOUBLENUM
%type <cVal> TOK_STRCONST
%type <cVal> TOK_IDENT TOK_PRINT
%type <variableEntry> var_ident
%type <variableEntries> ident_list
%type <stmtVal> stmt return_stmt fun_call_stmt break_stmt
%type <stmtList> stmt_star
%type <eventEntry> event_decl event_hdr event_call_header
%type <primPatVal> event_call primitive_pat_star primitive_pat
%type <strVector> event_params event_params_list
%type <functionEntry> func func_hdr
%type <compoundStmtVal> func_stmt compstmt_star compstmt
%type <exprList> func_params func_param_list
%type <classEntry> class_decl
%type <cVal> class_ident
%type <ruleNode> rule
%type <patVal> rule_pattern
%type <transList> rule_star
%type <exprVal> expr expr_star assign_expr fun_call
%type <ifVal> if_expr_star if_expr
%type <whileVal> while_expr
%type <refexpVal> ref_expr
%type <typeList> formal_params formal_param_list formal_list
%type <variableEntry> formal_param
/******************************** Type Info ********************************/
/* Uncomment types below as you start adding rules.
They are commented right now to prevent compile errors.
%type <functionEntry> function_header function_decl
%type <variableEntry> variable_decl formal_param variable_decl1
%type <typeList> formal_param_list formal_param_plus
%type <eventEntry> event_decl_hdr event_decl
%type <patVal> event_pattern rule_body1
%type <primPatVal> event primitive_pat
%type <typeVal> type baseType
%type <exprList> expr_list expr_plus
%type <exprVal> expr function_invocation asg_stmt
%type <refexpVal> ref_expr
%type <ruleNode> rule
%type <strVector> id_list id_plus
%type <cVal> TOK_IDENT TOK_PRINT
%type <funIval> ev_or_fun
%type <uVal> TOK_UINTNUM
%type <dVal> TOK_DOUBLENUM
%type <cVal> TOK_STRCONST
%type <valVal> literal
%type <stmtList> stmt_plus
%type <stmtVal> stmt simple_stmt
%type <compoundStmtVal> compoundStmt fun_rest
%type <ifVal> if_then_else_stmt
*/
/********************* Precedence and Associativity ********************/
%right TOK_SEMICOLON "reduce"
%right "then" TOK_ELSE
%nonassoc TOK_ASSIGN
%left TOK_PAT_OR
%left TOK_COLON
%left TOK_PAT_STAR
%right TOK_PAT_NOT
%left TOK_OR
%left TOK_AND
%right TOK_NOT
%nonassoc TOK_EQ TOK_NE TOK_GT TOK_LT TOK_GE TOK_LE
%left TOK_BITOR TOK_BITXOR
%left TOK_BITAND
%right TOK_BITNOT
%left TOK_SHL TOK_SHR
%right TOK_DOUBLE_COLON
%left TOK_PLUS TOK_MINUS
%left TOK_MULT TOK_DIV TOK_MOD
%right TOK_UMINUS
%left TOK_LBRACK
%left TOK_DOT
/**************************************************************************/
%start specification
%%
/*********** E-- Program General Flow : Various Declaratios Followed by E--Rules **********************/
specification: decl_star rule_star { };
/*********** Language General Declaration **********************/
decl_star: /* empty */ {}
| decl_star decl {}
| decl_star error TOK_SEMICOLON {
errMsg("Syntax error, expecting a declaration");
};
/* Generic Declaration and Rule Handling -- Start reading from here to get the flow of grammer */
decl: variable {}
| event_decl TOK_SEMICOLON {}
| func {}
| class_decl TOK_SEMICOLON {}
| TOK_SEMICOLON {};
/*********** E-- Variables **********************/
variable: type ident_list TOK_SEMICOLON {
for(std::vector<VariableEntry*>::iterator it = $2->begin(); it != $2->end(); it++) {
(*it)->type($1);
if(stm.insert(*it) == DUPLICATE_SYM) {
errMsg("Double declaration");
}
}
}
| type error TOK_SEMICOLON {
errMsg("Error in variable declaration, may be a missing identifier");
}
| TOK_IDENT error TOK_SEMICOLON {
errMsg("Error in variable declaration, may be a missing type name or identifier");
};
var_star: variable {}
| var_star variable {};
ident_list: ident_list TOK_COMMA var_ident {
if($3 != NULL)
$$->push_back($3);
}
| var_ident {
$$ = new vector<VariableEntry*>();
if($1 != NULL)
$$->push_back($1);
};
var_ident: TOK_IDENT {
SymTabEntry *ce = stm.currentScope();
VariableEntry::VarKind vk = VariableEntry::VarKind::LOCAL_VAR;
if(ce->kind() == SymTabEntry::Kind::GLOBAL_KIND)
vk = VariableEntry::VarKind::GLOBAL_VAR;
$$ = new VariableEntry($1, vk);
}
| TOK_IDENT TOK_ASSIGN expr {
SymTabEntry *ce = stm.currentScope();
VariableEntry::VarKind vk = VariableEntry::VarKind::LOCAL_VAR;
if(ce->kind() == SymTabEntry::Kind::GLOBAL_KIND)
vk = VariableEntry::VarKind::GLOBAL_VAR;
$$ = new VariableEntry($1, vk, NULL, $3);
};
/*********** E-- Class Declarations **********************/
class_decl: TOK_CLASS class_ident {
$$=new ClassEntry($2);
if(stm.insert($$) == DUPLICATE_SYM) {
errMsg("Double declaration");
}
}
|
TOK_CLASS error {
errMsg("Syntax error in class declaration: expecting class name");
};
class_ident: TOK_IDENT { $$ = $1; };
/****** E-- Event Calls *******/
event_decl: event_hdr formal_list {
$$=$1;
$$->type(new Type($2, Type::TypeTag::EVENT));
};
event_hdr: TOK_EVENT TOK_IDENT {
$$ = new EventEntry($2);
if(stm.insert($$) == DUPLICATE_SYM) {
errMsg("Double declaration");
}
stm.enterScope($$);
};
formal_list: TOK_LPAREN formal_param_list TOK_RPAREN {
SymTabEntry *cs = stm.currentScope();
if(cs->kind() == SymTabEntry::Kind::EVENT_KIND)
stm.leaveScope();
$$ = $2;
};
formal_param_list: /* empty */ { $$ = nullptr; }
| formal_params { $$ = $1; };
formal_params: formal_param {
$$ = new std::vector<Type*>();
$$->push_back(var_type);
}
| formal_params TOK_COMMA formal_param {
if ($1)
$1->push_back(var_type);
else {
$1 = new std::vector<Type*>();
$1->push_back(var_type);
}
};
formal_param: type var_ident {
$$ = new VariableEntry($2->name(), VariableEntry::VarKind::PARAM_VAR, $1);
if(stm.insert($$) == DUPLICATE_SYM) {
errMsg("Double declaration");
}
var_type = $1;
};
/*********** E-- Function Declarations **********************/
func: func_hdr formal_list TOK_SEMICOLON {
$1->type(new Type($2, fun_ret_type));
$$ = $1;
stm.leaveScope();
}
| func_hdr formal_list func_body {
$1->type(new Type($2, fun_ret_type));
$$ = $1;
stm.leaveScope();
};
func_hdr: type TOK_IDENT {
$$ = new FunctionEntry($2, nullptr);
fun_ret_type = $1;
if(stm.insert($$) == DUPLICATE_SYM) {
errMsg("Double declaration");
}
stm.enterScope($$);
}
| type error {
errMsg("Expecting a function declaration -- may be a missing function name");
};
func_body: TOK_LBRACE func_stmt TOK_RBRACE {
SymTabEntry *ce = stm.currentScope();
if(ce->kind() == SymTabEntry::Kind::FUNCTION_KIND)
((FunctionEntry*)ce)->body($2);
};
func_stmt: stmt_star { $$ = new CompoundStmtNode($1, yylinenum, 0, yyfilename); }
| var_star stmt_star { $$ = new CompoundStmtNode($2, yylinenum, 0, yyfilename); };
/*********** E-- Rules Handling **********************/
rule_star: rule {
stm.leaveScope();
stm.insert(rbe);
start_rule_scope = 0;
SymTabEntry *ce = stm.currentScope();
if(ce->kind() == SymTabEntry::Kind::GLOBAL_KIND)
((GlobalEntry*)ce)->addRule($1);
}
| rule_star rule {
stm.leaveScope();
stm.insert(rbe);
start_rule_scope = 0;
SymTabEntry *ce = stm.currentScope();
if(ce->kind() == SymTabEntry::Kind::GLOBAL_KIND)
((GlobalEntry*)ce)->addRule($2);
};
rule: rule_pattern TOK_ARROW stmt{
RuleBlockEntry *bE = new RuleBlockEntry();
$$ = new RuleNode(bE, $1, $3, yylinenum, 0, yyfilename);
};
/*********** E-- Rule Patterns **********************/
rule_pattern: primitive_pat_star { $$=$1; }
| rule_pattern TOK_PAT_STAR { $$ = new PatNode(BasePatNode::PatNodeKind::STAR, $1, NULL, yylinenum, 0, yyfilename); }
| TOK_NOT rule_pattern { $$ = new PatNode(BasePatNode::PatNodeKind::NEG, $2, NULL, yylinenum, 0, yyfilename); }
| rule_pattern TOK_PAT_OR rule_pattern{ $$ = new PatNode(BasePatNode::PatNodeKind::OR, $1, $3, yylinenum, 0, yyfilename); }
| rule_pattern TOK_COLON rule_pattern { $$ = new PatNode(BasePatNode::PatNodeKind::SEQ, $1, $3, yylinenum, 0, yyfilename); }
| TOK_LPAREN rule_pattern TOK_RPAREN { $$ = $2; };
primitive_pat_star: primitive_pat { $$=$1; }
| primitive_pat TOK_BITOR expr {
$1->cond($3);
$$ = $1;
};
primitive_pat: event_call { $$=$1; };
/* Event Invocation */
event_call_header: TOK_IDENT TOK_LPAREN {
EventEntry *epl = static_cast <EventEntry*> (stm.lookUp($1)); //TODO: lookUpScope() ?
rbe = new RuleBlockEntry();
if(!start_rule_scope) {
stm.enterScope(rbe);
start_rule_scope = 1;
}
$$ = epl;
};
event_call: event_call_header event_params_list TOK_RPAREN {
std::vector<VariableEntry*>* vent = new std::vector<VariableEntry*>();
std::vector<string>::iterator it;
int param_count = 0, count = 0;
if ($1 && $1->symTab()) {
if ($1->symTab()->size() > (int)$2->size())
param_count = $2->size();
else
param_count = $1->symTab()->size();
SymTab::iterator it_sym = $1->symTab()->begin();
for (it = $2->begin(), it_sym = $1->symTab()->begin(); it != $2->end(), it_sym != $1->symTab()->end(); ++it, ++it_sym) {
if (count < param_count)
vent->push_back(new VariableEntry(*it, VariableEntry::VarKind::PARAM_VAR, (*it_sym)->type()));
count++;
}
}
$$ = new PrimitivePatNode($1, vent, nullptr, yylinenum, 0, yyfilename);
}
| TOK_ANY {
EventEntry *epl = static_cast <EventEntry*> (stm.lookUp("any")); //TODO: lookUpScope() ?
rbe = new RuleBlockEntry();
$$ = new PrimitivePatNode(epl, nullptr, nullptr, yylinenum, 0, yyfilename);
if(!start_rule_scope) {
stm.enterScope(rbe);
start_rule_scope = 1;
}
};
event_params_list: event_params { $$=$1; };
event_params: { $$ = new vector<string>(); }
| TOK_IDENT {
$$ = new vector<string>();
if($1 != NULL)
$$->push_back($1);
}
| event_params TOK_COMMA TOK_IDENT {
if($3 != NULL)
$$->push_back($3);
};
/******************** E-- Statement Handling ******************/
stmt: TOK_SEMICOLON { $$=NULL; }
| return_stmt TOK_SEMICOLON { $$=$1; }
| break_stmt TOK_SEMICOLON { $$=$1; }
| compstmt_star { $$=$1; }
| assign_expr TOK_SEMICOLON { $$=new ExprStmtNode($1, yylinenum, 0, yyfilename); }
| if_expr_star { $$=$1; }
| while_expr { $$=$1; }
| fun_call_stmt { $$=$1; };
compstmt_star: compstmt { $$=$1; } %prec "reduce"
| compstmt TOK_SEMICOLON { $$=$1; };
compstmt: TOK_LBRACE stmt_star TOK_RBRACE { $$ = new CompoundStmtNode($2, yylinenum, 0, yyfilename); };
stmt_star: stmt_star stmt {
if($1 != NULL)
$$->push_back($2);
}
| stmt {
$$ = new list<StmtNode*>();
if($1 != NULL)
$$->push_back($1);
}
| stmt_star error {
errMsg("Syntax error while parsing a statement");
};
return_stmt: TOK_RETURN expr {
SymTabEntry *ce = stm.currentScope();
if(ce->kind() == SymTabEntry::Kind::FUNCTION_KIND)
$$ = new ReturnStmtNode($2, ((FunctionEntry*)ce), yylinenum, 0, yyfilename);
};
break_stmt: TOK_BREAK { $$ = new BreakStmtNode(NULL, Globwhile, yylinenum, 0, yyfilename); };
/********** If Expressions *************/
if_expr_star: if_expr %prec "then" { $$=$1; }
| if_expr TOK_ELSE stmt { $$ = new IfNode(((IfNode*)$1)->cond(), ((IfNode*)$1)->thenStmt(), $3, yylinenum, 0, yyfilename);
};
if_expr: TOK_IF expr stmt { $$ = new IfNode($2, $3, NULL, yylinenum, 0, yyfilename); };
/********** While Expressions *************/
while_expr: TOK_WHILE expr stmt { $$ = new WhileNode($2, $3, yylinenum, 0, yyfilename); Globwhile = $$;};
/************ Function Invocation *******************/
fun_call_stmt: fun_call TOK_SEMICOLON {
//$$ = new ExprStmtNode(new InvocationNode(stm.lookUp($1), $2), yylinenum, 0, yyfilename);
$$ = new ExprStmtNode($1, yylinenum, 0, yyfilename);
};
fun_call: TOK_IDENT func_params {
if ((strlen($1) == 6) && (strcmp($1, "printf") == 0)) {
$$=new OpNode(OpNode::OpCode::PRINT, NULL, NULL, yylinenum, 0, yyfilename);
$$->args($2);
} else
$$=new InvocationNode(stm.lookUp($1), $2, yylinenum, 0, yyfilename);
};
func_params: TOK_LPAREN func_param_list TOK_RPAREN { $$=$2; };
func_param_list: { $$ = new vector<ExprNode*>();}
| expr {
$$ = new vector<ExprNode*>();
if($1 != NULL)
$$->push_back($1);
}
| func_param_list TOK_COMMA expr {
if($3 != NULL)
$$->push_back($3);
};
/************** Expressions **********************/
expr: expr_star { $$=$1; }
| expr TOK_PLUS expr { $$=new OpNode(OpNode::OpCode::PLUS,$1,$3, yylinenum, 0, yyfilename); }
| expr TOK_MINUS expr { $$=new OpNode(OpNode::OpCode::MINUS,$1,$3, yylinenum, 0, yyfilename); }
| expr TOK_MULT expr { $$=new OpNode(OpNode::OpCode::MULT,$1,$3, yylinenum, 0, yyfilename); }
| expr TOK_DIV expr { $$=new OpNode(OpNode::OpCode::DIV,$1,$3, yylinenum, 0, yyfilename); }
| expr TOK_MOD expr { $$=new OpNode(OpNode::OpCode::MOD,$1,$3, yylinenum, 0, yyfilename); }
| expr TOK_BITAND expr { $$=new OpNode(OpNode::OpCode::BITAND,$1,$3, yylinenum, 0, yyfilename); }
| expr TOK_BITOR expr { $$=new OpNode(OpNode::OpCode::BITOR,$1,$3, yylinenum, 0, yyfilename); }
| expr TOK_BITXOR expr { $$=new OpNode(OpNode::OpCode::BITXOR,$1,$3, yylinenum, 0, yyfilename); }
| expr TOK_SHL expr { $$=new OpNode(OpNode::OpCode::SHL,$1,$3, yylinenum, 0, yyfilename); }
| expr TOK_SHR expr { $$=new OpNode(OpNode::OpCode::SHR,$1,$3, yylinenum, 0, yyfilename); }
| expr TOK_AND expr { $$=new OpNode(OpNode::OpCode::AND,$1,$3, yylinenum, 0, yyfilename); }
| expr TOK_OR expr { $$=new OpNode(OpNode::OpCode::OR,$1,$3, yylinenum, 0, yyfilename); }
| expr TOK_EQ expr { $$=new OpNode(OpNode::OpCode::EQ,$1,$3, yylinenum, 0, yyfilename); }
| expr TOK_NE expr { $$=new OpNode(OpNode::OpCode::NE,$1,$3, yylinenum, 0, yyfilename); }
| expr TOK_GT expr { $$=new OpNode(OpNode::OpCode::GT,$1,$3, yylinenum, 0, yyfilename); }
| expr TOK_LT expr { $$=new OpNode(OpNode::OpCode::LT,$1,$3, yylinenum, 0, yyfilename); }
| expr TOK_GE expr { $$=new OpNode(OpNode::OpCode::GE,$1,$3, yylinenum, 0, yyfilename); }
| expr TOK_LE expr { $$=new OpNode(OpNode::OpCode::LE,$1,$3, yylinenum, 0, yyfilename); }
| TOK_LPAREN expr TOK_RPAREN { $$=$2; }
| TOK_MINUS expr { $$=new OpNode(OpNode::OpCode::UMINUS,$2, NULL, yylinenum, 0, yyfilename); }
| TOK_NOT expr { $$=new OpNode(OpNode::OpCode::NOT,$2, NULL, yylinenum, 0, yyfilename); }
| TOK_BITNOT expr { $$=new OpNode(OpNode::OpCode::BITNOT,$2, NULL, yylinenum, 0, yyfilename); }
;
expr_star: literal { $$=new ValueNode($1, yylinenum, 0, yyfilename); }
| ref_expr { $$=$1; }
| assign_expr { $$=$1; }
| fun_call { $$=$1; };
assign_expr: ref_expr TOK_ASSIGN expr { $$=new OpNode(OpNode::OpCode::ASSIGN,$1,$3, yylinenum, 0, yyfilename); };
ref_expr: TOK_IDENT { SymTabEntry *ce = stm.lookUp($1); LOG("symbol table entry " << (unsigned long)ce);
$$=new RefExprNode($1, ce, yylinenum, 0, yyfilename); };
/******* Literal Constant Handling *****/
literal: TOK_STRCONST { $$=new Value($1); }
| TOK_UINTNUM { $$=new Value($1, Type::Type::UINT); }
| TOK_DOUBLENUM { $$=new Value($1); }
| TOK_TRUE { $$=new Value(true); }
| TOK_FALSE { $$=new Value(false); };
/*********** E-- Data Types ***************/
baseType: TOK_BOOL { $$=new Type(Type::TypeTag::BOOL); }
| TOK_BYTE { $$=new Type(Type::TypeTag::BYTE); }
| TOK_VOID { $$=new Type(Type::TypeTag::VOID); }
| TOK_INT { $$=new Type(Type::TypeTag::INT); }
| TOK_DOUBLE { $$=new Type(Type::TypeTag::DOUBLE); }
| TOK_STRING { $$=new Type(Type::TypeTag::STRING); }
| TOK_UNSIGNED TOK_INT { $$=new Type(Type::TypeTag::UINT); };
type: baseType { $$=$1; }
| TOK_IDENT {
SymTabEntry *ce=stm.lookUp($1);
if(ce==NULL)
$$=new Type(ce,Type::UNKNOWN);
else
$$=new Type(ce,Type::CLASS);
};
%%