prism 2.0.0.rc1-x86_64-linux-gnu → 2.0.0-x86_64-linux-gnu
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -2
- data/CODE_OF_CONDUCT.md +1 -1
- data/LICENSE.md +1 -1
- data/docs/serialization.md +20 -6
- data/ext/prism/api_node.c +81 -81
- data/ext/prism/extension.c +54 -69
- data/ext/prism/extension.h +1 -1
- data/include/prism/arena.h +8 -0
- data/include/prism/arena.hpp +42 -0
- data/include/prism/ast.h +11 -1
- data/include/prism/ast.hpp +641 -0
- data/include/prism/buffer.h +8 -0
- data/include/prism/buffer.hpp +55 -0
- data/include/prism/comments.h +17 -0
- data/include/prism/compiler/accel.h +3 -1
- data/include/prism/compiler/branch.h +26 -0
- data/include/prism/compiler/bswap.h +46 -0
- data/include/prism/compiler/cplusplus.hpp +16 -0
- data/include/prism/compiler/endianness.h +34 -0
- data/include/prism/compiler/exceptions.hpp +17 -0
- data/include/prism/compiler/format.h +2 -0
- data/include/prism/compiler/lifetimebound.hpp +25 -0
- data/include/prism/constant_pool.h +25 -0
- data/include/prism/diagnostic.h +18 -0
- data/include/prism/errors_format.h +8 -0
- data/include/prism/internal/buffer.h +3 -0
- data/include/prism/internal/node.h +8 -4
- data/include/prism/internal/parser.h +20 -0
- data/include/prism/internal/stringy.h +1 -6
- data/include/prism/internal/xxh3.h +16 -0
- data/include/prism/json.h +8 -0
- data/include/prism/line_offset_list.h +8 -0
- data/include/prism/magic_comments.h +18 -0
- data/include/prism/node.h +55 -10
- data/include/prism/node.hpp +272 -0
- data/include/prism/node_type.hpp +38 -0
- data/include/prism/options.h +10 -1
- data/include/prism/options.hpp +43 -0
- data/include/prism/parser.h +93 -64
- data/include/prism/parser.hpp +274 -0
- data/include/prism/prettyprint.h +8 -0
- data/include/prism/serialize.h +8 -0
- data/include/prism/source.h +8 -0
- data/include/prism/stream.h +8 -0
- data/include/prism/string_query.h +19 -0
- data/include/prism/stringy.h +16 -27
- data/include/prism/stringy.hpp +31 -0
- data/include/prism/version.h +9 -1
- data/include/prism.h +0 -8
- data/include/prism.hpp +24 -0
- data/lib/prism/3.3/prism.so +0 -0
- data/lib/prism/3.4/prism.so +0 -0
- data/lib/prism/4.0/prism.so +0 -0
- data/lib/prism/ffi.rb +6 -0
- data/lib/prism/node.rb +736 -0
- data/lib/prism/parse_result.rb +23 -8
- data/lib/prism/serialize.rb +2567 -3286
- data/lib/prism/string_query.rb +8 -0
- data/prism.gemspec +21 -4
- data/rbi/generated/prism/node.rbi +2430 -968
- data/rbi/generated/prism/parse_result.rbi +16 -4
- data/rbi/generated/prism/serialize.rbi +8 -4
- data/rbi/generated/prism/string_query.rbi +7 -0
- data/sig/generated/prism/node.rbs +2439 -967
- data/sig/generated/prism/parse_result.rbs +16 -4
- data/sig/generated/prism/serialize.rbs +9 -4
- data/sig/generated/prism/string_query.rbs +7 -0
- data/src/buffer.c +9 -0
- data/src/comments.c +2 -2
- data/src/diagnostic.c +8 -0
- data/src/node.c +216 -368
- data/src/options.c +7 -13
- data/src/parser.c +70 -48
- data/src/prism.c +581 -419
- data/src/regexp.c +0 -1
- data/src/serialize.c +2301 -1950
- data/src/source.c +8 -2
- data/src/string_query.c +14 -0
- data/src/stringy.c +3 -33
- data/src/xxh3.c +292 -0
- metadata +20 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d049e300ef2d9c5af5bd441bbadbcdff214d807763871245df453fc7ff19a1f7
|
|
4
|
+
data.tar.gz: 0add7f7ee8b9d36545edf64fd6dcbb8ec807d9f2538775c7e03b0bf1168c4421
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 48411e04db366ce83feef1f3dbff740178d47087b3712ec97b8d1cfd131ee19108d93fc1f8ee1fea3fffa0771cfb948b9d5e822a02bd5c6a0ed2bd216674d867
|
|
7
|
+
data.tar.gz: b6f406a99be3901c67bfc7c38476d164db22c17610190f5edb9c4a7e5a125c5dfa1eac294bba1b3a8a1d10064f1386bdf7e2da4329328b932731a1702722e5ba
|
data/CHANGELOG.md
CHANGED
|
@@ -6,12 +6,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [2.0.0] - 2026-10-21
|
|
10
|
+
|
|
9
11
|
### Highlights
|
|
10
12
|
|
|
11
13
|
- Significant performance and memory usage improvements.
|
|
12
14
|
- Precompiled platform-specific variants on rubygems.org.
|
|
13
15
|
- Many documentation improvements, including a new playground.
|
|
14
16
|
- Prism now ships accurate and complete RBS and RBI definitions.
|
|
17
|
+
- The license is now owned by the Ruby developers.
|
|
18
|
+
- Prism now ships an official C++ interface.
|
|
15
19
|
|
|
16
20
|
### Added
|
|
17
21
|
|
|
@@ -29,6 +33,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
|
29
33
|
- Allow pattern matching with prism nodes to match on location slices, like `node in Prism::StringNode[content: "foo"]`.
|
|
30
34
|
- `Prism.parse_file` and similar now accept anything responding to `to_path` (like `Pathname`) directly.
|
|
31
35
|
- `attach_comments` was added as a valid option. Each comment is attached to the node that ends latest on the comment's line before it, otherwise to the innermost node that contains it (or to that node's statements, if only whitespace and comments come between the comment and the statements), otherwise to the top-level statements. The attached comments are available through `Node#comments` and through `pm_node_comments_size` and `pm_node_comment` in the C API, as well as `pm_parser_comment_attachment`, `pm_parser_comment_ranges_size`, and `pm_parser_comment_range`, which expose the attachments grouped by node. When the option is set, the comments on the parse result are sorted by start offset.
|
|
36
|
+
- `StringQuery#keyword?` was added to check if the string query matches a keyword.
|
|
37
|
+
- `Source#checksum` was added to retrieve the checksum of the source content.
|
|
32
38
|
|
|
33
39
|
### Changed
|
|
34
40
|
|
|
@@ -64,6 +70,9 @@ Note that for this major version, almost every change listed below is breaking.
|
|
|
64
70
|
- Most allocations are now performed through an arena.
|
|
65
71
|
- You may now build side tables of comment attachments through the `attach_comments` option.
|
|
66
72
|
- `newline_list` was renamed to `list_offset_list`.
|
|
73
|
+
- Visitor callbacks passed to `pm_visit_node` and `pm_visit_child_nodes` now return a `pm_visit_result_t` instead of a `bool`. Returning `PM_VISIT_DESCEND` or `PM_VISIT_SKIP` replaces returning `true` or `false`, and returning `PM_VISIT_STOP` ends the walk. Both functions now return `false` if the walk was stopped.
|
|
74
|
+
- `pm_string_t` is now a view of bytes owned by someone else. It no longer has a `type` field, `pm_string_owned_init` was removed, and `pm_string_constant_init` was renamed to `pm_string_init`, which takes the bytes as `const uint8_t *`.
|
|
75
|
+
- `pm_options_free` no longer frees the names of scope locals. The parser copies them when it is created, so they only need to remain valid until then.
|
|
67
76
|
|
|
68
77
|
#### Rust
|
|
69
78
|
|
|
@@ -71,6 +80,7 @@ Note that for this major version, almost every change listed below is breaking.
|
|
|
71
80
|
- Most allocations are now performed through an arena.
|
|
72
81
|
- `newline_list` was renamed to `list_offset_list`.
|
|
73
82
|
- `Diagnostic::message` now returns `&[u8]` instead of `&str`.
|
|
83
|
+
- `StringQuery` is now exposed.
|
|
74
84
|
|
|
75
85
|
#### JavaScript
|
|
76
86
|
|
|
@@ -827,8 +837,9 @@ Note that for this major version, almost every change listed below is breaking.
|
|
|
827
837
|
|
|
828
838
|
- 🎉 Initial release! 🎉
|
|
829
839
|
|
|
830
|
-
[unreleased]: https://github.com/ruby/prism/compare/
|
|
831
|
-
[
|
|
840
|
+
[unreleased]: https://github.com/ruby/prism/compare/v2.0.0...HEAD
|
|
841
|
+
[2.0.0]: https://github.com/ruby/prism/compare/v1.9.0...v2.0.0
|
|
842
|
+
[1.9.0]: https://github.com/ruby/prism/compare/v1.8.1...v1.9.0
|
|
832
843
|
[1.8.1]: https://github.com/ruby/prism/compare/v1.8.0...v1.8.1
|
|
833
844
|
[1.8.0]: https://github.com/ruby/prism/compare/v1.7.0...v1.8.0
|
|
834
845
|
[1.7.0]: https://github.com/ruby/prism/compare/v1.6.0...v1.7.0
|
data/CODE_OF_CONDUCT.md
CHANGED
|
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
|
|
|
55
55
|
## Enforcement
|
|
56
56
|
|
|
57
57
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
-
reported by contacting the project team at
|
|
58
|
+
reported by contacting the project team at ruby-core@ruby-lang.org. All
|
|
59
59
|
complaints will be reviewed and investigated and will result in a response that
|
|
60
60
|
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
61
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
data/LICENSE.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright 2022-present,
|
|
1
|
+
Copyright 2022-present, Ruby developers
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
data/docs/serialization.md
CHANGED
|
@@ -106,6 +106,7 @@ The header is structured like the following table:
|
|
|
106
106
|
| `1` | 1 indicates only semantics fields were serialized, 0 indicates all fields were serialized (including location fields) |
|
|
107
107
|
| string | the encoding name |
|
|
108
108
|
| varsint | the start line |
|
|
109
|
+
| `8` | the checksum of the source up to the end of the `__END__` line in native endian order, see `pm_parser_checksum` |
|
|
109
110
|
| varuint | number of newline offsets |
|
|
110
111
|
| varuint* | newline offsets |
|
|
111
112
|
| varuint | number of comments |
|
|
@@ -124,8 +125,14 @@ The header is structured like the following table:
|
|
|
124
125
|
| varuint | content pool size |
|
|
125
126
|
|
|
126
127
|
After the header comes the body of the serialized string.
|
|
127
|
-
The body consists of a sequence of nodes that is built using a
|
|
128
|
-
|
|
128
|
+
The body consists of a sequence of nodes that is built using a postfix traversal order of the syntax tree: the children of each node come before the node itself, so the root node comes last.
|
|
129
|
+
The body ends at the content pool offset specified in the header.
|
|
130
|
+
|
|
131
|
+
The children of a node are the values of its `node`, `node?`, and `node[]` fields, which are serialized in the order in which the fields are listed in `config.yml`.
|
|
132
|
+
A `node` field is serialized as its node, a `node?` field is serialized as its node or as a single `0` byte if the node is not present, and a `node[]` field is serialized as each of its nodes in order.
|
|
133
|
+
A loader can therefore keep a stack of loaded nodes: a `0` byte pushes an absent node, and each node pops its children off the top of the stack (they are in field order) and then pushes itself.
|
|
134
|
+
|
|
135
|
+
After its children, each node is structured like the following table:
|
|
129
136
|
|
|
130
137
|
| # bytes | field |
|
|
131
138
|
| --- | --- |
|
|
@@ -134,12 +141,11 @@ Each node is structured like the following table:
|
|
|
134
141
|
| location | node location |
|
|
135
142
|
| varuint | node flags |
|
|
136
143
|
|
|
137
|
-
Every field on the node is then appended to the serialized string. The fields can be determined by referencing `config.yml`. Depending on the type of field, it could take a couple of different forms, described below:
|
|
144
|
+
Every other field on the node is then appended to the serialized string. The fields can be determined by referencing `config.yml`. Depending on the type of field, it could take a couple of different forms, described below:
|
|
138
145
|
|
|
139
146
|
* `double` - A field that is a `double`. This is structured as a sequence of 8 bytes in native endian order.
|
|
140
|
-
* `node` -
|
|
141
|
-
* `node
|
|
142
|
-
* `node[]` - A field that is an array of nodes. This is structured as a variable-length integer length, followed by the child nodes themselves.
|
|
147
|
+
* `node`, `node?` - Nothing is appended here, since the node has already been serialized as a child.
|
|
148
|
+
* `node[]` - A field that is an array of nodes. This is structured as a variable-length integer length, which is the number of children that belong to this field.
|
|
143
149
|
* `string` - A field that is a string. For example, this is used as the name of the method in a call node, since it cannot directly reference the source string (as in `@-` or `foo=`). This is structured as a variable-length integer byte length, followed by the string bytes (_without_ a trailing null byte).
|
|
144
150
|
* `constant` - A variable-length integer that represents an index in the constant pool.
|
|
145
151
|
* `constant?` - An optional variable-length integer that represents an index in the constant pool. If it's not present, then a single `0` byte will be written in its place.
|
|
@@ -149,6 +155,14 @@ Every field on the node is then appended to the serialized string. The fields ca
|
|
|
149
155
|
* `uint8` - A field that is an 8-bit unsigned integer. This is structured as a single byte.
|
|
150
156
|
* `uint32` - A field that is a 32-bit unsigned integer. This is structured as a variable-length integer.
|
|
151
157
|
|
|
158
|
+
The `body` field of a `DefNode` is lazy, which means that loaders can skip it and load it later. The children of a `DefNode` are preceded by the following, which loaders that do not skip lazy fields can ignore:
|
|
159
|
+
|
|
160
|
+
| # bytes | field |
|
|
161
|
+
| --- | --- |
|
|
162
|
+
| `1` | `255` |
|
|
163
|
+
| `4` | the byte length of the children that come before the `body` child |
|
|
164
|
+
| `4` | the byte length of the `body` child |
|
|
165
|
+
|
|
152
166
|
After the syntax tree, the content pool is serialized. This is a list of constants that were referenced from within the tree. The content pool begins at the offset specified in the header. Every constant is embedded in the serialization. Each constant is structured as follows:
|
|
153
167
|
|
|
154
168
|
| # bytes | field |
|