summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/output_slr.cpp81
-rw-r--r--src/output_slr.hpp8
-rw-r--r--src/parse.cpp740
3 files changed, 86 insertions, 743 deletions
diff --git a/src/output_slr.cpp b/src/output_slr.cpp
index 01b0560..563fd60 100644
--- a/src/output_slr.cpp
+++ b/src/output_slr.cpp
@@ -33,20 +33,29 @@
namespace solar {
-void output_slr_t::emit_state_shift(unsigned state, const symbol_t &token) {
- auto it = generator->get_shifts().find(std::make_pair(state, token));
- if (it == generator->get_shifts().end())
- return;
-
- 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_shift(unsigned state) {
+ std::map<unsigned, std::set<symbol_t>> shifts;
+
+ for (const symbol_t &token : generator->get_terminals()) {
+ auto it = generator->get_shifts().find(std::make_pair(state, token));
+ if (it == generator->get_shifts().end())
+ continue;
-void output_slr_t::emit_state_reduce(const item_t &item, const symbol_t &token, int rule_id) {
- std::fprintf(source_file, "\t\t\tcase %s:\n", symbol_case(token).c_str());
+ std::set<symbol_t> &symbols = shifts.insert(std::make_pair(it->second, std::set<symbol_t>())).first->second;
+ symbols.insert(token);
+ }
+
+ for (const auto &entry : shifts) {
+ for (const symbol_t &sym : entry.second)
+ std::fprintf(source_file, "\t\t\tcase %s:\n", symbol_case(sym).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", entry.first);
+ std::fprintf(source_file, "\t\t\t\treturn 1;\n\n");
+ }
+}
+
+void output_slr_t::emit_state_reduce_code(const item_t &item, int rule_id) {
const auto &rhs = item.get_rhs();
if (rhs.size())
std::fprintf(source_file, "\t\t\t\tparser->top -= %u;\n", unsigned(rhs.size()));
@@ -114,19 +123,38 @@ void output_slr_t::emit_state_reduce(const item_t &item, const symbol_t &token,
std::fprintf(source_file, "\t\t\t\t}\n");
}
-
- std::fprintf(source_file, "\t\t\t\tbreak;\n\n");
}
-void output_slr_t::do_emit_state(unsigned state, const symbol_t &token) {
- auto it = generator->get_reductions().find(std::make_pair(state, token));
- if (it == generator->get_reductions().end()) {
- emit_state_shift(state, token);
+bool output_slr_t::emit_state_reduce(unsigned state) {
+ std::map<unsigned, std::set<symbol_t>> reductions;
+
+ for (const symbol_t &token : generator->get_terminals()) {
+ auto it = generator->get_reductions().find(std::make_pair(state, token));
+ if (it == generator->get_reductions().end())
+ continue;
+
+ std::set<symbol_t> &symbols = reductions.insert(std::make_pair(it->second, std::set<symbol_t>())).first->second;
+ symbols.insert(token);
}
- else {
- const rule_t &rule = generator->get_grammar().rules[it->second];
- emit_state_reduce(rule.item, token, rule.action.empty() ? -1 : it->second);
+
+ for (const auto &entry : reductions) {
+ if (reductions.size() == 1) {
+ std::fprintf(source_file, "\t\t\tdefault:\n");
+ }
+ else {
+ for (const symbol_t &sym : entry.second)
+ std::fprintf(source_file, "\t\t\tcase %s:\n", symbol_case(sym).c_str());
+ }
+
+ const rule_t &rule = generator->get_grammar().rules[entry.first];
+ emit_state_reduce_code(rule.item, rule.action.empty() ? -1 : entry.first);
+
+ if (reductions.size() != 1)
+ std::fprintf(source_file, "\t\t\t\tbreak;\n\n");
+
}
+
+ return (reductions.size() == 1);
}
void output_slr_t::emit_state(unsigned state) {
@@ -138,13 +166,14 @@ void output_slr_t::emit_state(unsigned state) {
std::fprintf(source_file, "\t\t\t\treturn 0;\n\n");
}
- do_emit_state(state, symbol_t::empty());
+ emit_state_shift(state);
- for (const symbol_t &token : generator->get_terminals())
- do_emit_state(state, token);
+ bool def = emit_state_reduce(state);
- std::fprintf(source_file, "\t\t\tdefault:\n");
- std::fprintf(source_file, "\t\t\t\treturn -1;\n");
+ if (!def) {
+ std::fprintf(source_file, "\t\t\tdefault:\n");
+ std::fprintf(source_file, "\t\t\t\treturn -1;\n");
+ }
std::fprintf(source_file, "\t\t\t}\n");
std::fprintf(source_file, "\t\t\tbreak;\n\n");
diff --git a/src/output_slr.hpp b/src/output_slr.hpp
index aac9511..a64cecf 100644
--- a/src/output_slr.hpp
+++ b/src/output_slr.hpp
@@ -36,9 +36,11 @@ class output_slr_t : public output_t {
private:
const generator_slr_t *generator;
- void emit_state_shift(unsigned state, const symbol_t &token);
- void emit_state_reduce(const item_t &item, const symbol_t &token, int rule_id);
- void do_emit_state(unsigned state, const symbol_t &token);
+
+ void emit_state_shift(unsigned state);
+
+ void emit_state_reduce_code(const item_t &item, int rule_id);
+ bool emit_state_reduce(unsigned state);
protected:
virtual const generator_t * get_generator() {
diff --git a/src/parse.cpp b/src/parse.cpp
index 7c8b1f2..bca53dc 100644
--- a/src/parse.cpp
+++ b/src/parse.cpp
@@ -163,20 +163,8 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
switch (parser->stack[parser->top].state) {
case 0:
switch (token) {
- case 0:
- parser->stack[++parser->top].state = 1;
- break;
-
- case TOK_SYMBOL_LC:
- parser->stack[++parser->top].state = 1;
- break;
-
- case '%':
- parser->stack[++parser->top].state = 1;
- break;
-
default:
- return -1;
+ parser->stack[++parser->top].state = 1;
}
break;
@@ -202,48 +190,18 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 2:
switch (token) {
- case 0:
- parser->top -= 2;
- parser->stack[++parser->top].state = 1;
- break;
-
- case TOK_SYMBOL_LC:
- parser->top -= 2;
- parser->stack[++parser->top].state = 1;
- break;
-
- case '%':
+ default:
parser->top -= 2;
parser->stack[++parser->top].state = 1;
- break;
-
- default:
- return -1;
}
break;
case 3:
switch (token) {
- case 0:
- parser->top -= 1;
- parse_reduce_3(parser->stack[parser->top + 0].value.symbol_rule, grammar);
- parser->stack[++parser->top].state = 2;
- break;
-
- case TOK_SYMBOL_LC:
- parser->top -= 1;
- parse_reduce_3(parser->stack[parser->top + 0].value.symbol_rule, grammar);
- parser->stack[++parser->top].state = 2;
- break;
-
- case '%':
+ default:
parser->top -= 1;
parse_reduce_3(parser->stack[parser->top + 0].value.symbol_rule, grammar);
parser->stack[++parser->top].state = 2;
- break;
-
- default:
- return -1;
}
break;
@@ -348,38 +306,9 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 11:
switch (token) {
- case TOK_BLOCK:
- parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(grammar);
- parser->stack[++parser->top].state = 16;
- break;
-
- case TOK_CHAR:
- parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(grammar);
- parser->stack[++parser->top].state = 16;
- break;
-
- case TOK_STRING:
- parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(grammar);
- parser->stack[++parser->top].state = 16;
- break;
-
- case TOK_SYMBOL_LC:
- parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(grammar);
- parser->stack[++parser->top].state = 16;
- break;
-
- case TOK_SYMBOL_UC:
- parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(grammar);
- parser->stack[++parser->top].state = 16;
- break;
-
- case ';':
+ default:
parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(grammar);
parser->stack[++parser->top].state = 16;
- break;
-
- default:
- return -1;
}
break;
@@ -518,461 +447,105 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21:
switch (token) {
- case 0:
- parser->top -= 5;
- parser->stack[parser->top].value.symbol_rule = parse_reduce_9(parser->stack[parser->top + 0].value.token.str, parser->stack[parser->top + 3].value.symbol_rhs, parser->stack[parser->top + 4].value.symbol_action, grammar);
- parser->stack[++parser->top].state = 3;
- break;
-
- case TOK_SYMBOL_LC:
- parser->top -= 5;
- parser->stack[parser->top].value.symbol_rule = parse_reduce_9(parser->stack[parser->top + 0].value.token.str, parser->stack[parser->top + 3].value.symbol_rhs, parser->stack[parser->top + 4].value.symbol_action, grammar);
- parser->stack[++parser->top].state = 3;
- break;
-
- case '%':
+ default:
parser->top -= 5;
parser->stack[parser->top].value.symbol_rule = parse_reduce_9(parser->stack[parser->top + 0].value.token.str, parser->stack[parser->top + 3].value.symbol_rhs, parser->stack[parser->top + 4].value.symbol_action, grammar);
parser->stack[++parser->top].state = 3;
- break;
-
- default:
- return -1;
}
break;
case 22:
switch (token) {
- case TOK_BLOCK:
- parser->top -= 2;
- parser->stack[parser->top].value.symbol_rhs = parse_reduce_11(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, grammar);
- parser->stack[++parser->top].state = 16;
- break;
-
- case TOK_CHAR:
- parser->top -= 2;
- parser->stack[parser->top].value.symbol_rhs = parse_reduce_11(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, grammar);
- parser->stack[++parser->top].state = 16;
- break;
-
- case TOK_STRING:
- parser->top -= 2;
- parser->stack[parser->top].value.symbol_rhs = parse_reduce_11(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, grammar);
- parser->stack[++parser->top].state = 16;
- break;
-
- case TOK_SYMBOL_LC:
- parser->top -= 2;
- parser->stack[parser->top].value.symbol_rhs = parse_reduce_11(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, grammar);
- parser->stack[++parser->top].state = 16;
- break;
-
- case TOK_SYMBOL_UC:
- parser->top -= 2;
- parser->stack[parser->top].value.symbol_rhs = parse_reduce_11(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, grammar);
- parser->stack[++parser->top].state = 16;
- break;
-
case '(':
parser->stack[parser->top].value.token = *value;
parser->stack[++parser->top].state = 34;
return 1;
- case ';':
+ default:
parser->top -= 2;
parser->stack[parser->top].value.symbol_rhs = parse_reduce_11(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, grammar);
parser->stack[++parser->top].state = 16;
- break;
-
- default:
- return -1;
}
break;
case 23:
switch (token) {
- case TOK_BLOCK:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_symbol = parse_reduce_16(parser->stack[parser->top + 0].value.symbol_term, grammar);
- parser->stack[++parser->top].state = 22;
- break;
-
- case TOK_CHAR:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_symbol = parse_reduce_16(parser->stack[parser->top + 0].value.symbol_term, grammar);
- parser->stack[++parser->top].state = 22;
- break;
-
- case TOK_STRING:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_symbol = parse_reduce_16(parser->stack[parser->top + 0].value.symbol_term, grammar);
- parser->stack[++parser->top].state = 22;
- break;
-
- case TOK_SYMBOL_LC:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_symbol = parse_reduce_16(parser->stack[parser->top + 0].value.symbol_term, grammar);
- parser->stack[++parser->top].state = 22;
- break;
-
- case TOK_SYMBOL_UC:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_symbol = parse_reduce_16(parser->stack[parser->top + 0].value.symbol_term, grammar);
- parser->stack[++parser->top].state = 22;
- break;
-
- case '(':
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_symbol = parse_reduce_16(parser->stack[parser->top + 0].value.symbol_term, grammar);
- parser->stack[++parser->top].state = 22;
- break;
-
- case ';':
+ default:
parser->top -= 1;
parser->stack[parser->top].value.symbol_symbol = parse_reduce_16(parser->stack[parser->top + 0].value.symbol_term, grammar);
parser->stack[++parser->top].state = 22;
- break;
-
- default:
- return -1;
}
break;
case 24:
switch (token) {
- case 0:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_action = parse_reduce_15(parser->stack[parser->top + 0].value.token.str, grammar);
- parser->stack[++parser->top].state = 21;
- break;
-
- case TOK_SYMBOL_LC:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_action = parse_reduce_15(parser->stack[parser->top + 0].value.token.str, grammar);
- parser->stack[++parser->top].state = 21;
- break;
-
- case '%':
+ default:
parser->top -= 1;
parser->stack[parser->top].value.symbol_action = parse_reduce_15(parser->stack[parser->top + 0].value.token.str, grammar);
parser->stack[++parser->top].state = 21;
- break;
-
- default:
- return -1;
}
break;
case 25:
switch (token) {
- case TOK_BLOCK:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_term = parse_reduce_19(parser->stack[parser->top + 0].value.token.c, grammar);
- switch (parser->stack[parser->top].state) {
- case 16:
- parser->stack[++parser->top].state = 23;
- break;
- case 33:
- parser->stack[++parser->top].state = 38;
- break;
- }
- break;
-
- case TOK_CHAR:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_term = parse_reduce_19(parser->stack[parser->top + 0].value.token.c, grammar);
- switch (parser->stack[parser->top].state) {
- case 16:
- parser->stack[++parser->top].state = 23;
- break;
- case 33:
- parser->stack[++parser->top].state = 38;
- break;
- }
- break;
-
- case TOK_STRING:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_term = parse_reduce_19(parser->stack[parser->top + 0].value.token.c, grammar);
- switch (parser->stack[parser->top].state) {
- case 16:
- parser->stack[++parser->top].state = 23;
- break;
- case 33:
- parser->stack[++parser->top].state = 38;
- break;
- }
- break;
-
- case TOK_SYMBOL_LC:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_term = parse_reduce_19(parser->stack[parser->top + 0].value.token.c, grammar);
- switch (parser->stack[parser->top].state) {
- case 16:
- parser->stack[++parser->top].state = 23;
- break;
- case 33:
- parser->stack[++parser->top].state = 38;
- break;
- }
- break;
-
- case TOK_SYMBOL_UC:
+ default:
parser->top -= 1;
parser->stack[parser->top].value.symbol_term = parse_reduce_19(parser->stack[parser->top + 0].value.token.c, grammar);
switch (parser->stack[parser->top].state) {
case 16:
parser->stack[++parser->top].state = 23;
break;
- case 33:
- parser->stack[++parser->top].state = 38;
- break;
- }
- break;
- case '(':
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_term = parse_reduce_19(parser->stack[parser->top + 0].value.token.c, grammar);
- switch (parser->stack[parser->top].state) {
- case 16:
- parser->stack[++parser->top].state = 23;
- break;
case 33:
parser->stack[++parser->top].state = 38;
break;
- }
- break;
- case ';':
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_term = parse_reduce_19(parser->stack[parser->top + 0].value.token.c, grammar);
- switch (parser->stack[parser->top].state) {
- case 16:
- parser->stack[++parser->top].state = 23;
- break;
- case 33:
- parser->stack[++parser->top].state = 38;
- break;
}
- break;
-
- default:
- return -1;
}
break;
case 26:
switch (token) {
- case TOK_BLOCK:
- parser->top -= 2;
- parser->stack[parser->top].value.symbol_rhs = parse_reduce_13(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.token.str, grammar);
- parser->stack[++parser->top].state = 16;
- break;
-
- case TOK_CHAR:
- parser->top -= 2;
- parser->stack[parser->top].value.symbol_rhs = parse_reduce_13(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.token.str, grammar);
- parser->stack[++parser->top].state = 16;
- break;
-
- case TOK_STRING:
- parser->top -= 2;
- parser->stack[parser->top].value.symbol_rhs = parse_reduce_13(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.token.str, grammar);
- parser->stack[++parser->top].state = 16;
- break;
-
- case TOK_SYMBOL_LC:
- parser->top -= 2;
- parser->stack[parser->top].value.symbol_rhs = parse_reduce_13(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.token.str, grammar);
- parser->stack[++parser->top].state = 16;
- break;
-
- case TOK_SYMBOL_UC:
- parser->top -= 2;
- parser->stack[parser->top].value.symbol_rhs = parse_reduce_13(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.token.str, grammar);
- parser->stack[++parser->top].state = 16;
- break;
-
- case ';':
+ default:
parser->top -= 2;
parser->stack[parser->top].value.symbol_rhs = parse_reduce_13(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.token.str, grammar);
parser->stack[++parser->top].state = 16;
- break;
-
- default:
- return -1;
}
break;
case 27:
switch (token) {
- case TOK_BLOCK:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_symbol = parse_reduce_17(parser->stack[parser->top + 0].value.token.str, grammar);
- parser->stack[++parser->top].state = 22;
- break;
-
- case TOK_CHAR:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_symbol = parse_reduce_17(parser->stack[parser->top + 0].value.token.str, grammar);
- parser->stack[++parser->top].state = 22;
- break;
-
- case TOK_STRING:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_symbol = parse_reduce_17(parser->stack[parser->top + 0].value.token.str, grammar);
- parser->stack[++parser->top].state = 22;
- break;
-
- case TOK_SYMBOL_LC:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_symbol = parse_reduce_17(parser->stack[parser->top + 0].value.token.str, grammar);
- parser->stack[++parser->top].state = 22;
- break;
-
- case TOK_SYMBOL_UC:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_symbol = parse_reduce_17(parser->stack[parser->top + 0].value.token.str, grammar);
- parser->stack[++parser->top].state = 22;
- break;
-
- case '(':
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_symbol = parse_reduce_17(parser->stack[parser->top + 0].value.token.str, grammar);
- parser->stack[++parser->top].state = 22;
- break;
-
- case ';':
+ default:
parser->top -= 1;
parser->stack[parser->top].value.symbol_symbol = parse_reduce_17(parser->stack[parser->top + 0].value.token.str, grammar);
parser->stack[++parser->top].state = 22;
- break;
-
- default:
- return -1;
}
break;
case 28:
switch (token) {
- case TOK_BLOCK:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_term = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar);
- switch (parser->stack[parser->top].state) {
- case 16:
- parser->stack[++parser->top].state = 23;
- break;
- case 33:
- parser->stack[++parser->top].state = 38;
- break;
- }
- break;
-
- case TOK_CHAR:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_term = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar);
- switch (parser->stack[parser->top].state) {
- case 16:
- parser->stack[++parser->top].state = 23;
- break;
- case 33:
- parser->stack[++parser->top].state = 38;
- break;
- }
- break;
-
- case TOK_STRING:
+ default:
parser->top -= 1;
parser->stack[parser->top].value.symbol_term = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar);
switch (parser->stack[parser->top].state) {
case 16:
parser->stack[++parser->top].state = 23;
break;
- case 33:
- parser->stack[++parser->top].state = 38;
- break;
- }
- break;
- case TOK_SYMBOL_LC:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_term = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar);
- switch (parser->stack[parser->top].state) {
- case 16:
- parser->stack[++parser->top].state = 23;
- break;
case 33:
parser->stack[++parser->top].state = 38;
break;
- }
- break;
- case TOK_SYMBOL_UC:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_term = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar);
- switch (parser->stack[parser->top].state) {
- case 16:
- parser->stack[++parser->top].state = 23;
- break;
- case 33:
- parser->stack[++parser->top].state = 38;
- break;
- }
- break;
-
- case '(':
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_term = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar);
- switch (parser->stack[parser->top].state) {
- case 16:
- parser->stack[++parser->top].state = 23;
- break;
- case 33:
- parser->stack[++parser->top].state = 38;
- break;
}
- break;
-
- case ';':
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_term = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar);
- switch (parser->stack[parser->top].state) {
- case 16:
- parser->stack[++parser->top].state = 23;
- break;
- case 33:
- parser->stack[++parser->top].state = 38;
- break;
- }
- break;
-
- default:
- return -1;
}
break;
case 29:
switch (token) {
- case 0:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_action = parse_reduce_14(grammar);
- parser->stack[++parser->top].state = 21;
- break;
-
- case TOK_SYMBOL_LC:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_action = parse_reduce_14(grammar);
- parser->stack[++parser->top].state = 21;
- break;
-
- case '%':
+ default:
parser->top -= 1;
parser->stack[parser->top].value.symbol_action = parse_reduce_14(grammar);
parser->stack[++parser->top].state = 21;
- break;
-
- default:
- return -1;
}
break;
@@ -1019,14 +592,14 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
parser->stack[++parser->top].state = 25;
return 1;
- case TOK_SYMBOL_LC:
+ case TOK_SYMBOL_UC:
parser->stack[parser->top].value.token = *value;
- parser->stack[++parser->top].state = 39;
+ parser->stack[++parser->top].state = 28;
return 1;
- case TOK_SYMBOL_UC:
+ case TOK_SYMBOL_LC:
parser->stack[parser->top].value.token = *value;
- parser->stack[++parser->top].state = 28;
+ parser->stack[++parser->top].state = 39;
return 1;
default:
@@ -1130,214 +703,67 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 41:
switch (token) {
- case 0:
+ default:
parser->top -= 1;
parser->stack[parser->top].value.symbol_varname = parse_reduce_22(parser->stack[parser->top + 0].value.token.str, grammar);
switch (parser->stack[parser->top].state) {
case 34:
parser->stack[++parser->top].state = 40;
break;
- case 47:
- parser->stack[++parser->top].state = 53;
- break;
- case 56:
- parser->stack[++parser->top].state = 57;
- break;
- }
- break;
- case TOK_SYMBOL_LC:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_varname = parse_reduce_22(parser->stack[parser->top + 0].value.token.str, grammar);
- switch (parser->stack[parser->top].state) {
- case 34:
- parser->stack[++parser->top].state = 40;
- break;
case 47:
parser->stack[++parser->top].state = 53;
break;
- case 56:
- parser->stack[++parser->top].state = 57;
- break;
- }
- break;
- case '%':
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_varname = parse_reduce_22(parser->stack[parser->top + 0].value.token.str, grammar);
- switch (parser->stack[parser->top].state) {
- case 34:
- parser->stack[++parser->top].state = 40;
- break;
- case 47:
- parser->stack[++parser->top].state = 53;
- break;
case 56:
parser->stack[++parser->top].state = 57;
break;
- }
- break;
- case ')':
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_varname = parse_reduce_22(parser->stack[parser->top + 0].value.token.str, grammar);
- switch (parser->stack[parser->top].state) {
- case 34:
- parser->stack[++parser->top].state = 40;
- break;
- case 47:
- parser->stack[++parser->top].state = 53;
- break;
- case 56:
- parser->stack[++parser->top].state = 57;
- break;
}
- break;
-
- default:
- return -1;
}
break;
case 42:
switch (token) {
- case 0:
+ default:
parser->top -= 1;
parser->stack[parser->top].value.symbol_varname = parse_reduce_20(parser->stack[parser->top + 0].value.token.str, grammar);
switch (parser->stack[parser->top].state) {
case 34:
parser->stack[++parser->top].state = 40;
break;
- case 47:
- parser->stack[++parser->top].state = 53;
- break;
- case 56:
- parser->stack[++parser->top].state = 57;
- break;
- }
- break;
- case TOK_SYMBOL_LC:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_varname = parse_reduce_20(parser->stack[parser->top + 0].value.token.str, grammar);
- switch (parser->stack[parser->top].state) {
- case 34:
- parser->stack[++parser->top].state = 40;
- break;
case 47:
parser->stack[++parser->top].state = 53;
break;
- case 56:
- parser->stack[++parser->top].state = 57;
- break;
- }
- break;
- case '%':
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_varname = parse_reduce_20(parser->stack[parser->top + 0].value.token.str, grammar);
- switch (parser->stack[parser->top].state) {
- case 34:
- parser->stack[++parser->top].state = 40;
- break;
- case 47:
- parser->stack[++parser->top].state = 53;
- break;
case 56:
parser->stack[++parser->top].state = 57;
break;
- }
- break;
- case ')':
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_varname = parse_reduce_20(parser->stack[parser->top + 0].value.token.str, grammar);
- switch (parser->stack[parser->top].state) {
- case 34:
- parser->stack[++parser->top].state = 40;
- break;
- case 47:
- parser->stack[++parser->top].state = 53;
- break;
- case 56:
- parser->stack[++parser->top].state = 57;
- break;
}
- break;
-
- default:
- return -1;
}
break;
case 43:
switch (token) {
- case 0:
+ default:
parser->top -= 1;
parser->stack[parser->top].value.symbol_varname = parse_reduce_21(parser->stack[parser->top + 0].value.token.str, grammar);
switch (parser->stack[parser->top].state) {
case 34:
parser->stack[++parser->top].state = 40;
break;
- case 47:
- parser->stack[++parser->top].state = 53;
- break;
- case 56:
- parser->stack[++parser->top].state = 57;
- break;
- }
- break;
- case TOK_SYMBOL_LC:
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_varname = parse_reduce_21(parser->stack[parser->top + 0].value.token.str, grammar);
- switch (parser->stack[parser->top].state) {
- case 34:
- parser->stack[++parser->top].state = 40;
- break;
case 47:
parser->stack[++parser->top].state = 53;
break;
- case 56:
- parser->stack[++parser->top].state = 57;
- break;
- }
- break;
- case '%':
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_varname = parse_reduce_21(parser->stack[parser->top + 0].value.token.str, grammar);
- switch (parser->stack[parser->top].state) {
- case 34:
- parser->stack[++parser->top].state = 40;
- break;
- case 47:
- parser->stack[++parser->top].state = 53;
- break;
case 56:
parser->stack[++parser->top].state = 57;
break;
- }
- break;
- case ')':
- parser->top -= 1;
- parser->stack[parser->top].value.symbol_varname = parse_reduce_21(parser->stack[parser->top + 0].value.token.str, grammar);
- switch (parser->stack[parser->top].state) {
- case 34:
- parser->stack[++parser->top].state = 40;
- break;
- case 47:
- parser->stack[++parser->top].state = 53;
- break;
- case 56:
- parser->stack[++parser->top].state = 57;
- break;
}
- break;
-
- default:
- return -1;
}
break;
@@ -1401,69 +827,19 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 48:
switch (token) {
- case 0:
- parser->top -= 7;
- parse_reduce_4(parser->stack[parser->top + 5].value.token.str, parser->stack[parser->top + 6].value.token.str, grammar);
- parser->stack[++parser->top].state = 2;
- break;
-
- case TOK_SYMBOL_LC:
- parser->top -= 7;
- parse_reduce_4(parser->stack[parser->top + 5].value.token.str, parser->stack[parser->top + 6].value.token.str, grammar);
- parser->stack[++parser->top].state = 2;
- break;
-
- case '%':
+ default:
parser->top -= 7;
parse_reduce_4(parser->stack[parser->top + 5].value.token.str, parser->stack[parser->top + 6].value.token.str, grammar);
parser->stack[++parser->top].state = 2;
- break;
-
- default:
- return -1;
}
break;
case 49:
switch (token) {
- case TOK_BLOCK:
- parser->top -= 5;
- parser->stack[parser->top].value.symbol_rhs = parse_reduce_12(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, parser->stack[parser->top + 3].value.symbol_varname, grammar);
- parser->stack[++parser->top].state = 16;
- break;
-
- case TOK_CHAR:
- parser->top -= 5;
- parser->stack[parser->top].value.symbol_rhs = parse_reduce_12(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, parser->stack[parser->top + 3].value.symbol_varname, grammar);
- parser->stack[++parser->top].state = 16;
- break;
-
- case TOK_STRING:
- parser->top -= 5;
- parser->stack[parser->top].value.symbol_rhs = parse_reduce_12(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, parser->stack[parser->top + 3].value.symbol_varname, grammar);
- parser->stack[++parser->top].state = 16;
- break;
-
- case TOK_SYMBOL_LC:
- parser->top -= 5;
- parser->stack[parser->top].value.symbol_rhs = parse_reduce_12(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, parser->stack[parser->top + 3].value.symbol_varname, grammar);
- parser->stack[++parser->top].state = 16;
- break;
-
- case TOK_SYMBOL_UC:
- parser->top -= 5;
- parser->stack[parser->top].value.symbol_rhs = parse_reduce_12(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, parser->stack[parser->top + 3].value.symbol_varname, grammar);
- parser->stack[++parser->top].state = 16;
- break;
-
- case ';':
+ default:
parser->top -= 5;
parser->stack[parser->top].value.symbol_rhs = parse_reduce_12(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, parser->stack[parser->top + 3].value.symbol_varname, grammar);
parser->stack[++parser->top].state = 16;
- break;
-
- default:
- return -1;
}
break;
@@ -1481,76 +857,28 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 51:
switch (token) {
- case 0:
- parser->top -= 8;
- parse_reduce_7(parser->stack[parser->top + 7].value.token.str, grammar);
- parser->stack[++parser->top].state = 2;
- break;
-
- case TOK_SYMBOL_LC:
- parser->top -= 8;
- parse_reduce_7(parser->stack[parser->top + 7].value.token.str, grammar);
- parser->stack[++parser->top].state = 2;
- break;
-
- case '%':
+ default:
parser->top -= 8;
parse_reduce_7(parser->stack[parser->top + 7].value.token.str, grammar);
parser->stack[++parser->top].state = 2;
- break;
-
- default:
- return -1;
}
break;
case 52:
switch (token) {
- case 0:
- parser->top -= 8;
- parse_reduce_6(parser->stack[parser->top + 7].value.token.str, grammar);
- parser->stack[++parser->top].state = 2;
- break;
-
- case TOK_SYMBOL_LC:
- parser->top -= 8;
- parse_reduce_6(parser->stack[parser->top + 7].value.token.str, grammar);
- parser->stack[++parser->top].state = 2;
- break;
-
- case '%':
+ default:
parser->top -= 8;
parse_reduce_6(parser->stack[parser->top + 7].value.token.str, grammar);
parser->stack[++parser->top].state = 2;
- break;
-
- default:
- return -1;
}
break;
case 53:
switch (token) {
- case 0:
- parser->top -= 8;
- parse_reduce_5(parser->stack[parser->top + 5].value.symbol_term, parser->stack[parser->top + 6].value.token.str, parser->stack[parser->top + 7].value.symbol_varname, grammar);
- parser->stack[++parser->top].state = 2;
- break;
-
- case TOK_SYMBOL_LC:
- parser->top -= 8;
- parse_reduce_5(parser->stack[parser->top + 5].value.symbol_term, parser->stack[parser->top + 6].value.token.str, parser->stack[parser->top + 7].value.symbol_varname, grammar);
- parser->stack[++parser->top].state = 2;
- break;
-
- case '%':
+ default:
parser->top -= 8;
parse_reduce_5(parser->stack[parser->top + 5].value.symbol_term, parser->stack[parser->top + 6].value.token.str, parser->stack[parser->top + 7].value.symbol_varname, grammar);
parser->stack[++parser->top].state = 2;
- break;
-
- default:
- return -1;
}
break;
@@ -1602,26 +930,10 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 57:
switch (token) {
- case 0:
- parser->top -= 12;
- parse_reduce_8(parser->stack[parser->top + 10].value.token.str, parser->stack[parser->top + 11].value.symbol_varname, grammar);
- parser->stack[++parser->top].state = 2;
- break;
-
- case TOK_SYMBOL_LC:
- parser->top -= 12;
- parse_reduce_8(parser->stack[parser->top + 10].value.token.str, parser->stack[parser->top + 11].value.symbol_varname, grammar);
- parser->stack[++parser->top].state = 2;
- break;
-
- case '%':
+ default:
parser->top -= 12;
parse_reduce_8(parser->stack[parser->top + 10].value.token.str, parser->stack[parser->top + 11].value.symbol_varname, grammar);
parser->stack[++parser->top].state = 2;
- break;
-
- default:
- return -1;
}
break;