#include "parse.hpp" typedef union parse_symbol_value { parse_token_value_t token; std::string * symbol_action; std::pair, std::vector> * symbol_rhs; solar::rule_t * symbol_rule; solar::symbol_t * symbol_symbol; solar::symbol_t * symbol_term; std::string * symbol_varname; } parse_symbol_value_t; typedef struct parse_context_state { unsigned state; parse_symbol_value_t value; } parse_context_state_t; struct parse_context { unsigned top; parse_context_state_t stack[100]; }; parse_context_t * parse_alloc(void *(*alloc_func)(size_t)) { parse_context_t *parser = (parse_context_t *)alloc_func(sizeof(parse_context_t)); parser->top = 0; parser->stack[0].state = 0; return parser; } void parse_free(parse_context_t *parser, void (*free_func)(void *)) { free_func(parser); } static inline void parse_reduce_2(solar::rule_t * rule, __attribute__((unused)) solar::grammar_t * grammar) { if (grammar->rules.empty()) { solar::item_t init(""); init.get_rhs().push_back(solar::symbol_t::make_nonterm(rule->item.get_lhs().c_str())); grammar->rules.emplace_back(solar::rule_t {std::move(init), std::vector(), std::string()}); } grammar->rules.push_back(*rule); delete rule; } static inline void parse_reduce_3(std::string * nonterm, std::string * type, __attribute__((unused)) solar::grammar_t * grammar) { grammar->nonterm_types.insert(std::make_pair(*nonterm, *type)); delete nonterm; delete type; } static inline void parse_reduce_4(solar::symbol_t * term, std::string * type, std::string * name, __attribute__((unused)) solar::grammar_t * grammar) { grammar->term_types.insert(std::make_pair(*term, std::make_pair(*type, *name))); delete term; delete type; delete name; } static inline void parse_reduce_5(std::string * block, __attribute__((unused)) solar::grammar_t * grammar) { grammar->source_block = *block; delete block; } static inline void parse_reduce_6(std::string * block, __attribute__((unused)) solar::grammar_t * grammar) { grammar->header_block = *block; delete block; } static inline void parse_reduce_7(std::string * type, std::string * name, __attribute__((unused)) solar::grammar_t * grammar) { grammar->extra_args.push_back(std::make_pair(*type, *name)); delete type; delete name; } static inline solar::rule_t * parse_reduce_8(std::string * lhs, std::pair, std::vector> * rhs, std::string * action, __attribute__((unused)) solar::grammar_t * grammar) { auto *ret = new solar::rule_t {solar::item_t(*lhs, rhs->first), rhs->second, *action}; delete lhs; delete rhs; delete action; return ret; } static inline std::pair, std::vector> * parse_reduce_9(__attribute__((unused)) solar::grammar_t * grammar) { return new std::pair, std::vector>(); } static inline std::pair, std::vector> * parse_reduce_10(std::pair, std::vector> * rhs, solar::symbol_t * sym, __attribute__((unused)) solar::grammar_t * grammar) { rhs->first.push_back(*sym); rhs->second.emplace_back(); delete sym; return rhs; } static inline std::pair, std::vector> * parse_reduce_11(std::pair, std::vector> * rhs, solar::symbol_t * sym, std::string * var, __attribute__((unused)) solar::grammar_t * grammar) { rhs->first.push_back(*sym); rhs->second.push_back(*var); delete sym; delete var; return rhs; } static inline std::string * parse_reduce_12(__attribute__((unused)) solar::grammar_t * grammar) { return new std::string; } static inline std::string * parse_reduce_13(std::string * v, __attribute__((unused)) solar::grammar_t * grammar) { return v; } static inline solar::symbol_t * parse_reduce_14(solar::symbol_t * v, __attribute__((unused)) solar::grammar_t * grammar) { return v; } static inline solar::symbol_t * parse_reduce_15(std::string * v, __attribute__((unused)) solar::grammar_t * grammar) { solar::symbol_t *ret = new solar::symbol_t(solar::symbol_t::make_nonterm(*v)); delete v; return ret; } static inline solar::symbol_t * parse_reduce_16(std::string * v, __attribute__((unused)) solar::grammar_t * grammar) { solar::symbol_t *ret = new solar::symbol_t(solar::symbol_t::make_term(*v)); delete v; return ret; } static inline solar::symbol_t * parse_reduce_17(char v, __attribute__((unused)) solar::grammar_t * grammar) { return new solar::symbol_t(solar::symbol_t::make_char(v)); } static inline std::string * parse_reduce_18(std::string * v, __attribute__((unused)) solar::grammar_t * grammar) { return v; } static inline std::string * parse_reduce_19(std::string * v, __attribute__((unused)) solar::grammar_t * grammar) { return v; } static inline std::string * parse_reduce_20(std::string * v, __attribute__((unused)) solar::grammar_t * grammar) { return v; } int parse_push(parse_context_t *parser, int token, const parse_token_value_t *value, __attribute__((unused)) solar::grammar_t * grammar) { while (1) { switch (parser->stack[parser->top].state) { case 0: switch (token) { case 0: parser->stack[++parser->top].state = 1; break; case TOK_EXTRA_ARG: parser->stack[++parser->top].state = 1; break; case TOK_HEADER: parser->stack[++parser->top].state = 1; break; case TOK_SOURCE: parser->stack[++parser->top].state = 1; break; case TOK_SYMBOL_LC: parser->stack[++parser->top].state = 1; break; case TOK_TYPE: parser->stack[++parser->top].state = 1; break; default: return -1; } break; case 1: switch (token) { case 0: return 0; case TOK_EXTRA_ARG: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 3; return 1; case TOK_HEADER: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 4; return 1; case TOK_SOURCE: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 5; return 1; case TOK_SYMBOL_LC: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 6; return 1; case TOK_TYPE: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 7; return 1; default: return -1; } break; case 2: switch (token) { case 0: parser->top -= 2; parse_reduce_2(parser->stack[parser->top + 1].value.symbol_rule, grammar); parser->stack[++parser->top].state = 1; break; case TOK_EXTRA_ARG: parser->top -= 2; parse_reduce_2(parser->stack[parser->top + 1].value.symbol_rule, grammar); parser->stack[++parser->top].state = 1; break; case TOK_HEADER: parser->top -= 2; parse_reduce_2(parser->stack[parser->top + 1].value.symbol_rule, grammar); parser->stack[++parser->top].state = 1; break; case TOK_SOURCE: parser->top -= 2; parse_reduce_2(parser->stack[parser->top + 1].value.symbol_rule, grammar); parser->stack[++parser->top].state = 1; break; case TOK_SYMBOL_LC: parser->top -= 2; parse_reduce_2(parser->stack[parser->top + 1].value.symbol_rule, grammar); parser->stack[++parser->top].state = 1; break; case TOK_TYPE: parser->top -= 2; parse_reduce_2(parser->stack[parser->top + 1].value.symbol_rule, grammar); parser->stack[++parser->top].state = 1; break; default: return -1; } break; case 3: switch (token) { case TOK_BLOCK: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 8; return 1; default: return -1; } break; case 4: switch (token) { case TOK_BLOCK: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 9; return 1; default: return -1; } break; case 5: switch (token) { case TOK_BLOCK: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 10; return 1; default: return -1; } break; case 6: switch (token) { case '|': parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 11; return 1; default: return -1; } break; case 7: switch (token) { case TOK_CHAR: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 13; return 1; case TOK_SYMBOL_LC: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 14; return 1; case TOK_SYMBOL_UC: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 15; return 1; default: return -1; } break; case 8: switch (token) { case TOK_SYMBOL: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 17; return 1; case TOK_SYMBOL_LC: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 18; return 1; case TOK_SYMBOL_UC: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 19; return 1; default: return -1; } break; case 9: switch (token) { case 0: parser->top -= 3; parse_reduce_6(parser->stack[parser->top + 2].value.token.str, grammar); parser->stack[++parser->top].state = 1; break; case TOK_EXTRA_ARG: parser->top -= 3; parse_reduce_6(parser->stack[parser->top + 2].value.token.str, grammar); parser->stack[++parser->top].state = 1; break; case TOK_HEADER: parser->top -= 3; parse_reduce_6(parser->stack[parser->top + 2].value.token.str, grammar); parser->stack[++parser->top].state = 1; break; case TOK_SOURCE: parser->top -= 3; parse_reduce_6(parser->stack[parser->top + 2].value.token.str, grammar); parser->stack[++parser->top].state = 1; break; case TOK_SYMBOL_LC: parser->top -= 3; parse_reduce_6(parser->stack[parser->top + 2].value.token.str, grammar); parser->stack[++parser->top].state = 1; break; case TOK_TYPE: parser->top -= 3; parse_reduce_6(parser->stack[parser->top + 2].value.token.str, grammar); parser->stack[++parser->top].state = 1; break; default: return -1; } break; case 10: switch (token) { case 0: parser->top -= 3; parse_reduce_5(parser->stack[parser->top + 2].value.token.str, grammar); parser->stack[++parser->top].state = 1; break; case TOK_EXTRA_ARG: parser->top -= 3; parse_reduce_5(parser->stack[parser->top + 2].value.token.str, grammar); parser->stack[++parser->top].state = 1; break; case TOK_HEADER: parser->top -= 3; parse_reduce_5(parser->stack[parser->top + 2].value.token.str, grammar); parser->stack[++parser->top].state = 1; break; case TOK_SOURCE: parser->top -= 3; parse_reduce_5(parser->stack[parser->top + 2].value.token.str, grammar); parser->stack[++parser->top].state = 1; break; case TOK_SYMBOL_LC: parser->top -= 3; parse_reduce_5(parser->stack[parser->top + 2].value.token.str, grammar); parser->stack[++parser->top].state = 1; break; case TOK_TYPE: parser->top -= 3; parse_reduce_5(parser->stack[parser->top + 2].value.token.str, grammar); parser->stack[++parser->top].state = 1; break; default: return -1; } break; case 11: switch (token) { case '=': parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 20; return 1; default: return -1; } break; case 12: switch (token) { case TOK_BLOCK: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 21; return 1; default: return -1; } break; case 13: switch (token) { case TOK_BLOCK: parser->top -= 1; parser->stack[parser->top].value.symbol_term = parse_reduce_17(parser->stack[parser->top + 0].value.token.c, grammar); switch (parser->stack[parser->top].state) { case 7: parser->stack[++parser->top].state = 12; break; case 23: parser->stack[++parser->top].state = 27; break; } break; case TOK_CHAR: parser->top -= 1; parser->stack[parser->top].value.symbol_term = parse_reduce_17(parser->stack[parser->top + 0].value.token.c, grammar); switch (parser->stack[parser->top].state) { case 7: parser->stack[++parser->top].state = 12; break; case 23: parser->stack[++parser->top].state = 27; break; } break; case TOK_SYMBOL_LC: parser->top -= 1; parser->stack[parser->top].value.symbol_term = parse_reduce_17(parser->stack[parser->top + 0].value.token.c, grammar); switch (parser->stack[parser->top].state) { case 7: parser->stack[++parser->top].state = 12; break; case 23: parser->stack[++parser->top].state = 27; break; } break; case TOK_SYMBOL_UC: parser->top -= 1; parser->stack[parser->top].value.symbol_term = parse_reduce_17(parser->stack[parser->top + 0].value.token.c, grammar); switch (parser->stack[parser->top].state) { case 7: parser->stack[++parser->top].state = 12; break; case 23: parser->stack[++parser->top].state = 27; break; } break; case '(': parser->top -= 1; parser->stack[parser->top].value.symbol_term = parse_reduce_17(parser->stack[parser->top + 0].value.token.c, grammar); switch (parser->stack[parser->top].state) { case 7: parser->stack[++parser->top].state = 12; break; case 23: parser->stack[++parser->top].state = 27; break; } break; case ';': parser->top -= 1; parser->stack[parser->top].value.symbol_term = parse_reduce_17(parser->stack[parser->top + 0].value.token.c, grammar); switch (parser->stack[parser->top].state) { case 7: parser->stack[++parser->top].state = 12; break; case 23: parser->stack[++parser->top].state = 27; break; } break; default: return -1; } break; case 14: switch (token) { case TOK_BLOCK: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 22; return 1; default: return -1; } break; case 15: switch (token) { case TOK_BLOCK: parser->top -= 1; parser->stack[parser->top].value.symbol_term = parse_reduce_16(parser->stack[parser->top + 0].value.token.str, grammar); switch (parser->stack[parser->top].state) { case 7: parser->stack[++parser->top].state = 12; break; case 23: parser->stack[++parser->top].state = 27; break; } break; case TOK_CHAR: parser->top -= 1; parser->stack[parser->top].value.symbol_term = parse_reduce_16(parser->stack[parser->top + 0].value.token.str, grammar); switch (parser->stack[parser->top].state) { case 7: parser->stack[++parser->top].state = 12; break; case 23: parser->stack[++parser->top].state = 27; break; } break; case TOK_SYMBOL_LC: parser->top -= 1; parser->stack[parser->top].value.symbol_term = parse_reduce_16(parser->stack[parser->top + 0].value.token.str, grammar); switch (parser->stack[parser->top].state) { case 7: parser->stack[++parser->top].state = 12; break; case 23: parser->stack[++parser->top].state = 27; break; } break; case TOK_SYMBOL_UC: parser->top -= 1; parser->stack[parser->top].value.symbol_term = parse_reduce_16(parser->stack[parser->top + 0].value.token.str, grammar); switch (parser->stack[parser->top].state) { case 7: parser->stack[++parser->top].state = 12; break; case 23: parser->stack[++parser->top].state = 27; break; } break; case '(': parser->top -= 1; parser->stack[parser->top].value.symbol_term = parse_reduce_16(parser->stack[parser->top + 0].value.token.str, grammar); switch (parser->stack[parser->top].state) { case 7: parser->stack[++parser->top].state = 12; break; case 23: parser->stack[++parser->top].state = 27; break; } break; case ';': parser->top -= 1; parser->stack[parser->top].value.symbol_term = parse_reduce_16(parser->stack[parser->top + 0].value.token.str, grammar); switch (parser->stack[parser->top].state) { case 7: parser->stack[++parser->top].state = 12; break; case 23: parser->stack[++parser->top].state = 27; break; } break; default: return -1; } break; case 16: switch (token) { case 0: parser->top -= 4; parse_reduce_7(parser->stack[parser->top + 2].value.token.str, parser->stack[parser->top + 3].value.symbol_varname, grammar); parser->stack[++parser->top].state = 1; break; case TOK_EXTRA_ARG: parser->top -= 4; parse_reduce_7(parser->stack[parser->top + 2].value.token.str, parser->stack[parser->top + 3].value.symbol_varname, grammar); parser->stack[++parser->top].state = 1; break; case TOK_HEADER: parser->top -= 4; parse_reduce_7(parser->stack[parser->top + 2].value.token.str, parser->stack[parser->top + 3].value.symbol_varname, grammar); parser->stack[++parser->top].state = 1; break; case TOK_SOURCE: parser->top -= 4; parse_reduce_7(parser->stack[parser->top + 2].value.token.str, parser->stack[parser->top + 3].value.symbol_varname, grammar); parser->stack[++parser->top].state = 1; break; case TOK_SYMBOL_LC: parser->top -= 4; parse_reduce_7(parser->stack[parser->top + 2].value.token.str, parser->stack[parser->top + 3].value.symbol_varname, grammar); parser->stack[++parser->top].state = 1; break; case TOK_TYPE: parser->top -= 4; parse_reduce_7(parser->stack[parser->top + 2].value.token.str, parser->stack[parser->top + 3].value.symbol_varname, grammar); parser->stack[++parser->top].state = 1; break; default: return -1; } break; case 17: switch (token) { case 0: 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 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; break; } break; case TOK_EXTRA_ARG: 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 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; break; } break; case TOK_HEADER: 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 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; break; } break; case TOK_SOURCE: 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 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; 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 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; break; } break; case TOK_TYPE: 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 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; 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 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; break; } break; default: return -1; } break; case 18: switch (token) { case 0: parser->top -= 1; parser->stack[parser->top].value.symbol_varname = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar); switch (parser->stack[parser->top].state) { case 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; break; } break; case TOK_EXTRA_ARG: parser->top -= 1; parser->stack[parser->top].value.symbol_varname = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar); switch (parser->stack[parser->top].state) { case 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; break; } break; case TOK_HEADER: parser->top -= 1; parser->stack[parser->top].value.symbol_varname = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar); switch (parser->stack[parser->top].state) { case 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; break; } break; case TOK_SOURCE: parser->top -= 1; parser->stack[parser->top].value.symbol_varname = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar); switch (parser->stack[parser->top].state) { case 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; break; } break; case TOK_SYMBOL_LC: parser->top -= 1; parser->stack[parser->top].value.symbol_varname = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar); switch (parser->stack[parser->top].state) { case 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; break; } break; case TOK_TYPE: parser->top -= 1; parser->stack[parser->top].value.symbol_varname = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar); switch (parser->stack[parser->top].state) { case 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; break; } break; case ')': parser->top -= 1; parser->stack[parser->top].value.symbol_varname = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar); switch (parser->stack[parser->top].state) { case 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; break; } break; default: return -1; } break; case 19: switch (token) { case 0: parser->top -= 1; parser->stack[parser->top].value.symbol_varname = parse_reduce_19(parser->stack[parser->top + 0].value.token.str, grammar); switch (parser->stack[parser->top].state) { case 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; break; } break; case TOK_EXTRA_ARG: parser->top -= 1; parser->stack[parser->top].value.symbol_varname = parse_reduce_19(parser->stack[parser->top + 0].value.token.str, grammar); switch (parser->stack[parser->top].state) { case 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; break; } break; case TOK_HEADER: parser->top -= 1; parser->stack[parser->top].value.symbol_varname = parse_reduce_19(parser->stack[parser->top + 0].value.token.str, grammar); switch (parser->stack[parser->top].state) { case 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; break; } break; case TOK_SOURCE: parser->top -= 1; parser->stack[parser->top].value.symbol_varname = parse_reduce_19(parser->stack[parser->top + 0].value.token.str, grammar); switch (parser->stack[parser->top].state) { case 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; break; } break; case TOK_SYMBOL_LC: parser->top -= 1; parser->stack[parser->top].value.symbol_varname = parse_reduce_19(parser->stack[parser->top + 0].value.token.str, grammar); switch (parser->stack[parser->top].state) { case 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; break; } break; case TOK_TYPE: parser->top -= 1; parser->stack[parser->top].value.symbol_varname = parse_reduce_19(parser->stack[parser->top + 0].value.token.str, grammar); switch (parser->stack[parser->top].state) { case 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; break; } break; case ')': parser->top -= 1; parser->stack[parser->top].value.symbol_varname = parse_reduce_19(parser->stack[parser->top + 0].value.token.str, grammar); switch (parser->stack[parser->top].state) { case 8: parser->stack[++parser->top].state = 16; break; case 21: parser->stack[++parser->top].state = 24; break; case 31: parser->stack[++parser->top].state = 32; break; } break; default: return -1; } break; case 20: switch (token) { case TOK_BLOCK: parser->stack[parser->top].value.symbol_rhs = parse_reduce_9(grammar); parser->stack[++parser->top].state = 23; break; case TOK_CHAR: parser->stack[parser->top].value.symbol_rhs = parse_reduce_9(grammar); parser->stack[++parser->top].state = 23; break; case TOK_SYMBOL_LC: parser->stack[parser->top].value.symbol_rhs = parse_reduce_9(grammar); parser->stack[++parser->top].state = 23; break; case TOK_SYMBOL_UC: parser->stack[parser->top].value.symbol_rhs = parse_reduce_9(grammar); parser->stack[++parser->top].state = 23; break; case ';': parser->stack[parser->top].value.symbol_rhs = parse_reduce_9(grammar); parser->stack[++parser->top].state = 23; break; default: return -1; } break; case 21: switch (token) { case TOK_SYMBOL: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 17; return 1; case TOK_SYMBOL_LC: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 18; return 1; case TOK_SYMBOL_UC: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 19; return 1; default: return -1; } break; case 22: switch (token) { case 0: parser->top -= 4; parse_reduce_3(parser->stack[parser->top + 2].value.token.str, parser->stack[parser->top + 3].value.token.str, grammar); parser->stack[++parser->top].state = 1; break; case TOK_EXTRA_ARG: parser->top -= 4; parse_reduce_3(parser->stack[parser->top + 2].value.token.str, parser->stack[parser->top + 3].value.token.str, grammar); parser->stack[++parser->top].state = 1; break; case TOK_HEADER: parser->top -= 4; parse_reduce_3(parser->stack[parser->top + 2].value.token.str, parser->stack[parser->top + 3].value.token.str, grammar); parser->stack[++parser->top].state = 1; break; case TOK_SOURCE: parser->top -= 4; parse_reduce_3(parser->stack[parser->top + 2].value.token.str, parser->stack[parser->top + 3].value.token.str, grammar); parser->stack[++parser->top].state = 1; break; case TOK_SYMBOL_LC: parser->top -= 4; parse_reduce_3(parser->stack[parser->top + 2].value.token.str, parser->stack[parser->top + 3].value.token.str, grammar); parser->stack[++parser->top].state = 1; break; case TOK_TYPE: parser->top -= 4; parse_reduce_3(parser->stack[parser->top + 2].value.token.str, parser->stack[parser->top + 3].value.token.str, grammar); parser->stack[++parser->top].state = 1; break; default: return -1; } break; case 23: switch (token) { case TOK_BLOCK: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 28; return 1; case TOK_CHAR: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 13; return 1; case TOK_SYMBOL_LC: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 29; return 1; case TOK_SYMBOL_UC: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 15; return 1; case ';': parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 30; return 1; default: return -1; } break; case 24: switch (token) { case 0: parser->top -= 5; parse_reduce_4(parser->stack[parser->top + 2].value.symbol_term, parser->stack[parser->top + 3].value.token.str, parser->stack[parser->top + 4].value.symbol_varname, grammar); parser->stack[++parser->top].state = 1; break; case TOK_EXTRA_ARG: parser->top -= 5; parse_reduce_4(parser->stack[parser->top + 2].value.symbol_term, parser->stack[parser->top + 3].value.token.str, parser->stack[parser->top + 4].value.symbol_varname, grammar); parser->stack[++parser->top].state = 1; break; case TOK_HEADER: parser->top -= 5; parse_reduce_4(parser->stack[parser->top + 2].value.symbol_term, parser->stack[parser->top + 3].value.token.str, parser->stack[parser->top + 4].value.symbol_varname, grammar); parser->stack[++parser->top].state = 1; break; case TOK_SOURCE: parser->top -= 5; parse_reduce_4(parser->stack[parser->top + 2].value.symbol_term, parser->stack[parser->top + 3].value.token.str, parser->stack[parser->top + 4].value.symbol_varname, grammar); parser->stack[++parser->top].state = 1; break; case TOK_SYMBOL_LC: parser->top -= 5; parse_reduce_4(parser->stack[parser->top + 2].value.symbol_term, parser->stack[parser->top + 3].value.token.str, parser->stack[parser->top + 4].value.symbol_varname, grammar); parser->stack[++parser->top].state = 1; break; case TOK_TYPE: parser->top -= 5; parse_reduce_4(parser->stack[parser->top + 2].value.symbol_term, parser->stack[parser->top + 3].value.token.str, parser->stack[parser->top + 4].value.symbol_varname, grammar); parser->stack[++parser->top].state = 1; break; default: return -1; } break; case 25: switch (token) { case 0: parser->top -= 5; parser->stack[parser->top].value.symbol_rule = parse_reduce_8(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 = 2; break; case TOK_EXTRA_ARG: parser->top -= 5; parser->stack[parser->top].value.symbol_rule = parse_reduce_8(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 = 2; break; case TOK_HEADER: parser->top -= 5; parser->stack[parser->top].value.symbol_rule = parse_reduce_8(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 = 2; break; case TOK_SOURCE: parser->top -= 5; parser->stack[parser->top].value.symbol_rule = parse_reduce_8(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 = 2; break; case TOK_SYMBOL_LC: parser->top -= 5; parser->stack[parser->top].value.symbol_rule = parse_reduce_8(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 = 2; break; case TOK_TYPE: parser->top -= 5; parser->stack[parser->top].value.symbol_rule = parse_reduce_8(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 = 2; break; default: return -1; } break; case 26: switch (token) { case TOK_BLOCK: parser->top -= 2; parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, grammar); parser->stack[++parser->top].state = 23; break; case TOK_CHAR: parser->top -= 2; parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, grammar); parser->stack[++parser->top].state = 23; break; case TOK_SYMBOL_LC: parser->top -= 2; parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, grammar); parser->stack[++parser->top].state = 23; break; case TOK_SYMBOL_UC: parser->top -= 2; parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, grammar); parser->stack[++parser->top].state = 23; break; case '(': parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 31; return 1; case ';': parser->top -= 2; parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, grammar); parser->stack[++parser->top].state = 23; break; default: return -1; } break; case 27: switch (token) { case TOK_BLOCK: parser->top -= 1; parser->stack[parser->top].value.symbol_symbol = parse_reduce_14(parser->stack[parser->top + 0].value.symbol_term, grammar); parser->stack[++parser->top].state = 26; break; case TOK_CHAR: parser->top -= 1; parser->stack[parser->top].value.symbol_symbol = parse_reduce_14(parser->stack[parser->top + 0].value.symbol_term, grammar); parser->stack[++parser->top].state = 26; break; case TOK_SYMBOL_LC: parser->top -= 1; parser->stack[parser->top].value.symbol_symbol = parse_reduce_14(parser->stack[parser->top + 0].value.symbol_term, grammar); parser->stack[++parser->top].state = 26; break; case TOK_SYMBOL_UC: parser->top -= 1; parser->stack[parser->top].value.symbol_symbol = parse_reduce_14(parser->stack[parser->top + 0].value.symbol_term, grammar); parser->stack[++parser->top].state = 26; break; case '(': parser->top -= 1; parser->stack[parser->top].value.symbol_symbol = parse_reduce_14(parser->stack[parser->top + 0].value.symbol_term, grammar); parser->stack[++parser->top].state = 26; break; case ';': parser->top -= 1; parser->stack[parser->top].value.symbol_symbol = parse_reduce_14(parser->stack[parser->top + 0].value.symbol_term, grammar); parser->stack[++parser->top].state = 26; break; default: return -1; } break; case 28: switch (token) { case 0: parser->top -= 1; parser->stack[parser->top].value.symbol_action = parse_reduce_13(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[++parser->top].state = 25; break; case TOK_EXTRA_ARG: parser->top -= 1; parser->stack[parser->top].value.symbol_action = parse_reduce_13(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[++parser->top].state = 25; break; case TOK_HEADER: parser->top -= 1; parser->stack[parser->top].value.symbol_action = parse_reduce_13(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[++parser->top].state = 25; break; case TOK_SOURCE: parser->top -= 1; parser->stack[parser->top].value.symbol_action = parse_reduce_13(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[++parser->top].state = 25; break; case TOK_SYMBOL_LC: parser->top -= 1; parser->stack[parser->top].value.symbol_action = parse_reduce_13(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[++parser->top].state = 25; break; case TOK_TYPE: parser->top -= 1; parser->stack[parser->top].value.symbol_action = parse_reduce_13(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[++parser->top].state = 25; break; default: return -1; } break; case 29: switch (token) { case TOK_BLOCK: parser->top -= 1; parser->stack[parser->top].value.symbol_symbol = parse_reduce_15(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[++parser->top].state = 26; break; case TOK_CHAR: parser->top -= 1; parser->stack[parser->top].value.symbol_symbol = parse_reduce_15(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[++parser->top].state = 26; break; case TOK_SYMBOL_LC: parser->top -= 1; parser->stack[parser->top].value.symbol_symbol = parse_reduce_15(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[++parser->top].state = 26; break; case TOK_SYMBOL_UC: parser->top -= 1; parser->stack[parser->top].value.symbol_symbol = parse_reduce_15(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[++parser->top].state = 26; break; case '(': parser->top -= 1; parser->stack[parser->top].value.symbol_symbol = parse_reduce_15(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[++parser->top].state = 26; break; case ';': parser->top -= 1; parser->stack[parser->top].value.symbol_symbol = parse_reduce_15(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[++parser->top].state = 26; break; default: return -1; } break; case 30: switch (token) { case 0: parser->top -= 1; parser->stack[parser->top].value.symbol_action = parse_reduce_12(grammar); parser->stack[++parser->top].state = 25; break; case TOK_EXTRA_ARG: parser->top -= 1; parser->stack[parser->top].value.symbol_action = parse_reduce_12(grammar); parser->stack[++parser->top].state = 25; break; case TOK_HEADER: parser->top -= 1; parser->stack[parser->top].value.symbol_action = parse_reduce_12(grammar); parser->stack[++parser->top].state = 25; break; case TOK_SOURCE: parser->top -= 1; parser->stack[parser->top].value.symbol_action = parse_reduce_12(grammar); parser->stack[++parser->top].state = 25; break; case TOK_SYMBOL_LC: parser->top -= 1; parser->stack[parser->top].value.symbol_action = parse_reduce_12(grammar); parser->stack[++parser->top].state = 25; break; case TOK_TYPE: parser->top -= 1; parser->stack[parser->top].value.symbol_action = parse_reduce_12(grammar); parser->stack[++parser->top].state = 25; break; default: return -1; } break; case 31: switch (token) { case TOK_SYMBOL: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 17; return 1; case TOK_SYMBOL_LC: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 18; return 1; case TOK_SYMBOL_UC: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 19; return 1; default: return -1; } break; case 32: switch (token) { case ')': parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 33; return 1; default: return -1; } break; case 33: switch (token) { case TOK_BLOCK: parser->top -= 5; 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, parser->stack[parser->top + 3].value.symbol_varname, grammar); parser->stack[++parser->top].state = 23; break; case TOK_CHAR: parser->top -= 5; 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, parser->stack[parser->top + 3].value.symbol_varname, grammar); parser->stack[++parser->top].state = 23; break; case TOK_SYMBOL_LC: parser->top -= 5; 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, parser->stack[parser->top + 3].value.symbol_varname, grammar); parser->stack[++parser->top].state = 23; break; case TOK_SYMBOL_UC: parser->top -= 5; 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, parser->stack[parser->top + 3].value.symbol_varname, grammar); parser->stack[++parser->top].state = 23; break; case ';': parser->top -= 5; 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, parser->stack[parser->top + 3].value.symbol_varname, grammar); parser->stack[++parser->top].state = 23; break; default: return -1; } break; } } }