init/deinit in inline functions
This commit is contained in:
parent
42fd03f75d
commit
52e449e480
@ -102,30 +102,19 @@ void dump_output(void) {
|
|||||||
fputs(verbatim, yyout);
|
fputs(verbatim, yyout);
|
||||||
}
|
}
|
||||||
|
|
||||||
signed main(const int argc, const char * const * const argv) {
|
static inline
|
||||||
#ifdef DEBUG
|
void init(void) {
|
||||||
yydebug = 1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (handle_arguments(argc, argv)) { return 1; }
|
|
||||||
|
|
||||||
tbsp_yy_init();
|
tbsp_yy_init();
|
||||||
tbsp_tab_init();
|
tbsp_tab_init();
|
||||||
tbsp_c_yy_init();
|
tbsp_c_yy_init();
|
||||||
|
}
|
||||||
|
|
||||||
CHECKED_FOPEN(yyin, input_file_name, "r");
|
static inline
|
||||||
|
void deinit(void) {
|
||||||
int yyparse_r = yyparse();
|
|
||||||
if (yyparse_r) { return yyparse_r; }
|
|
||||||
|
|
||||||
dump_output();
|
|
||||||
|
|
||||||
// Deinit
|
|
||||||
for (int i = 0; i < kv_size(rules); i++) {
|
for (int i = 0; i < kv_size(rules); i++) {
|
||||||
free(kv_A(rules, i).string);
|
free(kv_A(rules, i).string);
|
||||||
free(kv_A(rules, i).code);
|
free(kv_A(rules, i).code);
|
||||||
}
|
}
|
||||||
|
|
||||||
tbsp_yy_deinit();
|
tbsp_yy_deinit();
|
||||||
tbsp_c_yy_deinit();
|
tbsp_c_yy_deinit();
|
||||||
free(output_file_name);
|
free(output_file_name);
|
||||||
@ -133,8 +122,27 @@ signed main(const int argc, const char * const * const argv) {
|
|||||||
free(verbatim);
|
free(verbatim);
|
||||||
free(language);
|
free(language);
|
||||||
free(top);
|
free(top);
|
||||||
|
}
|
||||||
|
|
||||||
|
signed main(const int argc, const char * const * const argv) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
yydebug = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (handle_arguments(argc, argv)) { return 1; }
|
||||||
|
|
||||||
|
init();
|
||||||
|
|
||||||
|
CHECKED_FOPEN(yyin, input_file_name, "r");
|
||||||
|
|
||||||
|
int yyparse_r = yyparse();
|
||||||
|
if (yyparse_r) { return yyparse_r; }
|
||||||
|
|
||||||
CHECKED_FOPEN(yyout, output_file_name, "w");
|
CHECKED_FOPEN(yyout, output_file_name, "w");
|
||||||
|
|
||||||
|
dump_output();
|
||||||
|
|
||||||
|
deinit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user