/*
* Copyright (C) 2012
* Dale Weiler
+ * Wolfgang Bumiller
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
int opts_standard = COMPILER_GMQCC;
bool opts_debug = false;
bool opts_memchk = false;
+bool opts_dumpfin = false;
bool opts_dump = false;
bool opts_werror = false;
bool opts_forcecrc = false;
options_set(opts_flags, ADJUST_VECTOR_FIELDS, false);
opts_standard = COMPILER_QCC;
} else if (!strcmp(argarg, "fte") || !strcmp(argarg, "fteqcc")) {
+ options_set(opts_flags, FTEPP, true);
options_set(opts_flags, ADJUST_VECTOR_FIELDS, false);
opts_standard = COMPILER_FTEQCC;
} else if (!strcmp(argarg, "qccx")) {
continue;
}
if (options_long_gcc("redirout", &argc, &argv, &redirout)) {
+ con_change(redirout, redirerr);
continue;
}
if (options_long_gcc("redirerr", &argc, &argv, &redirerr)) {
+ con_change(redirout, redirerr);
continue;
}
opts_dump = true;
continue;
}
+ if (!strcmp(argv[0]+1, "dumpfin")) {
+ opts_dumpfin = true;
+ continue;
+ }
if (!strcmp(argv[0]+1, "memchk")) {
opts_memchk = true;
continue;
case 'h':
usage();
exit(0);
- break;
+ /* break; never reached because of exit(0) */
case 'E':
opts_pp_only = true;
else
{
/* it's a QC filename */
- argitem item;
item.filename = argv[0];
item.type = TYPE_QC;
vec_push(items, item);
}
}
- con_change(redirout, redirerr);
return true;
}
int retval = 0;
bool opts_output_free = false;
bool progs_src = false;
+ FILE *outfile = NULL;
app_name = argv[0];
con_init();
options_set(opts_warn, WARN_MULTIFILE_IF, true);
options_set(opts_flags, ADJUST_VECTOR_FIELDS, true);
+ options_set(opts_flags, FTEPP, false);
if (!options_parse(argc, argv)) {
return usage();
if (opts_standard == COMPILER_GMQCC) {
operators = c_operators;
operator_count = c_operator_count;
+ } else if (opts_standard == COMPILER_FTEQCC) {
+ operators = fte_operators;
+ operator_count = fte_operator_count;
} else {
operators = qcc_operators;
operator_count = qcc_operator_count;
con_out("standard = %i\n", opts_standard);
}
+ if (opts_pp_only) {
+ if (opts_output_wasset) {
+ outfile = util_fopen(opts_output, "wb");
+ if (!outfile) {
+ con_err("failed to open `%s` for writing\n", opts_output);
+ retval = 1;
+ goto cleanup;
+ }
+ }
+ else
+ outfile = stdout;
+ }
+
if (!opts_pp_only) {
if (!parser_init()) {
con_err("failed to initialize parser\n");
goto cleanup;
}
}
- if (opts_pp_only || opts_standard == COMPILER_FTEQCC) {
- FILE *out = NULL;
- if (opts_output_wasset) {
- out = util_fopen(opts_output, "wb");
- if (!out) {
- con_err("failed to open `%s` for writing\n", opts_output);
- retval = 1;
- goto cleanup;
- }
- }
- if (!ftepp_init(out)) {
+ if (opts_pp_only || OPTS_FLAG(FTEPP)) {
+ if (!ftepp_init()) {
con_err("failed to initialize parser\n");
retval = 1;
goto cleanup;
}
if (opts_pp_only) {
+ const char *out;
if (!ftepp_preprocess_file(items[itr].filename)) {
retval = 1;
goto cleanup;
}
+ out = ftepp_get();
+ if (out)
+ fprintf(outfile, "%s", out);
+ ftepp_flush();
}
- else if (!parser_compile_file(items[itr].filename)) {
- retval = 1;
- goto cleanup;
+ else {
+ if (OPTS_FLAG(FTEPP)) {
+ const char *data;
+ if (!ftepp_preprocess_file(items[itr].filename)) {
+ retval = 1;
+ goto cleanup;
+ }
+ data = ftepp_get();
+ if (!parser_compile_string_len(items[itr].filename, data, vec_size(data)-1)) {
+ retval = 1;
+ goto cleanup;
+ }
+ ftepp_flush();
+ }
+ else {
+ if (!parser_compile_file(items[itr].filename)) {
+ retval = 1;
+ goto cleanup;
+ }
+ }
}
if (progs_src) {
con_close();
vec_free(items);
- parser_cleanup();
+ if (!opts_pp_only)
+ parser_cleanup();
if (opts_output_free)
mem_d((char*)opts_output);