Граф коммитов

1345 Коммитов

Автор SHA1 Сообщение Дата
nobu 0783f55cf8 parse.y: heredoc token
* parse.y (parser_heredoc_identifier): gather branches by quote
  char.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-26 23:26:03 +00:00
nobu 70da28c185 parse.y: STR_TERM_END
* parse.y (parser_parse_string): store the end of string literal
  mark in nd_term instead of nd_func.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-26 15:11:32 +00:00
nobu 49b884941a parse.y: parser_string_term
* parse.y (parser_string_term): return the token of string or
  regexp literal terminator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-26 15:07:51 +00:00
nobu 504908996c parse.y: reset indent in heredoc_dedent
* parse.y (parser_heredoc_dedent): reset heredoc_indent and return
  the dedented node.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-26 08:29:23 +00:00
nobu dcaeea4f6b parse.y: new_string1
* parse.y (new_string1): extract from the rule.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-26 08:29:22 +00:00
nobu cb1ebf84cc parse.y: new_xstring_gen
* parse.y (new_xstring_gen): extract from the rule.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56011 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-26 08:29:18 +00:00
nobu 1451785609 parse.y: new_regexp_gen
* parse.y (new_regexp_gen): extract from the rule.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-26 08:29:17 +00:00
nobu ec8f8fa4c8 parse.y: lparen_arg statement
* parse.y (primary): allow parenthesised statement as a method
  argument.  [Feature #12686]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-19 02:39:09 +00:00
nobu 90d9255ec2 parse.y: chained assignments
* parse.y (command_asgn, arg): fix syntax errors with chained
  assignment with op assign.  [Bug #12669]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-13 02:10:11 +00:00
nobu 5245e31426 parse.y: rescue modifier in rhs of op asgn
* parse.y (stmt, arg): rescue modifier in command op assignment
  should be limited to rhs only.  [ruby-core:75621] [Bug #12402]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-13 01:52:22 +00:00
nobu d63802b375 parse.y: const_decl_gen
* parse.y (const_decl_gen): extract as a function as well as
  ripper.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-12 03:29:50 +00:00
nobu 777f15a3b2 parse.y: assign_error
* parse.y (assign_error_gen): [ripper] rename without backref.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-12 03:29:49 +00:00
nobu c93875e6e3 parse.y: node_assign
* parse.y (stmt, command_asgn): unifiy parser and ripper code by
  node_assign macro.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-11 02:32:19 +00:00
nobu a2b06fe444 parse.y: backref_assign_error
* parse.y (backref_assign_error): unify parser and ripper code.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-11 02:20:34 +00:00
nobu 76e8f883d8 parse.y: const declaration macro
* parse.y (const_decl): unify parser and ripper code.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-11 02:12:57 +00:00
nobu 0859c42b77 parse.y: const field macros
* parse.y (const_path_field, top_const_field): unify parser and
  ripper code.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-11 01:24:24 +00:00
nobu 3433653240 parse.y: rhs with rescue modifier
* parse.y (command_rhs, arg_rhs): introduce new rules to reduce
  repeated rules with rescue modifier.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-10 13:37:03 +00:00
nobu 064ed74be4 parse.y: rescue modifier in rhs
* parse.y (command_asgn): rescue modifier in command assignment
  should be limited to rhs only.  [ruby-core:75621] [Bug #12402]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-10 08:26:46 +00:00
nobu 18cf70ebf6 parse.y: reg_fragment_enc_error
* parse.y (reg_fragment_enc_error): compile_error is different
  between parser and ripper.  [ruby-core:76397] [Bug #12651]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-03 12:31:25 +00:00
ko1 9f60791a04 * vm_core.h: revisit the structure of frame, block and env.
[Bug #12628]

  This patch introduce many changes.

  * Introduce concept of "Block Handler (BH)" to represent
    passed blocks.

  * move rb_control_frame_t::flag to ep[0] (as a special local
    variable). This flags represents not only frame type, but also
    env flags such as escaped.

  * rename `rb_block_t` to `struct rb_block`.

  * Make Proc, Binding and RubyVM::Env objects wb-protected.

  Check [Bug #12628] for more details.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-28 11:02:30 +00:00
nobu f540475134 Coverage on non-positive lines
* compile.c (ADD_TRACE): ignore trace instruction on non-positive
  line.
* parse.y (coverage): get rid of ArgumentError when the starting
  line number is not positive.  [ruby-core:76141] [Bug #12517]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-26 23:56:57 +00:00
nobu 75a68057c7 parse.y: no named capture conflict warnings
* parse.y (reg_named_capture_assign_iter): remove named capture
  conflict warnings.  it is just annoying rather than useful.
  [ruby-core:75416] [Bug #12359]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-13 11:50:09 +00:00
nobu e0611820df parse.y: trace elsif
* parse.y (new_if_gen): set newline flag to NODE_IF to trace all
  if/elsif statements.  [ruby-core:67720] [Bug #10763]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-03 05:19:20 +00:00
nobu 86b1179a03 error.c: SyntaxError#initialize
* error.c (syntax_error_initialize): move the default message,
  "compile error", from parse.y.  the default parameter should
  belong to the class definition.
* parse.y (yycompile0): use the default parameter.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-20 06:52:30 +00:00
nobu 97177a2d99 refactor syntax error
* compile.c (append_compile_error): use rb_syntax_error_append.
* error.c (rb_syntax_error_append): append messages into a
  SyntaxError exception instance.
* parse.y (yycompile0): make new SyntaxError instance in main
  mode, otherwize error_buffer should be a SyntaxError if error
  has occurred.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-20 01:25:55 +00:00
nobu 51c195948f refactor parser error
* error.c (err_vcatf): rename, and separate appending message from
  creating a string buffer.
* error.c (rb_syntax_error_append): merge rb_error_vsprintf and
  rb_compile_err_append.
* parse.y (parser_compile_error): use rb_syntax_error_append.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-19 08:42:50 +00:00
nobu 134d1ce892 parse.y: massign in cond
* parse.y (assign_in_cond): allow multiple assignment in
  conditional expression.  [Feature #10617]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-13 05:36:26 +00:00
nobu 028f3801f8 parse.y: get rid of ISASCII on ID
* parse.y (ripper_id2sym): do not call ISASCII() on ID, rb_isascii
  is restricted to int now.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-30 13:14:31 +00:00
nobu d7935475fc remove rb_thread_t::parse_in_eval
* parse.y (struct parser_params): move parse_in_eval flag from
  rb_thread_t.
* parse.y (rb_parser_set_context): set parsing context, not only
  mild error flag.
* iseq.c (rb_iseq_compile_with_option): the parser now refers no
  thread local states to be restored.
* vm_eval.c (eval_string_with_cref): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-28 21:39:24 +00:00
nobu 7bfeb1c2ae remove SIGN_EXTEND_CHAR macro
* marshal.c (r_long): cast to `signed char`, which is used
  already, instead of SIGN_EXTEND_CHAR.
* parse.y: SIGN_EXTEND_CHAR is no longer used.  [Fix GH-1302]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-23 02:44:54 +00:00
nobu bf99f85941 parse.y: lambda indentation check
* parse.y (lambda_body, parser_yylex): warn mismatched indentation
  of lambda block.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-22 05:19:01 +00:00
nobu bc343b851d SyntaxError message at iseq compile
* iseq.c (rb_iseq_compile_with_option): make the parser in mild
  error.
* load.c (rb_load_internal0): ditto.
* parse.y (yycompile0): return the error message within the error
  to be raised.  [Feature #11951]
* parse.y (parser_compile_error): accumulate error messages in the
  error_buffer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-19 05:46:20 +00:00
nobu 04eb614251 parse.y: mark debug_buffer
* parse.y (parser_mark): mark debug_buffer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-18 18:09:52 +00:00
nobu 7a3cc69779 parse.y: Fix for nth_ref_max
* parse.y (parse_numvar): NTH_REF must be less than a half of
  INT_MAX, as it is left-shifted to be ORed with back-ref flag.
  [ruby-core:74444] [Bug#12192] [Fix GH-1296]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-18 07:22:26 +00:00
nobu cb65717b45 parse.y: symbol literals for alias/undef
* defs/keywords (alias, undef): symbol literals are allowed.
* parse.y (parse_percent): should parse symbol literals for alias
  and undef.  [ruby-dev:47681] [Bug #8851]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-16 14:10:27 +00:00
nobu ea5e885a95 optimize named capture assignment
* compile.c (compile_named_capture_assign): optimize named capture
  assignments, by replacing repeating global variable accesses
  with `dup`, and by returning the matched result instead of
  re-getting it from the MatchData.

* parse.y (reg_named_capture_assign_gen): build just assignment
  nodes for the optimization.

ex. `/(?<x>.)/ =~ "bar"`

- old
  ```
  0000 putstring        "bar"
  0002 opt_regexpmatch1 /(?<x>.)/
  0004 pop
  0005 getglobal        $~
  0007 branchunless     25
  0009 getglobal        $~
  0011 putobject        :x
  0013 opt_aref         <callinfo!mid:[], argc:1, ARGS_SIMPLE>
  0016 setlocal_OP__WC__0 2
  0018 getglobal        $~
  0020 putobject_OP_INT2FIX_O_0_C_
  0021 opt_send_without_block <callinfo!mid:begin, argc:1, ARGS_SIMPLE>
  0024 leave
  0025 putobject        nil
  0027 setlocal_OP__WC__0 2
  0029 putobject        nil
  0031 leave
  ```

- new
  ```
  0000 putstring        "bar"
  0002 opt_regexpmatch1 /(?<x>.)/
  0004 getglobal        $~
  0006 dup
  0007 branchunless     14
  0009 putobject        :x
  0011 opt_aref         <callinfo!mid:[], argc:1, ARGS_SIMPLE>
  0014 setlocal_OP__WC__0 2
  0016 leave
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-14 07:53:39 +00:00
nobu 3392b6c9e2 parse.y: adjust indent
* parse.y: adjust indent and tabify spaces after tabs.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-13 16:26:04 +00:00
nobu cf09c0c351 iseq.h: coverage_enabled flag
* iseq.c (prepare_iseq_build): enable coverage by coverage_enabled
  option, not by parse_in_eval flag in the thread context.
* iseq.h (rb_compile_option_struct): add coverage_enabled flag.
* parse.y (yycompile0): set coverage_enabled flag if coverage
  array is made.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-10 08:34:18 +00:00
nobu 53fbaeab29 parse.y: optimize negate_lit
* parse.y (negate_lit): optimize bignum, rational, and complex
  negation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-05 01:33:04 +00:00
nobu e87d9a4346 parse.y: split nextc
* parse.y (parser_nextline, parser_cr): split less frequent paths
  from parser_nextc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-03 08:31:12 +00:00
nobu f6347e38e3 parse.y: cr_seen flag
* parse.y (parser_params): turn last_cr_line into cr_seen flag.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-03 07:42:32 +00:00
nobu d4819da611 parse without $.
* io.c (rb_io_gets_internal): read one line from an IO without
  setting ARGF.lineno.

* parse.y (lex_io_gets): use rb_io_gets_internal not to affect
  $. global variable.

* ruby.c (load_file): no longer reset $.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-24 08:21:04 +00:00
nobu 43f7eacdac parse.y: hide compile_option
* parse.y (parser_set_compile_option_flag): hide compile_option
  hash from ObjectSpace.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-24 02:42:40 +00:00
nobu 0201900d76 id.def: $~ and $_
* defs/id.def (predefined): add idLASTLINE and idBACKREF for $~
  and $_ respectively.
* parse.y: use idLASTLINE and idBACKREF instead of rb_intern.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-17 12:42:00 +00:00
nobu 8b019eed78 parse.y: short circuit by result
* parse.y (parse_ident): short circuit by result, as only
  tIDENTIFIER can be a local variable, but tFID and tCONSTANT not.
  fix up r53834.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-15 17:41:46 +00:00
nobu fbb51ff44c parse.y: kwarg to method with same name variable
* parse.y (parse_ident): allow keyword arguments just after a
  method where the same name local variable is defined.
  [ruby-core:73816] [Bug#12073]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-15 06:44:36 +00:00
nobu 5e59be3edd parse.y: simplify local ID condition
* parse.y (tokenize_ident, parse_ident): ident in tokenize_ident()
  can be a local id only when called from parse_ident(), but never
  from parse_gvar() and parse_atmark().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-15 06:06:31 +00:00
naruse 21daa56b2a * re.c: Introduce RREGEXP_PTR.
patch by dbussink.
  partially merge https://github.com/ruby/ruby/pull/497

* include/ruby/ruby.h: ditto.

* gc.c: ditto.

* ext/strscan/strscan.c: ditto.

* parse.y: ditto.

* string.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-02 04:39:44 +00:00
nobu ed34d855bb parse.y: show operations on BITSTACK
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-18 11:50:06 +00:00
nobu 45acdf4df4 parse.y: escaped newline in dedenting heredoc
* parse.y (parser_here_document): an escaped newline is not an
  actual newline, and the rest part should not be dedented.
  [ruby-core:72855] [Bug #11989]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-18 05:37:48 +00:00