replace "yylval" with "pylval" to make it compile with byacc.
MODIFY
mrbgems/mruby-bin-mruby/bintest/mruby.rb
mrbgems/mruby-bin-mruby/bintest/mruby.rb
@@ -2,9 +2,9 @@ require 'tempfile'
assert('regression for #1564') do
o = `#{cmd('mruby')} -e #{shellquote('<<')} 2>&1`
- assert_equal o, "-e:1:2: syntax error, unexpected tLSHFT\n"
+ assert_include o, "-e:1:2: syntax error"
o = `#{cmd('mruby')} -e #{shellquote('<<-')} 2>&1`
- assert_equal o, "-e:1:3: syntax error, unexpected tLSHFT\n"
+ assert_include o, "-e:1:3: syntax error"
end
assert('regression for #1572') do

MODIFY
mrbgems/mruby-compiler/core/parse.y
mrbgems/mruby-compiler/core/parse.y
@@ -3327,7 +3327,7 @@ none : /* none */
}
;
%%
-#define yylval (*((YYSTYPE*)(p->ylval)))
+#define pylval (*((YYSTYPE*)(p->ylval)))
static void
yyerror(parser_state *p, const char *s)
@@ -3962,7 +3962,7 @@ parse_string(parser_state *p)
yyerror(p, buf);
return 0;
}
- yylval.nd = new_str(p, tok(p), toklen(p));
+ pylval.nd = new_str(p, tok(p), toklen(p));
return tHD_STRING_MID;
}
if (c < 0) {
@@ -4035,7 +4035,7 @@ parse_string(parser_state *p)
tokfix(p);
p->lstate = EXPR_BEG;
p->cmd_start = TRUE;
- yylval.nd = new_str(p, tok(p), toklen(p));
+ pylval.nd = new_str(p, tok(p), toklen(p));
if (hinf) {
hinf->line_head = FALSE;
return tHD_STRING_PART;
@@ -4065,7 +4065,7 @@ parse_string(parser_state *p)
else {
pushback(p, c);
tokfix(p);
- yylval.nd = new_str(p, tok(p), toklen(p));
+ pylval.nd = new_str(p, tok(p), toklen(p));
return tSTRING_MID;
}
}
@@ -4077,7 +4077,7 @@ parse_string(parser_state *p)
end_strterm(p);
if (type & STR_FUNC_XQUOTE) {
- yylval.nd = new_xstr(p, tok(p), toklen(p));
+ pylval.nd = new_xstr(p, tok(p), toklen(p));
return tXSTRING;
}
@@ -4127,11 +4127,11 @@ parse_string(parser_state *p)
} else {
encp = NULL;
}
- yylval.nd = new_regx(p, s, dup, encp);
+ pylval.nd = new_regx(p, s, dup, encp);
return tREGEXP;
}
- yylval.nd = new_str(p, tok(p), toklen(p));
+ pylval.nd = new_str(p, tok(p), toklen(p));
if (IS_LABEL_POSSIBLE()) {
if (IS_LABEL_SUFFIX(0)) {
p->lstate = EXPR_BEG;
@@ -4209,7 +4209,7 @@ heredoc_identifier(parser_state *p)
p->heredocs_from_nextline = push(p->heredocs_from_nextline, newnode);
p->lstate = EXPR_END;
- yylval.nd = newnode;
+ pylval.nd = newnode;
return tHEREDOC_BEG;
}
@@ -4313,7 +4313,7 @@ parser_yylex(parser_state *p)
case '*':
if ((c = nextc(p)) == '*') {
if ((c = nextc(p)) == '=') {
- yylval.id = intern("**",2);
+ pylval.id = intern("**",2);
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
@@ -4322,7 +4322,7 @@ parser_yylex(parser_state *p)
}
else {
if (c == '=') {
- yylval.id = intern_c('*');
+ pylval.id = intern_c('*');
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
@@ -4438,7 +4438,7 @@ parser_yylex(parser_state *p)
}
if (c == '<') {
if ((c = nextc(p)) == '=') {
- yylval.id = intern("<<",2);
+ pylval.id = intern("<<",2);
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
@@ -4460,7 +4460,7 @@ parser_yylex(parser_state *p)
}
if (c == '>') {
if ((c = nextc(p)) == '=') {
- yylval.id = intern(">>",2);
+ pylval.id = intern(">>",2);
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
@@ -4557,7 +4557,7 @@ parser_yylex(parser_state *p)
tokadd(p, c);
}
tokfix(p);
- yylval.nd = new_str(p, tok(p), toklen(p));
+ pylval.nd = new_str(p, tok(p), toklen(p));
p->lstate = EXPR_END;
return tCHAR;
@@ -4565,7 +4565,7 @@ parser_yylex(parser_state *p)
if ((c = nextc(p)) == '&') {
p->lstate = EXPR_BEG;
if ((c = nextc(p)) == '=') {
- yylval.id = intern("&&",2);
+ pylval.id = intern("&&",2);
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
@@ -4577,7 +4577,7 @@ parser_yylex(parser_state *p)
return tANDDOT;
}
else if (c == '=') {
- yylval.id = intern_c('&');
+ pylval.id = intern_c('&');
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
@@ -4604,7 +4604,7 @@ parser_yylex(parser_state *p)
if ((c = nextc(p)) == '|') {
p->lstate = EXPR_BEG;
if ((c = nextc(p)) == '=') {
- yylval.id = intern("||",2);
+ pylval.id = intern("||",2);
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
@@ -4612,7 +4612,7 @@ parser_yylex(parser_state *p)
return tOROP;
}
if (c == '=') {
- yylval.id = intern_c('|');
+ pylval.id = intern_c('|');
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
@@ -4636,7 +4636,7 @@ parser_yylex(parser_state *p)
return '+';
}
if (c == '=') {
- yylval.id = intern_c('+');
+ pylval.id = intern_c('+');
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
@@ -4664,7 +4664,7 @@ parser_yylex(parser_state *p)
return '-';
}
if (c == '=') {
- yylval.id = intern_c('-');
+ pylval.id = intern_c('-');
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
@@ -4738,7 +4738,7 @@ parser_yylex(parser_state *p)
no_digits();
}
else if (nondigit) goto trailing_uc;
- yylval.nd = new_int(p, tok(p), 16);
+ pylval.nd = new_int(p, tok(p), 16);
return tINTEGER;
}
if (c == 'b' || c == 'B') {
@@ -4762,7 +4762,7 @@ parser_yylex(parser_state *p)
no_digits();
}
else if (nondigit) goto trailing_uc;
- yylval.nd = new_int(p, tok(p), 2);
+ pylval.nd = new_int(p, tok(p), 2);
return tINTEGER;
}
if (c == 'd' || c == 'D') {
@@ -4786,7 +4786,7 @@ parser_yylex(parser_state *p)
no_digits();
}
else if (nondigit) goto trailing_uc;
- yylval.nd = new_int(p, tok(p), 10);
+ pylval.nd = new_int(p, tok(p), 10);
return tINTEGER;
}
if (c == '_') {
@@ -4819,7 +4819,7 @@ parser_yylex(parser_state *p)
pushback(p, c);
tokfix(p);
if (nondigit) goto trailing_uc;
- yylval.nd = new_int(p, tok(p), 8);
+ pylval.nd = new_int(p, tok(p), 8);
return tINTEGER;
}
if (nondigit) {
@@ -4836,7 +4836,7 @@ parser_yylex(parser_state *p)
}
else {
pushback(p, c);
- yylval.nd = new_int(p, "0", 10);
+ pylval.nd = new_int(p, "0", 10);
return tINTEGER;
}
}
@@ -4920,10 +4920,10 @@ parser_yylex(parser_state *p)
yywarning_s(p, "float %s out of range", tok(p));
errno = 0;
}
- yylval.nd = new_float(p, tok(p));
+ pylval.nd = new_float(p, tok(p));
return tFLOAT;
}
- yylval.nd = new_int(p, tok(p), 10);
+ pylval.nd = new_int(p, tok(p), 10);
return tINTEGER;
}
@@ -4965,7 +4965,7 @@ parser_yylex(parser_state *p)
return tREGEXP_BEG;
}
if ((c = nextc(p)) == '=') {
- yylval.id = intern_c('/');
+ pylval.id = intern_c('/');
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
@@ -4984,7 +4984,7 @@ parser_yylex(parser_state *p)
case '^':
if ((c = nextc(p)) == '=') {
- yylval.id = intern_c('^');
+ pylval.id = intern_c('^');
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
@@ -5158,7 +5158,7 @@ parser_yylex(parser_state *p)
}
}
if ((c = nextc(p)) == '=') {
- yylval.id = intern_c('%');
+ pylval.id = intern_c('%');
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
@@ -5212,7 +5212,7 @@ parser_yylex(parser_state *p)
tokadd(p, '$');
tokadd(p, c);
tokfix(p);
- yylval.id = intern_cstr(tok(p));
+ pylval.id = intern_cstr(tok(p));
return tGVAR;
case '-':
@@ -5222,7 +5222,7 @@ parser_yylex(parser_state *p)
pushback(p, c);
gvar:
tokfix(p);
- yylval.id = intern_cstr(tok(p));
+ pylval.id = intern_cstr(tok(p));
return tGVAR;
case '&': /* $&: last match */
@@ -5234,7 +5234,7 @@ parser_yylex(parser_state *p)
tokadd(p, c);
goto gvar;
}
- yylval.nd = new_back_ref(p, c);
+ pylval.nd = new_back_ref(p, c);
return tBACK_REF;
case '1': case '2': case '3':
@@ -5253,7 +5253,7 @@ parser_yylex(parser_state *p)
yyerror_i(p, "capture group index must be <= %d", INT_MAX);
return 0;
}
- yylval.nd = new_nth_ref(p, (int)n);
+ pylval.nd = new_nth_ref(p, (int)n);
}
return tNTH_REF;
@@ -5381,7 +5381,7 @@ parser_yylex(parser_state *p)
p->lstate = EXPR_BEG;
nextc(p);
tokfix(p);
- yylval.id = intern_cstr(tok(p));
+ pylval.id = intern_cstr(tok(p));
return tLABEL;
}
}
@@ -5392,10 +5392,10 @@ parser_yylex(parser_state *p)
kw = mrb_reserved_word(tok(p), toklen(p));
if (kw) {
enum mrb_lex_state_enum state = p->lstate;
- yylval.num = p->lineno;
+ pylval.num = p->lineno;
p->lstate = kw->state;
if (state == EXPR_FNAME) {
- yylval.id = intern_cstr(kw->name);
+ pylval.id = intern_cstr(kw->name);
return kw->id[0];
}
if (p->lstate == EXPR_BEG) {
@@ -5442,7 +5442,7 @@ parser_yylex(parser_state *p)
{
mrb_sym ident = intern_cstr(tok(p));
- yylval.id = ident;
+ pylval.id = ident;
#if 0
if (last_state != EXPR_DOT && islower(tok(p)[0]) && lvar_defined(ident)) {
p->lstate = EXPR_END;

replace "yylval" with "pylval" to make it compile with byacc.