-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathparser.y
More file actions
741 lines (679 loc) · 20.8 KB
/
parser.y
File metadata and controls
741 lines (679 loc) · 20.8 KB
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
%{
#include <stdio.h>
#include <string.h>
#include "defs.h"
#include "translator.c"
#include "symtab.h"
#include "semantic.h"
#define YYSTYPE char*
int yyparse(void);
int yylex(void);
int yyerror(char *s);
int class_id = -1;
int designator_class_id = -1;
extern int line;
int level = 0;
char* type;
extern FILE * yyin;
int error_count = 0;
FILE *fp;
int function_index = -1;
char* function_type;
char* glob_designator = NULL;
int par_num = 0;
char* ex_type = NULL;
int if_or_while = 0;
int arg_num = 0;
int function_call_index = -1;
int glob_designator_id=-1;
char* to_assign_type=NULL;
int to_assign_id=-1;
int return_called=0;
%}
%token _TYPE
%token _IF
%token _ELSE
%token _RETURN
%token _ID
%token _INT_NUMBER
%token _UNSIGNED_NUMBER
%token _LPAREN
%token _RPAREN
%token _COMMA
%token _LBRACKET
%token _RBRACKET
%token _ASSIGN
%token _SEMICOLON
%token _PLUS
%token _MINUS
%token _TIMES
%token _DIV
%token _MOD
%token _RELOP
%token _INCLUDE
%token _CHAR
%token _REAL
%token _STRING
%token _VOJD
%token _WHILE
%token _SCANF
%token _APERSANT
%token _PRINTF
%token _ARRAY_VALUE
%token _SWITCH
%token _COLON
%token _BREAK
%token _RSQUARE_BRACKET
%token _AND
%token _OR
%token _NOT
%token _NOTB
%token _ORB
%token _PLUS_PLUS
%token _MINUS_MINUS
%token _PROGRAM
%token _NEW
%token _READ
%token _CLASS
%token _CONST
%token _EXTENDS
%token _FALSE
%token _TRUE
%token _DOT
%token _POINT_ID
%token _LSQUARE_BRACKET
%token _NULL
%token _START_METHOD_DECL
%%
program
: _PROGRAM _ID {
insert_symbol("eol", METHOD, "char", 0, -1);
set_attribute(0, 0);
insert_symbol("ord", METHOD, "int", 0, -1);
set_param_type(1, 1, "char");
set_attribute(1, 1);
insert_symbol("chr", METHOD, "char", 0, -1);
set_param_type(2, 1, "int");
set_attribute(2, 1);
insert_symbol("len", METHOD, "int", 0, -1);
set_param_type(3, 1, "string");
set_attribute(3, 1);
}
allDeclarations _LBRACKET methodDeclarations _RBRACKET {
check_main(); print_symtab();}
;
allDeclarations
: allDeclarations allDeclaration
|
;
allDeclaration
: classDeclaration {}
| varDeclaration {}
| constDeclaration {}
;
varDeclarations
: varDeclarations varDeclaration
| { }
;
varDeclaration
: type{
if (check_type_existance($1) == 1) type = $1;
else {
printf("Line: %d: Type does not exist", line);
type = "";
}
}
var_enumeration _SEMICOLON
;
classVarDeclarationsAndMethods
: varDeclarations varDeclaration methodDeclarations
|
;
constDeclaration
: _CONST type {type = $2; if(check_primitive_type($2) == -1) printf("Line: %d : Invalid constant type!\n", line); } clist _SEMICOLON
;
clist
: _ID _ASSIGN constvalue {if(strcmp(type, $3) != 0) printf("Line: %d : Invalid assignment!\n", line);
try_to_insert_constant($1, type);}
| clist _COMMA _ID _ASSIGN constvalue {if(strcmp(type, $5) != 0) printf("Line: %d : Invalid assignment!\n", line);
try_to_insert_constant($3, type);}
;
type
: _TYPE
| _ID
;
classDeclaration
: _CLASS _ID _EXTENDS _ID {
class_id = register_class($2, $4);
if (class_id != -1) level = 1 ;
else class_id = -11;
}
_LBRACKET varDeclarations methodDeclarations
_RBRACKET {
class_id = -1;
level = 0;
}
| _CLASS _ID _LBRACKET {
class_id = register_class($2, NULL);
if (class_id != -1) level = 1 ;
else class_id = -11;
}
varDeclarations methodDeclarations _RBRACKET {
class_id = -1;
level = 0;
}
;
methodDeclarations
: _START_METHOD_DECL{
function_index = insert_method(parse_method_name($1), class_id, parse_method_type($1), level);
level++;
}
formParams {
set_attribute(function_index, par_num);
par_num=0;
}
_RPAREN varDeclarations _LBRACKET statements _RBRACKET {
level--;
if(strcmp(get_type(function_index),"void") != 0 && return_called <=0)
printf("Line: %d: Method does not have a return call\n",line);
if (function_index != -1)
if (function_index != get_last_element() )
clear_symbols(function_index+1);
function_index = -1;
return_called=0;
}
methodDeclarations
|
;
formParams
: arguments
|
;
arguments
: type arrayOrId {
if (function_index != -1){
if (check_type_existance($1) == 1){
int index;
index = push_array_or_id($2, $1, class_id, level);
set_initialized(index,1);
par_num++;
set_param_type(function_index, par_num, get_type(index));
}else{ // ne valja nam type argumenta pa brisemo sve prethodne i metodu
clear_symbols(function_index);
function_index = -1; //OOOOOOOOVOOOOOOOOO DOOOOOOOOOBROOOOOOO TESTIRATIIIIIIIIIII
}
}
}
| arguments _COMMA type arrayOrId {
if (function_index != -1){
if (check_type_existance($3) == 1){
int index;
index = push_array_or_id($4, $3, class_id, level);
set_initialized(index,1);
par_num++;
set_param_type(function_index, par_num, get_type(index));
}else{ // ne valja nam type argumenta pa brisemo sve prethodne i metodu
clear_symbols(function_index);
function_index = -1; //OOOOOOOOVOOOOOOOOO DOOOOOOOOOBROOOOOOO TESTIRATIIIIIIIIIII
}
}
}
;
methodType
: type
| _VOJD
;
var_enumeration
: var_enumeration _COMMA arrayOrId {
if (strcmp(type, "") != 0)
push_array_or_id($3, type, class_id, level);
}
| arrayOrId {
if (strcmp(type, "") != 0)
push_array_or_id($1, type, class_id, level);
}
;
arrayOrId
: _ID {$$ = $1;}
| _ARRAY_VALUE _RSQUARE_BRACKET {$$ = strcat($1, $2);}
;
designator
: _ID {
glob_designator = $1;
designator_class_id = class_id;
if((glob_designator_id=lookup_id_in_class_var(glob_designator,class_id))==-1)
if((glob_designator_id=lookup_id(glob_designator,VARIABLE,0)) !=-1 || (glob_designator_id=lookup_id(glob_designator,METHOD,0)) !=-1){
designator_class_id=-1;
}
}
designatorExt
| _ARRAY_VALUE {
glob_designator = $1;
designator_class_id = class_id;
if((glob_designator_id=lookup_id_in_class_var(glob_designator,class_id)) == -1)
if((glob_designator_id=lookup_id(glob_designator,VARIABLE,0)) != -1 || (glob_designator_id=lookup_id(glob_designator,METHOD,0)) !=-1){
designator_class_id = -1;
}
}
expression _RSQUARE_BRACKET designatorExt
;
designatorExt
: _POINT_ID{
int index;
int glob_designator_index;
//printf("Id: %d\n",glob_designator_id);
if(glob_designator_id != -1){
if ((index = check_if_class_instance(glob_designator, get_class_id(glob_designator_id))) != -1){
glob_designator_index = lookup_var_in_class(glob_designator, designator_class_id);
if(is_initialized(glob_designator_index) == -1) {
printf("Line: %d: %s is not initialized!\n", line, glob_designator);
}
glob_designator = $1 + 1;
designator_class_id = index;
}
}
else{
printf("Line: %d: %s does not exist\n",line, glob_designator);
designator_class_id=-1;
}
}
| _LSQUARE_BRACKET expression _RSQUARE_BRACKET{
strcat(glob_designator,"[");
}
| designatorExt _POINT_ID{
int index;
int glob_designator_index;
if ((index = check_if_class_instance(glob_designator, designator_class_id)) != -1){
glob_designator_index = lookup_var_in_class(glob_designator, designator_class_id);
if(is_initialized(glob_designator_index) == -1) {
printf("Line: %d: %s is not initialized!\n", line, glob_designator);
}
glob_designator = $2 + 1;
designator_class_id = index;
//printf("glob_designator: %s\n",glob_designator);
}
}
| designatorExt _LSQUARE_BRACKET expression _RSQUARE_BRACKET {
strcat(glob_designator,"[");
}
|
;
statement
: designator {to_assign_type = glob_designator; to_assign_id = designator_class_id;}_ASSIGN
expression _SEMICOLON {
//printf("What id is it: %d\n",to_assign_id);
char* designator_type= get_designator_type(to_assign_type,to_assign_id);
//printf("Type 1: %s vs Type 2: *%s*\n",designator_type,$4);
if(designator_type!=NULL){
if(get_kind(lookup_var_in_class(to_assign_type,to_assign_id)) == VARIABLE) {
char *new = malloc(5);
new=strncpy(new,$4,4);
if(strcmp(new,"new ")==0){
if(strcmp(designator_type,$4+4)!=0){
printf("Line: %d: Wrong assignment type\n",line);
}
else set_initialized(lookup_var_in_class(to_assign_type,to_assign_id), 1);
}
else{
if(strcmp(designator_type,"int") != 0 && strcmp(designator_type,"char") != 0 && strcmp(designator_type,"bool") != 0){
if(strcmp(designator_type, $4) != 0 && strcmp($4,"null") != 0){
if(strcmp(designator_type,"char[]")!=0 || strcmp($4,"string")!=0)
printf("Line: %d: Wrong assignment type!\n", line);
else set_initialized(lookup_var_in_class(to_assign_type,to_assign_id), 1);
}
else set_initialized(lookup_var_in_class(to_assign_type,to_assign_id), 1);
}
else{
if(strcmp(designator_type, $4) != 0)
printf("Line: %d: Wrong assignment type!\n", line);
else set_initialized(lookup_var_in_class(to_assign_type,to_assign_id), 1);
}
}
}else {
printf("Line: %d: Can not assign a value to a method!\n", line);
}
}
}
| designator {
char* designator_type = get_designator_type(glob_designator,designator_class_id);
int index;
if(designator_type != NULL) {
if(get_kind(index = lookup_var_in_class(glob_designator, designator_class_id)) == METHOD){
function_call_index = index;
} else
printf("Line: %d: %s is not a method!\n", line, glob_designator);
}
}
_LPAREN actParams {arg_num = 0;} _RPAREN _SEMICOLON
| designator _PLUS_PLUS _SEMICOLON {
int index;
char* designator_type = get_designator_type(glob_designator,designator_class_id);
if(get_kind(index = lookup_var_in_class(glob_designator, designator_class_id)) == VARIABLE){
if(strcmp(designator_type, "int") == 0) {
if(is_initialized(index) == -1)
printf("Line: %d: %s is not initialized!\n", line, glob_designator);
}else {
printf("Line: %d: %s is not an integer!\n", line, glob_designator);
}
}else {
printf("Line: %d: %s is not a variable!\n", line, glob_designator);
}
}
| designator _MINUS_MINUS _SEMICOLON {
int index;
char* designator_type = get_designator_type(glob_designator,designator_class_id);
if(get_kind(index = lookup_var_in_class(glob_designator, designator_class_id)) == VARIABLE){
if(strcmp(designator_type, "int") == 0) {
if(is_initialized(index) == -1)
printf("Line: %d: %s is not initialized!\n", line, glob_designator);
}else {
printf("Line: %d: %s is not an integer!\n", line, glob_designator);
}
}else {
printf("Line: %d: %s is not a variable!\n", line, glob_designator);
}
}
| _IF _LPAREN condition _RPAREN {if_or_while++; } statement {if_or_while--; } //resen
| _IF _LPAREN condition _RPAREN {if_or_while++; } statement _ELSE statement {if_or_while--; } //resen
| _WHILE _LPAREN condition _RPAREN {if_or_while++; } statement {if_or_while--; } //resen
| _BREAK {
if(if_or_while <= 0) {
printf("Line: %d: Break can not be placed here!\n", line);
}
}
_SEMICOLON
| _RETURN _SEMICOLON {
if(strcmp("void", get_type(function_index)) != 0){
printf("Line: %d: Function has to return %s\n",line, get_type(function_index));
}
}
| _RETURN expression
{
if(strcmp(get_type(function_index), $2) != 0) {
if(strcmp(get_type(function_index), "void") == 0)
printf("Line: %d: Function does not have a return type\n", line);
else
printf("Line: %d: Function has to return %s \n", line, get_type(function_index));
}
return_called++;
}
_SEMICOLON
| _READ _LPAREN designator{
char* designator_type = get_designator_type(glob_designator,designator_class_id);
if(get_kind(lookup_var_in_class(glob_designator, designator_class_id)) != VARIABLE) {
printf("Line: %d: A value cannot be assigned to a method\n", line);
}
} _RPAREN _SEMICOLON
| _PRINTF _LPAREN expression {
if (check_primitive_type($3) == -1){
printf("Line: %d: Only primitive types can be printed\n", line);
}
} _RPAREN _SEMICOLON
| _PRINTF _LPAREN expression{
if (check_primitive_type($3) == -1)
printf("Line: %d: Only primitive types can be printed\n", line);
} _COMMA _INT_NUMBER _RPAREN _SEMICOLON
| _LBRACKET {level++;}
statements _RBRACKET {level--;}
;
statements
: statements statement
|
;
condition
: conditionTerm orConditionTerms
;
orConditionTerms
: _OR conditionTerm
| orConditionTerms _OR conditionTerm
|
;
conditionTerm
: conditionFactor andConditionFactors
;
andConditionFactors
: _AND conditionFactor
| andConditionFactors _AND conditionFactor
|
;
conditionFactor
: expression {
if(strcmp($1,"bool")!=0){
printf("Line: %d: Expression is not a boolean type\n",line);
}
}
| expression _RELOP expression{
if(strcmp($1,$3)!=0){
printf("Line: %d: Types not compatible\n",line);
}
}
;
expression
: _MINUS term addopTerms {
if($3[0]!=' ')
if(strcmp($2,$3+1)==0){
if($3[0]=='+'){
if(strcmp($2,"int")!=0 && strcmp($2,"string")!=0)
printf("Line: %d: Not integers or strings\n",line);
}
else{
if(strcmp($2,"int")!=0)
printf("Line: %d: Not integers\n",line);
}
}
else{
printf("Line: %d: Types not compatible\n",line);
}
$$=$2;
}
| term addopTerms {
//printf("Usli smo u expression, $1(term): %s $2(addopTerms): %s\n", $1, $2);
if($2[0]!=' ')
if(strcmp($1,$2+1)==0){
if($2[0]=='+'){
if(strcmp($1,"int")!=0 && strcmp($1,"string")!=0)
printf("Line: %d: Not integers or strings\n",line);
}
else{
if(strcmp($1,"int")!=0)
printf("Line: %d: Not integers\n",line);
}
}
else{
printf("Line: %d: Types not compatible\n",line);
}
//printf("Ne izadje bre\n");
$$=$1;
//printf("Line: %d: Jel stvarno %s\n",line,$1);
}
;
term
: factor mulopFactors {
//printf("Usli smo u term, $1(factor): %s $2(mulopFactor): *%s*\n", $1, $2);
if($2[0]!=' ')
if(strcmp($1,$2)==0){
if(strcmp($1,"int")!=0)
printf("Line: %d: Not integers\n",line);
}
else{
printf("Line: %d: Types not compatible\n",line);
}
//printf("Ovaj %s u termu prodje\n",$1);
$$=$1;
}
;
mulopFactors
: mulop factor {$$=$2;}
| mulopFactors mulop factor {
if(strcmp($1,$3)==0){
if(strcmp($1,"int")!=0)
printf("Line: %d: All operands should be integers\n",line);
}
else{
printf("Line: %d: Types not compatible\n",line);
}
$$=$3;
}
| {$$=" ";}
;
mulop
: _DIV
| _MOD
| _TIMES
;
addop
: _PLUS
| _MINUS
;
addopTerms
: addop term {$$=strcat($1,$2);}
| addopTerms addop term {
//printf("wdlfhgfehgowefhi\n");
if(strcmp($1,$3)!=0){
if(strcmp($2,"+")==0){
if(strcmp($1,"int")!=0 && strcmp($1,"string")!=0)
printf("Line: %d: Not integers or strings\n",line);
}else{
if(strcmp($1,"int")!=0)
printf("Line: %d: Not integers\n",line);
}
}
else{
printf("Line: %d: Types not compatible\n",line);
}
$$=strcat($1,$3);
}
| {$$=" ";}
;
factor
: designator {
char* designator_type;
designator_type = get_designator_type(glob_designator, designator_class_id);
if(designator_type != NULL) {
if(get_kind(lookup_var_in_class(glob_designator, designator_class_id)) == VARIABLE) {
if(is_initialized(lookup_var_in_class(glob_designator, designator_class_id)) == -1) {
printf("Line: %d: %s is not initialized\n",line,glob_designator);
}
$$=designator_type;
} else {
if (glob_designator[strlen(glob_designator)-1] == '[')
glob_designator[strlen(glob_designator)-1] = '\0';
printf("Line: %d: %s is not a variable!\n", line, glob_designator);
}
}
}
| designator {
int index;
//printf("Trivicev bug : glob_designator: %s designator_class_id: %d\n",glob_designator, designator_class_id);
char* designator_type = get_designator_type(glob_designator, designator_class_id);
//printf("Line: %d: tip pre %s\n",line,designator_type);
if(designator_type != NULL) {
if(get_kind(index = lookup_var_in_class(glob_designator, designator_class_id)) == METHOD) {
$1=designator_type;
//printf("Line: %d: tip %s\n",line,designator_type);
function_call_index = index;
} else {
if (glob_designator[strlen(glob_designator)-1] == '[')
glob_designator[strlen(glob_designator)-1] = '\0';
printf("Line: %d: %s is not a method!\n", line, glob_designator);
}
}
}
_LPAREN actParams{arg_num = 0;} _RPAREN { $$=$1;}
| num { $$=$1;
}
| _NEW type {
//printf("Line %d $2: %s\n", line, $2);
$$ = malloc(100);
strcat($$, "new ");
//printf("WTF\n");
strcat($$, $2);
//printf("Ispisujem nesto\n");
//printf("Line %d $$: %s\n", line, $$);
}
| _NEW _TYPE {
$$ = malloc(100);
strcat($$, "new ");
//printf("WTF\n");
strcat($$, $2);
}
_LSQUARE_BRACKET expression _RSQUARE_BRACKET
| _NEW _ARRAY_VALUE {
char* type=malloc(strlen($2)+1);
type[strlen($2)]=']';
$$ = malloc(100);
strcat($$, "new ");
strcat($$,type);
}
expression {}
_RSQUARE_BRACKET
| _LPAREN expression _RPAREN {$$=$2;}
;
num
: _INT_NUMBER {$$ = "int";}
| _UNSIGNED_NUMBER {$$ = "int";}
| _CHAR {$$ = "char";}
| _STRING {$$ = "string";}
| _NULL {$$ = "null";}
;
constvalue
: num
| _FALSE {$$ = "bool";}
| _TRUE {$$ = "bool";}
;
actParams
:{char* arg = malloc(2);
arg[0]=1;
arg[1]=function_call_index;
$$=arg;
}
expression {
char* tip= malloc(100);
tip = $1;
char* param_type = get_param_type($$[1], $$[0]);
//printf("FUNCTION CALL INDEX1: %d\n", $$[1]);
//printf("Expected type(%d): %s and current type: %s\n",$$[0],get_param_type($$[1],$$[0]),$2);
if(strcmp(param_type,"int") != 0 && strcmp(param_type,"char") != 0 && strcmp(param_type,"bool") != 0){
if(strcmp(param_type, $2) != 0 && strcmp($2,"null") != 0) {
printf("Line: %d: Incorrect argument type!\n", line);
}
}
else{
if(strcmp(param_type, $2) != 0) {
printf("Line: %d: Incorrect argument type!\n", line);
}
}
}
| actParams _COMMA expression {
char* arg = malloc(2);
arg[0]=$1[0]+1;
arg[1]=$1[1];
$$=arg;
char* tip=$3;
char* param_type=get_param_type($$[1], $$[0]);
//printf("FUNCTION CALL INDEX2: %d\n", $$[1]);
//printf("Expected type(%d): %s and current type: %s\n",$$[0],get_param_type($$[1],$$[0]),$3);
if(strcmp(param_type,"int") != 0 && strcmp(param_type,"char") != 0 && strcmp(param_type,"bool") != 0){
if(strcmp(param_type, $3) != 0 && strcmp($3,"null") != 0){
printf("Line: %d: Incorrect argument type!\n", line);
}
}
else{
if(strcmp(param_type, $3) != 0) {
printf("Line: %d: Incorrect argument type!\n", line);
}
}
}
|
;
%%
int yyerror(char *s) {
fprintf(stderr, "\nERROR (%d): %s", line, s);
error_count++;
return 0;
}
int main(int argc, char *argv[]) {
yyin = fopen(argv[1], "r");
yyparse();
return error_count;
}