summaryrefslogtreecommitdiffstats
path: root/src/output_slr.cpp
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-04-10 19:00:43 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-04-10 19:10:17 +0200
commitaeaeba2d7362a055c5c78f410a743ea977d8cd36 (patch)
treeeceab3dcaf74b3d224aaab9481c0f051bed10c9c /src/output_slr.cpp
parent475326bf1295f1985b1853d04ca036156bcad889 (diff)
downloadsolar-aeaeba2d7362a055c5c78f410a743ea977d8cd36.tar
solar-aeaeba2d7362a055c5c78f410a743ea977d8cd36.zip
Add support for escape sequences in character symbols
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())