Add support for square-bracketed actions

This commit is contained in:
Matthias Schiffer 2015-04-11 01:47:28 +02:00
parent 0f3c53fb63
commit 69d5b76e1a
5 changed files with 206 additions and 196 deletions

View file

@ -166,7 +166,7 @@ int lex_t::unterminated_block(parse_token_value_t *value) {
return -1; return -1;
} }
int lex_t::lex_block(parse_token_value_t *value) { int lex_t::lex_block(parse_token_value_t *value, int token, char open, char close) {
size_t parens = 0; size_t parens = 0;
bool line_comment = false; bool line_comment = false;
bool block_comment = false; bool block_comment = false;
@ -202,10 +202,10 @@ int lex_t::lex_block(parse_token_value_t *value) {
pp = false; pp = false;
} }
else { else {
if (cur == '{') { if (cur == open) {
parens++; parens++;
} }
else if (cur == '}') { else if (cur == close) {
if (!parens) if (!parens)
break; break;
@ -234,7 +234,7 @@ int lex_t::lex_block(parse_token_value_t *value) {
next(true); next(true);
consume(true); consume(true);
return TOK_BLOCK; return token;
} }
int lex_t::lex_symbol(parse_token_value_t *value) { int lex_t::lex_symbol(parse_token_value_t *value) {
@ -403,7 +403,10 @@ int lex_t::lex(parse_token_value_t *value) {
return TOK_CHAR; return TOK_CHAR;
case '{': case '{':
return lex_block(value); return lex_block(value, TOK_BLOCK, '{', '}');
case '[':
return lex_block(value, TOK_SQBLOCK, '[', ']');
case '"': case '"':
return lex_string(value); return lex_string(value);

View file

@ -70,7 +70,7 @@ private:
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_block(parse_token_value_t *value); int lex_block(parse_token_value_t *value, int token, char open, char close);
int lex_symbol(parse_token_value_t *value); int lex_symbol(parse_token_value_t *value);
char current() { char current() {

View file

@ -126,30 +126,31 @@ static inline std::string * parse_reduce_15(std::string * v, __attribute__((unus
return v; return v;
} }
static inline solar::symbol_t * parse_reduce_16(solar::symbol_t * v, __attribute__((unused)) solar::grammar_t * grammar) { static inline std::string * parse_reduce_16(std::string * v, __attribute__((unused)) solar::grammar_t * grammar) {
*v = "\n\treturn " + *v + ";\n";
return v; return v;
} }
static inline solar::symbol_t * parse_reduce_17(std::string * v, __attribute__((unused)) solar::grammar_t * grammar) { static inline solar::symbol_t * parse_reduce_17(solar::symbol_t * v, __attribute__((unused)) solar::grammar_t * grammar) {
return v;
}
static inline solar::symbol_t * parse_reduce_18(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_18(std::string * v, __attribute__((unused)) solar::grammar_t * grammar) { static inline solar::symbol_t * parse_reduce_19(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_19(char v, __attribute__((unused)) solar::grammar_t * grammar) { static inline solar::symbol_t * parse_reduce_20(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_20(std::string * v, __attribute__((unused)) solar::grammar_t * grammar) {
return v;
}
static inline std::string * parse_reduce_21(std::string * v, __attribute__((unused)) solar::grammar_t * grammar) { static inline std::string * parse_reduce_21(std::string * v, __attribute__((unused)) solar::grammar_t * grammar) {
return v; return v;
} }
@ -158,6 +159,10 @@ static inline std::string * parse_reduce_22(std::string * v, __attribute__((unus
return v; return v;
} }
static inline std::string * parse_reduce_23(std::string * v, __attribute__((unused)) solar::grammar_t * grammar) {
return v;
}
static int parse_do_push(parse_context_t *parser, int token, __attribute__((unused)) solar::grammar_t * grammar) { static int parse_do_push(parse_context_t *parser, int token, __attribute__((unused)) solar::grammar_t * grammar) {
while (1) { while (1) {
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
@ -354,22 +359,26 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
parser->stack[++parser->top].state = 25; parser->stack[++parser->top].state = 25;
return 1; return 1;
case TOK_STRING: case TOK_SQBLOCK:
parser->stack[++parser->top].state = 26; parser->stack[++parser->top].state = 26;
return 1; return 1;
case TOK_SYMBOL_LC: case TOK_STRING:
parser->stack[++parser->top].state = 27; parser->stack[++parser->top].state = 27;
return 1; return 1;
case TOK_SYMBOL_UC: case TOK_SYMBOL_LC:
parser->stack[++parser->top].state = 28; parser->stack[++parser->top].state = 28;
return 1; return 1;
case ';': case TOK_SYMBOL_UC:
parser->stack[++parser->top].state = 29; parser->stack[++parser->top].state = 29;
return 1; return 1;
case ';':
parser->stack[++parser->top].state = 30;
return 1;
default: default:
return -1; return -1;
} }
@ -378,7 +387,7 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
case 17: case 17:
switch (token) { switch (token) {
case 'r': case 'r':
parser->stack[++parser->top].state = 30; parser->stack[++parser->top].state = 31;
return 1; return 1;
default: default:
@ -389,7 +398,7 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
case 18: case 18:
switch (token) { switch (token) {
case 'd': case 'd':
parser->stack[++parser->top].state = 31; parser->stack[++parser->top].state = 32;
return 1; return 1;
default: default:
@ -400,7 +409,7 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
case 19: case 19:
switch (token) { switch (token) {
case 'r': case 'r':
parser->stack[++parser->top].state = 32; parser->stack[++parser->top].state = 33;
return 1; return 1;
default: default:
@ -411,7 +420,7 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
case 20: case 20:
switch (token) { switch (token) {
case 'e': case 'e':
parser->stack[++parser->top].state = 33; parser->stack[++parser->top].state = 34;
return 1; return 1;
default: default:
@ -431,7 +440,7 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
case 22: case 22:
switch (token) { switch (token) {
case '(': case '(':
parser->stack[++parser->top].state = 34; parser->stack[++parser->top].state = 35;
return 1; return 1;
default: default:
@ -445,7 +454,7 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
switch (token) { switch (token) {
default: default:
parser->top -= 1; 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].value.symbol_symbol = parse_reduce_17(parser->stack[parser->top + 0].value.symbol_term, grammar);
parser->stack[++parser->top].state = 22; parser->stack[++parser->top].state = 22;
} }
break; break;
@ -463,14 +472,14 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
switch (token) { switch (token) {
default: default:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_term = parse_reduce_19(parser->stack[parser->top + 0].value.token.c, grammar); parser->stack[parser->top].value.symbol_term = parse_reduce_20(parser->stack[parser->top + 0].value.token.c, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 16: case 16:
parser->stack[++parser->top].state = 23; parser->stack[++parser->top].state = 23;
break; break;
case 33: case 34:
parser->stack[++parser->top].state = 38; parser->stack[++parser->top].state = 39;
break; break;
} }
@ -480,18 +489,18 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
case 26: case 26:
switch (token) { switch (token) {
default: default:
parser->top -= 2; parser->top -= 1;
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].value.symbol_action = parse_reduce_16(parser->stack[parser->top + 0].value.token.str, grammar);
parser->stack[++parser->top].state = 16; parser->stack[++parser->top].state = 21;
} }
break; break;
case 27: case 27:
switch (token) { switch (token) {
default: default:
parser->top -= 1; parser->top -= 2;
parser->stack[parser->top].value.symbol_symbol = parse_reduce_17(parser->stack[parser->top + 0].value.token.str, grammar); 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 = 22; parser->stack[++parser->top].state = 16;
} }
break; break;
@ -499,21 +508,30 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
switch (token) { switch (token) {
default: default:
parser->top -= 1; parser->top -= 1;
parser->stack[parser->top].value.symbol_term = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar); parser->stack[parser->top].value.symbol_symbol = parse_reduce_18(parser->stack[parser->top + 0].value.token.str, grammar);
parser->stack[++parser->top].state = 22;
}
break;
case 29:
switch (token) {
default:
parser->top -= 1;
parser->stack[parser->top].value.symbol_term = 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 16: case 16:
parser->stack[++parser->top].state = 23; parser->stack[++parser->top].state = 23;
break; break;
case 33: case 34:
parser->stack[++parser->top].state = 38; parser->stack[++parser->top].state = 39;
break; break;
} }
} }
break; break;
case 29: case 30:
switch (token) { switch (token) {
default: default:
parser->top -= 1; parser->top -= 1;
@ -522,20 +540,9 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
} }
break; break;
case 30:
switch (token) {
case 'a':
parser->stack[++parser->top].state = 35;
return 1;
default:
return -1;
}
break;
case 31: case 31:
switch (token) { switch (token) {
case 'e': case 'a':
parser->stack[++parser->top].state = 36; parser->stack[++parser->top].state = 36;
return 1; return 1;
@ -546,7 +553,7 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
case 32: case 32:
switch (token) { switch (token) {
case 'c': case 'e':
parser->stack[++parser->top].state = 37; parser->stack[++parser->top].state = 37;
return 1; return 1;
@ -557,16 +564,8 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
case 33: case 33:
switch (token) { switch (token) {
case TOK_CHAR: case 'c':
parser->stack[++parser->top].state = 25; parser->stack[++parser->top].state = 38;
return 1;
case TOK_SYMBOL_UC:
parser->stack[++parser->top].state = 28;
return 1;
case TOK_SYMBOL_LC:
parser->stack[++parser->top].state = 39;
return 1; return 1;
default: default:
@ -576,16 +575,16 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
case 34: case 34:
switch (token) { switch (token) {
case TOK_SYMBOL: case TOK_CHAR:
parser->stack[++parser->top].state = 41; parser->stack[++parser->top].state = 25;
return 1;
case TOK_SYMBOL_LC:
parser->stack[++parser->top].state = 42;
return 1; return 1;
case TOK_SYMBOL_UC: case TOK_SYMBOL_UC:
parser->stack[++parser->top].state = 43; parser->stack[++parser->top].state = 29;
return 1;
case TOK_SYMBOL_LC:
parser->stack[++parser->top].state = 40;
return 1; return 1;
default: default:
@ -595,7 +594,15 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
case 35: case 35:
switch (token) { switch (token) {
case '_': case TOK_SYMBOL:
parser->stack[++parser->top].state = 42;
return 1;
case TOK_SYMBOL_LC:
parser->stack[++parser->top].state = 43;
return 1;
case TOK_SYMBOL_UC:
parser->stack[++parser->top].state = 44; parser->stack[++parser->top].state = 44;
return 1; return 1;
@ -606,7 +613,7 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
case 36: case 36:
switch (token) { switch (token) {
case 'r': case '_':
parser->stack[++parser->top].state = 45; parser->stack[++parser->top].state = 45;
return 1; return 1;
@ -617,7 +624,7 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
case 37: case 37:
switch (token) { switch (token) {
case 'e': case 'r':
parser->stack[++parser->top].state = 46; parser->stack[++parser->top].state = 46;
return 1; return 1;
@ -628,7 +635,7 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
case 38: case 38:
switch (token) { switch (token) {
case TOK_BLOCK: case 'e':
parser->stack[++parser->top].state = 47; parser->stack[++parser->top].state = 47;
return 1; return 1;
@ -650,7 +657,7 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
case 40: case 40:
switch (token) { switch (token) {
case ')': case TOK_BLOCK:
parser->stack[++parser->top].state = 49; parser->stack[++parser->top].state = 49;
return 1; return 1;
@ -661,23 +668,12 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
case 41: case 41:
switch (token) { switch (token) {
case ')':
parser->stack[++parser->top].state = 50;
return 1;
default: default:
parser->top -= 1; return -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; break;
@ -685,18 +681,18 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
switch (token) { switch (token) {
default: default:
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_23(parser->stack[parser->top + 0].value.token.str, grammar);
switch (parser->stack[parser->top].state) { switch (parser->stack[parser->top].state) {
case 34: case 35:
parser->stack[++parser->top].state = 40; parser->stack[++parser->top].state = 41;
break; break;
case 47: case 48:
parser->stack[++parser->top].state = 53; parser->stack[++parser->top].state = 54;
break; break;
case 56: case 57:
parser->stack[++parser->top].state = 57; parser->stack[++parser->top].state = 58;
break; break;
} }
@ -709,16 +705,16 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
parser->top -= 1; 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_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 34: case 35:
parser->stack[++parser->top].state = 40; parser->stack[++parser->top].state = 41;
break; break;
case 47: case 48:
parser->stack[++parser->top].state = 53; parser->stack[++parser->top].state = 54;
break; break;
case 56: case 57:
parser->stack[++parser->top].state = 57; parser->stack[++parser->top].state = 58;
break; break;
} }
@ -727,18 +723,29 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
case 44: case 44:
switch (token) { switch (token) {
case 'a':
parser->stack[++parser->top].state = 50;
return 1;
default: default:
return -1; 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 35:
parser->stack[++parser->top].state = 41;
break;
case 48:
parser->stack[++parser->top].state = 54;
break;
case 57:
parser->stack[++parser->top].state = 58;
break;
}
} }
break; break;
case 45: case 45:
switch (token) { switch (token) {
case TOK_BLOCK: case 'a':
parser->stack[++parser->top].state = 51; parser->stack[++parser->top].state = 51;
return 1; return 1;
@ -760,16 +767,8 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
case 47: case 47:
switch (token) { switch (token) {
case TOK_SYMBOL: case TOK_BLOCK:
parser->stack[++parser->top].state = 41; parser->stack[++parser->top].state = 53;
return 1;
case TOK_SYMBOL_LC:
parser->stack[++parser->top].state = 42;
return 1;
case TOK_SYMBOL_UC:
parser->stack[++parser->top].state = 43;
return 1; return 1;
default: default:
@ -778,6 +777,25 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
break; break;
case 48: case 48:
switch (token) {
case TOK_SYMBOL:
parser->stack[++parser->top].state = 42;
return 1;
case TOK_SYMBOL_LC:
parser->stack[++parser->top].state = 43;
return 1;
case TOK_SYMBOL_UC:
parser->stack[++parser->top].state = 44;
return 1;
default:
return -1;
}
break;
case 49:
switch (token) { switch (token) {
default: default:
parser->top -= 7; parser->top -= 7;
@ -786,7 +804,7 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
} }
break; break;
case 49: case 50:
switch (token) { switch (token) {
default: default:
parser->top -= 5; parser->top -= 5;
@ -795,47 +813,9 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
} }
break; break;
case 50:
switch (token) {
case 'r':
parser->stack[++parser->top].state = 54;
return 1;
default:
return -1;
}
break;
case 51: case 51:
switch (token) { switch (token) {
default: case 'r':
parser->top -= 8;
parse_reduce_7(parser->stack[parser->top + 7].value.token.str, grammar);
parser->stack[++parser->top].state = 2;
}
break;
case 52:
switch (token) {
default:
parser->top -= 8;
parse_reduce_6(parser->stack[parser->top + 7].value.token.str, grammar);
parser->stack[++parser->top].state = 2;
}
break;
case 53:
switch (token) {
default:
parser->top -= 8;
parse_reduce_5(parser->stack[parser->top + 5].value.symbol_term, parser->stack[parser->top + 6].value.token.str, parser->stack[parser->top + 7].value.symbol_varname, grammar);
parser->stack[++parser->top].state = 2;
}
break;
case 54:
switch (token) {
case 'g':
parser->stack[++parser->top].state = 55; parser->stack[++parser->top].state = 55;
return 1; return 1;
@ -844,9 +824,36 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
} }
break; break;
case 52:
switch (token) {
default:
parser->top -= 8;
parse_reduce_7(parser->stack[parser->top + 7].value.token.str, grammar);
parser->stack[++parser->top].state = 2;
}
break;
case 53:
switch (token) {
default:
parser->top -= 8;
parse_reduce_6(parser->stack[parser->top + 7].value.token.str, grammar);
parser->stack[++parser->top].state = 2;
}
break;
case 54:
switch (token) {
default:
parser->top -= 8;
parse_reduce_5(parser->stack[parser->top + 5].value.symbol_term, parser->stack[parser->top + 6].value.token.str, parser->stack[parser->top + 7].value.symbol_varname, grammar);
parser->stack[++parser->top].state = 2;
}
break;
case 55: case 55:
switch (token) { switch (token) {
case TOK_BLOCK: case 'g':
parser->stack[++parser->top].state = 56; parser->stack[++parser->top].state = 56;
return 1; return 1;
@ -857,16 +864,8 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
case 56: case 56:
switch (token) { switch (token) {
case TOK_SYMBOL: case TOK_BLOCK:
parser->stack[++parser->top].state = 41; parser->stack[++parser->top].state = 57;
return 1;
case TOK_SYMBOL_LC:
parser->stack[++parser->top].state = 42;
return 1;
case TOK_SYMBOL_UC:
parser->stack[++parser->top].state = 43;
return 1; return 1;
default: default:
@ -875,6 +874,25 @@ static int parse_do_push(parse_context_t *parser, int token, __attribute__((unus
break; break;
case 57: case 57:
switch (token) {
case TOK_SYMBOL:
parser->stack[++parser->top].state = 42;
return 1;
case TOK_SYMBOL_LC:
parser->stack[++parser->top].state = 43;
return 1;
case TOK_SYMBOL_UC:
parser->stack[++parser->top].state = 44;
return 1;
default:
return -1;
}
break;
case 58:
switch (token) { switch (token) {
default: default:
parser->top -= 12; parser->top -= 12;

View file

@ -6,10 +6,11 @@
enum parse_token_t { enum parse_token_t {
TOK_BLOCK = 256, TOK_BLOCK = 256,
TOK_CHAR = 257, TOK_CHAR = 257,
TOK_STRING = 258, TOK_SQBLOCK = 258,
TOK_SYMBOL = 259, TOK_STRING = 259,
TOK_SYMBOL_LC = 260, TOK_SYMBOL = 260,
TOK_SYMBOL_UC = 261, TOK_SYMBOL_LC = 261,
TOK_SYMBOL_UC = 262,
}; };
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 SQBLOCK {std::string *} str
%type STRING {std::string *} str %type STRING {std::string *} str
%type CHAR {char} c %type CHAR {char} c
@ -78,9 +79,7 @@ rule |= SYMBOL_LC(lhs) "|=" rhs(rhs) action(action) {
} }
rhs |= { rhs |= [new std::pair<std::vector<solar::symbol_t>, std::vector<std::string>>()]
return new std::pair<std::vector<solar::symbol_t>, std::vector<std::string>>();
}
rhs |= rhs(rhs) symbol(sym) { rhs |= rhs(rhs) symbol(sym) {
rhs->first.push_back(*sym); rhs->first.push_back(*sym);
@ -112,18 +111,17 @@ rhs |= rhs(rhs) STRING(str) {
} }
action |= ';' { action |= ';' [new std::string]
return new std::string;
}
action |= BLOCK(v) { action |= BLOCK(v) [v]
action |= SQBLOCK(v) {
*v = "\n\treturn " + *v + ";\n";
return v; return v;
} }
symbol |= term(v) { symbol |= term(v) [v]
return v;
}
symbol |= SYMBOL_LC(v) { symbol |= SYMBOL_LC(v) {
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));
@ -138,19 +136,9 @@ term |= SYMBOL_UC(v) {
return ret; return ret;
} }
term |= CHAR(v) { term |= CHAR(v) [new solar::symbol_t(solar::symbol_t::make_char(v))]
return new solar::symbol_t(solar::symbol_t::make_char(v));
}
varname |= SYMBOL_LC(v) { varname |= SYMBOL_LC(v) [v]
return v; varname |= SYMBOL_UC(v) [v]
} varname |= SYMBOL(v) [v]
varname |= SYMBOL_UC(v) {
return v;
}
varname |= SYMBOL(v) {
return v;
}