Commit graph

20692 commits

Author SHA1 Message Date
Kevin Menard
82fb6a90d5 [ruby/prism] Track both the unescaped bytes and source string for a regular expression so we can accurately set its encoding flags.
dc6dd3a926
2024-03-08 18:48:53 +00:00
Hartley McGuire
4756eaf5aa [ruby/rdoc] Fix ToMarkdown missing newlines for label-lists
Previously, using ToMarkdown on a label-list would generate output that
could not be reparsed by the RDoc::Markdown parser:

```
md = <<~MD
apple
: a red fruit

banana
: a yellow fruit
MD

doc = RDoc::Markdown.parse(md)
doc # => [doc: [list: NOTE [item: ["apple"]; [para: "a red fruit"]], [item: ["banana"]; [para: "a yellow fruit"]]]]

new_md = doc.accept(RDoc::Markup::ToMarkdown.new)
new_md # => "apple\n:   a red fruit\nbanana\n:   a yellow fruit\n\n"

new_doc = RDoc::Markdown.parse(new_md)
new_doc # => [doc: [list: NOTE [item: ["apple"]; [para: "a red fruit\nbanana\n: a yellow fruit"]]]]
```

The issue is that the [PHP Markdown Extra spec][1] requires a newline
after each definition list item, but ToMarkdown was not putting newlines
between label-list items.

This commit fixes the issue by properly appending a newline after each
label-list item so that the output of ToMarkdown can be reparsed by
RDoc::Markdown:

```
md = <<~MD
apple
: a red fruit

banana
: a yellow fruit
MD

doc = RDoc::Markdown.parse(mdoc)
doc # => [doc: [list: NOTE [item: ["apple"]; [para: "a red fruit"]], [item: ["banana"]; [para: "a yellow fruit"]]]]

new_md = doc.accept(RDoc::Markup::ToMarkdown.new)
new_md # => "apple\n:   a red fruit\n\nbanana\n:   a yellow fruit\n\n"

new_doc = RDoc::Markdown.parse(new_md)
new_doc # => [doc: [list: NOTE [item: ["apple"]; [para: "a red fruit"]], [item: ["banana"]; [para: "a yellow fruit"]]]]
```

[1]: https://michelf.ca/projects/php-markdown/extra/#def-list

c65266437c
2024-03-08 10:13:04 +00:00
dependabot[bot]
86ce78d73a [rubygems/rubygems] Bump rb-sys
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.89 to 0.9.90.
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.89...v0.9.90)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

ce663279b9
2024-03-08 12:27:31 +09:00
Kevin Newton
7e1183200a [ruby/prism] Fix up test suite
2929c35630
2024-03-07 23:13:41 +00:00
tompng
4186609d88 [ruby/prism] Add bignum parse test
503a0ea6cd
2024-03-07 18:02:33 -05:00
Kevin Newton
ec159fc8ba [ruby/prism] Support parsing streams
efdc2b7222
2024-03-07 20:40:39 +00:00
Kevin Newton
76e11595e2 [ruby/prism] Fix up tilde heredoc line continuations
15e74b2f65
2024-03-07 20:25:24 +00:00
John Hawthorn
18ee7c9a10 Clear all refined CCs on reopening refinement mod
In cfd7729ce7 we started using inline
caches for refinements. However, we weren't clearing inline caches when
defined on a reopened refinement module.

