summaryrefslogtreecommitdiff
path: root/parse.y
AgeCommit message (Collapse)Author
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
2017-12-11parse.y: Change locations of NODE_DVAR in NODE_MASGNyui-knk
* parse.y: Change the last location of NODE_DVAR to be equal to the first location of NODE_DVAR. NODE_DVAR of NODE_MASGN (nd_value) is an internal variable, so it has no length. e.g. The locations of the NODE_DVAR is changed: ``` a.b {|(c,d)| e} ``` * Before ``` NODE_DVAR (line: 1, code_range: (1,7)-(1,10)) ``` * After ``` NODE_DVAR (line: 1, code_range: (1,7)-(1,7)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61124 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11parse.y: Fix locations of NODE_DSTR generated by evstr2dstr_genyui-knk
* parse.y (evstr2dstr_gen): Fix to only include a range of node. e.g. The locations of the NODE_DSTR is fixed: ``` %W[a #{b} c] ``` * Before ``` NODE_DSTR (line: 1, code_range: (1,3)-(1,9)) ``` * After ``` NODE_DSTR (line: 1, code_range: (1,5)-(1,9)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11parse.y: Remove not used argumentyui-knk
* parse.y (list_append_gen): location is not used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11parse.y: Fix locations of NODE_SCOPE in NODE_MODULEyui-knk
* parse.y: Fix to only include a range of bodystmt. e.g. The locations of the NODE_SCOPE is fixed: ``` module M def m end end ``` * Before ``` NODE_SCOPE (line: 4, code_range: (1,0)-(4,3)) ``` * After ``` NODE_SCOPE (line: 4, code_range: (1,8)-(4,3)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-10parse.y: Fix the last location of NODE_COLON2yui-knk
* parse.y: Fix to only include a range from primary_value to tCONSTANT. e.g. The locations of the NODE_COLON2 is fixed: ``` A::B ||= 1 ``` * Before ``` NODE_COLON2 (line: 1, code_range: (1,0)-(1,10)) ``` * After ``` NODE_COLON2 (line: 1, code_range: (1,0)-(1,4)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61101 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-10parse.y: Change the first location of NODE_ARRAY in NODE_DSTR (nd_next->nd_next)yui-knk
* parse.y (list_append_gen): Change the first location to start with the location of item if new list is generated. e.g. The locations of the NODE_ARRAY is changed: ``` "#{a}.#{b}" ``` * Before ``` NODE_ARRAY (line: 1, code_range: (1,0)-(1,6)) ``` * After ``` NODE_ARRAY (line: 1, code_range: (1,5)-(1,6)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-09parse.y: Fix locations of NODE_ARRAY in NODE_ATTRASGN (nd_args)yui-knk
* parse.y (arg_append_gen): Fix to only include a range of node2 if new list is generated. e.g. The locations of the NODE_ARRAY is fixed: ``` x.default = 5 ``` * Before ``` NODE_ARRAY (line: 1, code_range: (1,0)-(1,13)) ``` * After ``` NODE_ARRAY (line: 1, code_range: (1,12)-(1,13)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-09parse.y: Change locations of NODE_BLOCK in NODE_RESBODY (nd_body)yui-knk
* parse.y: Change to only include a range from exc_var to compstmt. e.g. The locations of the NODE_BLOCK is changed: ``` begin :a rescue E => e :b end ``` * Before ``` NODE_BLOCK (line: 3, code_range: (3,0)-(5,3)) ``` * After ``` NODE_BLOCK (line: 3, code_range: (3,9)-(4,4)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-09parse.y: Fix locations of NODE_SCOPE in NODE_SCLASSyui-knk
* parse.y: Fix to only include a range of bodystmt. e.g. The locations of the NODE_SCOPE is fixed: ``` class << [] def m; end end ``` * Before ``` NODE_SCOPE (line: 3, code_range: (1,0)-(3,3)) ``` * After ``` NODE_SCOPE (line: 3, code_range: (2,2)-(3,3)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-09parse.y: Fix locations of NODE_ARRAY in NODE_OPCALL(nd_args)yui-knk
* parse.y: Fix to only include a range of arg1. e.g. The locations of the NODE_ARRAY is fixed: ``` 1 + 2 ``` * Before ``` NODE_ARRAY (line: 1, code_range: (1,0)-(1,5)) ``` * After ``` NODE_ARRAY (line: 1, code_range: (1,4)-(1,5)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-09parse.y: Fix locations of NODE_SCOPE in NODE_CLASSyui-knk
* parse.y: Fix to only include a range of bodystmt. e.g. The locations of the NODE_SCOPE is fixed: ``` class A def a; end end ``` * Before ``` NODE_SCOPE (line: 3, code_range: (1,0)-(3,3)) ``` * After ``` NODE_SCOPE (line: 3, code_range: (1,7)-(3,3)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-08parse.y Fix compile erroryui-knk
ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-08parse.y: Fix locations of modifier_rescueyui-knk
* parse.y: Fix to only include a range from modifier_rescue to stmt (or arg). e.g. The locations of the NODE_RESBODY is fixed: ``` a rescue 1 ``` * Before ``` NODE_RESBODY (line: 1, code_range: (1,0)-(1,10)) ``` * After ``` NODE_RESBODY (line: 1, code_range: (1,2)-(1,10)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-07parse.y: Fix locations of stringyui-knk
* parse.y: Fix to include locations of tSTRING_BEG and tSTRING_END. e.g. The locations of the NODE_STR is fixed: ``` "a" ``` * Before ``` NODE_STR (line: 1, code_range: (1,1)-(1,2)) ``` * After ``` NODE_STR (line: 1, code_range: (1,0)-(1,3)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-07parse.y: Fix locations of arrayyui-knk
* parse.y (make_array): Set locations of ary to include locations of start token (tLBRACK, tWORDS_BEG, ...) and end token (']', tSTRING_END, ...) of array. e.g. The locations of the NODE_ARRAY is fixed: ``` [1, 2, 3] ``` * Before ``` NODE_ARRAY (line: 1, code_range: (1,1)-(1,8)) ``` * After ``` NODE_ARRAY (line: 1, code_range: (1,0)-(1,9)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-07parse.y: fix for old compilersnobu
* parse.y (arg_value): initialization of aggregation type with non-constant values is not allowed in C89. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-07parse.y: Fix locations of dsymyui-knk
* parse.y: Fix to only include a range from tSTRING_BEG to tLABEL_END. e.g. The locations of the NODE_LIT is fixed: ``` { "a": 10 } ``` * Before ``` NODE_LIT (line: 1, code_range: (1,2)-(1,9)) ``` * After ``` NODE_LIT (line: 1, code_range: (1,2)-(1,6)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-07parse.y: Fix locations of dsymyui-knk
* parse.y (dsym_node_gen): Always set locations to include locations of tSYMBEG and tSTRING_END. e.g. The locations of the NODE_LIT is fixed: ``` :"a" ``` * Before ``` NODE_LIT (line: 1, code_range: (1,2)-(1,3)) ``` * After ``` NODE_LIT (line: 1, code_range: (1,0)-(1,4)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-07parse.y: Fix locations of regexpyui-knk
* parse.y (new_regexp_gen): Always set locations to include locations of tREGEXP_BEG and tREGEXP_END. e.g. The locations of the NODE_LIT is fixed: ``` /a/ ``` * Before ``` NODE_LIT (line: 1, code_range: (1,1)-(1,2)) ``` * After ``` NODE_LIT (line: 1, code_range: (1,0)-(1,3)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-07parse.y: Fix locations of xstringyui-knk
* parse.y (new_xstring_gen): Always set locations to include locations of tXSTRING_BEG and tSTRING_END. e.g. The locations of the NODE_XSTR is fixed: ``` `a` ``` * Before ``` NODE_XSTR (line: 1, code_range: (1,1)-(1,2)) ``` * After ``` NODE_XSTR (line: 1, code_range: (1,0)-(1,3)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-06parse.y: Fix the first location of heredoc identifieryui-knk
* parse.y (parser_heredoc_identifier): Put length of term at the head of rb_strterm_heredoc_struct.term. * parse.y (rb_parser_set_location_from_strterm_heredoc): Use length of term to calculate first_loc.column. e.g. The locations of the NODE_DSTR is fixed: ``` a <<STR 123 #{:a} STR ``` * Before ``` NODE_DSTR (line: 3, code_range: (1,3)-(1,7)) ``` * After ``` NODE_DSTR (line: 3, code_range: (1,2)-(1,7)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-06parse.y: remove redefined typedefmame
Clang told me that this is C11 feature. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-06parse.y: Fix locations of HEREDOCyui-knk
* parse.y (rb_parser_set_location_from_strterm_heredoc): Set locations based on rb_strterm_heredoc_t. * parse.y (yylex): Set yylloc based on rb_strterm_heredoc_t when parsing heredoc. e.g. The locations of the NODE_DSTR is changed: ``` a <<STR 123 #{:a} STR ``` * Before ``` NODE_DSTR (line: 3, code_range: (3,0)-(1,7)) ``` * After ``` NODE_DSTR (line: 3, code_range: (1,3)-(1,7)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-05parse.y: nd_line of new nodenobu
* parse.y (nd_set_loc): set nd_line of the newly created node to the first location. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e