Commit graph

1920 commits

Author SHA1 Message Date
Nobuyoshi Nakada
fd461dea06
Ripper#validate_object: check if the object is hidden 2019-07-19 07:57:17 +09:00
Nobuyoshi Nakada
59d6ce4f4b
Moved RIPPER_DEBUG methods to Ripper from Kernel 2019-07-19 07:50:32 +09:00
Nobuyoshi Nakada
18bce998dd
Fixed build error with RIPPER_DEBUG 2019-07-19 07:50:32 +09:00
Nobuyoshi Nakada
a027c4b5b0
Use Qnull instead of 0 and Qundef 2019-07-19 06:23:19 +09:00
Nobuyoshi Nakada
0e23e0c3a0
Adjust indent [ci skip] 2019-07-17 17:04:37 +09:00
Yusuke Endoh
711dfec3fa parse.y (here_document): remove dead code
str is always zero when evaluating the branch.
Found by Coverity Scan.
2019-07-15 14:08:17 +09:00
Yusuke Endoh
9e3971c3ad Add a /* fall through */ comment 2019-07-15 00:29:56 +09:00
Yusuke Endoh
20a3fb3c4b Add a /* fall through */ comment 2019-07-14 21:34:32 +09:00
Nobuyoshi Nakada
4e038a7e64
Revert "parse.y: Deprecate flip-flops"
This reverts commit bae638ad5b.

