From 34d9043c81e8db4d40f65334e025c36a1b7bc179 Mon Sep 17 00:00:00 2001 From: Yukihiro Matsumoto Date: Thu, 24 May 2012 09:35:42 +0900 Subject: parser->colum number was wrong --- src/parse.y | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/parse.y') diff --git a/src/parse.y b/src/parse.y index 316e7309c..5924cd43c 100644 --- a/src/parse.y +++ b/src/parse.y @@ -2925,10 +2925,10 @@ yyerror(parser_state *p, const char *s) if (! p->capture_errors) { if (p->filename) { - fprintf(stderr, "%s:%d:%d: %s\n", p->filename, p->lineno, p->column+1, s); + fprintf(stderr, "%s:%d:%d: %s\n", p->filename, p->lineno, p->column, s); } else { - fprintf(stderr, "line %d:%d: %s\n", p->lineno, p->column+1, s); + fprintf(stderr, "line %d:%d: %s\n", p->lineno, p->column, s); } } else if (p->nerr < sizeof(p->error_buffer) / sizeof(p->error_buffer[0])) { @@ -2937,7 +2937,7 @@ yyerror(parser_state *p, const char *s) memcpy(c, s, n + 1); p->error_buffer[p->nerr].message = c; p->error_buffer[p->nerr].lineno = p->lineno; - p->error_buffer[p->nerr].column = p->column+1; + p->error_buffer[p->nerr].column = p->column; } p->nerr++; } @@ -2959,10 +2959,10 @@ yywarn(parser_state *p, const char *s) if (! p->capture_errors) { if (p->filename) { - fprintf(stderr, "%s:%d:%d: %s\n", p->filename, p->lineno, p->column+1, s); + fprintf(stderr, "%s:%d:%d: %s\n", p->filename, p->lineno, p->column, s); } else { - fprintf(stderr, "line %d:%d: %s\n", p->lineno, p->column+1, s); + fprintf(stderr, "line %d:%d: %s\n", p->lineno, p->column, s); } } else if (p->nerr < sizeof(p->warn_buffer) / sizeof(p->warn_buffer[0])) { @@ -3400,7 +3400,7 @@ parse_qstring(parser_state *p, int term) switch (c) { case '\n': p->lineno++; - p->column = 0; + p->column = 1; continue; case '\\': @@ -3469,7 +3469,7 @@ parser_yylex(parser_state *p) /* fall through */ case '\n': p->lineno++; - p->column = 0; + p->column = 1; switch (p->lstate) { case EXPR_BEG: case EXPR_FNAME: @@ -4258,7 +4258,7 @@ parser_yylex(parser_state *p) c = nextc(p); if (c == '\n') { p->lineno++; - p->column = 0; + p->column = 1; space_seen = 1; goto retry; /* skip \\n */ } @@ -4694,6 +4694,7 @@ mrb_parser_new(mrb_state *mrb) p->capture_errors = 0; p->lineno = 1; + p->column = 1; #if defined(PARSER_TEST) || defined(PARSER_DEBUG) yydebug = 1; #endif @@ -4716,7 +4717,7 @@ mrb_parser_lineno(struct mrb_parser_state *p, int n) if (n <= 0) { return p->lineno; } - p->column = 0; + p->column = 1; p->lineno = n; return n; } -- cgit v1.2.3 From 2f4ef95ae65490d180571b8563374c052cd2afd7 Mon Sep 17 00:00:00 2001 From: Masamitsu MURASE Date: Sun, 27 May 2012 23:05:43 +0900 Subject: Add 'ifndef/endif' to avoid conflict of 'TRUE' definition. --- src/parse.y | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/parse.y') diff --git a/src/parse.y b/src/parse.y index 5924cd43c..887ba0134 100644 --- a/src/parse.y +++ b/src/parse.y @@ -41,8 +41,13 @@ static void backref_error(parser_state *p, node *n); #define identchar(c) (isalnum(c) || (c) == '_' || !isascii(c)) +#ifndef TRUE #define TRUE 1 +#endif + +#ifndef FALSE #define FALSE 0 +#endif typedef unsigned int stack_type; -- cgit v1.2.3 From c14e440897b2cf8c0769f00d9a14810b11ca9a99 Mon Sep 17 00:00:00 2001 From: Yukihiro Matsumoto Date: Mon, 28 May 2012 08:50:10 +0900 Subject: column adjustment was wrong for pushed back characters --- src/parse.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/parse.y') diff --git a/src/parse.y b/src/parse.y index 887ba0134..37a16c614 100644 --- a/src/parse.y +++ b/src/parse.y @@ -3040,8 +3040,8 @@ nextc(parser_state *p) if (c == '\n') { // must understand heredoc } - p->column++; } + p->column++; return c; } -- cgit v1.2.3 From cf8f429624e6c2e75cbd146e548dd1ca62930149 Mon Sep 17 00:00:00 2001 From: Yukihiro Matsumoto Date: Mon, 28 May 2012 15:50:30 +0900 Subject: ignore error nodes (with node_begin initialization) --- src/parse.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/parse.y') diff --git a/src/parse.y b/src/parse.y index 37a16c614..2d7003f62 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1008,7 +1008,7 @@ top_stmts : none } | error top_stmt { - $$ = $2; + $$ = new_begin(p, 0); } ; -- cgit v1.2.3 From dae33d3f660e598c95b7c9feb67f5716227607ce Mon Sep 17 00:00:00 2001 From: Yukihiro Matsumoto Date: Mon, 28 May 2012 15:51:07 +0900 Subject: column position adjustment was wrong --- src/parse.y | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/parse.y') diff --git a/src/parse.y b/src/parse.y index 2d7003f62..55c82c12d 100644 --- a/src/parse.y +++ b/src/parse.y @@ -3405,7 +3405,7 @@ parse_qstring(parser_state *p, int term) switch (c) { case '\n': p->lineno++; - p->column = 1; + p->column = 0; continue; case '\\': @@ -3474,7 +3474,7 @@ parser_yylex(parser_state *p) /* fall through */ case '\n': p->lineno++; - p->column = 1; + p->column = 0; switch (p->lstate) { case EXPR_BEG: case EXPR_FNAME: @@ -3569,8 +3569,8 @@ parser_yylex(parser_state *p) if (p->column == 1) { if (peeks(p, "begin\n")) { skips(p, "\n=end\n"); + goto retry; } - goto retry; } switch (p->lstate) { case EXPR_FNAME: case EXPR_DOT: @@ -4263,7 +4263,7 @@ parser_yylex(parser_state *p) c = nextc(p); if (c == '\n') { p->lineno++; - p->column = 1; + p->column = 0; space_seen = 1; goto retry; /* skip \\n */ } @@ -4699,7 +4699,7 @@ mrb_parser_new(mrb_state *mrb) p->capture_errors = 0; p->lineno = 1; - p->column = 1; + p->column = 0; #if defined(PARSER_TEST) || defined(PARSER_DEBUG) yydebug = 1; #endif @@ -4722,7 +4722,7 @@ mrb_parser_lineno(struct mrb_parser_state *p, int n) if (n <= 0) { return p->lineno; } - p->column = 1; + p->column = 0; p->lineno = n; return n; } -- cgit v1.2.3