summaryrefslogtreecommitdiffstats
path: root/src/output_slr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/output_slr.cpp')
-rw-r--r--src/output_slr.cpp15
1 files changed, 2 insertions, 13 deletions
diff --git a/src/output_slr.cpp b/src/output_slr.cpp
index ad0d415..371d55b 100644
--- a/src/output_slr.cpp
+++ b/src/output_slr.cpp
@@ -38,25 +38,14 @@ void output_slr_t::emit_state_shift(unsigned i, const symbol_t &token) {
if (it == generator->get_shifts().end())
return;
- if (token.get_type() == SYMBOL_TYPE_CHAR)
- std::fprintf(source_file, "\t\t\tcase '%c':\n", token.get_value()[0]);
- else if (!token.get_value().empty())
- std::fprintf(source_file, "\t\t\tcase %s%s:\n", token_prefix(), token.get_value().c_str());
- else
- std::fprintf(source_file, "\t\t\tcase 0:\n");
-
+ std::fprintf(source_file, "\t\t\tcase %s:\n", symbol_case(token).c_str());
std::fprintf(source_file, "\t\t\t\tparser->stack[parser->top].value.token = *value;\n");
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");
}
void output_slr_t::emit_state_reduce(const item_t &item, const symbol_t &token, int rule_id) {
- if (token.get_type() == SYMBOL_TYPE_CHAR)
- std::fprintf(source_file, "\t\t\tcase '%c':\n", token.get_value()[0]);
- else if (!token.get_value().empty())
- std::fprintf(source_file, "\t\t\tcase %s%s:\n", token_prefix(), token.get_value().c_str());
- else
- std::fprintf(source_file, "\t\t\tcase 0:\n");
+ std::fprintf(source_file, "\t\t\tcase %s:\n", symbol_case(token).c_str());
const auto &rhs = item.get_rhs();
if (rhs.size())