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

868 Коммитов

Автор SHA1 Сообщение Дата
Kevin Newton 4ede15fb53 [PRISM] Fix up nested string flags inside string concatenation 2024-08-26 10:49:35 -04:00
Alexander Momchilov 2b0b68fa46 Shrink `pm_integer_t` (32 bytes → 24) 2024-08-26 12:38:58 +00:00
Nobuyoshi Nakada 620ce3807b
[Bug #20680] `ensure` block is always void context 2024-08-25 08:16:54 +09:00
Kevin Newton 3eb42054d9 [ruby/prism] Pass Unicode escapes on to onigmo
When we encounter an invalid unicode escape within a regular
expression, we now pass that error on to Onigmo as if it didn't
exist in the parser (which matches the upstream parser's behavior).

We do this because there are tests that specify that you are
allowed to have invalid Unicode escapes if they are within the
context of a regular expression comment for a regular expression
in extended mode. That looks like:

    /# \u /x

Note that this _only_ applies to Unicode escapes (as opposed to
applying to hex or meta/control escapes as well). Importantly it
also only applies if the regular expression is terminated. An
unterminated regular expression will still get error handling done
in the parser. That would look like:

    /# \u

that would result in the same error handling we have today.

https://github.com/ruby/prism/commit/fb98034806
2024-08-23 19:18:14 +00:00
Kevin Newton 3f30c4df8c [ruby/prism] Update templates/include/prism/ast.h.erb
https://github.com/ruby/prism/commit/7f7620b6d5
2024-08-22 15:23:33 +00:00
Alexander Momchilov 0ef703b91c [ruby/prism] Render node comments into their `ast.h`
https://github.com/ruby/prism/commit/b17c3241d3
2024-08-22 15:23:32 +00:00
Kevin Newton d57486cb10 [ruby/prism] Turn off extended mode when parsing extended group
https://github.com/ruby/prism/commit/098b3f08bc
2024-08-22 14:43:35 +00:00
Kevin Newton 5cb6954baa [ruby/prism] Fix up lex result constants
https://github.com/ruby/prism/commit/084baca463
2024-08-15 16:50:00 +00:00
Kevin Newton cbf508da58 [ruby/prism] Special error for too short unicode errors
https://github.com/ruby/prism/commit/9f1f7d08bd
2024-08-15 16:40:05 +00:00
Kevin Newton a952ea243f [ruby/prism] Callback on shebang switches
Add the ability to receive a callback when the parser encounters a
shebang that contains additional switches after the Ruby engine.
This is necessary because some command-line flags may be present
there that will alter the parse.

https://github.com/ruby/prism/commit/afc5000331
2024-08-14 17:40:43 +00:00
Kevin Newton a6581114b0 [ruby/prism] Fix up spacing in generated node.rb
https://github.com/ruby/prism/commit/50d79b734b
2024-08-13 12:41:07 +00:00
Koichi ITO ad23bbe574 [ruby/prism] [Doc] Tweak the docs for lex APIs
`Prism.lex` and `Prism.lex_file` return `ParseLexResult` instead of `Array`.
`Prism::parse_lex` and `Prism::parse_lex_file` return `ParseLexResult` instead of `ParseResult`.
This PR updates the documentation to reflect these return values.

https://github.com/ruby/prism/commit/ee331941c0
2024-08-10 08:42:36 +00:00
Yuta Saito a65c205a1b [ruby/prism] Add explicit check for PRISM_HAS_NO_FILESYSTEM
https://github.com/ruby/prism/commit/89c22f0e6c
2024-07-26 17:07:50 +00:00
Yuta Saito 1992bd31a5 [ruby/prism] Fallback to pm_string_file_init on platforms without memory-mapped files
> ..., and on other POSIX systems we'll use `read`.

As `pm_string_mapped_init`'s doc comment says, it should fall back to
`read(2)`-based implementation on platforms without memory-mapped files
like WASI, but it didn't. This commit fixes it by calling `pm_string_file_init`
in the fallback case.
Also `defined(_POSIX_MAPPED_FILES)` check for `read(2)`-based path is
unnecessary, and it prevents the fallback from being executed, so this
change removes it.

https://github.com/ruby/prism/commit/b3d9064b71
2024-07-26 17:07:50 +00:00
Benoit Daloze 53f0d3b1f7 [ruby/prism] Do not serialize common flags when PRISM_SERIALIZE_ONLY_SEMANTICS_FIELDS is set
* Note that we could shift the flags by 2 on serialize & deserialize
  but it does not seems worth it as it does not save serialized size
  in any significant amount, i.e. average was 0.799 before #2924.
* $ bundle exec rake serialized_size:topgems
Before:
Total sizes for top 100 gems:
total source size:      90207647
total serialized size:  69477115
total serialized/total source: 0.770

Stats of ratio serialized/source per file:
average: 0.844
median:  0.825
1st quartile: 0.597
3rd quartile: 1.064
min - max: 0.078 - 3.792

After:
Total sizes for top 100 gems:
total source size:      90207647
total serialized size:  66150209
total serialized/total source: 0.733

Stats of ratio serialized/source per file:
average: 0.800
median:  0.779
1st quartile: 0.568
3rd quartile: 1.007
min - max: 0.076 - 3.675

https://github.com/ruby/prism/commit/e012072f70
2024-07-25 11:39:05 +00:00
Benoit Daloze 9cc2747ebb [ruby/prism] Do not serialize node_id when PRISM_SERIALIZE_ONLY_SEMANTICS_FIELDS is set
* $ bundle exec rake serialized_size:topgems
Before:
Total sizes for top 100 gems:
total source size:      90207647
total serialized size:  86284647
total serialized/total source: 0.957

Stats of ratio serialized/source per file:
average: 0.952
median:  0.937
1st quartile: 0.669
3rd quartile: 1.206
min - max: 0.080 - 4.065

After:
Total sizes for top 100 gems:
total source size:      90207647
total serialized size:  69477115
total serialized/total source: 0.770

Stats of ratio serialized/source per file:
average: 0.844
median:  0.825
1st quartile: 0.597
3rd quartile: 1.064
min - max: 0.078 - 3.792

https://github.com/ruby/prism/commit/cf90fe5759
2024-07-25 11:39:04 +00:00
Kevin Newton 575fe63e20 [ruby/prism] Inherit ractor state for child scopes
https://github.com/ruby/prism/commit/4576cb1d96
2024-07-24 16:24:21 +00:00
Nobuyoshi Nakada e642ddf7ae
[Bug #20647] Disallow `return` directly within a singleton class 2024-07-24 14:44:32 +09:00
Kevin Newton cb863907d8 [ruby/prism] Single line method bodies should not be marked as newline
https://github.com/ruby/prism/commit/18a8597276
2024-07-23 18:44:31 +00:00
Kevin Newton 744cf0549e [ruby/prism] Recurse upward to detect invalid returns
https://github.com/ruby/prism/commit/3d39b7961f
2024-07-23 14:54:01 +00:00
Kevin Newton 959c95a01e [ruby/prism] Ignore shebangs in evals
https://github.com/ruby/prism/commit/4c55409794
2024-07-22 19:46:26 +00:00
Kevin Newton 2effa98b6f [ruby/prism] Implement mismatched indentation warning
https://github.com/ruby/prism/commit/5d5bf92be8
2024-07-22 18:57:10 +00:00
Kevin Newton 1e4c4fe478 [ruby/prism] Fix parsing parentheses in hash patterns
https://github.com/ruby/prism/commit/22c3b559cd
2024-07-19 12:55:49 +00:00
Kevin Newton 059535bd65 [ruby/prism] Mark local variable writes in value positions as being read
https://github.com/ruby/prism/commit/f5149870ab
2024-07-18 19:38:53 +00:00
Kevin Newton 8e5ac5a87d [PRISM] Ensure not opening directories 2024-07-18 13:03:25 -04:00
Kevin Newton e77e4aa608 [ruby/prism] Have parse_stream handle NUL bytes
https://github.com/ruby/prism/commit/4a41d298c8
2024-07-17 19:44:32 +00:00
Koichi ITO 0fe816f380 [ruby/prism] [Doc] Tweak example of `Prism::Dispatcher`
This PR tweaked the documentation to correct an error encountered
when running the example code of `Prism::Dispatcher`.
This aims to make understanding the example smoother.

https://github.com/ruby/prism/commit/165a1a0e78
2024-07-17 18:17:59 +00:00
Nobuyoshi Nakada 644424941a [Bug #20457] [Prism] Remove redundant return flag 2024-07-17 14:06:11 -04:00
Kevin Newton c06f79c575 [ruby/prism] Fix up implicit flags
https://github.com/ruby/prism/commit/f4152c1f50
2024-07-15 18:12:37 +00:00
Kevin Newton 6298667ff5 [ruby/prism] When parsing an invalid write, still add to the local table
https://github.com/ruby/prism/commit/a54abc4d1b
2024-07-12 13:50:00 +00:00
Kevin Newton cfaa3e9311 [ruby/prism] Bump typecheck dependencies to fix CI
https://github.com/ruby/prism/commit/c7a4a90ee8
2024-07-11 19:46:51 +00:00
Kevin Newton ac093f5a06 [PRISM] Fix up shareable constant casting 2024-07-11 14:25:54 -04:00
Kevin Newton c1df15c3e6 [PRISM] Use node ids for error highlight 2024-07-11 14:25:54 -04:00
Stan Lo be4589df80 [ruby/prism] Prevent optional block parameter from accepting certain prefixed values
This commit prevents the following unary operators from being accepted
as the value prefix of a block's optional parameter:

- `+`
- `-`
- `~`
- `!`

For example, `f { |a = +b| }` will now raise a syntax error.

https://github.com/ruby/prism/commit/3024bee60c

Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2024-07-11 14:25:54 -04:00
Kevin Newton aa473489a2 [ruby/prism] Various cleanup for initializers and typechecks
https://github.com/ruby/prism/commit/86cf82794a
2024-07-11 14:25:54 -04:00
Kevin Newton 2bf9ae3fa1 [ruby/prism] Add node ids to nodes
https://github.com/ruby/prism/commit/bf16ade7f9
2024-07-11 14:25:54 -04:00
Kevin Newton 39dcfe26ee [ruby/prism] Move Node#type and Node::type documentation
https://github.com/ruby/prism/commit/08a71f6259
2024-07-11 14:25:54 -04:00
Kevin Newton 32090e2b8d [ruby/prism] Add Node#breadth_first_search
https://github.com/ruby/prism/commit/1ffb141199
2024-07-11 14:25:54 -04:00
Kevin Newton aca42a2478 [ruby/prism] Expose common flags in inspect output
https://github.com/ruby/prism/commit/d0143865c2
2024-07-11 14:25:54 -04:00
Kevin Newton 687be43c79 [ruby/prism] Expose flags on every node type
https://github.com/ruby/prism/commit/9f12a56fd6
2024-07-11 14:25:54 -04:00
Kevin Newton ca48fb76fb [ruby/prism] Move location to second position for node initializers
https://github.com/ruby/prism/commit/4cc0eda4ca
2024-07-11 14:25:54 -04:00
Kevin Newton 0ac9c6dc10 [ruby/prism] Fix up find and array patterns with multiple rests
https://github.com/ruby/prism/commit/035890a839
2024-07-01 15:22:40 +00:00
Kevin Newton 8fb2227205 [ruby/prism] Properly support parsing regexp in extended mode
https://github.com/ruby/prism/commit/bedc4585ed
2024-07-01 14:42:10 +00:00
Kevin Newton ce7299d09a [ruby/prism] Handle block exits under modifiers
https://github.com/ruby/prism/commit/6b78f5309b
2024-06-26 20:46:27 +00:00
Andrew Konchin a47c152ab5 [ruby/prism] Fix documentation comment in generated with templates files
Fix warning
```
/******************************************************************************/
^
warning: [dangling-doc-comments] documentation comment is not attached to any declaration

```
in Nodes.java and AbstractNodeVisitor.java files. /** is treated as a starting of a javadoc comment.

https://github.com/ruby/prism/commit/c83d7844b8
2024-06-25 20:15:25 +00:00
Yusuke Endoh 9a22d4b9a0 [ruby/prism] Update `#line` that was missed to update
Follow up https://github.com/ruby/prism/commit/1a2626be275d

https://github.com/ruby/prism/commit/8174aac929
2024-06-21 12:32:04 +00:00
Yusuke Endoh c3b5b98e15 [ruby/prism] Set `#line" directives to respect the path in ruby/ruby repo
ruby/ruby measures test coverage of C code, but the `#line` directive
generated by prism points to a file that does not exist, so coverage is
not taken properly.

This changeset specifies the location of the source files as a relative
path in terms of ruby/ruby repo.

https://github.com/ruby/prism/commit/1a2626be27
2024-06-20 12:36:18 +00:00
Kevin Newton c93b70cfdd [ruby/prism] Make sure Init_prism is visible for extension
https://github.com/ruby/prism/commit/4601d3adfd
2024-06-19 00:06:01 +00:00
Herwin 84947c515a [ruby/prism] Document MultiWriteNode fields
https://github.com/ruby/prism/commit/b6a97a43c2
2024-06-15 15:03:18 +00:00
Herwin 6184882b84 [ruby/prism] Document MultiTargetNode
https://github.com/ruby/prism/commit/b817cd25c5
2024-06-15 12:06:49 +00:00