Fixes [Bug #20246]
2024-03-07 10:06:48 -08:00
Koichi ITO
0e4bfd08e5 [ruby/prism] Fix an AST and token incompatibility for Prism::Translation::Parser
Fixes https://github.com/ruby/prism/pull/2506.

This PR fixes an AST and token incompatibility between Parser gem and `Prism::Translation::Parser`
for symbols quoted with line breaks.

06ab4df8cd
2024-03-07 14:05:20 +00:00
Nobuyoshi Nakada
d3279a0c11
[Bug #20327] Do not count subsecond to calculate UTC offset
Assume that there will never be any time zones with UTC offsets that
are subseconds.  Historically, UTC offset has only been used down to
the second.
2024-03-07 13:08:37 +09:00
Kevin Newton
d266b71467 [ruby/prism] Use the diagnostic types in the parser translation layer
1a8a0063dc
2024-03-06 21:42:54 -05:00
Kevin Newton
4b5fc91617 [ruby/prism] Fix implicit local variables in hashes
05e0c6792c
2024-03-06 21:37:26 +00:00
Kevin Newton
1966b5c8c6 [ruby/prism] Only run ripper tests on 3.3+
f8b973e8cd
2024-03-06 16:43:05 +00:00
Kevin Newton
294fe8490b [ruby/prism] Simplify ripper tests in ripper translation
a66d066162
2024-03-06 16:43:03 +00:00
Kevin Newton
2574e783f4 [ruby/prism] Stop looking at generated tree in ripper translation
3f59d07388
2024-03-06 16:43:03 +00:00
Kevin Newton
507ffc9686 [ruby/prism] Better handle splats in MRHS in rescues in ripper translation
36a0b2e45a
2024-03-06 16:43:02 +00:00
Kevin Newton
8528e765b7 [ruby/prism] Handle single splat in rescue in ripper translation
76cf29e68d
2024-03-06 16:43:02 +00:00
Kevin Newton
d23ebdfa6d [ruby/prism] Support elsif in ripper translation
0c008fcf34
2024-03-06 16:43:02 +00:00
Kevin Newton
06d36f7d6d [ruby/prism] Correctly detect void stmts in classes and modules in ripper translation
1729e8aec0
2024-03-06 16:43:01 +00:00
Kevin Newton
8c04d7e33c [ruby/prism] Handle empty programs in ripper translation
b607e3a98d
2024-03-06 16:43:01 +00:00
Kevin Newton
fa1db73335 [ruby/prism] Fix up blocks for index nodes in ripper translation
a35eadce47
2024-03-06 16:43:01 +00:00
Kevin Newton
554ad9dc1c [ruby/prism] Allow rescue modifier after MRHS in ripper translation
37db4d8c2d
2024-03-06 16:43:00 +00:00
Kevin Newton
46e9f71a91 [ruby/prism] Handle empty parentheses in lambda in ripper translation
e0a836ebc2
2024-03-06 16:43:00 +00:00
Kevin Newton
059f28eaac [ruby/prism] Handle empty embedded expressions in ripper translation
99eca8b1d2
2024-03-06 16:43:00 +00:00
Kevin Newton
1dae34f1c6 [ruby/prism] Implement string concat for ripper translation
6019342278
2024-03-06 16:42:59 +00:00
Kevin Newton
3c95848770 [ruby/prism] Share argument logic with calls and keywords in ripper translation
240bb08c2c
2024-03-06 16:42:59 +00:00
Kevin Newton
f75aa767f7 [ruby/prism] Better handle splat in MRHS
8331874218
2024-03-06 16:42:59 +00:00
Kevin Newton
cdb47b1b3a [ruby/prism] Handle numbered parameters in ripper translation
cf21c08c0b
2024-03-06 16:42:58 +00:00
Kevin Newton
f96ce41ac8 [ruby/prism] Disallow keywords as method names in ripper translation
dc74428e2e
2024-03-06 16:42:58 +00:00
Kevin Newton
14877e737b [ruby/prism] Split up multi target visits for methods in ripper translation
4e7733491f
2024-03-06 16:42:58 +00:00
Kevin Newton
9018e46cc2 [ruby/prism] Better split between fcall and command for ripper translation
972fe60aea
2024-03-06 16:42:57 +00:00
Kevin Newton
409a49c832 [ruby/prism] Handle trailing commas in method calls for ripper translation
fe10b5f49f
2024-03-06 16:42:57 +00:00
Kevin Newton
dad21783ac [ruby/prism] Better handle hash pattern in ripper translation
4639803277
2024-03-06 16:42:57 +00:00
Kevin Newton
2a051b0140 [ruby/prism] Share argument handling in super nodes in ripper translation
f315bdb45d
2024-03-06 16:42:57 +00:00
Kevin Newton
4304f5b6fb [ruby/prism] Fix up method naming in ripper translation
06a89c3540
2024-03-06 16:42:56 +00:00
Kevin Newton
d38894c156 [ruby/prism] Fix up symbols that look like cvar/ivar/gvar in ripper translation
64e8190da0
2024-03-06 16:42:56 +00:00
Kevin Newton
7d3f3ac983 [ruby/prism] Handle MRHS in ripper translation
6088ca1152
2024-03-06 16:42:56 +00:00
Kevin Newton
ae3f385c5f [ruby/prism] Fix up block arguments node for ripper translation
81feef447a
2024-03-06 16:42:55 +00:00
Kevin Newton
be5d99f7a2 [ruby/prism] Fix up MLHS posts in ripper translation
1f16df1f9e
2024-03-06 16:42:55 +00:00
Kevin Newton
712e841a4e [ruby/prism] Better void stmt detection for comments in ripper translation
36bae94f06
2024-03-06 16:42:54 +00:00
Kevin Newton
c6299dda3d [ruby/prism] Fix up begin node clause semicolon detection in ripper translation
117c7418af
2024-03-06 16:42:54 +00:00
Kevin Newton
ff9df28955 [ruby/prism] Fix up case consequent in ripper translation
9c298f294d
2024-03-06 16:42:54 +00:00
Kevin Newton
f4d1a36ab3 [ruby/prism] Fix up void stmt generation in ripper translation
27a427bc22
2024-03-06 16:42:53 +00:00
Kevin Newton
66356577d9 [ruby/prism] Consolidate symbol key handling in ripper translation
f4f7f8fc87
2024-03-06 16:42:53 +00:00
Kevin Newton
6361e37f3f [ruby/prism] Tilde heredocs for ripper translation
de9e55dd43
2024-03-06 16:42:53 +00:00
Kevin Newton
75e24a74d9 [ruby/prism] Implement call shorthand for ripper translation
4d08736bd5
2024-03-06 16:42:52 +00:00
Kevin Newton
8b721fcd06 [ruby/prism] Fix up multi write parentheses in ripper translation
41c84df423
2024-03-06 16:42:52 +00:00
Kevin Newton
d8cce33f07 [ruby/prism] Fix up body semicolon finding in ripper translation
8fa476d9a1
2024-03-06 16:42:52 +00:00
Kevin Newton
434e7bc56e [ruby/prism] Fix up backtick events on ripper translation
87538f1a12
2024-03-06 16:42:51 +00:00
Kevin Newton
6539258dcc [ruby/prism] Implement ternaries in ripper translation
8b14a85a4c
2024-03-06 16:42:51 +00:00