prism 1.4.0 → 1.8.0

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.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +89 -1
  3. data/Makefile +14 -6
  4. data/README.md +3 -1
  5. data/config.yml +294 -41
  6. data/docs/build_system.md +2 -2
  7. data/docs/cruby_compilation.md +1 -1
  8. data/docs/design.md +2 -2
  9. data/docs/parser_translation.md +8 -23
  10. data/docs/releasing.md +4 -25
  11. data/docs/ripper_translation.md +1 -1
  12. data/docs/ruby_api.md +1 -0
  13. data/ext/prism/api_node.c +9 -3
  14. data/ext/prism/extconf.rb +1 -1
  15. data/ext/prism/extension.c +24 -3
  16. data/ext/prism/extension.h +1 -1
  17. data/include/prism/ast.h +360 -70
  18. data/include/prism/diagnostic.h +7 -0
  19. data/include/prism/options.h +49 -3
  20. data/include/prism/parser.h +3 -0
  21. data/include/prism/regexp.h +2 -2
  22. data/include/prism/util/pm_buffer.h +8 -0
  23. data/include/prism/util/pm_integer.h +4 -0
  24. data/include/prism/util/pm_list.h +6 -0
  25. data/include/prism/util/pm_string.h +12 -2
  26. data/include/prism/version.h +2 -2
  27. data/include/prism.h +40 -15
  28. data/lib/prism/compiler.rb +457 -152
  29. data/lib/prism/desugar_compiler.rb +1 -0
  30. data/lib/prism/dispatcher.rb +16 -0
  31. data/lib/prism/dot_visitor.rb +10 -1
  32. data/lib/prism/dsl.rb +5 -2
  33. data/lib/prism/ffi.rb +28 -10
  34. data/lib/prism/inspect_visitor.rb +4 -0
  35. data/lib/prism/lex_compat.rb +18 -75
  36. data/lib/prism/lex_ripper.rb +64 -0
  37. data/lib/prism/mutation_compiler.rb +3 -0
  38. data/lib/prism/node.rb +1663 -350
  39. data/lib/prism/node_ext.rb +4 -1
  40. data/lib/prism/pack.rb +2 -0
  41. data/lib/prism/parse_result/comments.rb +1 -0
  42. data/lib/prism/parse_result/errors.rb +1 -0
  43. data/lib/prism/parse_result/newlines.rb +1 -0
  44. data/lib/prism/parse_result.rb +3 -15
  45. data/lib/prism/pattern.rb +1 -0
  46. data/lib/prism/polyfill/scan_byte.rb +14 -0
  47. data/lib/prism/polyfill/warn.rb +36 -0
  48. data/lib/prism/reflection.rb +4 -1
  49. data/lib/prism/relocation.rb +1 -0
  50. data/lib/prism/serialize.rb +30 -22
  51. data/lib/prism/string_query.rb +1 -0
  52. data/lib/prism/translation/parser/builder.rb +1 -0
  53. data/lib/prism/translation/parser/compiler.rb +63 -41
  54. data/lib/prism/translation/parser/lexer.rb +29 -21
  55. data/lib/prism/translation/parser.rb +25 -4
  56. data/lib/prism/translation/parser_current.rb +26 -0
  57. data/lib/prism/translation/parser_versions.rb +36 -0
  58. data/lib/prism/translation/ripper/lexer.rb +46 -0
  59. data/lib/prism/translation/ripper/sexp.rb +1 -0
  60. data/lib/prism/translation/ripper.rb +44 -5
  61. data/lib/prism/translation/ruby_parser.rb +341 -23
  62. data/lib/prism/translation.rb +7 -3
  63. data/lib/prism/visitor.rb +458 -153
  64. data/lib/prism.rb +23 -1
  65. data/prism.gemspec +9 -7
  66. data/rbi/prism/dsl.rbi +6 -6
  67. data/rbi/prism/node.rbi +42 -17
  68. data/rbi/prism/translation/parser_versions.rbi +23 -0
  69. data/sig/prism/dispatcher.rbs +3 -0
  70. data/sig/prism/dsl.rbs +5 -5
  71. data/sig/prism/node.rbs +463 -38
  72. data/sig/prism/node_ext.rbs +84 -17
  73. data/sig/prism/parse_result/comments.rbs +38 -0
  74. data/sig/prism/parse_result.rbs +4 -0
  75. data/sig/prism/reflection.rbs +1 -1
  76. data/sig/prism.rbs +4 -0
  77. data/src/diagnostic.c +13 -1
  78. data/src/encoding.c +172 -67
  79. data/src/node.c +11 -0
  80. data/src/options.c +17 -7
  81. data/src/prettyprint.c +18 -0
  82. data/src/prism.c +1533 -2038
  83. data/src/serialize.c +9 -1
  84. data/src/token_type.c +38 -36
  85. data/src/util/pm_constant_pool.c +1 -1
  86. data/src/util/pm_string.c +6 -8
  87. metadata +11 -9
  88. data/lib/prism/translation/parser33.rb +0 -12
  89. data/lib/prism/translation/parser34.rb +0 -12
  90. data/lib/prism/translation/parser35.rb +0 -12
  91. data/rbi/prism/translation/parser33.rbi +0 -6
  92. data/rbi/prism/translation/parser34.rbi +0 -6
  93. data/rbi/prism/translation/parser35.rbi +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0209a58426470fc6afedb5922c9bf9264cb9ccd2debbef68fb1a307a4d1be78
