From 634e5db20969023f7545ad0780181b0d3085567d Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 10 Apr 2015 18:01:10 +0200 Subject: Don't parse keywords in the lexer --- src/lex.cpp | 92 +-- src/lex.hpp | 3 +- src/parse.cpp | 1719 +++++++++++++++++++++++++++------------------------------ src/parse.hpp | 12 +- src/parse.y | 10 +- 5 files changed, 851 insertions(+), 985 deletions(-) (limited to 'src') diff --git a/src/lex.cpp b/src/lex.cpp index 3746c91..9415d8b 100644 --- a/src/lex.cpp +++ b/src/lex.cpp @@ -34,26 +34,6 @@ namespace solar { - -struct keyword_t { - const char *keyword; - int token; -}; - -/* the keyword list must be sorted */ -static const keyword_t keywords[] = { - {"%extra_arg", TOK_EXTRA_ARG}, - {"%header", TOK_HEADER}, - {"%source", TOK_SOURCE}, - {"%type", TOK_TYPE}, -}; - -static int compare_keywords(const void *v1, const void *v2) { - const keyword_t *k1 = static_cast(v1), *k2 = static_cast(v2); - return std::strcmp(k1->keyword, k2->keyword); -} - - bool lex_t::advance() { if (start > 0) { std::memmove(buffer, buffer+start, end - start); @@ -183,61 +163,6 @@ int lex_t::lex_string(parse_token_value_t *value) { return TOK_STRING; } -/* -int lex_t::lex_number(parse_token_value_t *value) { - if (needspace) - return syntax_error(value); - - while (next(false)) { - char cur = current(); - - if (cur >= '0' && cur <= '9') - continue; - - if (cur == 'x' || (cur >= 'a' && cur <= 'f') || (cur >= 'A' && cur <= 'F')) - continue; - - break; - } - - char *endptr, *token = get_token(); - value->number = std::strtoull(token, &endptr, 0); - - bool ok = !*endptr; - free(token); - - if (!ok) - return syntax_error(value); - - consume(true); - - return TOK_UINT; -}*/ - -int lex_t::lex_keyword(parse_token_value_t *value) { - if (needspace) - return syntax_error(value); - - while (next(false)) { - char cur = current(); - - if (!((cur >= 'a' && cur <= 'z') || (cur >= '0' && cur <= '9') || cur == '_')) - break; - } - - std::string *token = get_token(); - const keyword_t key = { .keyword = token->c_str(), .token = 0 }; - const keyword_t *ret = static_cast(bsearch(&key, keywords, array_size(keywords), sizeof(keyword_t), compare_keywords)); - delete token; - - if (!ret) - return syntax_error(value); - - consume(true); - - return ret->token; -} - int lex_t::unterminated_block(parse_token_value_t *value) { if (ferror(file)) return io_error(value); @@ -366,8 +291,18 @@ int lex_t::lex(parse_token_value_t *value) { case '\r': next(true); consume(false); + dumb_mode = false; continue; + } + + if (dumb_mode) { + token = current(); + next(true); + consume(false); + return token; + } + switch (current()) { case ';': case ':': case '|': @@ -432,7 +367,12 @@ int lex_t::lex(parse_token_value_t *value) { return lex_symbol(value); case '%': - return lex_keyword(value); + dumb_mode = true; + + token = current(); + next(true); + consume(false); + return token; default: return syntax_error(value); diff --git a/src/lex.hpp b/src/lex.hpp index bbf1de2..417c6e4 100644 --- a/src/lex.hpp +++ b/src/lex.hpp @@ -51,6 +51,7 @@ private: std::FILE *file; bool needspace; + bool dumb_mode; size_t start; size_t end; @@ -69,8 +70,6 @@ private: int unterminated_string(parse_token_value_t *value); int lex_string(parse_token_value_t *value); - //int lex_number(parse_token_value_t *value); - int lex_keyword(parse_token_value_t *value); int lex_block(parse_token_value_t *value); int lex_symbol(parse_token_value_t *value); diff --git a/src/parse.cpp b/src/parse.cpp index d09522c..7c8b1f2 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -167,23 +167,11 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va 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: + case '%': parser->stack[++parser->top].state = 1; break; @@ -197,31 +185,16 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va case 0: return 0; - case TOK_EXTRA_ARG: + case TOK_SYMBOL_LC: parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 4; return 1; - case TOK_HEADER: + case '%': parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 5; return 1; - case TOK_SOURCE: - parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 6; - return 1; - - case TOK_SYMBOL_LC: - parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 7; - return 1; - - case TOK_TYPE: - parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 8; - return 1; - default: return -1; } @@ -234,27 +207,12 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va parser->stack[++parser->top].state = 1; break; - case TOK_EXTRA_ARG: - parser->top -= 2; - parser->stack[++parser->top].state = 1; - break; - - case TOK_HEADER: - parser->top -= 2; - parser->stack[++parser->top].state = 1; - break; - - case TOK_SOURCE: - 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 TOK_TYPE: + case '%': parser->top -= 2; parser->stack[++parser->top].state = 1; break; @@ -272,31 +230,13 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va parser->stack[++parser->top].state = 2; break; - case TOK_EXTRA_ARG: - parser->top -= 1; - parse_reduce_3(parser->stack[parser->top + 0].value.symbol_rule, grammar); - parser->stack[++parser->top].state = 2; - break; - - case TOK_HEADER: - parser->top -= 1; - parse_reduce_3(parser->stack[parser->top + 0].value.symbol_rule, grammar); - parser->stack[++parser->top].state = 2; - break; - - case TOK_SOURCE: - 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 TOK_TYPE: + case '%': parser->top -= 1; parse_reduce_3(parser->stack[parser->top + 0].value.symbol_rule, grammar); parser->stack[++parser->top].state = 2; @@ -309,9 +249,9 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va case 4: switch (token) { - case TOK_BLOCK: + case '|': parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 9; + parser->stack[++parser->top].state = 6; return 1; default: @@ -321,7 +261,22 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va case 5: switch (token) { - case TOK_BLOCK: + case 'e': + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 7; + return 1; + + case 'h': + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 8; + return 1; + + case 's': + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 9; + return 1; + + case 't': parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 10; return 1; @@ -333,7 +288,7 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va case 6: switch (token) { - case TOK_BLOCK: + case '=': parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 11; return 1; @@ -345,7 +300,7 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va case 7: switch (token) { - case '|': + case 'x': parser->stack[parser->top].value.token = *value; parser->stack[++parser->top].state = 12; return 1; @@ -357,19 +312,9 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va case 8: switch (token) { - case TOK_CHAR: - parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 14; - return 1; - - case TOK_SYMBOL_LC: - parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 15; - return 1; - - case TOK_SYMBOL_UC: + case 'e': parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 16; + parser->stack[++parser->top].state = 13; return 1; default: @@ -379,19 +324,21 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va case 9: switch (token) { - case TOK_SYMBOL: + case 'o': parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 18; + parser->stack[++parser->top].state = 14; return 1; - case TOK_SYMBOL_LC: - parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 19; - return 1; + default: + return -1; + } + break; - case TOK_SYMBOL_UC: + case 10: + switch (token) { + case 'y': parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 20; + parser->stack[++parser->top].state = 15; return 1; default: @@ -399,42 +346,36 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va } break; - case 10: + case 11: switch (token) { - case 0: - parser->top -= 2; - parse_reduce_7(parser->stack[parser->top + 1].value.token.str, grammar); - parser->stack[++parser->top].state = 2; + case TOK_BLOCK: + parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(grammar); + parser->stack[++parser->top].state = 16; break; - case TOK_EXTRA_ARG: - parser->top -= 2; - parse_reduce_7(parser->stack[parser->top + 1].value.token.str, grammar); - parser->stack[++parser->top].state = 2; + case TOK_CHAR: + parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(grammar); + parser->stack[++parser->top].state = 16; break; - case TOK_HEADER: - parser->top -= 2; - parse_reduce_7(parser->stack[parser->top + 1].value.token.str, grammar); - parser->stack[++parser->top].state = 2; + case TOK_STRING: + parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(grammar); + parser->stack[++parser->top].state = 16; break; - case TOK_SOURCE: - parser->top -= 2; - parse_reduce_7(parser->stack[parser->top + 1].value.token.str, grammar); - parser->stack[++parser->top].state = 2; + 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_LC: - parser->top -= 2; - parse_reduce_7(parser->stack[parser->top + 1].value.token.str, grammar); - parser->stack[++parser->top].state = 2; + case TOK_SYMBOL_UC: + parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(grammar); + parser->stack[++parser->top].state = 16; break; - case TOK_TYPE: - parser->top -= 2; - parse_reduce_7(parser->stack[parser->top + 1].value.token.str, grammar); - parser->stack[++parser->top].state = 2; + case ';': + parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(grammar); + parser->stack[++parser->top].state = 16; break; default: @@ -442,54 +383,35 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va } break; - case 11: + case 12: switch (token) { - case 0: - parser->top -= 2; - parse_reduce_6(parser->stack[parser->top + 1].value.token.str, grammar); - parser->stack[++parser->top].state = 2; - break; - - case TOK_EXTRA_ARG: - parser->top -= 2; - parse_reduce_6(parser->stack[parser->top + 1].value.token.str, grammar); - parser->stack[++parser->top].state = 2; - break; - - case TOK_HEADER: - parser->top -= 2; - parse_reduce_6(parser->stack[parser->top + 1].value.token.str, grammar); - parser->stack[++parser->top].state = 2; - break; - - case TOK_SOURCE: - parser->top -= 2; - parse_reduce_6(parser->stack[parser->top + 1].value.token.str, grammar); - parser->stack[++parser->top].state = 2; - break; + case 't': + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 17; + return 1; - case TOK_SYMBOL_LC: - parser->top -= 2; - parse_reduce_6(parser->stack[parser->top + 1].value.token.str, grammar); - parser->stack[++parser->top].state = 2; - break; + default: + return -1; + } + break; - case TOK_TYPE: - parser->top -= 2; - parse_reduce_6(parser->stack[parser->top + 1].value.token.str, grammar); - parser->stack[++parser->top].state = 2; - break; + case 13: + switch (token) { + case 'a': + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 18; + return 1; default: return -1; } break; - case 12: + case 14: switch (token) { - case '=': + case 'u': parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 21; + parser->stack[++parser->top].state = 19; return 1; default: @@ -497,11 +419,11 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va } break; - case 13: + case 15: switch (token) { - case TOK_BLOCK: + case 'p': parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 22; + parser->stack[++parser->top].state = 20; return 1; default: @@ -509,109 +431,48 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va } break; - case 14: + case 16: 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 8: - parser->stack[++parser->top].state = 13; - break; - case 24: - parser->stack[++parser->top].state = 28; - break; - } - break; + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 24; + return 1; 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 8: - parser->stack[++parser->top].state = 13; - break; - case 24: - parser->stack[++parser->top].state = 28; - break; - } - break; + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 25; + return 1; 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 8: - parser->stack[++parser->top].state = 13; - break; - case 24: - parser->stack[++parser->top].state = 28; - break; - } - break; + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 26; + return 1; 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 8: - parser->stack[++parser->top].state = 13; - break; - case 24: - parser->stack[++parser->top].state = 28; - break; - } - break; + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 27; + return 1; case TOK_SYMBOL_UC: - 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 8: - parser->stack[++parser->top].state = 13; - break; - case 24: - parser->stack[++parser->top].state = 28; - 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 8: - parser->stack[++parser->top].state = 13; - break; - case 24: - parser->stack[++parser->top].state = 28; - break; - } - break; + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 28; + return 1; 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 8: - parser->stack[++parser->top].state = 13; - break; - case 24: - parser->stack[++parser->top].state = 28; - break; - } - break; + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 29; + return 1; default: return -1; } break; - case 15: + case 17: switch (token) { - case TOK_BLOCK: + case 'r': parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 23; + parser->stack[++parser->top].state = 30; return 1; default: @@ -619,97 +480,60 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va } break; - case 16: + case 18: 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 8: - parser->stack[++parser->top].state = 13; - break; - case 24: - parser->stack[++parser->top].state = 28; - break; - } - break; + case 'd': + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 31; + return 1; - 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 8: - parser->stack[++parser->top].state = 13; - break; - case 24: - parser->stack[++parser->top].state = 28; - break; - } - break; + default: + return -1; + } + break; - case TOK_STRING: - 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 8: - parser->stack[++parser->top].state = 13; - break; - case 24: - parser->stack[++parser->top].state = 28; - break; - } - break; + case 19: + switch (token) { + case 'r': + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 32; + return 1; - 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 8: - parser->stack[++parser->top].state = 13; - break; - case 24: - parser->stack[++parser->top].state = 28; - break; - } - break; + default: + return -1; + } + 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 8: - parser->stack[++parser->top].state = 13; - break; - case 24: - parser->stack[++parser->top].state = 28; - break; - } + case 20: + switch (token) { + case 'e': + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 33; + return 1; + + default: + return -1; + } + break; + + 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 '(': - 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 8: - parser->stack[++parser->top].state = 13; - break; - case 24: - parser->stack[++parser->top].state = 28; - 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 ';': - 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 8: - parser->stack[++parser->top].state = 13; - break; - case 24: - parser->stack[++parser->top].state = 28; - break; - } + case '%': + 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: @@ -717,42 +541,47 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va } break; - case 17: + case 22: switch (token) { - case 0: - parser->top -= 3; - parse_reduce_8(parser->stack[parser->top + 1].value.token.str, parser->stack[parser->top + 2].value.symbol_varname, grammar); - parser->stack[++parser->top].state = 2; + 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_EXTRA_ARG: - parser->top -= 3; - parse_reduce_8(parser->stack[parser->top + 1].value.token.str, parser->stack[parser->top + 2].value.symbol_varname, grammar); - parser->stack[++parser->top].state = 2; + 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_HEADER: - parser->top -= 3; - parse_reduce_8(parser->stack[parser->top + 1].value.token.str, parser->stack[parser->top + 2].value.symbol_varname, grammar); - parser->stack[++parser->top].state = 2; + 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_SOURCE: - parser->top -= 3; - parse_reduce_8(parser->stack[parser->top + 1].value.token.str, parser->stack[parser->top + 2].value.symbol_varname, grammar); - parser->stack[++parser->top].state = 2; + 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_LC: - parser->top -= 3; - parse_reduce_8(parser->stack[parser->top + 1].value.token.str, parser->stack[parser->top + 2].value.symbol_varname, grammar); - parser->stack[++parser->top].state = 2; + 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 TOK_TYPE: - parser->top -= 3; - parse_reduce_8(parser->stack[parser->top + 1].value.token.str, parser->stack[parser->top + 2].value.symbol_varname, grammar); - parser->stack[++parser->top].state = 2; + case '(': + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 34; + return 1; + + case ';': + 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: @@ -760,118 +589,48 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va } break; - case 18: + case 23: switch (token) { - case 0: + case TOK_BLOCK: 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; - break; - case 33: - parser->stack[++parser->top].state = 34; - break; - } + 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_EXTRA_ARG: + case TOK_CHAR: 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; - break; - case 33: - parser->stack[++parser->top].state = 34; - break; - } + 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_HEADER: + case TOK_STRING: 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; - break; - case 33: - parser->stack[++parser->top].state = 34; - break; - } + 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_SOURCE: + 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; - break; - case 33: - parser->stack[++parser->top].state = 34; - break; - } + 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: + case TOK_SYMBOL_UC: 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; - break; - case 33: - parser->stack[++parser->top].state = 34; - break; - } + 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_TYPE: + 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; - break; - case 33: - parser->stack[++parser->top].state = 34; - break; - } + 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 ')': + 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; - break; - case 33: - parser->stack[++parser->top].state = 34; - break; - } + 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: @@ -879,116 +638,120 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va } break; - case 19: + case 24: 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; - break; - case 33: - parser->stack[++parser->top].state = 34; - break; - } + 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_EXTRA_ARG: + 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); + 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 '%': + 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; + case 16: + parser->stack[++parser->top].state = 23; break; case 33: - parser->stack[++parser->top].state = 34; + parser->stack[++parser->top].state = 38; break; } break; - case TOK_HEADER: + case TOK_CHAR: parser->top -= 1; - parser->stack[parser->top].value.symbol_varname = parse_reduce_20(parser->stack[parser->top + 0].value.token.str, grammar); + 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; + case 16: + parser->stack[++parser->top].state = 23; break; case 33: - parser->stack[++parser->top].state = 34; + parser->stack[++parser->top].state = 38; break; } break; - case TOK_SOURCE: + case TOK_STRING: parser->top -= 1; - parser->stack[parser->top].value.symbol_varname = parse_reduce_20(parser->stack[parser->top + 0].value.token.str, grammar); + 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; + case 16: + parser->stack[++parser->top].state = 23; break; case 33: - parser->stack[++parser->top].state = 34; + parser->stack[++parser->top].state = 38; 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); + 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; + case 16: + parser->stack[++parser->top].state = 23; break; case 33: - parser->stack[++parser->top].state = 34; + parser->stack[++parser->top].state = 38; break; } break; - case TOK_TYPE: + case TOK_SYMBOL_UC: parser->top -= 1; - parser->stack[parser->top].value.symbol_varname = parse_reduce_20(parser->stack[parser->top + 0].value.token.str, grammar); + 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; + case 16: + parser->stack[++parser->top].state = 23; break; case 33: - parser->stack[++parser->top].state = 34; + parser->stack[++parser->top].state = 38; break; } break; - case ')': + case '(': parser->top -= 1; - parser->stack[parser->top].value.symbol_varname = parse_reduce_20(parser->stack[parser->top + 0].value.token.str, grammar); + 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; + case 16: + parser->stack[++parser->top].state = 23; break; case 33: - parser->stack[++parser->top].state = 34; + 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; @@ -998,116 +761,187 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va } break; - case 20: + case 26: switch (token) { - case 0: + 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 ';': + 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_varname = parse_reduce_21(parser->stack[parser->top + 0].value.token.str, grammar); + 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 ';': + 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; + case 16: + parser->stack[++parser->top].state = 23; break; case 33: - parser->stack[++parser->top].state = 34; + parser->stack[++parser->top].state = 38; break; } break; - case TOK_EXTRA_ARG: + case TOK_CHAR: parser->top -= 1; - parser->stack[parser->top].value.symbol_varname = parse_reduce_21(parser->stack[parser->top + 0].value.token.str, grammar); + 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; + case 16: + parser->stack[++parser->top].state = 23; break; case 33: - parser->stack[++parser->top].state = 34; + parser->stack[++parser->top].state = 38; break; } break; - case TOK_HEADER: + case TOK_STRING: parser->top -= 1; - parser->stack[parser->top].value.symbol_varname = parse_reduce_21(parser->stack[parser->top + 0].value.token.str, grammar); + 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; + case 16: + parser->stack[++parser->top].state = 23; break; case 33: - parser->stack[++parser->top].state = 34; + parser->stack[++parser->top].state = 38; break; } break; - case TOK_SOURCE: + 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); + 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; + case 16: + parser->stack[++parser->top].state = 23; break; case 33: - parser->stack[++parser->top].state = 34; + parser->stack[++parser->top].state = 38; break; } break; - case TOK_SYMBOL_LC: + case TOK_SYMBOL_UC: parser->top -= 1; - parser->stack[parser->top].value.symbol_varname = parse_reduce_21(parser->stack[parser->top + 0].value.token.str, grammar); + 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; + case 16: + parser->stack[++parser->top].state = 23; break; case 33: - parser->stack[++parser->top].state = 34; + parser->stack[++parser->top].state = 38; break; } break; - case TOK_TYPE: + case '(': parser->top -= 1; - parser->stack[parser->top].value.symbol_varname = parse_reduce_21(parser->stack[parser->top + 0].value.token.str, grammar); + 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; + case 16: + parser->stack[++parser->top].state = 23; break; case 33: - parser->stack[++parser->top].state = 34; + parser->stack[++parser->top].state = 38; break; } break; - case ')': + case ';': parser->top -= 1; - parser->stack[parser->top].value.symbol_varname = parse_reduce_21(parser->stack[parser->top + 0].value.token.str, grammar); + 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 9: - parser->stack[++parser->top].state = 17; - break; - case 22: - parser->stack[++parser->top].state = 25; + case 16: + parser->stack[++parser->top].state = 23; break; case 33: - parser->stack[++parser->top].state = 34; + parser->stack[++parser->top].state = 38; break; } break; @@ -1117,58 +951,82 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va } break; - case 21: + case 29: switch (token) { - case TOK_BLOCK: - parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(grammar); - parser->stack[++parser->top].state = 24; + 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_CHAR: - parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(grammar); - parser->stack[++parser->top].state = 24; + 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 TOK_STRING: - parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(grammar); - parser->stack[++parser->top].state = 24; + case '%': + 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->stack[parser->top].value.symbol_rhs = parse_reduce_10(grammar); - parser->stack[++parser->top].state = 24; - break; + default: + return -1; + } + break; - case TOK_SYMBOL_UC: - parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(grammar); - parser->stack[++parser->top].state = 24; - break; + case 30: + switch (token) { + case 'a': + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 35; + return 1; - case ';': - parser->stack[parser->top].value.symbol_rhs = parse_reduce_10(grammar); - parser->stack[++parser->top].state = 24; - break; + default: + return -1; + } + break; + + case 31: + switch (token) { + case 'e': + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 36; + return 1; default: return -1; } break; - case 22: + case 32: switch (token) { - case TOK_SYMBOL: + case 'c': parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 18; + parser->stack[++parser->top].state = 37; + return 1; + + default: + return -1; + } + break; + + case 33: + switch (token) { + case TOK_CHAR: + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 25; return 1; case TOK_SYMBOL_LC: parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 19; + parser->stack[++parser->top].state = 39; return 1; case TOK_SYMBOL_UC: parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 20; + parser->stack[++parser->top].state = 28; return 1; default: @@ -1176,79 +1034,93 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va } break; - case 23: + case 34: switch (token) { - case 0: - parser->top -= 3; - parse_reduce_4(parser->stack[parser->top + 1].value.token.str, parser->stack[parser->top + 2].value.token.str, grammar); - parser->stack[++parser->top].state = 2; - break; - - case TOK_EXTRA_ARG: - parser->top -= 3; - parse_reduce_4(parser->stack[parser->top + 1].value.token.str, parser->stack[parser->top + 2].value.token.str, grammar); - parser->stack[++parser->top].state = 2; - break; - - case TOK_HEADER: - parser->top -= 3; - parse_reduce_4(parser->stack[parser->top + 1].value.token.str, parser->stack[parser->top + 2].value.token.str, grammar); - parser->stack[++parser->top].state = 2; - break; - - case TOK_SOURCE: - parser->top -= 3; - parse_reduce_4(parser->stack[parser->top + 1].value.token.str, parser->stack[parser->top + 2].value.token.str, grammar); - parser->stack[++parser->top].state = 2; - break; + case TOK_SYMBOL: + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 41; + return 1; case TOK_SYMBOL_LC: - parser->top -= 3; - parse_reduce_4(parser->stack[parser->top + 1].value.token.str, parser->stack[parser->top + 2].value.token.str, grammar); - parser->stack[++parser->top].state = 2; - break; + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 42; + return 1; - case TOK_TYPE: - parser->top -= 3; - parse_reduce_4(parser->stack[parser->top + 1].value.token.str, parser->stack[parser->top + 2].value.token.str, grammar); - parser->stack[++parser->top].state = 2; - break; + case TOK_SYMBOL_UC: + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 43; + return 1; default: return -1; } break; - case 24: + case 35: switch (token) { - case TOK_BLOCK: + case '_': parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 29; + parser->stack[++parser->top].state = 44; return 1; - case TOK_CHAR: + default: + return -1; + } + break; + + case 36: + switch (token) { + case 'r': parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 14; + parser->stack[++parser->top].state = 45; return 1; - case TOK_STRING: + default: + return -1; + } + break; + + case 37: + switch (token) { + case 'e': parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 30; + parser->stack[++parser->top].state = 46; return 1; - case TOK_SYMBOL_LC: + default: + return -1; + } + break; + + case 38: + switch (token) { + case TOK_BLOCK: parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 31; + parser->stack[++parser->top].state = 47; return 1; - case TOK_SYMBOL_UC: + default: + return -1; + } + break; + + case 39: + switch (token) { + case TOK_BLOCK: parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 16; + parser->stack[++parser->top].state = 48; return 1; - case ';': + default: + return -1; + } + break; + + case 40: + switch (token) { + case ')': parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 32; + parser->stack[++parser->top].state = 49; return 1; default: @@ -1256,42 +1128,70 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va } break; - case 25: + case 41: switch (token) { case 0: - parser->top -= 4; - parse_reduce_5(parser->stack[parser->top + 1].value.symbol_term, parser->stack[parser->top + 2].value.token.str, parser->stack[parser->top + 3].value.symbol_varname, grammar); - parser->stack[++parser->top].state = 2; - break; - - case TOK_EXTRA_ARG: - parser->top -= 4; - parse_reduce_5(parser->stack[parser->top + 1].value.symbol_term, parser->stack[parser->top + 2].value.token.str, parser->stack[parser->top + 3].value.symbol_varname, grammar); - parser->stack[++parser->top].state = 2; - break; - - case TOK_HEADER: - parser->top -= 4; - parse_reduce_5(parser->stack[parser->top + 1].value.symbol_term, parser->stack[parser->top + 2].value.token.str, parser->stack[parser->top + 3].value.symbol_varname, grammar); - parser->stack[++parser->top].state = 2; + 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_SOURCE: - parser->top -= 4; - parse_reduce_5(parser->stack[parser->top + 1].value.symbol_term, parser->stack[parser->top + 2].value.token.str, parser->stack[parser->top + 3].value.symbol_varname, grammar); - parser->stack[++parser->top].state = 2; + 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 TOK_SYMBOL_LC: - parser->top -= 4; - parse_reduce_5(parser->stack[parser->top + 1].value.symbol_term, parser->stack[parser->top + 2].value.token.str, parser->stack[parser->top + 3].value.symbol_varname, grammar); - parser->stack[++parser->top].state = 2; + 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 TOK_TYPE: - parser->top -= 4; - parse_reduce_5(parser->stack[parser->top + 1].value.symbol_term, parser->stack[parser->top + 2].value.token.str, parser->stack[parser->top + 3].value.symbol_varname, grammar); - parser->stack[++parser->top].state = 2; + 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: @@ -1299,42 +1199,70 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va } break; - case 26: + case 42: 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_EXTRA_ARG: - 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_HEADER: - 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; + 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_SOURCE: - 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; + 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 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; + 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 TOK_TYPE: - 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; + 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: @@ -1342,139 +1270,153 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va } break; - case 27: + case 43: 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 = 24; + case 0: + 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_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 = 24; + 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 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 = 24; + 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 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 = 24; + 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 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 = 24; - break; + default: + return -1; + } + break; - case '(': + case 44: + switch (token) { + case 'a': parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 33; + parser->stack[++parser->top].state = 50; return 1; - case ';': - 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 = 24; - break; + default: + return -1; + } + break; + + case 45: + switch (token) { + case TOK_BLOCK: + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 51; + return 1; default: return -1; } break; - case 28: + case 46: 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 = 27; - break; + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 52; + return 1; - 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 = 27; - break; + default: + return -1; + } + 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 = 27; - break; + case 47: + switch (token) { + case TOK_SYMBOL: + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 41; + return 1; 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 = 27; - break; + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 42; + return 1; 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 = 27; - 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 = 27; - 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 = 27; - break; + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 43; + return 1; default: return -1; } break; - case 29: + case 48: 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 = 26; - break; - - case TOK_EXTRA_ARG: - 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 = 26; - break; - - case TOK_HEADER: - 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 = 26; - break; - - case TOK_SOURCE: - 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 = 26; + 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 -= 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 = 26; + 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_TYPE: - 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 = 26; + case '%': + 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: @@ -1482,42 +1424,42 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va } break; - case 30: + case 49: 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 = 24; + 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 -= 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 = 24; + 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 -= 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 = 24; + 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 -= 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 = 24; + 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 -= 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 = 24; + 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 ';': - 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 = 24; + 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: @@ -1525,48 +1467,36 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va } break; - case 31: + case 50: 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 = 27; - break; + case 'r': + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 54; + return 1; - 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 = 27; - break; + default: + return -1; + } + 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 = 27; + 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 -= 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 = 27; - 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 = 27; - 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 = 27; + parser->top -= 8; + parse_reduce_7(parser->stack[parser->top + 7].value.token.str, grammar); + parser->stack[++parser->top].state = 2; 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 = 27; + case '%': + parser->top -= 8; + parse_reduce_7(parser->stack[parser->top + 7].value.token.str, grammar); + parser->stack[++parser->top].state = 2; break; default: @@ -1574,42 +1504,49 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va } break; - case 32: + case 52: switch (token) { case 0: - parser->top -= 1; - parser->stack[parser->top].value.symbol_action = parse_reduce_14(grammar); - parser->stack[++parser->top].state = 26; + parser->top -= 8; + parse_reduce_6(parser->stack[parser->top + 7].value.token.str, grammar); + parser->stack[++parser->top].state = 2; break; - case TOK_EXTRA_ARG: - parser->top -= 1; - parser->stack[parser->top].value.symbol_action = parse_reduce_14(grammar); - parser->stack[++parser->top].state = 26; + 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 TOK_HEADER: - parser->top -= 1; - parser->stack[parser->top].value.symbol_action = parse_reduce_14(grammar); - parser->stack[++parser->top].state = 26; + case '%': + parser->top -= 8; + parse_reduce_6(parser->stack[parser->top + 7].value.token.str, grammar); + parser->stack[++parser->top].state = 2; break; - case TOK_SOURCE: - parser->top -= 1; - parser->stack[parser->top].value.symbol_action = parse_reduce_14(grammar); - parser->stack[++parser->top].state = 26; + 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 -= 1; - parser->stack[parser->top].value.symbol_action = parse_reduce_14(grammar); - parser->stack[++parser->top].state = 26; + 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_TYPE: - parser->top -= 1; - parser->stack[parser->top].value.symbol_action = parse_reduce_14(grammar); - parser->stack[++parser->top].state = 26; + case '%': + 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: @@ -1617,21 +1554,23 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va } break; - case 33: + case 54: switch (token) { - case TOK_SYMBOL: + case 'g': parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 18; + parser->stack[++parser->top].state = 55; return 1; - case TOK_SYMBOL_LC: - parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 19; - return 1; + default: + return -1; + } + break; - case TOK_SYMBOL_UC: + case 55: + switch (token) { + case TOK_BLOCK: parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 20; + parser->stack[++parser->top].state = 56; return 1; default: @@ -1639,11 +1578,21 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va } break; - case 34: + case 56: switch (token) { - case ')': + case TOK_SYMBOL: parser->stack[parser->top].value.token = *value; - parser->stack[++parser->top].state = 35; + parser->stack[++parser->top].state = 41; + return 1; + + case TOK_SYMBOL_LC: + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 42; + return 1; + + case TOK_SYMBOL_UC: + parser->stack[parser->top].value.token = *value; + parser->stack[++parser->top].state = 43; return 1; default: @@ -1651,42 +1600,24 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va } break; - case 35: + case 57: 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 = 24; - 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 = 24; - 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 = 24; + 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 -= 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 = 24; - 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 = 24; + 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 ';': - 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 = 24; + case '%': + 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: diff --git a/src/parse.hpp b/src/parse.hpp index 86aa095..7b3d73f 100644 --- a/src/parse.hpp +++ b/src/parse.hpp @@ -6,14 +6,10 @@ enum parse_token_t { TOK_BLOCK = 256, TOK_CHAR = 257, - TOK_EXTRA_ARG = 258, - TOK_HEADER = 259, - TOK_SOURCE = 260, - TOK_STRING = 261, - TOK_SYMBOL = 262, - TOK_SYMBOL_LC = 263, - TOK_SYMBOL_UC = 264, - TOK_TYPE = 265, + TOK_STRING = 258, + TOK_SYMBOL = 259, + TOK_SYMBOL_LC = 260, + TOK_SYMBOL_UC = 261, }; typedef struct parse_token_value { diff --git a/src/parse.y b/src/parse.y index 52f53a6..259e0de 100644 --- a/src/parse.y +++ b/src/parse.y @@ -34,14 +34,14 @@ directive |= rule(rule) { delete rule; } -directive |= TYPE SYMBOL_LC(nonterm) BLOCK(type) { +directive |= "%type" SYMBOL_LC(nonterm) BLOCK(type) { grammar->nonterm_types.insert(std::make_pair(*nonterm, *type)); delete nonterm; delete type; } -directive |= TYPE term(term) BLOCK(type) varname(name) { +directive |= "%type" term(term) BLOCK(type) varname(name) { grammar->term_types.insert(std::make_pair(*term, std::make_pair(*type, *name))); delete term; @@ -49,17 +49,17 @@ directive |= TYPE term(term) BLOCK(type) varname(name) { delete name; } -directive |= SOURCE BLOCK(block) { +directive |= "%source" BLOCK(block) { grammar->source_block = *block; delete block; } -directive |= HEADER BLOCK(block) { +directive |= "%header" BLOCK(block) { grammar->header_block = *block; delete block; } -directive |= EXTRA_ARG BLOCK(type) varname(name) { +directive |= "%extra_arg" BLOCK(type) varname(name) { grammar->extra_args.push_back(std::make_pair(*type, *name)); delete type; -- cgit v1.2.3