diff options
Diffstat (limited to 'mrbgems/mruby-compiler/core/parse.y')
| -rw-r--r-- | mrbgems/mruby-compiler/core/parse.y | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index 22d31a390..90b8812b9 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -1089,7 +1089,7 @@ heredoc_end(parser_state *p) %token <id> tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tLABEL %token <nd> tINTEGER tFLOAT tCHAR tXSTRING tREGEXP -%token <nd> tSTRING tSTRING_PART tSTRING_MID +%token <nd> tSTRING tSTRING_PART tSTRING_MID tLABEL_END %token <nd> tNTH_REF tBACK_REF %token <num> tREGEXP_END @@ -2972,7 +2972,7 @@ superclass : /* term */ expr_value term { $$ = $3; - } /* + } /* | error term { yyerrok; @@ -3241,6 +3241,18 @@ assoc : arg_value tASSOC arg_value { $$ = cons(new_sym(p, $1), $2); } + | tLABEL_END arg_value + { + $$ = cons(new_sym(p, new_strsym(p, $1)), $2); + } + | tSTRING_BEG tLABEL_END arg_value + { + $$ = cons(new_sym(p, new_strsym(p, $2)), $3); + } + | tSTRING_BEG string_rep tLABEL_END arg_value + { + $$ = cons(new_dsym(p, push($2, $3)), $4); + } ; operation : tIDENTIFIER @@ -3895,6 +3907,8 @@ parse_string(parser_state *p) int end = (intptr_t)p->lex_strterm->cdr->cdr->cdr; parser_heredoc_info *hinf = (type & STR_FUNC_HEREDOC) ? parsing_heredoc_inf(p) : NULL; + if (beg == 0) beg = -3; /* should never happen */ + if (end == 0) end = -3; newtok(p); while ((c = nextc(p)) != end || nest_level != 0) { if (hinf && (c == '\n' || c < 0)) { @@ -4080,8 +4094,13 @@ parse_string(parser_state *p) return tREGEXP; } - yylval.nd = new_str(p, tok(p), toklen(p)); + if (IS_LABEL_SUFFIX(0)) { + p->lstate = EXPR_BEG; + nextc(p); + return tLABEL_END; + } + return tSTRING; } @@ -5460,7 +5479,10 @@ mrb_parser_parse(parser_state *p, mrbc_context *c) p->lex_strterm = NULL; parser_init_cxt(p, c); - yyparse(p); + if (yyparse(p) != 0 || p->nerr > 0) { + p->tree = 0; + return; + } if (!p->tree) { p->tree = new_nil(p); } @@ -6487,7 +6509,7 @@ mrb_parser_dump(mrb_state *mrb, node *tree, int offset) break; case NODE_HEREDOC: - printf("NODE_HEREDOC:\n"); + printf("NODE_HEREDOC (<<%s):\n", ((parser_heredoc_info*)tree)->term); mrb_parser_dump(mrb, ((parser_heredoc_info*)tree)->doc, offset+1); break; |