4
- data.tar.gz: 491a11ab3d9d840f4ac228e8b79e85ddb24ae1f82b3cee7cbdb1003bea9f33f2
3
+ metadata.gz: 2344922b08aa30076aab32c5a92e0d7f21a05f03bb85d089cc69e228a71e3b20
4
+ data.tar.gz: 7a44533dd2827ec9f6c31fc69c533c9f90b88520aef71219a348aa61fa460fbd
5
5
  SHA512:
6
- metadata.gz: 30b9cb40262daf924f047034c6314b418c367691eccc188acd08328bd92e6a51d3818a91c3d17fb5dc3f159129186ef6c4bd7bfbe815b9c8f268fa9b938fd1ac
7
- data.tar.gz: a1b9ab207e98c779b0d371f2f14e6c5fb8315273af7518bc8e8135ba3dff4f1385787e169a4e4c146aa1ea7c10f6fce4f82d37958f88e8f68f1e8dabe54115bf
6
+ metadata.gz: c278e7b881b89f51150850df09062d9a9bd5e5076746e4b86ab199729a588f8aa346e12b6ba9b95dc0cf53592866bf216977bbb7da10cef6bd8a018681e9f45f
7
+ data.tar.gz: '009dee7695d1f7d58adb68d3829f97ecff445cc0eb8509526979f938932e553abdc2ba601049df67b8b29a75b7d542a9fb06d4c1984131d6f60e2ac9e3cf83c2'
data/CHANGELOG.md CHANGED
@@ -4,8 +4,90 @@ All notable changes to this project will be documented in this file.
4
4
 
5
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
6
 
7
+ ## [1.8.0] - 2026-01-12
8
+
9
+ ### Added
10
+
11
+ - Optimize ruby visitor.
12
+ - Report unterminated construct errors at opening token.
13
+
14
+ ### Changed
15
+
16
+ - Correctly expose ripper state.
17
+ - Use one file for versioned parser classes.
18
+ - Fix denominator of rational float literal.
19
+ - Decouple ripper translator from ripper library.
20
+ - Sync Prism::Translation::ParserCurrent with Ruby 4.0.
21
+
7
22
  ## [Unreleased]
8
23
 
