From 9c990ae801b949de2728bfff4258aa90f9c96a52 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 8 Apr 2015 23:49:42 +0200 Subject: Allow adding source blocks to the top the of header and source files --- src/output.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/output.cpp') 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()); -- cgit v1.2.3