6b23b49fd59ad3b5835eb6c217598d8e5f61e321
10 extern int yylex_destroy(void);
12 void usage(FILE *out
, char *arg0
)
15 "Usage: %s [OPTS] [FILE]\n"
17 "Compile an spl file. If FILE is not specified stdin is used.\n"
20 "\t-p\tPretty print the parsed abstract syntax tree\n"
21 "\t-t\tPretty print the typed abstract syntax tree\n"
22 "\t-h\tShow this help\n"
26 int main(int argc
, char *argv
[])
29 bool pparse
= false, ptype
= false;
31 while ((opt
= getopt(argc
, argv
, "hpt")) != -1) {
40 usage(stdout
, argv
[0]);
43 usage(stderr
, argv
[0]);
47 if (optind
+ 1 == argc
&& strcmp(argv
[optind
], "-") != 0)
48 if ((yyin
= fopen(argv
[optind
], "r")) == NULL
)
51 struct ast
*result
= NULL
;
52 int r
= yyparse(&result
);
57 ast_print(result
, stdout
);
58 if ((result
= type(result
)) == NULL
) {
63 ast_print(result
, stdout
);
71 if (fclose(yyin
) == -1)