yarp 0.9.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +39 -1
  3. data/CONTRIBUTING.md +7 -0
  4. data/Makefile +5 -1
  5. data/config.yml +308 -166
  6. data/docs/configuration.md +0 -1
  7. data/docs/encoding.md +5 -5
  8. data/docs/mapping.md +91 -91
  9. data/docs/serialization.md +25 -22
  10. data/ext/yarp/api_node.c +1210 -483
  11. data/ext/yarp/extension.c +22 -8
  12. data/ext/yarp/extension.h +2 -2
  13. data/include/yarp/ast.h +692 -183
  14. data/include/yarp/defines.h +2 -1
  15. data/include/yarp/diagnostic.h +200 -3
  16. data/include/yarp/enc/yp_encoding.h +10 -10
  17. data/include/yarp/node.h +0 -4
  18. data/include/yarp/parser.h +19 -19
  19. data/include/yarp/regexp.h +1 -1
  20. data/include/yarp/unescape.h +4 -4
  21. data/include/yarp/util/yp_buffer.h +3 -0
  22. data/include/yarp/util/yp_char.h +16 -16
  23. data/include/yarp/util/yp_constant_pool.h +12 -5
  24. data/include/yarp/util/yp_newline_list.h +5 -5
  25. data/include/yarp/util/yp_string.h +4 -4
  26. data/include/yarp/util/yp_string_list.h +0 -3
  27. data/include/yarp/util/yp_strpbrk.h +1 -1
  28. data/include/yarp/version.h +2 -2
  29. data/include/yarp.h +5 -4
  30. data/lib/yarp/desugar_visitor.rb +59 -122
  31. data/lib/yarp/mutation_visitor.rb +22 -12
  32. data/lib/yarp/node.rb +3081 -501
  33. data/lib/yarp/parse_result/comments.rb +172 -0
  34. data/lib/yarp/parse_result/newlines.rb +60 -0
  35. data/lib/yarp/pattern.rb +239 -0
  36. data/lib/yarp/serialize.rb +152 -129
  37. data/lib/yarp.rb +109 -49
  38. data/src/diagnostic.c +254 -2
  39. data/src/enc/yp_big5.c +15 -42
  40. data/src/enc/yp_euc_jp.c +16 -43
  41. data/src/enc/yp_gbk.c +19 -46
  42. data/src/enc/yp_shift_jis.c +16 -43
  43. data/src/enc/yp_tables.c +36 -38
  44. data/src/enc/yp_unicode.c +20 -25
  45. data/src/enc/yp_windows_31j.c +16 -43
  46. data/src/node.c +1871 -1466
  47. data/src/prettyprint.c +463 -230
  48. data/src/regexp.c +21 -21
  49. data/src/serialize.c +352 -184
  50. data/src/unescape.c +152 -122
  51. data/src/util/yp_buffer.c +7 -2
  52. data/src/util/yp_char.c +35 -40
  53. data/src/util/yp_constant_pool.c +45 -12
  54. data/src/util/yp_memchr.c +1 -1
  55. data/src/util/yp_newline_list.c +10 -5
  56. data/src/util/yp_string.c +22 -20
  57. data/src/util/yp_string_list.c +4 -7
  58. data/src/util/yp_strncasecmp.c +3 -6
  59. data/src/util/yp_strpbrk.c +8 -8
  60. data/src/yarp.c +1288 -1021
  61. data/yarp.gemspec +4 -1
  62. metadata +6 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '028bafce371c205e4f9a845aa0328a8911519b064ec92be9a970c0077088ca5c'
4
- data.tar.gz: ed653e7a3734884de2f42d1df304be7eb1532b29d7acf63214c747ee84426ec0
3
+ metadata.gz: 9d096d8bdda05ec360a58c8c6d98d1aeb6680b95a983a7d10d916d4a941be1c8
4
+ data.tar.gz: 7833c692ae2547f6628d15972b539484e06804179277d8f73a33cf448687f48b
5
5
  SHA512:
6
- metadata.gz: e33c681424d19626c0ee1d5c21265bcdfce4ec56909a5707d4bf7025ea5356b5ac41b080a1e54a8490124065a1595bd5833af8e488558f0ff01c4f14a92d0430
7
- data.tar.gz: d55c0483e944f9a33e76a2baeef11841da8f8bf8755512ff90497d07b0fedf2dc568f6ad8c384831b6b382b1482e34177c6dbd8314d6570542c59faca71ad23e
6
+ metadata.gz: 6c42795d64e15210922249c5b81a7bd8a4f04f6589f8266aaf73341afbd72bde016aeafa879eddb12dd0ae75b6e2b91bba7c28599495f31030031117d12be9cf
7
+ data.tar.gz: 6534173b9aa41bf180358750198c16749279723575045fffb819040509f6ca2e4f264653ad7857af152f64f7bdb16e95cbdedaab474bb62d86f9f920c5e44d83
data/CHANGELOG.md CHANGED
@@ -6,6 +6,42 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.11.0] - 2023-09-08
10
+
11
+ ### Added
12
+
13
+ - `Node#inspect` is much improved.
14
+ - `YARP::Pattern` is introduced, which can construct procs to match against nodes.
15
+ - `BlockLocalVariableNode` is introduced to take the place of the locations array on `BlockParametersNode`.
16
+ - `ParseResult#attach_comments!` is now provided to attach comments to locations in the tree.
17
+ - `MultiTargetNode` is introduced as the target of multi writes and for loops.
18
+ - `Node#comment_targets` is introduced to return the list of objects that can have attached comments.
19
+
20
+ ### Changed
21
+
22
+ - **BREAKING**: `GlobalVariable*Node#name` now returns a symbol.
23
+ - **BREAKING**: `Constant*Node#name` now returns a symbol.
24
+ - **BREAKING**: `BlockParameterNode`, `KeywordParameterNode`, `KeywordRestParameterNode`, `RestParameterNode`, `DefNode` all have their `name` methods returning symbols now.
25
+ - **BREAKING**: `ClassNode#name` and `ModuleNode#name` now return symbols.
26
+ - **BREAKING**: `Location#end_column` is now exclusive instead of inclusive.
27
+ - `Location#slice` now returns a properly encoded string.
28
+ - `CallNode#operator_loc` is now `CallNode#call_operator_loc`.
29
+ - `CallOperatorAndWriteNode` is renamed to `CallAndWriteNode` and its structure has changed.
30
+ - `CallOperatorOrWriteNode` is renamed to `CallOrWriteNode` and its structure has changed.
31
+
32
+ ## [0.10.0] - 2023-09-01
33
+
34
+ ### Added
35
+
36
+ - `InstanceVariable*Node` and `ClassVariable*Node` objects now have their `name` returning a Symbol. This is because they are now part of the constant pool.
37
+ - `NumberedReferenceReadNode` now has a `number` field, which returns an Integer.
38
+
39
+ ### Changed
40
+
41
+ - **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.
42
+ - `%w`, `%W`, `%i`, `%I`, `%q`, and `%Q` literals can now span around the contents of a heredoc.
43
+ - **BREAKING**: All of the public C APIs that accept the source string now accept `const uint8_t *` as opposed to `const char *`.
44
+
9
45
  ## [0.9.0] - 2023-08-25
10
46
 
11
47
  ### Added
@@ -81,7 +117,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
81
117
 
82
118
  - 🎉 Initial release! 🎉
83
119
 
84
- [unreleased]: https://github.com/ruby/yarp/compare/v0.9.0...HEAD
120
+ [unreleased]: https://github.com/ruby/yarp/compare/v0.11.0...HEAD
121
+ [0.11.0]: https://github.com/ruby/yarp/compare/v0.10.0...v0.11.0
122
+ [0.10.0]: https://github.com/ruby/yarp/compare/v0.9.0...v0.10.0
85
123
  [0.9.0]: https://github.com/ruby/yarp/compare/v0.8.0...v0.9.0
86
124
  [0.8.0]: https://github.com/ruby/yarp/compare/v0.7.0...v0.8.0
87
125
  [0.7.0]: https://github.com/ruby/yarp/compare/v0.6.0...v0.7.0
data/CONTRIBUTING.md CHANGED
@@ -32,6 +32,13 @@ bundle exec rake compile test
32
32
  bundle exec rake compile:yarp test
33
33
  ```
34
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
+
35
42
  ## Documentation
36
43
 
37
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.
data/Makefile CHANGED
@@ -44,6 +44,7 @@ build/static/%.o: src/%.c Makefile $(HEADERS)
44
44
 
45
45
  build/fuzz.%: $(SOURCES) fuzz/%.c fuzz/fuzz.c
46
46
  $(ECHO) "building $* fuzzer"
47
+ $(Q) mkdir -p $(@D)
47
48
  $(ECHO) "building main fuzz binary"
48
49
  $(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 $@ $^
49
50
  $(ECHO) "building cmplog binary"
@@ -70,10 +71,13 @@ fuzz-run-%: FORCE fuzz-docker-build
70
71
  $(Q) docker run -it --rm -v $(shell pwd):/yarp -v $(FUZZ_OUTPUT_DIR):/fuzz_output yarp/fuzz /bin/bash -c "./fuzz/$*.sh /fuzz_output/$*"
71
72
  FORCE:
72
73
 
74
+ fuzz-clean:
75
+ $(Q) rm -f -r fuzz/output
76
+
73
77
  clean:
74
78
  $(Q) rm -f -r build
75
79
 
76
- .PHONY: clean
80
+ .PHONY: clean fuzz-clean
77
81
 
78
82
  all-no-debug: DEBUG_FLAGS := -DNDEBUG=1
79
83
  all-no-debug: OPTFLAGS := -O3