24
+ ## [1.7.0] - 2025-12-18
25
+
26
+ ### Added
27
+
28
+ - Support `4.1` as a version option.
29
+ - Add `equal_loc` to `CallNode`.
30
+ - Add `len()`/`is_empty()` to `ConstantList` and `NodeList` in the Rust API.
31
+
32
+ ### Changed
33
+
34
+ - Rename version `3.5` to version `4.0`.
35
+ - Fix compiling the gem from source on Windows.
36
+ - Fix parsing of unary method calls like `42.~@`.
37
+ - Reject `def f a, (b) = 1`.
38
+ - Reject endless method as a block parameter default.
39
+ - Reject variable capture in alternative pattern.
40
+ - Many fixes in regards to memory safety, found through fuzzing.
41
+ - Many fixes to better handle invalid syntax, also found through fuzzing.
42
+ - Fix the ruby version used by the `ripper` translator.
43
+ - Fix `ruby_parser` translation comment processing.
44
+
45
+ ## [1.6.0] - 2025-10-16
46
+
47
+ ### Added
48
+
49
+ - Add support for passing `"current"` as the version option to `Prism.*` APIs.
50
+
51
+ ### Changed
52
+
53
+ - Remove a compiler warning for a missing unsigned cast for a shift value.
54
+
55
+ ## [1.5.2] - 2025-10-09
56
+
57
+ ### Changed
58
+
59
+ - Fix character literal forced encoding when a unicode escape sequence is used.
60
+ - Reject `1 if foo = bar baz`.
61
+ - Clear static literal flag on interpolated strings.
62
+ - Reject optional argument/endless method definition ambiguity.
63
+
64
+ ## [1.5.1] - 2025-09-13
65
+
66
+ ### Changed
67
+
68
+ - Revert of a bug introduced with static literal flags on interpolated strings.
69
+
70
+ ## [1.5.0] - 2025-09-12
71
+
72
+ ### Added
73
+
74
+ - Add `Prism::Translation::ParserCurrent`.
75
+ - Add `Integer::to_u32_digits` for the Rust API.
76
+ - Add `pm_comment_type_t` field for the Rust API.
77
+ - Support leading logical operators for CRuby 3.5+.
78
+
79
+ ### Changed
80
+
81
+ - Mark Prism as ractor-safe.
82
+ - Enforce a minimum version for the parser translation layer.
83
+ - Many fixes to the parser translation layer.
84
+ - Accept a newline after the `defined?` keyword.
85
+ - Reject `true && not true`.
86
+ - Make `it = it` assign nil to match parse.y behavior [Bug #21139].
87
+ - Some fixes to the ruby parser translation layer.
88
+ - Ensure call nodes have the correct ending location.
89
+ - Reject `foo && return bar`.
90
+
9
91
  ## [1.4.0] - 2025-03-18
10
92
 
11
93
  ### Added
@@ -649,7 +731,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
649
731
 
650
732
  - 🎉 Initial release! 🎉
651
733
 
652
- [unreleased]: https://github.com/ruby/prism/compare/v1.4.0...HEAD
734
+ [unreleased]: https://github.com/ruby/prism/compare/v1.8.0...HEAD
735
+ [1.8.0]: https://github.com/ruby/prism/compare/v1.7.0...v1.8.0
736
+ [1.7.0]: https://github.com/ruby/prism/compare/v1.6.0...v1.7.0
737
+ [1.6.0]: https://github.com/ruby/prism/compare/v1.5.2...v1.6.0
738
+ [1.5.2]: https://github.com/ruby/prism/compare/v1.5.1...v1.5.2
739
+ [1.5.1]: https://github.com/ruby/prism/compare/v1.5.0...v1.5.1
740
+ [1.5.0]: https://github.com/ruby/prism/compare/v1.4.0...v1.5.0
653
741
  [1.4.0]: https://github.com/ruby/prism/compare/v1.3.0...v1.4.0
654
742
  [1.3.0]: https://github.com/ruby/prism/compare/v1.2.0...v1.3.0
655
743
  [1.2.0]: https://github.com/ruby/prism/compare/v1.1.0...v1.2.0
data/Makefile CHANGED
@@ -12,8 +12,10 @@ SOEXT ?= $(shell ruby -e 'puts RbConfig::CONFIG["SOEXT"]')
12
12
 
13
13
  CPPFLAGS := -Iinclude $(CPPFLAGS)
14
14
  CFLAGS := -g -O2 -std=c99 -Wall -Werror -Wextra -Wpedantic -Wundef -Wconversion -Wno-missing-braces -fPIC -fvisibility=hidden -Wimplicit-fallthrough $(CFLAGS)
15
+ JAVA_WASM_CFLAGS := -g -Oz -std=c99 -Wall -Werror -Wextra -Wpedantic -Wundef -Wconversion -Wno-missing-braces -fPIC -fvisibility=hidden -Wimplicit-fallthrough $(JAVA_WASM_CFLAGS)
15
16
  CC ?= cc
16
17
  AR ?= ar
18
+ ARFLAGS ?= -r$(V0:1=v)
17
19
  WASI_SDK_PATH := /opt/wasi-sdk
18
20
 
19
21
  MAKEDIRS ?= mkdir -p
@@ -37,15 +39,21 @@ build/libprism.$(SOEXT): $(SHARED_OBJECTS)
37
39
 
38
40
  build/libprism.a: $(STATIC_OBJECTS)
39
41
  $(ECHO) "building $@ with $(AR)"
40
- $(Q) $(AR) $(ARFLAGS) $@ $(STATIC_OBJECTS) $(Q1:0=>/dev/null)
42
+ $(Q) $(AR) $(ARFLAGS) $@ $(STATIC_OBJECTS)
41
43
 
42
44
  javascript/src/prism.wasm: Makefile $(SOURCES) $(HEADERS)
43
45
  $(ECHO) "building $@"
44
- $(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)
46
+ $(Q) $(WASI_SDK_PATH)/bin/clang --sysroot=$(WASI_SDK_PATH)/share/wasi-sysroot/ \
47
+ $(DEBUG_FLAGS) \
48
+ -DPRISM_EXPORT_SYMBOLS -DPRISM_EXCLUDE_PRETTYPRINT -DPRISM_EXCLUDE_JSON -DPRISM_EXCLUDE_PACK \
49
+ -D_WASI_EMULATED_MMAN -lwasi-emulated-mman $(CPPFLAGS) $(CFLAGS) \
50
+ -Wl,--export-all -Wl,--gc-sections -Wl,--strip-all -Wl,--lto-O3 -Wl,--no-entry -mexec-model=reactor \
51
+ -Oz -g0 -flto -fdata-sections -ffunction-sections \
52
+ -o $@ $(SOURCES)
45
53
 
46
54
  java-wasm/src/test/resources/prism.wasm: Makefile $(SOURCES) $(HEADERS)
47
55
  $(ECHO) "building $@"
48
- $(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)
56
+ $(Q) $(WASI_SDK_PATH)/bin/clang $(DEBUG_FLAGS) -DPRISM_EXCLUDE_PRETTYPRINT -DPRISM_EXPORT_SYMBOLS -D_WASI_EMULATED_MMAN -lwasi-emulated-mman $(CPPFLAGS) $(JAVA_WASM_CFLAGS) -Wl,--export-all -Wl,--no-entry -mexec-model=reactor -lc++ -lc++abi -o $@ $(SOURCES)
49
57
 
50
58
  build/shared/%.o: src/%.c Makefile $(HEADERS)
51
59
  $(ECHO) "compiling $@"
@@ -61,12 +69,12 @@ build/fuzz.%: $(SOURCES) fuzz/%.c fuzz/fuzz.c
61
69
  $(ECHO) "building $* fuzzer"
62
70
  $(Q) $(MAKEDIRS) $(@D)
63
71
  $(ECHO) "building main fuzz binary"
64
- $(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 $@ $^
72
+ $(Q) afl-clang-lto $(DEBUG_FLAGS) $(CPPFLAGS) $(CFLAGS) $(FUZZ_FLAGS) -O0 -fsanitize-ignorelist=fuzz/asan.ignore -fsanitize=fuzzer,address -ggdb3 -std=c99 -Iinclude -o $@ $^
65
73
  $(ECHO) "building cmplog binary"
66
- $(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 $^
74
+ $(Q) 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 $^
67
75
 
68
76
  build/fuzz.heisenbug.%: $(SOURCES) fuzz/%.c fuzz/heisenbug.c
69
- $(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 $@ $^
77
+ $(Q) afl-clang-lto $(DEBUG_FLAGS) $(CPPFLAGS) $(CFLAGS) $(FUZZ_FLAGS) -O0 -fsanitize-ignorelist=fuzz/asan.ignore -fsanitize=fuzzer,address -ggdb3 -std=c99 -Iinclude -o $@ $^
70
78
 
71
79
  fuzz-debug:
72
80
  $(ECHO) "entering debug shell"
data/README.md CHANGED
@@ -116,7 +116,7 @@ Prism has been integrated into the majority of Ruby runtimes, many libraries, an
116
116
  * [JRuby](https://github.com/jruby/jruby/pull/8103) (via Java)
117
117
  * [Natalie](https://github.com/natalie-lang/natalie/pull/1213) (via C++ and Ruby)
118
118
  * [Opal](https://github.com/opal/opal/pull/2642) (via Ruby and WASM)
119
- * [TruffleRuby](https://github.com/oracle/truffleruby/issues/3117) (via Java)
119
+ * [TruffleRuby](https://github.com/truffleruby/truffleruby/issues/3117) (via Java)
120
120
 
121
121
  ### Libraries
122
122
 
@@ -135,7 +135,9 @@ Prism has been integrated into the majority of Ruby runtimes, many libraries, an
135
135
  * [sorbet-eraser](https://github.com/kddnewton/sorbet-eraser/pull/25)
136
136
  * [synvert](https://github.com/xinminlabs/synvert-core-ruby)
137
137
  * [typeprof](https://github.com/ruby/typeprof)
138
+ * [unparser](https://github.com/mbj/unparser) (via parser translator)
138
139
 
139
140
  ### Applications
140
141
 
141
142
  * [gem.sh](https://github.com/marcoroth/gem.sh/pull/96)
143
+ * [Sorbet](https://github.com/sorbet/sorbet)