8 extern int yylex_destroy(void);
10 void usage(FILE *out
, char *arg0
)
13 "Usage: %s [OPTS] [FILE]\n"
15 "Compile an spl file. If FILE is not specified stdin is used.\n"
18 "\t-p\tJust parse and pretty print\n"
19 "\t-t\tJust parse and typecheck\n"
20 "\t-c\tparse, typecheck and compile (default)\n"
21 "\t-h\tShow this help\n"
25 enum mode
{parse
,type
,compile
};
27 int main(int argc
, char *argv
[])
30 enum mode mode
= compile
;
32 while ((opt
= getopt(argc
, argv
, "hptc")) != -1) {
44 usage(stdout
, argv
[0]);
47 usage(stderr
, argv
[0]);
51 if (optind
+ 1 == argc
&& strcmp(argv
[optind
], "-") != 0)
52 if ((yyin
= fopen(argv
[optind
], "r")) == NULL
)
55 struct ast
*result
= NULL
;
56 int r
= yyparse(&result
);
61 ast_print(result
, stdout
);
67 if (fclose(yyin
) == -1)