summaryrefslogtreecommitdiffstats
path: root/src/output.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/output.cpp')
-rw-r--r--src/output.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/output.cpp b/src/output.cpp
index 72e9a6e..e1ca496 100644
--- a/src/output.cpp
+++ b/src/output.cpp
@@ -88,6 +88,11 @@ void output_t::emit_token_value() {
}
void output_t::emit_header() {
+ std::fprintf(header_file, "#pragma once\n\n");
+
+ if (!generator->get_header_block().empty())
+ std::fprintf(header_file, "%s\n", generator->get_header_block().c_str());
+
emit_tokens();
emit_token_value();
@@ -261,12 +266,15 @@ void output_t::emit_header_include() {
const char *slash = std::strrchr(header_filename.c_str(), sep);
const char *basename = slash ? slash+1 : header_filename.c_str();
- std::fprintf(source_file, "#include \"%s\"\n\n\n", basename);
+ std::fprintf(source_file, "#include \"%s\"\n\n", basename);
}
void output_t::emit_source() {
emit_header_include();
+ if (!generator->get_source_block().empty())
+ std::fprintf(source_file, "%s\n\n", generator->get_source_block().c_str());
+
std::fprintf(source_file, "typedef union %ssymbol_value {\n", prefix());
std::fprintf(source_file, "\t%stoken_value_t token;\n", prefix());