Allow specifying sequences of character terminals as strings

This commit is contained in:
Matthias Schiffer 2015-04-10 17:22:55 +02:00
parent 5a54699f18
commit 48b791d443
5 changed files with 285 additions and 168 deletions

View file

@ -135,7 +135,6 @@ int lex_t::consume_comment(parse_token_value_t *value) {
return -1; return -1;
} }
/*
int lex_t::unterminated_string(parse_token_value_t *value) { int lex_t::unterminated_string(parse_token_value_t *value) {
if (ferror(file)) if (ferror(file))
return io_error(value); return io_error(value);
@ -145,18 +144,14 @@ int lex_t::unterminated_string(parse_token_value_t *value) {
} }
int lex_t::lex_string(parse_token_value_t *value) { int lex_t::lex_string(parse_token_value_t *value) {
char *buf = NULL;
size_t len = 1024;
size_t pos = 0;
if (needspace) if (needspace)
return syntax_error(value); return syntax_error(value);
buf = static_cast<char*>(std::malloc(len)); std::string *buf = new std::string;
while (true) { while (true) {
if (!next(true)) { if (!next(true)) {
std::free(buf); delete buf;
return unterminated_string(value); return unterminated_string(value);
} }
@ -177,16 +172,10 @@ int lex_t::lex_string(parse_token_value_t *value) {
continue; continue;
} }
if (pos >= len) { *buf += cur;
len *= 2;
buf = static_cast<char*>(std::realloc(buf, len));
}
buf[pos++] = cur;
} }
value->str = strndup(buf, pos); value->str = buf;
std::free(buf);
next(true); next(true);
consume(true); consume(true);
@ -194,6 +183,7 @@ int lex_t::lex_string(parse_token_value_t *value) {
return TOK_STRING; return TOK_STRING;
} }
/*
int lex_t::lex_number(parse_token_value_t *value) { int lex_t::lex_number(parse_token_value_t *value) {
if (needspace) if (needspace)
return syntax_error(value); return syntax_error(value);
@ -431,8 +421,8 @@ int lex_t::lex(parse_token_value_t *value) {
case '{': case '{':
return lex_block(value); return lex_block(value);
//case '"': case '"':
//return lex_string(value); return lex_string(value);
//case '0' ... '9': //case '0' ... '9':
//return lex_number(value); //return lex_number(value);

View file

@ -66,9 +66,9 @@ private:
int syntax_error(parse_token_value_t *value); int syntax_error(parse_token_value_t *value);
int consume_comment(parse_token_value_t *value); int consume_comment(parse_token_value_t *value);
int unterminated_block(parse_token_value_t *value); int unterminated_block(parse_token_value_t *value);
//int unterminated_string(parse_token_value_t *value); int unterminated_string(parse_token_value_t *value);
//int lex_string(parse_token_value_t *value); int lex_string(parse_token_value_t *value);
//int lex_number(parse_token_value_t *value); //int lex_number(parse_token_value_t *value);
int lex_keyword(parse_token_value_t *value); int lex_keyword(parse_token_value_t *value);
int lex_block(parse_token_value_t *value); int lex_block(parse_token_value_t *value);

View file

@ -107,38 +107,45 @@ static inline std::pair<std::vector<solar::symbol_t>, std::vector<std::string>>
return rhs; return rhs;
} }
static inline std::string * parse_reduce_12(__attribute__((unused)) solar::grammar_t * grammar) { static inline std::pair<std::vector<solar::symbol_t>, std::vector<std::string>> * parse_reduce_12(std::pair<std::vector<solar::symbol_t>, std::vector<std::string>> * rhs, std::string * str, __attribute__((unused)) solar::grammar_t * grammar) {
for (char c : *str) {
rhs->first.push_back(solar::symbol_t::make_char(c));
rhs->second.emplace_back();
}
delete str;
return rhs;
}
static inline std::string * parse_reduce_13(__attribute__((unused)) solar::grammar_t * grammar) {
return new std::string; return new std::string;
} }
static inline std::string * parse_reduce_13(std::string * v, __attribute__((unused)) solar::grammar_t * grammar) { static inline std::string * parse_reduce_14(std::string * v, __attribute__((unused)) solar::grammar_t * grammar) {
return v; return v;
} }
static inline solar::symbol_t * parse_reduce_14(solar::symbol_t * v, __attribute__((unused)) solar::grammar_t * grammar) { static inline solar::symbol_t * parse_reduce_15(solar::symbol_t * v, __attribute__((unused)) solar::grammar_t * grammar) {
return v; return v;
} }
static inline solar::symbol_t * parse_reduce_15(std::string * v, __attribute__((unused)) solar::grammar_t * grammar) { 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_nonterm(*v)); solar::symbol_t *ret = new solar::symbol_t(solar::symbol_t::make_nonterm(*v));
delete v; delete v;
return ret; return ret;
} }
static inline solar::symbol_t * parse_reduce_16(std::string * v, __attribute__((unused)) solar::grammar_t * grammar) { static inline solar::symbol_t * parse_reduce_17(std::string * v, __attribute__((unused)) solar::grammar_t * grammar) {
solar::symbol_t *ret = new solar::symbol_t(solar::symbol_t::make_term(*v)); solar::symbol_t *ret = new solar::symbol_t(solar::symbol_t::make_term(*v));
delete v; delete v;
return ret; return ret;
} }
static inline solar::symbol_t * parse_reduce_17(char v, __attribute__((unused)) solar::grammar_t * grammar) { static inline solar::symbol_t * parse_reduce_18(char v, __attribute__((unused)) solar::grammar_t * grammar) {
return new solar::symbol_t(solar::symbol_t::make_char(v)); 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) { static inline std::string * parse_reduce_19(std::string * v, __attribute__((unused)) solar::grammar_t * grammar) {
return v; return v;
} }
@ -147,6 +154,10 @@ static inline std::string * parse_reduce_20(std::string * v, __attribute__((unus
return v; return v;
} }
static inline std::string * parse_reduce_21(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) { int parse_push(parse_context_t *parser, int token, const parse_token_value_t *value, __attribute__((unused)) solar::grammar_t * grammar) {
while (1) { while (1) {
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
@ -465,7 +476,7 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
switch (token) { switch (token) {
case TOK_BLOCK: case TOK_BLOCK:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_term = parse_reduce_17(parser->stack[parser->top + 0].value.token.c, grammar); parser->stack[parser->top].value.symbol_term = parse_reduce_18(parser->stack[parser->top + 0].value.token.c, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 7: case 7:
parser->stack[++parser->top].state = 12; parser->stack[++parser->top].state = 12;
@ -478,7 +489,20 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case TOK_CHAR: case TOK_CHAR:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_term = parse_reduce_17(parser->stack[parser->top + 0].value.token.c, grammar); parser->stack[parser->top].value.symbol_term = parse_reduce_18(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_STRING:
parser->top -= 1;
parser->stack[parser->top].value.symbol_term = parse_reduce_18(parser->stack[parser->top + 0].value.token.c, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 7: case 7:
parser->stack[++parser->top].state = 12; parser->stack[++parser->top].state = 12;
@ -491,7 +515,7 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case TOK_SYMBOL_LC: case TOK_SYMBOL_LC:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_term = parse_reduce_17(parser->stack[parser->top + 0].value.token.c, grammar); parser->stack[parser->top].value.symbol_term = parse_reduce_18(parser->stack[parser->top + 0].value.token.c, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 7: case 7:
parser->stack[++parser->top].state = 12; parser->stack[++parser->top].state = 12;
@ -504,7 +528,7 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case TOK_SYMBOL_UC: case TOK_SYMBOL_UC:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_term = parse_reduce_17(parser->stack[parser->top + 0].value.token.c, grammar); parser->stack[parser->top].value.symbol_term = parse_reduce_18(parser->stack[parser->top + 0].value.token.c, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 7: case 7:
parser->stack[++parser->top].state = 12; parser->stack[++parser->top].state = 12;
@ -517,7 +541,7 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case '(': case '(':
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_term = parse_reduce_17(parser->stack[parser->top + 0].value.token.c, grammar); parser->stack[parser->top].value.symbol_term = parse_reduce_18(parser->stack[parser->top + 0].value.token.c, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 7: case 7:
parser->stack[++parser->top].state = 12; parser->stack[++parser->top].state = 12;
@ -530,7 +554,7 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case ';': case ';':
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_term = parse_reduce_17(parser->stack[parser->top + 0].value.token.c, grammar); parser->stack[parser->top].value.symbol_term = parse_reduce_18(parser->stack[parser->top + 0].value.token.c, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 7: case 7:
parser->stack[++parser->top].state = 12; parser->stack[++parser->top].state = 12;
@ -562,7 +586,7 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
switch (token) { switch (token) {
case TOK_BLOCK: case TOK_BLOCK:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_term = parse_reduce_16(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[parser->top].value.symbol_term = parse_reduce_17(parser->stack[parser->top + 0].value.token.str, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 7: case 7:
parser->stack[++parser->top].state = 12; parser->stack[++parser->top].state = 12;
@ -575,7 +599,20 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case TOK_CHAR: case TOK_CHAR:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_term = parse_reduce_16(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[parser->top].value.symbol_term = parse_reduce_17(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_STRING:
parser->top -= 1;
parser->stack[parser->top].value.symbol_term = parse_reduce_17(parser->stack[parser->top + 0].value.token.str, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 7: case 7:
parser->stack[++parser->top].state = 12; parser->stack[++parser->top].state = 12;
@ -588,7 +625,7 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case TOK_SYMBOL_LC: case TOK_SYMBOL_LC:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_term = parse_reduce_16(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[parser->top].value.symbol_term = parse_reduce_17(parser->stack[parser->top + 0].value.token.str, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 7: case 7:
parser->stack[++parser->top].state = 12; parser->stack[++parser->top].state = 12;
@ -601,7 +638,7 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case TOK_SYMBOL_UC: case TOK_SYMBOL_UC:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_term = parse_reduce_16(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[parser->top].value.symbol_term = parse_reduce_17(parser->stack[parser->top + 0].value.token.str, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 7: case 7:
parser->stack[++parser->top].state = 12; parser->stack[++parser->top].state = 12;
@ -614,7 +651,7 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case '(': case '(':
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_term = parse_reduce_16(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[parser->top].value.symbol_term = parse_reduce_17(parser->stack[parser->top + 0].value.token.str, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 7: case 7:
parser->stack[++parser->top].state = 12; parser->stack[++parser->top].state = 12;
@ -627,7 +664,7 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case ';': case ';':
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_term = parse_reduce_16(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[parser->top].value.symbol_term = parse_reduce_17(parser->stack[parser->top + 0].value.token.str, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 7: case 7:
parser->stack[++parser->top].state = 12; parser->stack[++parser->top].state = 12;
@ -690,7 +727,7 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
switch (token) { switch (token) {
case 0: case 0:
parser->top -= 1; 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_varname = parse_reduce_21(parser->stack[parser->top + 0].value.token.str, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -698,15 +735,15 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
case TOK_EXTRA_ARG: case TOK_EXTRA_ARG:
parser->top -= 1; 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_varname = parse_reduce_21(parser->stack[parser->top + 0].value.token.str, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -714,15 +751,15 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
case TOK_HEADER: case TOK_HEADER:
parser->top -= 1; 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_varname = parse_reduce_21(parser->stack[parser->top + 0].value.token.str, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -730,15 +767,15 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
case TOK_SOURCE: case TOK_SOURCE:
parser->top -= 1; 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_varname = parse_reduce_21(parser->stack[parser->top + 0].value.token.str, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -746,15 +783,15 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
case TOK_SYMBOL_LC: case TOK_SYMBOL_LC:
parser->top -= 1; 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_varname = parse_reduce_21(parser->stack[parser->top + 0].value.token.str, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -762,15 +799,15 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
case TOK_TYPE: case TOK_TYPE:
parser->top -= 1; 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_varname = parse_reduce_21(parser->stack[parser->top + 0].value.token.str, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -778,15 +815,15 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
case ')': case ')':
parser->top -= 1; 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_varname = parse_reduce_21(parser->stack[parser->top + 0].value.token.str, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -794,8 +831,8 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
@ -809,7 +846,7 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
switch (token) { switch (token) {
case 0: case 0:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_varname = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar); 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) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -817,15 +854,15 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
case TOK_EXTRA_ARG: case TOK_EXTRA_ARG:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_varname = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar); 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) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -833,15 +870,15 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
case TOK_HEADER: case TOK_HEADER:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_varname = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar); 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) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -849,15 +886,15 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
case TOK_SOURCE: case TOK_SOURCE:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_varname = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar); 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) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -865,15 +902,15 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
case TOK_SYMBOL_LC: case TOK_SYMBOL_LC:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_varname = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar); 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) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -881,15 +918,15 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
case TOK_TYPE: case TOK_TYPE:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_varname = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar); 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) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -897,15 +934,15 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
case ')': case ')':
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_varname = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar); 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) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -913,8 +950,8 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
@ -928,7 +965,7 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
switch (token) { switch (token) {
case 0: case 0:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_varname = parse_reduce_19(parser->stack[parser->top + 0].value.token.str, grammar); 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) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -936,15 +973,15 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
case TOK_EXTRA_ARG: case TOK_EXTRA_ARG:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_varname = parse_reduce_19(parser->stack[parser->top + 0].value.token.str, grammar); 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) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -952,15 +989,15 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
case TOK_HEADER: case TOK_HEADER:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_varname = parse_reduce_19(parser->stack[parser->top + 0].value.token.str, grammar); 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) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -968,15 +1005,15 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
case TOK_SOURCE: case TOK_SOURCE:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_varname = parse_reduce_19(parser->stack[parser->top + 0].value.token.str, grammar); 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) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -984,15 +1021,15 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
case TOK_SYMBOL_LC: case TOK_SYMBOL_LC:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_varname = parse_reduce_19(parser->stack[parser->top + 0].value.token.str, grammar); 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) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -1000,15 +1037,15 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
case TOK_TYPE: case TOK_TYPE:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_varname = parse_reduce_19(parser->stack[parser->top + 0].value.token.str, grammar); 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) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -1016,15 +1053,15 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
case ')': case ')':
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_varname = parse_reduce_19(parser->stack[parser->top + 0].value.token.str, grammar); 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) { switch (parser->stack[parser->top].state) {
case 8: case 8:
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 16;
@ -1032,8 +1069,8 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 21: case 21:
parser->stack[++parser->top].state = 24; parser->stack[++parser->top].state = 24;
break; break;
case 31: case 32:
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
break; break;
} }
break; break;
@ -1055,6 +1092,11 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
parser->stack[++parser->top].state = 23; parser->stack[++parser->top].state = 23;
break; break;
case TOK_STRING:
parser->stack[parser->top].value.symbol_rhs = parse_reduce_9(grammar);
parser->stack[++parser->top].state = 23;
break;
case TOK_SYMBOL_LC: case TOK_SYMBOL_LC:
parser->stack[parser->top].value.symbol_rhs = parse_reduce_9(grammar); parser->stack[parser->top].value.symbol_rhs = parse_reduce_9(grammar);
parser->stack[++parser->top].state = 23; parser->stack[++parser->top].state = 23;
@ -1152,11 +1194,16 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
parser->stack[++parser->top].state = 13; parser->stack[++parser->top].state = 13;
return 1; return 1;
case TOK_SYMBOL_LC: case TOK_STRING:
parser->stack[parser->top].value.token = *value; parser->stack[parser->top].value.token = *value;
parser->stack[++parser->top].state = 29; parser->stack[++parser->top].state = 29;
return 1; return 1;
case TOK_SYMBOL_LC:
parser->stack[parser->top].value.token = *value;
parser->stack[++parser->top].state = 30;
return 1;
case TOK_SYMBOL_UC: case TOK_SYMBOL_UC:
parser->stack[parser->top].value.token = *value; parser->stack[parser->top].value.token = *value;
parser->stack[++parser->top].state = 15; parser->stack[++parser->top].state = 15;
@ -1164,7 +1211,7 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case ';': case ';':
parser->stack[parser->top].value.token = *value; parser->stack[parser->top].value.token = *value;
parser->stack[++parser->top].state = 30; parser->stack[++parser->top].state = 31;
return 1; return 1;
default: default:
@ -1272,6 +1319,12 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
parser->stack[++parser->top].state = 23; parser->stack[++parser->top].state = 23;
break; break;
case TOK_STRING:
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: case TOK_SYMBOL_LC:
parser->top -= 2; 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].value.symbol_rhs = parse_reduce_10(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.symbol_symbol, grammar);
@ -1286,7 +1339,7 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case '(': case '(':
parser->stack[parser->top].value.token = *value; parser->stack[parser->top].value.token = *value;
parser->stack[++parser->top].state = 31; parser->stack[++parser->top].state = 32;
return 1; return 1;
case ';': case ';':
@ -1304,37 +1357,43 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
switch (token) { switch (token) {
case TOK_BLOCK: case TOK_BLOCK:
parser->top -= 1; 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].value.symbol_symbol = parse_reduce_15(parser->stack[parser->top + 0].value.symbol_term, grammar);
parser->stack[++parser->top].state = 26; parser->stack[++parser->top].state = 26;
break; break;
case TOK_CHAR: case TOK_CHAR:
parser->top -= 1; 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].value.symbol_symbol = parse_reduce_15(parser->stack[parser->top + 0].value.symbol_term, grammar);
parser->stack[++parser->top].state = 26;
break;
case TOK_STRING:
parser->top -= 1;
parser->stack[parser->top].value.symbol_symbol = parse_reduce_15(parser->stack[parser->top + 0].value.symbol_term, grammar);
parser->stack[++parser->top].state = 26; parser->stack[++parser->top].state = 26;
break; break;
case TOK_SYMBOL_LC: case TOK_SYMBOL_LC:
parser->top -= 1; 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].value.symbol_symbol = parse_reduce_15(parser->stack[parser->top + 0].value.symbol_term, grammar);
parser->stack[++parser->top].state = 26; parser->stack[++parser->top].state = 26;
break; break;
case TOK_SYMBOL_UC: case TOK_SYMBOL_UC:
parser->top -= 1; 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].value.symbol_symbol = parse_reduce_15(parser->stack[parser->top + 0].value.symbol_term, grammar);
parser->stack[++parser->top].state = 26; parser->stack[++parser->top].state = 26;
break; break;
case '(': case '(':
parser->top -= 1; 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].value.symbol_symbol = parse_reduce_15(parser->stack[parser->top + 0].value.symbol_term, grammar);
parser->stack[++parser->top].state = 26; parser->stack[++parser->top].state = 26;
break; break;
case ';': case ';':
parser->top -= 1; 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].value.symbol_symbol = parse_reduce_15(parser->stack[parser->top + 0].value.symbol_term, grammar);
parser->stack[++parser->top].state = 26; parser->stack[++parser->top].state = 26;
break; break;
@ -1347,37 +1406,37 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
switch (token) { switch (token) {
case 0: case 0:
parser->top -= 1; 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].value.symbol_action = parse_reduce_14(parser->stack[parser->top + 0].value.token.str, grammar);
parser->stack[++parser->top].state = 25; parser->stack[++parser->top].state = 25;
break; break;
case TOK_EXTRA_ARG: case TOK_EXTRA_ARG:
parser->top -= 1; 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].value.symbol_action = parse_reduce_14(parser->stack[parser->top + 0].value.token.str, grammar);
parser->stack[++parser->top].state = 25; parser->stack[++parser->top].state = 25;
break; break;
case TOK_HEADER: case TOK_HEADER:
parser->top -= 1; 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].value.symbol_action = parse_reduce_14(parser->stack[parser->top + 0].value.token.str, grammar);
parser->stack[++parser->top].state = 25; parser->stack[++parser->top].state = 25;
break; break;
case TOK_SOURCE: case TOK_SOURCE:
parser->top -= 1; 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].value.symbol_action = parse_reduce_14(parser->stack[parser->top + 0].value.token.str, grammar);
parser->stack[++parser->top].state = 25; parser->stack[++parser->top].state = 25;
break; break;
case TOK_SYMBOL_LC: case TOK_SYMBOL_LC:
parser->top -= 1; 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].value.symbol_action = parse_reduce_14(parser->stack[parser->top + 0].value.token.str, grammar);
parser->stack[++parser->top].state = 25; parser->stack[++parser->top].state = 25;
break; break;
case TOK_TYPE: case TOK_TYPE:
parser->top -= 1; 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].value.symbol_action = parse_reduce_14(parser->stack[parser->top + 0].value.token.str, grammar);
parser->stack[++parser->top].state = 25; parser->stack[++parser->top].state = 25;
break; break;
@ -1389,39 +1448,39 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 29: case 29:
switch (token) { switch (token) {
case TOK_BLOCK: case TOK_BLOCK:
parser->top -= 1; parser->top -= 2;
parser->stack[parser->top].value.symbol_symbol = parse_reduce_15(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[parser->top].value.symbol_rhs = parse_reduce_12(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.token.str, grammar);
parser->stack[++parser->top].state = 26; parser->stack[++parser->top].state = 23;
break; break;
case TOK_CHAR: case TOK_CHAR:
parser->top -= 1; parser->top -= 2;
parser->stack[parser->top].value.symbol_symbol = parse_reduce_15(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[parser->top].value.symbol_rhs = parse_reduce_12(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.token.str, grammar);
parser->stack[++parser->top].state = 26; parser->stack[++parser->top].state = 23;
break;
case TOK_STRING:
parser->top -= 2;
parser->stack[parser->top].value.symbol_rhs = parse_reduce_12(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.token.str, grammar);
parser->stack[++parser->top].state = 23;
break; break;
case TOK_SYMBOL_LC: case TOK_SYMBOL_LC:
parser->top -= 1; parser->top -= 2;
parser->stack[parser->top].value.symbol_symbol = parse_reduce_15(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[parser->top].value.symbol_rhs = parse_reduce_12(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.token.str, grammar);
parser->stack[++parser->top].state = 26; parser->stack[++parser->top].state = 23;
break; break;
case TOK_SYMBOL_UC: case TOK_SYMBOL_UC:
parser->top -= 1; parser->top -= 2;
parser->stack[parser->top].value.symbol_symbol = parse_reduce_15(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[parser->top].value.symbol_rhs = parse_reduce_12(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.token.str, grammar);
parser->stack[++parser->top].state = 26; parser->stack[++parser->top].state = 23;
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; break;
case ';': case ';':
parser->top -= 1; parser->top -= 2;
parser->stack[parser->top].value.symbol_symbol = parse_reduce_15(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[parser->top].value.symbol_rhs = parse_reduce_12(parser->stack[parser->top + 0].value.symbol_rhs, parser->stack[parser->top + 1].value.token.str, grammar);
parser->stack[++parser->top].state = 26; parser->stack[++parser->top].state = 23;
break; break;
default: default:
@ -1431,40 +1490,46 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
case 30: case 30:
switch (token) { switch (token) {
case 0: case TOK_BLOCK:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_action = parse_reduce_12(grammar); parser->stack[parser->top].value.symbol_symbol = parse_reduce_16(parser->stack[parser->top + 0].value.token.str, grammar);
parser->stack[++parser->top].state = 25; parser->stack[++parser->top].state = 26;
break; break;
case TOK_EXTRA_ARG: case TOK_CHAR:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_action = parse_reduce_12(grammar); parser->stack[parser->top].value.symbol_symbol = parse_reduce_16(parser->stack[parser->top + 0].value.token.str, grammar);
parser->stack[++parser->top].state = 25; parser->stack[++parser->top].state = 26;
break; break;
case TOK_HEADER: case TOK_STRING:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_action = parse_reduce_12(grammar); parser->stack[parser->top].value.symbol_symbol = parse_reduce_16(parser->stack[parser->top + 0].value.token.str, grammar);
parser->stack[++parser->top].state = 25; parser->stack[++parser->top].state = 26;
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; break;
case TOK_SYMBOL_LC: case TOK_SYMBOL_LC:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_action = parse_reduce_12(grammar); parser->stack[parser->top].value.symbol_symbol = parse_reduce_16(parser->stack[parser->top + 0].value.token.str, grammar);
parser->stack[++parser->top].state = 25; parser->stack[++parser->top].state = 26;
break; break;
case TOK_TYPE: case TOK_SYMBOL_UC:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_action = parse_reduce_12(grammar); parser->stack[parser->top].value.symbol_symbol = parse_reduce_16(parser->stack[parser->top + 0].value.token.str, grammar);
parser->stack[++parser->top].state = 25; parser->stack[++parser->top].state = 26;
break;
case '(':
parser->top -= 1;
parser->stack[parser->top].value.symbol_symbol = parse_reduce_16(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_16(parser->stack[parser->top + 0].value.token.str, grammar);
parser->stack[++parser->top].state = 26;
break; break;
default: default:
@ -1473,6 +1538,49 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
break; break;
case 31: case 31:
switch (token) {
case 0:
parser->top -= 1;
parser->stack[parser->top].value.symbol_action = parse_reduce_13(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(grammar);
parser->stack[++parser->top].state = 25;
break;
case TOK_HEADER:
parser->top -= 1;
parser->stack[parser->top].value.symbol_action = parse_reduce_13(grammar);
parser->stack[++parser->top].state = 25;
break;
case TOK_SOURCE:
parser->top -= 1;
parser->stack[parser->top].value.symbol_action = parse_reduce_13(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(grammar);
parser->stack[++parser->top].state = 25;
break;
case TOK_TYPE:
parser->top -= 1;
parser->stack[parser->top].value.symbol_action = parse_reduce_13(grammar);
parser->stack[++parser->top].state = 25;
break;
default:
return -1;
}
break;
case 32:
switch (token) { switch (token) {
case TOK_SYMBOL: case TOK_SYMBOL:
parser->stack[parser->top].value.token = *value; parser->stack[parser->top].value.token = *value;
@ -1494,11 +1602,11 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
} }
break; break;
case 32: case 33:
switch (token) { switch (token) {
case ')': case ')':
parser->stack[parser->top].value.token = *value; parser->stack[parser->top].value.token = *value;
parser->stack[++parser->top].state = 33; parser->stack[++parser->top].state = 34;
return 1; return 1;
default: default:
@ -1506,7 +1614,7 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
} }
break; break;
case 33: case 34:
switch (token) { switch (token) {
case TOK_BLOCK: case TOK_BLOCK:
parser->top -= 5; parser->top -= 5;
@ -1520,6 +1628,12 @@ int parse_push(parse_context_t *parser, int token, const parse_token_value_t *va
parser->stack[++parser->top].state = 23; parser->stack[++parser->top].state = 23;
break; break;
case TOK_STRING:
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: case TOK_SYMBOL_LC:
parser->top -= 5; 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].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);

View file

@ -9,10 +9,11 @@ enum parse_token_t {
TOK_EXTRA_ARG = 258, TOK_EXTRA_ARG = 258,
TOK_HEADER = 259, TOK_HEADER = 259,
TOK_SOURCE = 260, TOK_SOURCE = 260,
TOK_SYMBOL = 261, TOK_STRING = 261,
TOK_SYMBOL_LC = 262, TOK_SYMBOL = 262,
TOK_SYMBOL_UC = 263, TOK_SYMBOL_LC = 263,
TOK_TYPE = 264, TOK_SYMBOL_UC = 264,
TOK_TYPE = 265,
}; };
typedef struct parse_token_value { typedef struct parse_token_value {

View file

@ -2,6 +2,7 @@
%type SYMBOL_UC {std::string *} str %type SYMBOL_UC {std::string *} str
%type SYMBOL_LC {std::string *} str %type SYMBOL_LC {std::string *} str
%type BLOCK {std::string *} str %type BLOCK {std::string *} str
%type STRING {std::string *} str
%type CHAR {char} c %type CHAR {char} c
%type rule {solar::rule_t *} %type rule {solar::rule_t *}
@ -65,7 +66,7 @@ grammar |= grammar EXTRA_ARG BLOCK(type) varname(name) {
} }
rule |= SYMBOL_LC(lhs) '|' '=' rhs(rhs) action(action) { rule |= SYMBOL_LC(lhs) "|=" rhs(rhs) action(action) {
auto *ret = new solar::rule_t {solar::item_t(*lhs, rhs->first), rhs->second, *action}; auto *ret = new solar::rule_t {solar::item_t(*lhs, rhs->first), rhs->second, *action};
delete lhs; delete lhs;
@ -98,6 +99,17 @@ rhs |= rhs(rhs) symbol(sym) '(' varname(var) ')' {
return rhs; return rhs;
} }
rhs |= rhs(rhs) STRING(str) {
for (char c : *str) {
rhs->first.push_back(solar::symbol_t::make_char(c));
rhs->second.emplace_back();
}
delete str;
return rhs;
}
action |= ';' { action |= ';' {
return new std::string; return new std::string;