[Feature #5400]
2019-07-11 14:52:02 +09:00
Nobuyoshi Nakada
49cad67635
Removed duplicate assignment
This `last_state` is set to `lex.state` just before the `switch`
statement, and `token_flush` nor `nextc` never change the state.
2019-07-10 00:20:00 +09:00
Nobuyoshi Nakada
995ae6d529
Check indent of end against else if present 2019-07-08 17:09:59 +09:00
Nobuyoshi Nakada
a13636e756
Message to pipe should end with a newline 2019-07-07 18:18:22 +09:00
Nobuyoshi Nakada
d548073f68
Enable indentation warning against if just after else
```ruby
if false
  puts 'false'
else if true
  puts 'true'
end # -:5: warning: mismatched indentations at 'end' with 'if' at 3
end
```

[Feature #15990]
2019-07-07 15:47:40 +09:00
Nobuyoshi Nakada
789e49dc7e
Renamed column in token_info to indent 2019-07-07 14:43:54 +09:00
Nobuyoshi Nakada
d746a41e85
Multiple codepoints are not allowed at single character literal
It has unintentionally passed since 2.5.
2019-07-05 22:39:54 +09:00
Kazuhiro NISHIYAMA
fae4489a3a
Fix a typo 2019-07-05 19:00:37 +09:00
Nobuyoshi Nakada
f19e048d24
Do not dispatch a nil token in ripper
As a comment token includes the newline, so delayed newline token
just follows it should not be dispatched.  [Bug #11485]

Co-Authored-By: Jeremy Evans <code@jeremyevans.net>
2019-07-04 15:58:47 +09:00
Nobuyoshi Nakada
78a8888c3e
Hoisted out f_rest_marg
* parse.y (f_rest_marg): extract named and unnamed rest parameter
  in parenthesized method arguments, and should not be warned as
  unused.
2019-06-30 10:57:24 +09:00
Nobuyoshi Nakada
27723b699b
Should not warn massign parameters as unused 2019-06-29 18:45:24 +09:00
Nobuyoshi Nakada
1f7cb4bee9
Omit EXPR_ prefix to show lex_state 2019-06-27 20:31:10 +09:00
Nobuyoshi Nakada
097554855c
Fix ripper fatal
* parse.y (parser_yylex): return END_OF_INPUT at unterminated here
  document instead of an error.  [Bug #15962]
2019-06-27 15:32:03 +09:00
Nobuyoshi Nakada
c8e9e0b74b
Fix wrong "void value expression" error
* parse.y (value_expr_check): `then` or `else` only `if` is not a
  void value expression, as the counterpart is evaluated as `nil`.
  [Bug #15932]
2019-06-17 22:30:52 +09:00
Nobuyoshi Nakada
01b3a38043
Fix wrong "void value expression" error
* parse.y (value_expr_check): if either of `then` or `else`
  statements is not a void value expression, the whole `if` is not
  also a void value expression.  [Bug #15932]
2019-06-17 21:44:06 +09:00
Nobuyoshi Nakada
a064e46762
Support Bison 3 2019-06-17 03:09:52 +09:00
Nobuyoshi Nakada
53e9908d8a
Fix memory leak
* string.c (str_replace_shared_without_enc): free previous buffer
  before replaced.

* parse.y (gettable): make sure in advance that the `__FILE__`
  object shares a fstring, to get rid of replacement with the
  fstring later.
  TODO: this hack may be needed in other places.

[Bug #15916]

Co-Authored-By: luke-gru (Luke Gruber) <luke.gru@gmail.com>
2019-06-16 23:51:22 +09:00
Nobuyoshi Nakada
5d79054906
Revert github/pull/2230, commit miss 2019-06-15 12:04:16 +09:00
Nobuyoshi Nakada
6fa4c90448
Prefer enum yytokentype to int 2019-06-15 11:58:02 +09:00
Josh Cheek
b8730f1251
Multiline method chain with leading dot works for blank lines 2019-06-15 11:25:38 +09:00
Josh Cheek
2240de98c0
Remove blank line I accidentally added 2019-06-15 11:25:38 +09:00
Josh Cheek
cc180e9371
Rename LINEND to EMPTYLN 2019-06-15 11:25:38 +09:00
Josh Cheek
5af5dd4639
Omg, it works!
I'll rename it and squash this commit later,
just wanted to make sure I couldn't lose it
(took a long time to come up with).
2019-06-15 11:25:13 +09:00
Nobuyoshi Nakada
d365fd5a02
An operator is not allowed just after |>
https://twitter.com/yukihiro_matz/status/1139454774640726019
2019-06-14 18:17:50 +09:00
Nobuyoshi Nakada
aa7211836b
Continue to the next line beginning with a pipeline 2019-06-13 22:19:47 +09:00
Nobuyoshi Nakada
043f010c28
parse.y: moved pipeline to expr
To allow arguments without parentheses.
2019-06-13 22:03:10 +09:00
Nobuyoshi Nakada
f169043d81
Add pipeline operator [Feature #15799] 2019-06-13 18:44:32 +09:00
Nobuyoshi Nakada
39ae88ad0d
Refined syntax error messages 2019-06-11 22:31:57 +09:00
Nobuyoshi Nakada
140b8117bd
&. is not allowed inside LHS of massign
https://hackerone.com/reports/605262
2019-06-11 15:22:16 +09:00
Martin Dürst
f258137083 Fix grammar of macro name: ECCESSED -> ECCESSIVE
Fix the name of the macro variable introduced in 0872ea5330
from NODE_SPECIAL_EXCESSED_COMMA to NODE_SPECIAL_EXCESSIVE_COMMA.
2019-06-05 14:03:50 +09:00
Yusuke Endoh
0872ea5330 node.h: Avoid a magic number to represent excessed comma
`(ID)1` was assigned to NODE_ARGS#rest_arg for `{|x,| }`.
This change removes the magic number by introducing an explicit macro
variable for it: NODE_SPECIAL_EXCESSED_COMMA.
2019-06-04 23:17:18 +09:00
Nobuyoshi Nakada
aa8d393d8a
EOF by 2 ^D on a TTY
Terminate the input from a TTY by 2 ^D at the middle of line, like
as many programs, `cat`, `perl` and so on, do.  By the first ^D,
the line will be sent without a newline, and then EOF will be send
by the next ^D.
2019-06-04 09:24:17 +09:00
Nobuyoshi Nakada
c990b3c41a
Fix the error token on "invalid hex escape"
* parse.y (tok_hex): flush token after dispatching the "invalid
  hex escape" parse error.
2019-06-03 15:15:54 +09:00
Nobuyoshi Nakada
92ecf58b1e
parse.y: adjust here-doc error token
* parse.y (here_document): adjust token to the here-doc identifier
  in compile_error when a here-document misses the closing
  identifier.
2019-05-30 22:03:33 +09:00
Nobuyoshi Nakada
4a31c1e45d
parse.y: continue after heredoc error
* parse.y: continue parsing the rest of the here-document starting
  line, after the terminator was not found.
2019-05-30 12:38:50 +09:00
Nobuyoshi Nakada
1da5c73932
parse.y: fix state after ivar/cvar
* parse.y (parse_atmark): return EXPR_END or EXPR_ENDFN, depending
  on the previous state, even incomplete names consistently.
2019-05-29 21:42:58 +09:00
Nobuyoshi Nakada
cc66272e50
parse.y: flush invalid char 2019-05-29 13:24:24 +09:00
Nobuyoshi Nakada
c730c25354
parse.y: warn escaped whitespace
* parse.y (warn_space_char_code): warn whitespace characters
  escaped with meta/control prefix.
2019-05-29 00:00:26 +09:00
Nobuyoshi Nakada
62b3d4c721
Skip following all digits after @@ 2019-05-28 14:36:29 +09:00
Nobuyoshi Nakada
1cdaa17a06
parse.y: numbered parameter symbol
* parse.y (parse_atmark): numbered parameter name is not allowed
  as a symbol regardless the context.
2019-05-28 09:00:02 +09:00
Nobuyoshi Nakada
b4365e75fd
Do not make an incomplete escape a valid char 2019-05-27 23:08:48 +09:00
Nobuyoshi Nakada
c40003da25
Ripper#token
* parse.y (ripper_token): added Ripper#token which returns the
  current token string.  [EXPERIMENTAL]
2019-05-27 23:08:45 +09:00