diff options
| -rw-r--r-- | src/parse.y | 1 | ||||
| -rw-r--r-- | tools/mirb/mirb.c | 67 |
2 files changed, 30 insertions, 38 deletions
diff --git a/src/parse.y b/src/parse.y index 2b2dd6851..4b1f02106 100644 --- a/src/parse.y +++ b/src/parse.y @@ -4634,6 +4634,7 @@ mrb_parser_parse(parser_state *p) p->cmd_start = TRUE; p->in_def = p->in_single = FALSE; p->nerr = p->nwarn = 0; + p->sterm = 0; yyparse(p); tree = p->tree; diff --git a/tools/mirb/mirb.c b/tools/mirb/mirb.c index 15e7520dc..d05f57d61 100644 --- a/tools/mirb/mirb.c +++ b/tools/mirb/mirb.c @@ -20,6 +20,35 @@ is_code_block_open(struct mrb_parser_state *parser) { int code_block_open = FALSE; + /* check if parser error are available */ + if (0 < parser->nerr) { + const char *unexpected_end = "syntax error, unexpected $end"; + /* a parser error occur, we have to check if */ + /* we need to read one more line or if there is */ + /* a different issue which we have to show to */ + /* the user */ + + if (strncmp(parser->error_buffer[0].message, unexpected_end, strlen(unexpected_end)) == 0) { + code_block_open = TRUE; + } + else if (strcmp(parser->error_buffer[0].message, + "syntax error, unexpected keyword_end") == 0) { + code_block_open = TRUE; + } + else if (strcmp(parser->error_buffer[0].message, + "syntax error, unexpected $end, expecting keyword_then or ';' or '\\n'") == 0) { + code_block_open = TRUE; + } + else if (strcmp(parser->error_buffer[0].message, + "syntax error, unexpected tREGEXP_BEG") == 0) { + code_block_open = TRUE; + } + else if (strcmp(parser->error_buffer[0].message, + "unterminated string meets end of file") == 0) { + code_block_open = TRUE; + } + } + switch (parser->lstate) { /* all states which need more code */ @@ -78,44 +107,6 @@ is_code_block_open(struct mrb_parser_state *parser) break; } - if (!code_block_open) { - /* based on the last parser state the code */ - /* block seems to be closed */ - - /* now check if parser error are available */ - if (0 < parser->nerr) { - const char *unexpected_end = "syntax error, unexpected $end"; - /* a parser error occur, we have to check if */ - /* we need to read one more line or if there is */ - /* a different issue which we have to show to */ - /* the user */ - - if (strncmp(parser->error_buffer[0].message, unexpected_end, strlen(unexpected_end)) == 0) { - code_block_open = TRUE; - } - else if (strcmp(parser->error_buffer[0].message, - "syntax error, unexpected keyword_end") == 0) { - code_block_open = TRUE; - } - else if (strcmp(parser->error_buffer[0].message, - "syntax error, unexpected $end, expecting keyword_then or ';' or '\\n'") == 0) { - code_block_open = TRUE; - } - else if (strcmp(parser->error_buffer[0].message, - "syntax error, unexpected tREGEXP_BEG") == 0) { - code_block_open = TRUE; - } - else if (strcmp(parser->error_buffer[0].message, - "unterminated string meets end of file") == 0) { - code_block_open = TRUE; - } - } - } - else { - /* last parser state suggest that this code */ - /* block is open, WE NEED MORE CODE!! */ - } - return code_block_open; } |
