output: fix emission of terminal case conditions

This commit is contained in:
Matthias Schiffer 2015-04-05 02:37:25 +02:00
parent 96dd0ebd26
commit 9154865ac3

View file

@ -34,7 +34,7 @@ namespace solar {
output_t::output_t(const generator_t *generator0, const char *header, const char *source)
: prefix_str("parse_"),
token_prefix_str("TOKEN_"),
token_prefix_str("TOK_"),
stack_size(100),
generator(generator0) {
header_file = std::fopen(header, "w");
@ -107,7 +107,7 @@ void output_t::emit_state_shift(unsigned i) {
if (token.get_type() == SYMBOL_TYPE_CHAR)
std::fprintf(source_file, "\t\t\tcase '%c':\n", token.get_value()[0]);
else
std::fprintf(source_file, "\t\t\tcase %u:\n", tokens[token.get_value()]);
std::fprintf(source_file, "\t\t\tcase %s%s:\n", token_prefix(), token.get_value().c_str());
std::fprintf(source_file, "\t\t\t\tparser->stack[++parser->top].state = %u;\n", unsigned(it->second));
std::fprintf(source_file, "\t\t\t\treturn 1;\n\n");