summaryrefslogtreecommitdiffstats
path: root/src/output.cpp
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-04-08 23:49:42 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-04-08 23:49:42 +0200
commit9c990ae801b949de2728bfff4258aa90f9c96a52 (patch)
treeba2742dc1b3ef0b9898e20a6162e54fb58f440e2 /src/output.cpp
parent7b8ebfcef1dada98ff36aeb4d16cd3c06517e879 (diff)
downloadsolar-9c990ae801b949de2728bfff4258aa90f9c96a52.tar
solar-9c990ae801b949de2728bfff4258aa90f9c96a52.zip
Allow adding source blocks to the top the of header and source files
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());