summaryrefslogtreecommitdiff
path: root/parse.y
AgeCommit message (Collapse)Author
2018-01-08parse.y: Factor out code fragments that merges two code rangesmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08parse.y (block_append_gen): Remove a not used argumentyui-knk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08parse.y: Use nd_loc of head and tailyui-knk
* parse.y (block_append_gen): Use nd_loc of head(tail) when create NEW_BLOCK of head(tail). e.g. The locations of the NODE_BLOCK is fixed: ``` BEGIN { :a } BEGIN { :b } ``` * Before ``` NODE_BLOCK (line: 5, code_range: (5,0)-(7,1)) ``` * After ``` NODE_BLOCK (line: 1, code_range: (1,0)-(7,1)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08parse.y: Fix the lineno of nd_set_lineyui-knk
* parse.y: Follow up of r61676. r61676 removed ruby_sourceline from some actions. When stop to use lineno of "n th" symbol, it's better to use last location's lineno of "n-1 th" symbol. e.g. ``` primary : k_begin {} bodystmt k_end ``` Before r61676 we use lineno of `@2` (ruby_sourceline). In this case, last location's lineno of `k_begin` (`@1`) is suitable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08parse.y: Remove dispose_stringmame
I think that recycling the delimiter string objects doesn't pay its complexity. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08parse.y: Use last_loc.lineno instead of ruby_sourcelinemame
State-less way is better. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08parse.y: Remove `$<num>$ = ruby_sourceline` hacksmame
Instead, use bison's lineno. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08parse.y: constified NULL_LOCnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08parse.y: Factor out special handling of a short-cut operator idmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08parse.y: Remove duplicated nd_loc setyui-knk
* parse.y: nd_loc is set by NEW_CASE2/NEW_WHEN git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08parse.y: Embed simple wrapper functions for NEW_NODEsmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08parse.y: Make NULL_LOC to be internalyui-knk
* parse.y (NULL_LOC): We will create NODEs only inside of parse.y, so make NULL_LOC to be internal. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08parse.y: Remove unneeded wrapper functions for NEW_NODEsmame
Just refactoring. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08parse.y: set bison's first_loc.lineno to nd_line by defaultmame
This change initializes nd_line, lineno of each node, by default, by using the first line number of code range that bison tracks, instead of extracting from lexer state. The lexer state basically provides only the last line number of code range, so many hacks are used to approximate the first line number. The hacks have been introduced on demand, or very ad-hocly. I think this change will make it possible to remove most of the hacks. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08parse.y: make all NEW_NODE macros receive locationmame
This looks a big change, but just for refactoring. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-07parse.y: do not overwrite case_body positionnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-07parse.y: set case_body line position to argsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-07parse.y: removed unused macro new_command_callnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-07parse.y: nd_line of new_qcallnobu
* parse.y (new_qcall): set nd_line to the method name location. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05parse.y: Use nd_set_loc instead of direct modification to nd_locmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05parse.y: Remove unneeded codemame
Because block_append sets prelude->nd_loc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05parse.y: make method_add_block accept locationmame
Also, use method_add_block instead of direct modification to nd_iter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05node_h (NEW_DEFN): remove unused argumentmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05node.h: remove NODE_PRELUDEmame
NODE_PRELUDE contains a `BEGIN` node, a main node, and compile_option. This node is assumed that it must be located immediately under the root NODE_SCOPE, but this strange assumption is not so good, IMO. This change removes the assumtion; it integrates the former two nodes by block_append, and moves compile_option into rb_ast_body_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05node.h: define rb_ast_body_t and restructure rb_ast_tmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05parse.y: refactor out ast generation code of two rb_parser_compile_*mame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-04node.h: add NODE_ONCE instead of reuse of NODE_SCOPEmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-02parse.y: fix typonobu
* parse.y (singleton): fix typo, show the expression. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-02parse.y: code end positionnobu
* parse.y (parser_yyerror): use the given location as the end of erred code, instead of the current position. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-01parse.y: highlight yyerrornobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-31parse.y: yyerror1nobu
* parse.y (yyerror1): pass location to parser_yyerror. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-31parse.y: yylloc at yyerrornobu
* parse.y (parser_yyerror): consider the case first_loc and last_loc point different lines. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-31parse.y: assignable_errornobu
* parse.y (assignable_gen): should return valid NODE always even on errors. [ruby-core:84565] [Bug #14261] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-31parse.y: yylloc at yyerrornobu
* parse.y (parser_yyerror): utilize the location given by bison. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-26parse.y: warning for locationsnobu
* parse.y (gettable_gen): warn for __FILE__/__LINE__ when eval with binding only. promote use of Binding#source_location instead. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-21parse.y: change NODE_SCOPE's nd_loc to one of the parent NODEmame
This change (ad-hocly) adjusts the code range of NODE_SCOPE in class/module definition because the same adjust is already done in method definition. I intend to just remove inconsistency between class/module definition and method definition, but this kind of adjust is dirty, so it should be fixed later (maybe in 2.6). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-20parse.y: end of script at newlinenobu
* parse.y (parser_yylex): deal with end of script chars just after ignored newline as other places. [ruby-core:84349] [Bug #14206] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-14node.h: add nd_last_loc and nd_set_last_locmame
Just refactoring. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-14node.[ch], parse.y, compile.c: rename nd_column to nd_first_columnmame
nd_set_column -> nd_first_set_column nd_lineno -> nd_first_lineno nd_set_lineno -> nd_first_set_lineno git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-14parse.y: suppress "unused variable" warning of ripper.ymame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61223 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-13parse.y: Revert r61196yui-knk
* parse.y: Because top_stmts is generated from none (not "/* none */"), @0 is not set by YYLLOC_DEFAULT. So @0 is a meaningless location. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12parse.y: Fix the locations of an empty scriptyui-knk
* parse.y: Fix the locations of NODE_BEGIN in an empty script. ``` ruby --dump=p -e '' ``` * Before ``` NODE_BEGIN (line: 1, code_range: (1,1)-(1,1)) ``` * After ``` NODE_BEGIN (line: 1, code_range: (1,0)-(1,0)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12parse.y: Change the last location of noneyui-knk
* parse.y: Change the last location of none to be equal to the first location of none. Sometimes none has length (`parser->tokp` does not match `lex_p` when none is generated). This leads to invalid code_ranges. e.g. The locations of the NODE_CALL (:sort) is fixed: ``` x.sort.join(" ") ``` * Before ``` NODE_CALL (line: 1, code_range: (1,0)-(1,7)) ``` * After ``` NODE_CALL (line: 1, code_range: (1,0)-(1,6)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12parse.y: Set locations of nd_body in NODE_ITER explicitlyyui-knk
* parse.y: Same as r61168, but for brace_block. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12parse.y: Set locations of nd_body in NODE_ITER explicitlyyui-knk
* parse.y: Currently the location of do_body is set by new_do_body. Sometimes the last part of do_body is none, because bodystmt ends with opt_ensure. Token keyword_end has been looked ahead when a tokenizer generates none, so the last location of opt_ensure matches the last location of `end`. But this relation will be broken when we change the last location of none to be equal to the first location of none. So set locations of nd_body in NODE_ITER explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12parse.y: Fix the locations of NODE_ITER (cmd_brace_block)yui-knk
* parse.y: Update the locations of NODE_ITER when nd_iter is determined. ``` a (1) {|i|} ``` * Before ``` NODE_ITER (line: 1, code_range: (1,6)-(1,10)) ``` * After ``` NODE_ITER (line: 1, code_range: (1,0)-(1,11)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12parse.y: Fix locations of NODE_ARRAY of mlhs_headyui-knk
* parse.y: Fix to only include a range of mlhs_item (exclude ',' form range). e.g. The locations of the NODE_ARRAY is fixed: ``` (a,) = 1,2 ``` * Before ``` NODE_ARRAY (line: 1, code_range: (1,1)-(1,3)) ``` * After ``` NODE_ARRAY (line: 1, code_range: (1,1)-(1,2)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12parse.y: Fix locations of NODE_ARRAY in NODE_CALL(:=~)yui-knk
* parse.y (match_op_gen): Fix to only include a range of node2. e.g. The locations of the NODE_ARRAY is fixed: ``` re =~ s1 ``` * Before ``` NODE_ARRAY (line: 1, code_range: (1,0)-(1,8)) ``` * After ``` NODE_ARRAY (line: 1, code_range: (1,6)-(1,8)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12parse.y: Fix locations of NODE_ARRAY of opt_call_argsyui-knk
* parse.y: Fix to only include a range of assocs (exclude ',' form range). e.g. The locations of the NODE_ARRAY is fixed: ``` m1(str: "bar",) ``` * Before ``` NODE_ARRAY (line: 1, code_range: (1,3)-(1,14)) ``` * After ``` NODE_ARRAY (line: 1, code_range: (1,3)-(1,13)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11parse.y: Fix locations of NODE_ARRAY in NODE_BLOCK_PASSyui-knk
* parse.y: Fix to only include a range of assocs. e.g. The locations of the NODE_ARRAY is fixed: ``` m1(str: "bar", &blk) ``` * Before ``` NODE_ARRAY (line: 1, code_range: (1,3)-(1,19)) ``` * After ``` NODE_ARRAY (line: 1, code_range: (1,3)-(1,13)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e