summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authoryui-knk <spiketeika@gmail.com>2022-10-01 17:44:28 +0900
committerYuichiro Kaneko <spiketeika@gmail.com>2022-10-08 17:59:11 +0900
commit4bfdf6d06ddbcf21345461038f2a9e3012f77268 (patch)
treec218b83b15c56b3a3727c5bd6a2d399564f01349 /parse.y
parent4f24f3ea94e43d1021fdd8548480f130f5112b99 (diff)
downloadruby-4bfdf6d06ddbcf21345461038f2a9e3012f77268.tar.gz
Move `error` from top_stmts and top_stmt to stmt
By this change, syntax error is recovered smaller units. In the case below, "DEFN :bar" is same level with "CLASS :Foo" now. ``` module Z class Foo foo. end def bar end end ``` [Feature #19013]
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y14
1 files changed, 6 insertions, 8 deletions
diff --git a/parse.y b/parse.y
index c0959a5e81..a8eadfebd3 100644
--- a/parse.y
+++ b/parse.y
@@ -1430,10 +1430,6 @@ top_stmts : none
/*% %*/
/*% ripper: stmts_add!($1, $3) %*/
}
- | error top_stmt
- {
- $$ = remove_begin($2);
- }
;
top_stmt : stmt
@@ -1503,10 +1499,6 @@ stmts : none
/*% %*/
/*% ripper: stmts_add!($1, $3) %*/
}
- | error stmt
- {
- $$ = remove_begin($2);
- }
;
stmt_or_begin : stmt
@@ -1659,6 +1651,12 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem
/*% ripper: massign!($1, $4) %*/
}
| expr
+ | error
+ {
+ /*%%%*/
+ $$ = NEW_ERROR(&@$);
+ /*% %*/
+ }
;
command_asgn : lhs '=' lex_ctxt command_rhs