summaryrefslogtreecommitdiff
path: root/parse.y
AgeCommit message (Collapse)Author
2018-01-11parse.y: Remove LEXPOP hackmame
cmdarg_stack became inconsistent state due to look-ahead, and LEXPOP hack smoothed over the inconsistency. This commit fixes the inconsisitent state itself, and removes LEXPOP hack. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-11Fix a typo [ci skip]kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-11parse.y: disentangle the lexer handling of ')', ']', and '}'mame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-11parse.y: simplify and add a comment for paren_nest and lpar_begmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-11parse.y: add a simple comment for COND_* and CMDARG_*mame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-11parse.y (local_push_gen): Rewrite the condition of "unused var" warningmame
It was unnecessarily too complex, IMO. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09parse.y: insane syntax too (class definition in cond)mame
This change partially reverts r61724 and take another approach: exploiting struct local_vars to backup the cond_stack state. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09Fix indent [ci skip]kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09parse.y: insane syntaxnobu
* parse.y (primary): save/restore COND and CMDARG stacks at method definition, to distinguish do_block and do_cond properly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09Rename code_range to code_locationmame
Because the name "code_range" is ambiguous with encoding's. Abbreviations ("crange", and "cr") are also renamed to "loc". The traditional "code_location" (a pair of lineno and column) is renamed to "code_position". Abbreviations are also renamed (first_loc to beg_pos, and last_loc to end_pos). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09Allow `-> do rescue; end` as well as `proc do rescue; end`mame
https://twitter.com/takiuchi/status/950593389963051008 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09parse.y: Remove redefinition of mallocmame
Because the purpose is now unsure (maybe, to support very old bison?). If an issue occurs, it should be resurrected with explicit comment. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09parse.y: PARSER_DEBUG is no longer usedmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09parse.y: Remove meaningless ifndef guardsmame
Because the part of the code is already within `#ifndef RIPPER`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09parse.y: set ID to yylval ID instead of tokennobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09parse.y: Remove special handling of tOROP and tANDOPmame
The complexity is no longer considered necessary. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09parse.y: use change_shortcut_operator_idnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09parse.y: Remove duplicated nd_line setyui-knk
* parse.y: These nodes are created with `@$` locations. Start position of `@$` is same as start position of `@1`. And NEW_XXX macros set first_loc.lineno of a passed code range to nd_line. So these nd_set_line are not needed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08parse.y: Make consistent with the terms about code ranges and locationsmame
"loc" was ambiguous; it might refer both a location and a code range. This change uses "loc" for a location, and "crange" or "cr" for a code range. A location (abbr. loc) is a point in a program and consists of line number and column number. A code range (abbr. crange and cr) is a range within a program and consists of a pair of locations which is the first and the last. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08parse.y (remove_duplicate_keys): Remove a not used argumentyui-knk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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