-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
50 lines (40 loc) · 677 Bytes
/
main.c
File metadata and controls
50 lines (40 loc) · 677 Bytes
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
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
extern FILE *yyin;
extern print_tree() ;
int nb_lines = 1 ;
yyerror(char *s)
{
printf ("%s at line %d\n",s,nb_lines) ;
}
usage ()
{
printf ("usage: while [file]\n") ;
exit (1) ;
}
check (char *s)
{
yyin = fopen (s, "r") ;
if (yyin==NULL) usage() ;
}
main (int argc, char *argv[])
{
int result ;
switch (argc)
{
case 1 :
yyin = stdin ;
break ;
case 2 :
check (argv[1]) ;
break ;
default:
usage ();
}
result = yyparse() ; // call to the parser
if (result==0){
print_tree() ;
/* insert here the calls to the code generation main function */
}
}