jruby-prism-parser 0.23.0.pre.SNAPSHOT-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +401 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/CONTRIBUTING.md +62 -0
- data/LICENSE.md +7 -0
- data/Makefile +101 -0
- data/README.md +98 -0
- data/config.yml +2902 -0
- data/docs/build_system.md +91 -0
- data/docs/configuration.md +64 -0
- data/docs/cruby_compilation.md +27 -0
- data/docs/design.md +53 -0
- data/docs/encoding.md +121 -0
- data/docs/fuzzing.md +88 -0
- data/docs/heredocs.md +36 -0
- data/docs/javascript.md +118 -0
- data/docs/local_variable_depth.md +229 -0
- data/docs/mapping.md +117 -0
- data/docs/parser_translation.md +34 -0
- data/docs/parsing_rules.md +19 -0
- data/docs/releasing.md +98 -0
- data/docs/ripper.md +36 -0
- data/docs/ruby_api.md +43 -0
- data/docs/ruby_parser_translation.md +19 -0
- data/docs/serialization.md +209 -0
- data/docs/testing.md +55 -0
- data/ext/prism/api_node.c +5098 -0
- data/ext/prism/api_pack.c +267 -0
- data/ext/prism/extconf.rb +110 -0
- data/ext/prism/extension.c +1155 -0
- data/ext/prism/extension.h +18 -0
- data/include/prism/ast.h +5807 -0
- data/include/prism/defines.h +102 -0
- data/include/prism/diagnostic.h +339 -0
- data/include/prism/encoding.h +265 -0
- data/include/prism/node.h +57 -0
- data/include/prism/options.h +230 -0
- data/include/prism/pack.h +152 -0
- data/include/prism/parser.h +732 -0
- data/include/prism/prettyprint.h +26 -0
- data/include/prism/regexp.h +33 -0
- data/include/prism/util/pm_buffer.h +155 -0
- data/include/prism/util/pm_char.h +205 -0
- data/include/prism/util/pm_constant_pool.h +209 -0
- data/include/prism/util/pm_list.h +97 -0
- data/include/prism/util/pm_memchr.h +29 -0
- data/include/prism/util/pm_newline_list.h +93 -0
- data/include/prism/util/pm_state_stack.h +42 -0
- data/include/prism/util/pm_string.h +150 -0
- data/include/prism/util/pm_string_list.h +44 -0
- data/include/prism/util/pm_strncasecmp.h +32 -0
- data/include/prism/util/pm_strpbrk.h +46 -0
- data/include/prism/version.h +29 -0
- data/include/prism.h +289 -0
- data/jruby-prism.jar +0 -0
- data/lib/prism/compiler.rb +486 -0
- data/lib/prism/debug.rb +206 -0
- data/lib/prism/desugar_compiler.rb +207 -0
- data/lib/prism/dispatcher.rb +2150 -0
- data/lib/prism/dot_visitor.rb +4634 -0
- data/lib/prism/dsl.rb +785 -0
- data/lib/prism/ffi.rb +346 -0
- data/lib/prism/lex_compat.rb +908 -0
- data/lib/prism/mutation_compiler.rb +753 -0
- data/lib/prism/node.rb +17864 -0
- data/lib/prism/node_ext.rb +212 -0
- data/lib/prism/node_inspector.rb +68 -0
- data/lib/prism/pack.rb +224 -0
- data/lib/prism/parse_result/comments.rb +177 -0
- data/lib/prism/parse_result/newlines.rb +64 -0
- data/lib/prism/parse_result.rb +498 -0
- data/lib/prism/pattern.rb +250 -0
- data/lib/prism/serialize.rb +1354 -0
- data/lib/prism/translation/parser/compiler.rb +1838 -0
- data/lib/prism/translation/parser/lexer.rb +335 -0
- data/lib/prism/translation/parser/rubocop.rb +37 -0
- data/lib/prism/translation/parser.rb +178 -0
- data/lib/prism/translation/ripper.rb +577 -0
- data/lib/prism/translation/ruby_parser.rb +1521 -0
- data/lib/prism/translation.rb +11 -0
- data/lib/prism/version.rb +3 -0
- data/lib/prism/visitor.rb +495 -0
- data/lib/prism.rb +99 -0
- data/prism.gemspec +135 -0
- data/rbi/prism.rbi +7767 -0
- data/rbi/prism_static.rbi +207 -0
- data/sig/prism.rbs +4773 -0
- data/sig/prism_static.rbs +201 -0
- data/src/diagnostic.c +400 -0
- data/src/encoding.c +5132 -0
- data/src/node.c +2786 -0
- data/src/options.c +213 -0
- data/src/pack.c +493 -0
- data/src/prettyprint.c +8881 -0
- data/src/prism.c +18406 -0
- data/src/regexp.c +638 -0
- data/src/serialize.c +1554 -0
- data/src/token_type.c +700 -0
- data/src/util/pm_buffer.c +190 -0
- data/src/util/pm_char.c +318 -0
- data/src/util/pm_constant_pool.c +322 -0
- data/src/util/pm_list.c +49 -0
- data/src/util/pm_memchr.c +35 -0
- data/src/util/pm_newline_list.c +84 -0
- data/src/util/pm_state_stack.c +25 -0
- data/src/util/pm_string.c +203 -0
- data/src/util/pm_string_list.c +28 -0
- data/src/util/pm_strncasecmp.c +24 -0
- data/src/util/pm_strpbrk.c +180 -0
- metadata +156 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7ead6f42c9c521873866db1a5f121ab72544b82fdc45a80dacc303a5a3f9abb6
|
4
|
+
data.tar.gz: 21b03935e3e15cebac23f9a2b8c04515e0f8adacc8007553580115927981424a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6d90539efa94a2219d4c91b0a2d15ae7b55e103826b611239f3a80a785c2e686002c8bce8900bc5e060016987aeeb7c2befec72b41907ae7f6e95b8c6b1bbc03
|
7
|
+
data.tar.gz: 1efe46d346eb266f29e1b1166e50f9532891f1c3b741c0cc0fc2a06cc5bed9d3c450065726e134aeb690acedce2ad0e1836a60b45cfe3f361176af8a4ce9cc89
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,401 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
## [0.23.0] - 2024-02-14
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- More support for `Prism::RipperCompat` is added.
|
14
|
+
- A significantly faster offset cache for `Prism::Translation::Parser` is added for files with multibyte characters.
|
15
|
+
- `Prism::Translation::RubyParser` is added.
|
16
|
+
- `Prism::ConstantPathTarget#full_name` is added.
|
17
|
+
- `version: "3.4.0"` is added as an option that is an alias for `version: "latest"`.
|
18
|
+
- Four new APIs are added to `Prism::Location`:
|
19
|
+
- `Prism::Location#start_code_units_offset`
|
20
|
+
- `Prism::Location#end_code_units_offset`
|
21
|
+
- `Prism::Location#start_code_units_column`
|
22
|
+
- `Prism::Location#end_code_units_column`
|
23
|
+
- Invalid multibyte characters are now validated within strings, lists, and heredocs.
|
24
|
+
|
25
|
+
### Changed
|
26
|
+
|
27
|
+
- When defining `def !@`, the `name_loc` was previously only pointing to `!`, but now includes the `@`. The `name` is the same.
|
28
|
+
- `Prism::RipperCompat` has been moved to `Prism::Translation::Ripper`.
|
29
|
+
- Many of the error messages that prism produces have been changed to match the error messages that CRuby produces.
|
30
|
+
|
31
|
+
## [0.22.0] - 2024-02-07
|
32
|
+
|
33
|
+
### Added
|
34
|
+
|
35
|
+
- More support for `Prism::RipperCompat` is added.
|
36
|
+
- Support for Ruby 2.7 has been added, and the minimum Ruby requirement has been lowered to 2.7.
|
37
|
+
|
38
|
+
### Changed
|
39
|
+
|
40
|
+
- The error for an invalid source encoding has a new `:argument` level to indicate it raises an argument error.
|
41
|
+
- `BeginNode` nodes that are used when a class, singleton class, module, method definition, or block have an inline `rescue`/`ensure`/`else` now have their opening locations set to the beginning of the respective keyword.
|
42
|
+
- Improved error messages for invalid characters.
|
43
|
+
- `Prism.parse_file` and similar APIs will raise more appropriate errors when the file does not exist or cannot be mapped.
|
44
|
+
- Correctly handle the `recover` parameter for `Prism::Translation::Parser`.
|
45
|
+
|
46
|
+
## [0.21.0] - 2024-02-05
|
47
|
+
|
48
|
+
### Added
|
49
|
+
|
50
|
+
- Add the `pm_constant_pool_find` API for finding a constant.
|
51
|
+
|
52
|
+
### Changed
|
53
|
+
|
54
|
+
- Fixes for `Prism::Translation::Parser`.
|
55
|
+
- Ensure all errors flow through `parser.diagnostics.process`.
|
56
|
+
- Fix the find pattern node.
|
57
|
+
- Fix block forwarding with `NumberedParametersNode`.
|
58
|
+
- Ensure we can parse strings with invalid bytes for the encoding.
|
59
|
+
- Fix hash pairs in pattern matching.
|
60
|
+
- Properly reject operator writes on operator calls, e.g., `a.+ -= b`.
|
61
|
+
- Fix multi-byte escapes.
|
62
|
+
- Handle missing body in `begin` within the receiver of a method call.
|
63
|
+
|
64
|
+
## [0.20.0] - 2024-02-01
|
65
|
+
|
66
|
+
### Added
|
67
|
+
|
68
|
+
- String literal hash keys are now marked as frozen as static literal.
|
69
|
+
- `IndexTargetNode` now always has the `ATTRIBUTE_WRITE` flag.
|
70
|
+
- `Call*Node` nodes now have an `IGNORE_VISIBILITY` flag.
|
71
|
+
- We now support the `it` default parameter.
|
72
|
+
- Errors and warnings now have levels associated with them.
|
73
|
+
- Symbols now have correct encoding flags.
|
74
|
+
- We have now merged `parser-prism` in, which provides translation to the `whitequark/parser` AST.
|
75
|
+
- We now emit errors for invalid method definition receivers.
|
76
|
+
|
77
|
+
### Changed
|
78
|
+
|
79
|
+
- We now emit errors on invalid pinned local variables.
|
80
|
+
- When passed scopes, it is now assumed that the innermost scope is the current binding.
|
81
|
+
- We now provide better error recovery for non terminated heredocs.
|
82
|
+
- Fix for `RationalNode#value` for non-decimal integers.
|
83
|
+
- Unary symbols `!@` and `~@` now unescape to `!` and `~`, respectively.
|
84
|
+
- `frozen_string_literal: false` now works properly.
|
85
|
+
|
86
|
+
### Removed
|
87
|
+
|
88
|
+
- We've removed the `locals_body_index` field.
|
89
|
+
- We've removed the `verbose` option on the various parse APIs. Warnings are now always emitted with their associated level so that consumers can decide how to handle them.
|
90
|
+
|
91
|
+
## [0.19.0] - 2023-12-14
|
92
|
+
|
93
|
+
### Added
|
94
|
+
|
95
|
+
- `ArrayNode` now has a `contains_splat?` flag if it has a splatted element in it.
|
96
|
+
- All of the remaining encodings have been implemented.
|
97
|
+
- Allow forwarding `&` in a method that has a `...` parameter.
|
98
|
+
- Many statements that are found in non-statement positions are being properly rejected now.
|
99
|
+
- Void values are now properly checked.
|
100
|
+
- Referencing a parameter in its own default value is now properly rejected.
|
101
|
+
- `DATA`/`__END__` is now parsed as its own field on parse result (`data_loc`) as opposed to as a comment.
|
102
|
+
- Blank `*` now properly forwards into arrays.
|
103
|
+
- `ImplicitRestNode` is introduced to represent the implicit rest of a destructure.
|
104
|
+
- We now support negative start lines.
|
105
|
+
- `StringNode#heredoc?`, `InterpolatedStringNode#heredoc?`, `XStringNode#heredoc?`, and `InterpolatedXStringNode#heredoc?` are introduced.
|
106
|
+
- `NumberedParametersNode` is introduced to represent the implicit set of parameters when numbered parameters are used.
|
107
|
+
- `Prism::parse_success?` and `Prism::parse_failure?` are introduced to bypass reifying the AST.
|
108
|
+
- We now emit a warning for constant assignments in method definitions.
|
109
|
+
- We now provide flags on strings and xstrings to indicate the correct encoding.
|
110
|
+
- The hash pattern `rest` field now more accurately parses `**` and `**nil`.
|
111
|
+
- The equality operators are now properly parsed as non-associative.
|
112
|
+
|
113
|
+
### Changed
|
114
|
+
|
115
|
+
- **BREAKING**: Many fields have changed positions within their nodes. This impacts the C API and the Ruby API if you are manually creating nodes through the initializer.
|
116
|
+
- **BREAKING**: Almost all of the error messages have been updated to begin with lowercase characters to match ruby/spec.
|
117
|
+
- Unterminated strings with only plain content are now always `StringNode` as opposed to `InterpolatedStringNode`
|
118
|
+
- **BREAKING**: Call node has been split up when it is in the target position into `CallTargetNode` and `IndexTargetNode`.
|
119
|
+
|
120
|
+
## [0.18.0] - 2023-11-21
|
121
|
+
|
122
|
+
### Added
|
123
|
+
|
124
|
+
- The `ParametersNode#signature` method is added, which returns the same thing as `Method#parameters`.
|
125
|
+
- Visitor functionality has been added to the JavaScript API.
|
126
|
+
- The `Node#to_dot` API has been added to convert syntax trees to Graphviz digraphs.
|
127
|
+
- `IfNode` and `UnlessNode` now have a `then_keyword_loc` field.
|
128
|
+
- Many more encodings are now supported.
|
129
|
+
- Some new `Location` APIs have been added for dealing with characters instead of bytes, which are: `start_character_offset`, `end_character_offset`, `start_character_column`, and `end_character_column`.
|
130
|
+
- A warning has been added for when `END {}` is used within a method.
|
131
|
+
- `ConstantPathNode#full_name{,_parts}` will now raise an error if the receiver of the constant path is not itself a constant.
|
132
|
+
- The `in` keyword and the `=>` operator now respect non-associativity.
|
133
|
+
- The `..` and `...` operators now properly respect non-associativity.
|
134
|
+
|
135
|
+
### Changed
|
136
|
+
|
137
|
+
- Previously `...` in blocks was accepted, but it is now properly rejected.
|
138
|
+
- **BREAKING**: `librubyparser.*` has been renamed to `libprism.*` in the C API.
|
139
|
+
- We now properly reject floats with exponent and rational suffixes.
|
140
|
+
- We now properly reject void value expressions.
|
141
|
+
- **BREAKING**: The `--disable-static` option has been removed from the C extension.
|
142
|
+
- The rescue modifier keyword is now properly parsed in terms of precedence.
|
143
|
+
- We now properly reject defining a numbered parameter method.
|
144
|
+
- **BREAKING**: `MatchWriteNode` now has a list of `targets`, which are local variable target nodes. This is instead of `locals` which was a constant list. This is to support writing to local variables outside the current scope. It has the added benefit of providing location information for the local variable targets.
|
145
|
+
- **BREAKING**: `CaseNode` has been split into `CaseNode` and `CaseMatchNode`, the latter is used for `case ... in` expressions.
|
146
|
+
- **BREAKING**: `StringConcatNode` has been removed in favor of using `InterpolatedStringNode` as a list.
|
147
|
+
|
148
|
+
## [0.17.1] - 2023-11-03
|
149
|
+
|
150
|
+
### Changed
|
151
|
+
|
152
|
+
- Do not use constant nesting in RBI files.
|
153
|
+
|
154
|
+
## [0.17.0] - 2023-11-03
|
155
|
+
|
156
|
+
### Added
|
157
|
+
|
158
|
+
- We now properly support forwarding arguments into arrays, like `def foo(*) = [*]`.
|
159
|
+
- We now have much better documentation for the C and Ruby APIs.
|
160
|
+
- We now properly provide an error message when attempting to assign to numbered parameters from within regular expression named capture groups, as in `/(?<_1>)/ =~ ""`.
|
161
|
+
|
162
|
+
### Changed
|
163
|
+
|
164
|
+
- **BREAKING**: `KeywordParameterNode` is split into `OptionalKeywordParameterNode` and `RequiredKeywordParameterNode`. `RequiredKeywordParameterNode` has no `value` field.
|
165
|
+
- **BREAKING**: Most of the `Prism::` APIs now accept a bunch of keyword options. The options we now support are: `filepath`, `encoding`, `line`, `frozen_string_literal`, `verbose`, and `scopes`. See [the pull request](https://github.com/ruby/prism/pull/1763) for more details.
|
166
|
+
- **BREAKING**: Comments are now split into three different classes instead of a single class, and the `type` field has been removed. They are: `InlineComment`, `EmbDocComment`, and `DATAComment`.
|
167
|
+
|
168
|
+
## [0.16.0] - 2023-10-30
|
169
|
+
|
170
|
+
### Added
|
171
|
+
|
172
|
+
- `InterpolatedMatchLastLineNode#options` and `MatchLastLineNode#options` are added, which are the same methods as are exposed on `InterpolatedRegularExpressionNode` and `RegularExpressionNode`.
|
173
|
+
- The project can now be compiled with `wasi-sdk` to expose a WebAssembly interface.
|
174
|
+
- `ArgumentsNode#keyword_splat?` is added to indicate if the arguments node has a keyword splat.
|
175
|
+
- The C API `pm_prettyprint` has a much improved output which lines up closely with `Node#inspect`.
|
176
|
+
- Prism now ships with `RBS` and `RBI` type signatures (in the `/sig` and `/rbi` directories, respectively).
|
177
|
+
- `Prism::parse_comments` and `Prism::parse_file_comments` APIs are added to extract only the comments from the source code.
|
178
|
+
|
179
|
+
### Changed
|
180
|
+
|
181
|
+
- **BREAKING**: `Multi{Target,Write}Node#targets` is split up now into `lefts`, `rest`, and `rights`. This is to avoid having to scan the list in the case that there are splat nodes.
|
182
|
+
- Some bugs are fixed on `Multi{Target,Write}Node` accidentally creating additional nesting when not necessary.
|
183
|
+
- **BREAKING**: `RequiredDestructuredParameterNode` has been removed in favor of using `MultiTargetNode` in those places.
|
184
|
+
- **BREAKING**: `HashPatternNode#assocs` has been renamed to `HashPatternNode#elements`. `HashPatternNode#kwrest` has been renamed to `HashPatternNode#rest`.
|
185
|
+
|
186
|
+
## [0.15.1] - 2023-10-18
|
187
|
+
|
188
|
+
### Changed
|
189
|
+
|
190
|
+
- Fix compilation warning on assigning to bitfield.
|
191
|
+
|
192
|
+
## [0.15.0] - 2023-10-18
|
193
|
+
|
194
|
+
### Added
|
195
|
+
|
196
|
+
- `BackReferenceReadNode#name` is now provided.
|
197
|
+
- `Index{Operator,And,Or}WriteNode` are introduced, split out from `Call{Operator,And,Or}WriteNode` when the method is `[]`.
|
198
|
+
|
199
|
+
### Changed
|
200
|
+
|
201
|
+
- Ensure `PM_NODE_FLAG_COMMON_MASK` into a constant expression to fix compile errors.
|
202
|
+
- `super(&arg)` is now fixed.
|
203
|
+
- Ensure the last encoding flag on regular expressions wins.
|
204
|
+
- Fix the common whitespace calculation when embedded expressions begin on a line.
|
205
|
+
- Capture groups in regular expressions now scan the unescaped version to get the correct local variables.
|
206
|
+
- `*` and `&` are added to the local table when `...` is found in the parameters of a method definition.
|
207
|
+
|
208
|
+
## [0.14.0] - 2023-10-13
|
209
|
+
|
210
|
+
### Added
|
211
|
+
|
212
|
+
- Syntax errors are added for invalid lambda local semicolon placement.
|
213
|
+
- Lambda locals are now checked for duplicate names.
|
214
|
+
- Destructured parameters are now checked for duplicate names.
|
215
|
+
- `Constant{Read,Path,PathTarget}Node#full_name` and `Constant{Read,Path,PathTarget}Node#full_name_parts` are added to walk constant paths for you to find the full name of the constant.
|
216
|
+
- Syntax errors are added when assigning to a numbered parameter.
|
217
|
+
- `Node::type` is added, which matches the `Node#type` API.
|
218
|
+
- Magic comments are now parsed as part of the parsing process and a new field is added in the form of `ParseResult#magic_comments` to access them.
|
219
|
+
|
220
|
+
### Changed
|
221
|
+
|
222
|
+
- **BREAKING**: `Call*Node#name` methods now return symbols instead of strings.
|
223
|
+
- **BREAKING**: For loops now have their index value considered as part of the body, so depths of local variable assignments will be increased by 1.
|
224
|
+
- Tilde heredocs now split up their lines into multiple string nodes to make them easier to dedent.
|
225
|
+
|
226
|
+
## [0.13.0] - 2023-09-29
|
227
|
+
|
228
|
+
### Added
|
229
|
+
|
230
|
+
- `BEGIN {}` blocks are only allowed at the top-level, and will now provide a syntax error if they are not.
|
231
|
+
- Numbered parameters are not allowed in block parameters, and will now provide a syntax error if they are.
|
232
|
+
- Many more Ruby modules and classes are now documented. Also, many have been moved into their own files and autoloaded so that initial boot time of the gem is much faster.
|
233
|
+
- `PM_TOKEN_METHOD_NAME` is introduced, used to indicate an identifier that if definitely a method name because it has an `!` or `?` at the end.
|
234
|
+
- In the C API, arrays, assocs, and hashes now can have the `PM_NODE_FLAG_STATIC_LITERAL` flag attached if they can be compiled statically. This is used in CRuby, for example, to determine if a `duphash`/`duparray` instruction can be used as opposed to a `newhash`/`newarray`.
|
235
|
+
- `Node#type` is introduced, which returns a symbol representing the type of the node. This is useful for case comparisons when you have to compare against multiple types.
|
236
|
+
|
237
|
+
### Changed
|
238
|
+
|
239
|
+
- **BREAKING**: Everything has been renamed to `prism` instead of `yarp`. The `yp_`/`YP_` prefix in the C API has been changed to `pm_`/`PM_`. For the most part, everything should be find/replaceable.
|
240
|
+
- **BREAKING**: `BlockArgumentNode` nodes now go into the `block` field on `CallNode` nodes, in addition to the `BlockNode` nodes that used to be there. Hopefully this makes it more consistent to compile/deal with in general, but it does mean it can be a surprising breaking change.
|
241
|
+
- Escaped whitespace in `%w` lists is now properly unescaped.
|
242
|
+
- `Node#pretty_print` now respects pretty print indentation.
|
243
|
+
- `Dispatcher` was previously firing `_leave` events in the incorrect order. This has now been fixed.
|
244
|
+
- **BREAKING**: `Visitor` has now been split into `Visitor` and `Compiler`. The visitor visits nodes but doesn't return anything from the visit methods. It is suitable for taking action based on the tree, but not manipulating the tree itself. The `Compiler` visits nodes and returns the computed value up the tree. It is suitable for compiling the tree into another format. As such, `MutationVisitor` has been renamed to `MutationCompiler`.
|
245
|
+
|
246
|
+
## [0.12.0] - 2023-09-15
|
247
|
+
|
248
|
+
### Added
|
249
|
+
|
250
|
+
- `RegularExpressionNode#options` and `InterpolatedRegularExpressionNode#options` are now provided. These return integers that match up to the `Regexp#options` API.
|
251
|
+
- Greatly improved `Node#inspect` and `Node#pretty_print` APIs.
|
252
|
+
- `MatchLastLineNode` and `InterpolatedMatchLastLineNode` are introduced to represent using a regular expression as the predicate of an `if` or `unless` statement.
|
253
|
+
- `IntegerNode` now has a base flag on it.
|
254
|
+
- Heredocs that were previously `InterpolatedStringNode` and `InterpolatedXStringNode` nodes without any actual interpolation are now `StringNode` and `XStringNode`, respectively.
|
255
|
+
- `StringNode` now has a `frozen?` flag on it, which respects the `frozen_string_literal` magic comment.
|
256
|
+
- Numbered parameters are now supported, and are properly represented using `LocalVariableReadNode` nodes.
|
257
|
+
- `ImplicitNode` is introduced, which wraps implicit calls, local variable reads, or constant reads in omitted hash values.
|
258
|
+
- `YARP::Dispatcher` is introduced, which provides a way for multiple objects to listen for certain events on the AST while it is being walked. This is effectively a way to implement a more efficient visitor pattern when you have many different uses for the AST.
|
259
|
+
|
260
|
+
### Changed
|
261
|
+
|
262
|
+
- **BREAKING**: Flags fields are now marked as private, to ensure we can change their implementation under the hood. Actually querying should be through the accessor methods.
|
263
|
+
- **BREAKING**: `AliasNode` is now split into `AliasMethodNode` and `AliasGlobalVariableNode`.
|
264
|
+
- Method definitions on local variables is now correctly handled.
|
265
|
+
- Unary minus precedence has been fixed.
|
266
|
+
- Concatenating character literals with string literals is now fixed.
|
267
|
+
- Many more invalid syntaxes are now properly rejected.
|
268
|
+
- **BREAKING**: Comments now no longer include their trailing newline.
|
269
|
+
|
270
|
+
## [0.11.0] - 2023-09-08
|
271
|
+
|
272
|
+
### Added
|
273
|
+
|
274
|
+
- `Node#inspect` is much improved.
|
275
|
+
- `YARP::Pattern` is introduced, which can construct procs to match against nodes.
|
276
|
+
- `BlockLocalVariableNode` is introduced to take the place of the locations array on `BlockParametersNode`.
|
277
|
+
- `ParseResult#attach_comments!` is now provided to attach comments to locations in the tree.
|
278
|
+
- `MultiTargetNode` is introduced as the target of multi writes and for loops.
|
279
|
+
- `Node#comment_targets` is introduced to return the list of objects that can have attached comments.
|
280
|
+
|
281
|
+
### Changed
|
282
|
+
|
283
|
+
- **BREAKING**: `GlobalVariable*Node#name` now returns a symbol.
|
284
|
+
- **BREAKING**: `Constant*Node#name` now returns a symbol.
|
285
|
+
- **BREAKING**: `BlockParameterNode`, `KeywordParameterNode`, `KeywordRestParameterNode`, `RestParameterNode`, `DefNode` all have their `name` methods returning symbols now.
|
286
|
+
- **BREAKING**: `ClassNode#name` and `ModuleNode#name` now return symbols.
|
287
|
+
- **BREAKING**: `Location#end_column` is now exclusive instead of inclusive.
|
288
|
+
- `Location#slice` now returns a properly encoded string.
|
289
|
+
- `CallNode#operator_loc` is now `CallNode#call_operator_loc`.
|
290
|
+
- `CallOperatorAndWriteNode` is renamed to `CallAndWriteNode` and its structure has changed.
|
291
|
+
- `CallOperatorOrWriteNode` is renamed to `CallOrWriteNode` and its structure has changed.
|
292
|
+
|
293
|
+
## [0.10.0] - 2023-09-01
|
294
|
+
|
295
|
+
### Added
|
296
|
+
|
297
|
+
- `InstanceVariable*Node` and `ClassVariable*Node` objects now have their `name` returning a Symbol. This is because they are now part of the constant pool.
|
298
|
+
- `NumberedReferenceReadNode` now has a `number` field, which returns an Integer.
|
299
|
+
|
300
|
+
### Changed
|
301
|
+
|
302
|
+
- **BREAKING**: Various `operator_id` and `constant_id` fields have been renamed to `operator` and `name`, respectively. See [09d0a144](https://github.com/ruby/yarp/commit/09d0a144dfd519c5b5f96f0b6ee95d256e2cb1a6) for details.
|
303
|
+
- `%w`, `%W`, `%i`, `%I`, `%q`, and `%Q` literals can now span around the contents of a heredoc.
|
304
|
+
- **BREAKING**: All of the public C APIs that accept the source string now accept `const uint8_t *` as opposed to `const char *`.
|
305
|
+
|
306
|
+
## [0.9.0] - 2023-08-25
|
307
|
+
|
308
|
+
### Added
|
309
|
+
|
310
|
+
- Regular expressions can now be bound by `\n`, `\r`, and a combination of `\r\n`.
|
311
|
+
- Strings delimited by `%`, `%q`, and `%Q` can now be bound by `\n`, `\r`, and a combination of `\r\n`.
|
312
|
+
- `IntegerNode#value` now returns the value of the integer as a Ruby `Integer`.
|
313
|
+
- `FloatNode#value` now returns the value of the float as a Ruby `Float`.
|
314
|
+
- `RationalNode#value` now returns the value of the rational as a Ruby `Rational`.
|
315
|
+
- `ImaginaryNode#value` now returns the value of the imaginary as a Ruby `Complex`.
|
316
|
+
- `ClassNode#name` is now a string that returns the name of just the class, without the namespace.
|
317
|
+
- `ModuleNode#name` is now a string that returns the name of just the module, without the namespace.
|
318
|
+
- Regular expressions and strings found after a heredoc declaration but before the heredoc body are now parsed correctly.
|
319
|
+
- The serialization API now supports shared strings, which should help reduce the size of the serialized AST.
|
320
|
+
- `*Node#copy` is introduced, which returns a copy of the node with the given overrides.
|
321
|
+
- `Location#copy` is introduced, which returns a copy of the location with the given overrides.
|
322
|
+
- `DesugarVisitor` is introduced, which provides a simpler AST for use in tools that want to process fewer node types.
|
323
|
+
- `{ClassVariable,Constant,ConstantPath,GlobalVariable,InstanceVariable,LocalVariable}TargetNode` are introduced. These nodes represent the target of writes in locations where a value cannot be provided, like a multi write or a rescue reference.
|
324
|
+
- `UntilNode#closing_loc` and `WhileNode#closing_loc` are now provided.
|
325
|
+
- `Location#join` is now provided, which joins two locations together.
|
326
|
+
- `YARP::parse_lex` and `YARP::parse_lex_file` are introduced to parse and lex in one result.
|
327
|
+
|
328
|
+
### Changed
|
329
|
+
|
330
|
+
- When there is a magic encoding comment, the encoding of the first token's source string is now properly reencoded.
|
331
|
+
- Constants followed by unary `&` are now properly parsed as a call with a passed block argument.
|
332
|
+
- Escaping multi-byte characters in a string literal will now properly escape the entire character.
|
333
|
+
- `YARP.lex_compat` now has more accurate behavior when a byte-order mark is present in the file.
|
334
|
+
- **BREAKING**: `AndWriteNode`, `OrWriteNode`, and `OperatorWriteNode` have been split back up into their `0.7.0` versions.
|
335
|
+
- We now properly support spaces between the `encoding` and `=`/`:` in a magic encoding comment.
|
336
|
+
- We now properly parse `-> foo: bar do end`.
|
337
|
+
|
338
|
+
## [0.8.0] - 2023-08-18
|
339
|
+
|
340
|
+
### Added
|
341
|
+
|
342
|
+
- Some performance improvements when converting from the C AST to the Ruby AST.
|
343
|
+
- Two rust crates have been added: `yarp-sys` and `yarp`. They are as yet unpublished.
|
344
|
+
|
345
|
+
### Changed
|
346
|
+
|
347
|
+
- Escaped newlines in strings and heredocs are now handled more correctly.
|
348
|
+
- Dedenting heredocs that result in empty string nodes will now drop those string nodes from the list.
|
349
|
+
- Beginless and endless ranges in conditional expressions now properly form a flip flop node.
|
350
|
+
- `%` at the end of files no longer crashes.
|
351
|
+
- Location information has been corrected for `if/elsif` chains that have no `else`.
|
352
|
+
- `__END__` at the very end of the file was previously parsed as an identifier, but is now correct.
|
353
|
+
- **BREAKING**: Nodes that reference `&&=`, `||=`, and other writing operators have been consolidated. Previously, they were separate individual nodes. Now they are a tree with the target being the left-hand side and the value being the right-hand side with a joining `AndWriteNode`, `OrWriteNode`, or `OperatorWriteNode` in the middle. This impacts all of the nodes that match this pattern: `{ClassVariable,Constant,ConstantPath,GlobalVariable,InstanceVariable,LocalVariable}Operator{And,Or,}WriteNode`.
|
354
|
+
- **BREAKING**: `BlockParametersNode`, `ClassNode`, `DefNode`, `LambdaNode`, `ModuleNode`, `ParenthesesNode`, and `SingletonClassNode` have had their `statements` field renamed to `body` to give a hint that it might not be a `StatementsNode` (it could also be a `BeginNode`).
|
355
|
+
|
356
|
+
## [0.7.0] - 2023-08-14
|
357
|
+
|
358
|
+
### Added
|
359
|
+
|
360
|
+
- We now have an explicit `FlipFlopNode`. It has the same flags as `RangeNode`.
|
361
|
+
- We now have a syntax error when implicit and explicit blocks are passed to a method call.
|
362
|
+
- `Node#slice` is now implemented, for retrieving the slice of the source code corresponding to a node.
|
363
|
+
- We now support the `utf8-mac` encoding.
|
364
|
+
- Predicate methods have been added for nodes that have flags. For example `CallNode#safe_navigation?` and `RangeNode#exclude_end?`.
|
365
|
+
- The gem now functions on JRuby and TruffleRuby, thanks to a new FFI backend.
|
366
|
+
- Comments are now part of the serialization API.
|
367
|
+
|
368
|
+
### Changed
|
369
|
+
|
370
|
+
- Autotools has been removed from the build system, so when the gem is installed it will no longer need to go through a configure step.
|
371
|
+
- The AST for `foo = *bar` has changed to have an explicit array on the right hand side, rather than a splat node. This is more consistent with how other parsers handle this.
|
372
|
+
- **BREAKING**: `RangeNodeFlags` has been renamed to `RangeFlags`.
|
373
|
+
- Unary minus on number literals is now parsed as part of the literal, rather than a call to a unary operator. This is more consistent with how other parsers handle this.
|
374
|
+
|
375
|
+
## [0.6.0] - 2023-08-09
|
376
|
+
|
377
|
+
### Added
|
378
|
+
|
379
|
+
- 🎉 Initial release! 🎉
|
380
|
+
|
381
|
+
[unreleased]: https://github.com/ruby/prism/compare/v0.23.0...HEAD
|
382
|
+
[0.23.0]: https://github.com/ruby/prism/compare/v0.22.0...v0.23.0
|
383
|
+
[0.22.0]: https://github.com/ruby/prism/compare/v0.21.0...v0.22.0
|
384
|
+
[0.21.0]: https://github.com/ruby/prism/compare/v0.20.0...v0.21.0
|
385
|
+
[0.20.0]: https://github.com/ruby/prism/compare/v0.19.0...v0.20.0
|
386
|
+
[0.19.0]: https://github.com/ruby/prism/compare/v0.18.0...v0.19.0
|
387
|
+
[0.18.0]: https://github.com/ruby/prism/compare/v0.17.1...v0.18.0
|
388
|
+
[0.17.1]: https://github.com/ruby/prism/compare/v0.17.0...v0.17.1
|
389
|
+
[0.17.0]: https://github.com/ruby/prism/compare/v0.16.0...v0.17.0
|
390
|
+
[0.16.0]: https://github.com/ruby/prism/compare/v0.15.1...v0.16.0
|
391
|
+
[0.15.1]: https://github.com/ruby/prism/compare/v0.15.0...v0.15.1
|
392
|
+
[0.15.0]: https://github.com/ruby/prism/compare/v0.14.0...v0.15.0
|
393
|
+
[0.14.0]: https://github.com/ruby/prism/compare/v0.13.0...v0.14.0
|
394
|
+
[0.13.0]: https://github.com/ruby/prism/compare/v0.12.0...v0.13.0
|
395
|
+
[0.12.0]: https://github.com/ruby/prism/compare/v0.11.0...v0.12.0
|
396
|
+
[0.11.0]: https://github.com/ruby/prism/compare/v0.10.0...v0.11.0
|
397
|
+
[0.10.0]: https://github.com/ruby/prism/compare/v0.9.0...v0.10.0
|
398
|
+
[0.9.0]: https://github.com/ruby/prism/compare/v0.8.0...v0.9.0
|
399
|
+
[0.8.0]: https://github.com/ruby/prism/compare/v0.7.0...v0.8.0
|
400
|
+
[0.7.0]: https://github.com/ruby/prism/compare/v0.6.0...v0.7.0
|
401
|
+
[0.6.0]: https://github.com/ruby/prism/compare/d60531...v0.6.0
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
9
|
+
level of experience, education, socio-economic status, nationality, personal
|
10
|
+
appearance, race, religion, or sexual identity and orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
- Using welcoming and inclusive language
|
18
|
+
- Being respectful of differing viewpoints and experiences
|
19
|
+
- Gracefully accepting constructive criticism
|
20
|
+
- Focusing on what is best for the community
|
21
|
+
- Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
- The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
- Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
- Public or private harassment
|
29
|
+
- Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
- Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at opensource@shopify.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
72
|
+
|
73
|
+
[homepage]: https://www.contributor-covenant.org
|
74
|
+
|
75
|
+
For answers to common questions about this code of conduct, see
|
76
|
+
https://www.contributor-covenant.org/faq
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
Thank you for your interest in contributing to prism! Below are a couple of ways that you can help out.
|
4
|
+
|
5
|
+
## Discussions
|
6
|
+
|
7
|
+
The discussions page on the GitHub repository are open. If you have a question or want to discuss the project, feel free to open a new discussion or comment on an existing one. This is the best place to ask questions about the project.
|
8
|
+
|
9
|
+
## Code
|
10
|
+
|
11
|
+
If you want to contribute code, please first open or contribute to a discussion. A lot of the project is in flux, and we want to make sure that you are contributing to the right place. Once you have a discussion going, you can open a pull request with your changes. We will review your code and get it merged in.
|
12
|
+
|
13
|
+
### Ruby Features
|
14
|
+
|
15
|
+
Pattern matching and endless method definitions should be avoided as long as the latest TruffleRuby release does not support it.
|
16
|
+
|
17
|
+
## Tests
|
18
|
+
|
19
|
+
We could always use more tests! One of the biggest challenges of this project is building up a big test suite. If you want to contribute tests, feel free to open a pull request. These will get merged in as soon as possible.
|
20
|
+
|
21
|
+
The `test` Rake task will not compile libraries or the C extension, and this is intentional (to make testing against an installed version easier). If you want to test your changes, please make sure you're also running either the task:
|
22
|
+
|
23
|
+
``` sh
|
24
|
+
bundle exec rake
|
25
|
+
```
|
26
|
+
|
27
|
+
or explicitly running the `compile` task:
|
28
|
+
|
29
|
+
``` sh
|
30
|
+
bundle exec rake compile test
|
31
|
+
# or to just compile the C extension ...
|
32
|
+
bundle exec rake compile:prism test
|
33
|
+
```
|
34
|
+
|
35
|
+
To test the rust bindings (with caveats about setting up your Rust environment properly first):
|
36
|
+
|
37
|
+
``` sh
|
38
|
+
bundle exec rake compile test:rust
|
39
|
+
```
|
40
|
+
|
41
|
+
|
42
|
+
## Documentation
|
43
|
+
|
44
|
+
We could always use more documentation! If you want to contribute documentation, feel free to open a pull request. These will get merged in as soon as possible. Documenting functions or methods is always useful, but we also need more guides and tutorials. If you have an idea for a guide or tutorial, feel free to open an issue and we can discuss it.
|
45
|
+
|
46
|
+
## Developing
|
47
|
+
|
48
|
+
To get `clangd` support in the editor for development, generate the compilation database. This command will
|
49
|
+
create an ignored `compile_commands.json` file at the project root, which is used by clangd to provide functionality.
|
50
|
+
|
51
|
+
You will need `bear` which can be installed on macOS with `brew install bear`.
|
52
|
+
|
53
|
+
```sh
|
54
|
+
bundle exec rake bear
|
55
|
+
```
|
56
|
+
|
57
|
+
## Debugging
|
58
|
+
|
59
|
+
Some useful rake tasks:
|
60
|
+
|
61
|
+
- `test:valgrind` runs the test suite under valgrind to look for illegal memory access or memory leaks
|
62
|
+
- `test:gdb` and `test:lldb` run the test suite under those debuggers
|
data/LICENSE.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright 2022-present, Shopify Inc.
|
2
|
+
|
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
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Makefile
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
|
2
|
+
# V=0 quiet, V=1 verbose. other values don't work.
|
3
|
+
V = 0
|
4
|
+
V0 = $(V:0=)
|
5
|
+
Q1 = $(V:1=)
|
6
|
+
Q = $(Q1:0=@)
|
7
|
+
ECHO1 = $(V:1=@ :)
|
8
|
+
ECHO = $(ECHO1:0=@ echo)
|
9
|
+
FUZZ_OUTPUT_DIR = $(shell pwd)/fuzz/output
|
10
|
+
|
11
|
+
SOEXT := $(shell ruby -e 'puts RbConfig::CONFIG["SOEXT"]')
|
12
|
+
|
13
|
+
CPPFLAGS := -Iinclude
|
14
|
+
CFLAGS := -g -O2 -std=c99 -Wall -Werror -Wextra -Wpedantic -Wundef -Wconversion -Wno-missing-braces -fPIC -fvisibility=hidden
|
15
|
+
CC := cc
|
16
|
+
WASI_SDK_PATH := /opt/wasi-sdk
|
17
|
+
|
18
|
+
HEADERS := $(shell find include -name '*.h')
|
19
|
+
SOURCES := $(shell find src -name '*.c')
|
20
|
+
SHARED_OBJECTS := $(subst src/,build/shared/,$(SOURCES:.c=.o))
|
21
|
+
STATIC_OBJECTS := $(subst src/,build/static/,$(SOURCES:.c=.o))
|
22
|
+
|
23
|
+
all: shared static
|
24
|
+
|
25
|
+
shared: build/libprism.$(SOEXT)
|
26
|
+
static: build/libprism.a
|
27
|
+
wasm: javascript/src/prism.wasm
|
28
|
+
java-wasm: java-wasm/src/test/resources/prism.wasm
|
29
|
+
|
30
|
+
build/libprism.$(SOEXT): $(SHARED_OBJECTS)
|
31
|
+
$(ECHO) "linking $@"
|
32
|
+
$(Q) $(CC) $(DEBUG_FLAGS) $(CFLAGS) -shared -o $@ $(SHARED_OBJECTS)
|
33
|
+
|
34
|
+
build/libprism.a: $(STATIC_OBJECTS)
|
35
|
+
$(ECHO) "building $@"
|
36
|
+
$(Q) $(AR) $(ARFLAGS) $@ $(STATIC_OBJECTS) $(Q1:0=>/dev/null)
|
37
|
+
|
38
|
+
javascript/src/prism.wasm: Makefile $(SOURCES) $(HEADERS)
|
39
|
+
$(ECHO) "building $@"
|
40
|
+
$(Q) $(WASI_SDK_PATH)/bin/clang --sysroot=$(WASI_SDK_PATH)/share/wasi-sysroot/ $(DEBUG_FLAGS) -DPRISM_EXPORT_SYMBOLS -D_WASI_EMULATED_MMAN -lwasi-emulated-mman $(CPPFLAGS) $(CFLAGS) -Wl,--export-all -Wl,--no-entry -mexec-model=reactor -o $@ $(SOURCES)
|
41
|
+
|
42
|
+
java-wasm/src/test/resources/prism.wasm: Makefile $(SOURCES) $(HEADERS)
|
43
|
+
$(ECHO) "building $@"
|
44
|
+
$(Q) $(WASI_SDK_PATH)/bin/clang $(DEBUG_FLAGS) -DPRISM_EXPORT_SYMBOLS -D_WASI_EMULATED_MMAN -lwasi-emulated-mman $(CPPFLAGS) $(CFLAGS) -Wl,--export-all -Wl,--no-entry -mexec-model=reactor -lc++ -lc++abi -o $@ $(SOURCES)
|
45
|
+
|
46
|
+
build/shared/%.o: src/%.c Makefile $(HEADERS)
|
47
|
+
$(ECHO) "compiling $@"
|
48
|
+
$(Q) mkdir -p $(@D)
|
49
|
+
$(Q) $(CC) $(DEBUG_FLAGS) -DPRISM_EXPORT_SYMBOLS $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
|
50
|
+
|
51
|
+
build/static/%.o: src/%.c Makefile $(HEADERS)
|
52
|
+
$(ECHO) "compiling $@"
|
53
|
+
$(Q) mkdir -p $(@D)
|
54
|
+
$(Q) $(CC) $(DEBUG_FLAGS) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
|
55
|
+
|
56
|
+
build/fuzz.%: $(SOURCES) fuzz/%.c fuzz/fuzz.c
|
57
|
+
$(ECHO) "building $* fuzzer"
|
58
|
+
$(Q) mkdir -p $(@D)
|
59
|
+
$(ECHO) "building main fuzz binary"
|
60
|
+
$(Q) AFL_HARDEN=1 afl-clang-lto $(DEBUG_FLAGS) $(CPPFLAGS) $(CFLAGS) $(FUZZ_FLAGS) -O0 -fsanitize-ignorelist=fuzz/asan.ignore -fsanitize=fuzzer,address -ggdb3 -std=c99 -Iinclude -o $@ $^
|
61
|
+
$(ECHO) "building cmplog binary"
|
62
|
+
$(Q) AFL_HARDEN=1 AFL_LLVM_CMPLOG=1 afl-clang-lto $(DEBUG_FLAGS) $(CPPFLAGS) $(CFLAGS) $(FUZZ_FLAGS) -O0 -fsanitize-ignorelist=fuzz/asan.ignore -fsanitize=fuzzer,address -ggdb3 -std=c99 -Iinclude -o $@.cmplog $^
|
63
|
+
|
64
|
+
build/fuzz.heisenbug.%: $(SOURCES) fuzz/%.c fuzz/heisenbug.c
|
65
|
+
$(Q) AFL_HARDEN=1 afl-clang-lto $(DEBUG_FLAGS) $(CPPFLAGS) $(CFLAGS) $(FUZZ_FLAGS) -O0 -fsanitize-ignorelist=fuzz/asan.ignore -fsanitize=fuzzer,address -ggdb3 -std=c99 -Iinclude -o $@ $^
|
66
|
+
|
67
|
+
fuzz-debug:
|
68
|
+
$(ECHO) "entering debug shell"
|
69
|
+
$(Q) docker run -it --rm -e HISTFILE=/prism/fuzz/output/.bash_history -v $(shell pwd):/prism -v $(FUZZ_OUTPUT_DIR):/fuzz_output prism/fuzz
|
70
|
+
|
71
|
+
fuzz-docker-build: fuzz/docker/Dockerfile
|
72
|
+
$(ECHO) "building docker image"
|
73
|
+
$(Q) docker build -t prism/fuzz fuzz/docker/
|
74
|
+
|
75
|
+
fuzz-run-%: FORCE fuzz-docker-build
|
76
|
+
$(ECHO) "generating templates"
|
77
|
+
$(Q) bundle exec rake templates
|
78
|
+
$(ECHO) "running $* fuzzer"
|
79
|
+
$(Q) docker run --rm -v $(shell pwd):/prism prism/fuzz /bin/bash -c "FUZZ_FLAGS=\"$(FUZZ_FLAGS)\" make build/fuzz.$*"
|
80
|
+
$(ECHO) "starting AFL++ run"
|
81
|
+
$(Q) mkdir -p $(FUZZ_OUTPUT_DIR)/$*
|
82
|
+
$(Q) docker run -it --rm -v $(shell pwd):/prism -v $(FUZZ_OUTPUT_DIR):/fuzz_output prism/fuzz /bin/bash -c "./fuzz/$*.sh /fuzz_output/$*"
|
83
|
+
FORCE:
|
84
|
+
|
85
|
+
fuzz-clean:
|
86
|
+
$(Q) rm -f -r fuzz/output
|
87
|
+
|
88
|
+
clean:
|
89
|
+
$(Q) rm -f -r build
|
90
|
+
|
91
|
+
.PHONY: clean fuzz-clean
|
92
|
+
|
93
|
+
all-no-debug: DEBUG_FLAGS := -DNDEBUG=1
|
94
|
+
all-no-debug: OPTFLAGS := -O3
|
95
|
+
all-no-debug: all
|
96
|
+
|
97
|
+
run: Makefile $(STATIC_OBJECTS) $(HEADERS) test.c
|
98
|
+
$(ECHO) "compiling test.c"
|
99
|
+
$(Q) $(CC) $(CPPFLAGS) $(CFLAGS) $(STATIC_OBJECTS) test.c
|
100
|
+
$(ECHO) "running test.c"
|
101
|
+
$(Q) ./a.out
|