prism 0.17.1 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +60 -1
  3. data/Makefile +5 -5
  4. data/README.md +4 -3
  5. data/config.yml +214 -68
  6. data/docs/build_system.md +6 -6
  7. data/docs/building.md +10 -3
  8. data/docs/configuration.md +11 -9
  9. data/docs/encoding.md +92 -88
  10. data/docs/heredocs.md +1 -1
  11. data/docs/javascript.md +29 -1
  12. data/docs/local_variable_depth.md +229 -0
  13. data/docs/ruby_api.md +16 -0
  14. data/docs/serialization.md +18 -13
  15. data/ext/prism/api_node.c +411 -240
  16. data/ext/prism/extconf.rb +97 -127
  17. data/ext/prism/extension.c +97 -33
  18. data/ext/prism/extension.h +1 -1
  19. data/include/prism/ast.h +377 -159
  20. data/include/prism/defines.h +17 -0
  21. data/include/prism/diagnostic.h +38 -6
  22. data/include/prism/{enc/pm_encoding.h → encoding.h} +126 -64
  23. data/include/prism/options.h +2 -2
  24. data/include/prism/parser.h +62 -36
  25. data/include/prism/regexp.h +2 -2
  26. data/include/prism/util/pm_buffer.h +9 -1
  27. data/include/prism/util/pm_memchr.h +2 -2
  28. data/include/prism/util/pm_strpbrk.h +3 -3
  29. data/include/prism/version.h +3 -3
  30. data/include/prism.h +13 -15
  31. data/lib/prism/compiler.rb +15 -3
  32. data/lib/prism/debug.rb +13 -4
  33. data/lib/prism/desugar_compiler.rb +4 -3
  34. data/lib/prism/dispatcher.rb +70 -14
  35. data/lib/prism/dot_visitor.rb +4612 -0
  36. data/lib/prism/dsl.rb +77 -57
  37. data/lib/prism/ffi.rb +19 -6
  38. data/lib/prism/lex_compat.rb +19 -9
  39. data/lib/prism/mutation_compiler.rb +26 -6
  40. data/lib/prism/node.rb +1314 -522
  41. data/lib/prism/node_ext.rb +102 -19
  42. data/lib/prism/parse_result.rb +58 -27
  43. data/lib/prism/ripper_compat.rb +49 -34
  44. data/lib/prism/serialize.rb +251 -227
  45. data/lib/prism/visitor.rb +15 -3
  46. data/lib/prism.rb +21 -4
  47. data/prism.gemspec +7 -9
  48. data/rbi/prism.rbi +688 -284
  49. data/rbi/prism_static.rbi +3 -0
  50. data/sig/prism.rbs +426 -156
  51. data/sig/prism_static.rbs +1 -0
  52. data/src/diagnostic.c +280 -216
  53. data/src/encoding.c +5137 -0
  54. data/src/node.c +99 -21
  55. data/src/options.c +21 -2
  56. data/src/prettyprint.c +1743 -1241
  57. data/src/prism.c +1774 -831
  58. data/src/regexp.c +15 -15
  59. data/src/serialize.c +261 -164
  60. data/src/util/pm_buffer.c +10 -1
  61. data/src/util/pm_memchr.c +1 -1
  62. data/src/util/pm_strpbrk.c +4 -4
  63. metadata +8 -10
  64. data/src/enc/pm_big5.c +0 -53
  65. data/src/enc/pm_euc_jp.c +0 -59
  66. data/src/enc/pm_gbk.c +0 -62
  67. data/src/enc/pm_shift_jis.c +0 -57
  68. data/src/enc/pm_tables.c +0 -743
  69. data/src/enc/pm_unicode.c +0 -2369
  70. data/src/enc/pm_windows_31j.c +0 -57
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a4a6459265bca653fd8db970fcf2d3863bca8bf0b839629beff1a2a8bed68df
4
- data.tar.gz: 3b309ffb711f9f6a5b57e3b130a66ed8c3ffc172c903642e74b00d4729d41016
3
+ metadata.gz: 72e48ffbc7a58cb622a709f860470c4cf2178113a2ba6a2c9cd4f838229ccff8
4
+ data.tar.gz: 709ecc0c274a141a868661f94d28aad3fda3032e1b253b2f699a15ff71200c37
5
5
  SHA512:
6
- metadata.gz: 631a5028085ce1c853ab38b2e82462c869ba70860d8b8fc0532e1fdc5a53329f4aa582b0f2be58363d4c642f8d576751b14fa76e685aa90b68e854c6c51a38c3
7
- data.tar.gz: e2f7601d879b9f4d81e8e80d8ddf4776fca36395e38e460798635810ab229054753ad172dce8577174253b3353cc99d3176a7c1bdc31e1205a2f4e000a7ae3b3
6
+ metadata.gz: 42a21574ff5ca1ce62c836839a8c54ed7d6a3f943cfbbd13d860aa30f3d1cf2b6fd5add3082d7622b30e3403ecbf98a404f3c9ef831744e60d40deabeae44ba2
7
+ data.tar.gz: 8ef39e9818ba2f13808a0e1131514709e6c7cbbbf2a0c784d047637d56b0024d35951a852c91d8f29c72477b5e923a6cc2687335cf44ccc761ab2e8e5eb5e521
data/CHANGELOG.md CHANGED
@@ -6,6 +6,63 @@ 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.19.0] - 2023-12-14
10
+
11
+ ### Added
12
+
13
+ - `ArrayNode` now has a `contains_splat?` flag if it has a splatted element in it.
14
+ - All of the remaining encodings have been implemented.
15
+ - Allow forwarding `&` in a method that has a `...` parameter.
16
+ - Many statements that are found in non-statement positions are being properly rejected now.
17
+ - Void values are now properly checked.
18
+ - Referencing a parameter in its own default value is now properly rejected.
19
+ - `DATA`/`__END__` is now parsed as its own field on parse result (`data_loc`) as opposed to as a comment.
20
+ - Blank `*` now properly forwards into arrays.
21
+ - `ImplicitRestNode` is introduced to represent the implicit rest of a destructure.
22
+ - We now support negative start lines.
23
+ - `StringNode#heredoc?`, `InterpolatedStringNode#heredoc?`, `XStringNode#heredoc?`, and `InterpolatedXStringNode#heredoc?` are introduced.
24
+ - `NumberedParametersNode` is introduced to represent the implicit set of parameters when numbered parameters are used.
25
+ - `Prism::parse_success?` and `Prism::parse_failure?` are introduced to bypass reifying the AST.
26
+ - We now emit a warning for constant assignments in method definitions.
27
+ - We now provide flags on strings and xstrings to indicate the correct encoding.
28
+ - The hash pattern `rest` field now more accurately parses `**` and `**nil`.
29
+ - The equality operators are now properly parsed as non-associative.
30
+
31
+ ### Changed
32
+
33
+ - **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.
34
+ - **BREAKING**: Almost all of the error messages have been updated to begin with lowercase characters to match ruby/spec.
35
+ - Unterminated strings with only plain content are now always `StringNode` as opposed to `InterpolatedStringNode`
36
+ - **BREAKING**: Call node has been split up when it is in the target position into `CallTargetNode` and `IndexTargetNode`.
37
+
38
+ ## [0.18.0] - 2023-11-21
39
+
40
+ ### Added
41
+
42
+ - The `ParametersNode#signature` method is added, which returns the same thing as `Method#parameters`.
43
+ - Visitor functionality has been added to the JavaScript API.
44
+ - The `Node#to_dot` API has been added to convert syntax trees to Graphviz digraphs.
45
+ - `IfNode` and `UnlessNode` now have a `then_keyword_loc` field.
46
+ - Many more encodings are now supported.
47
+ - 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`.
48
+ - A warning has been added for when `END {}` is used within a method.
49
+ - `ConstantPathNode#full_name{,_parts}` will now raise an error if the receiver of the constant path is not itself a constant.
50
+ - The `in` keyword and the `=>` operator now respect non-associativity.
51
+ - The `..` and `...` operators now properly respect non-associativity.
52
+
53
+ ### Changed
54
+
55
+ - Previously `...` in blocks was accepted, but it is now properly rejected.
56
+ - **BREAKING**: `librubyparser.*` has been renamed to `libprism.*` in the C API.
57
+ - We now properly reject floats with exponent and rational suffixes.
58
+ - We now properly reject void value expressions.
59
+ - **BREAKING**: The `--disable-static` option has been removed from the C extension.
60
+ - The rescue modifier keyword is now properly parsed in terms of precedence.
61
+ - We now properly reject defining a numbered parameter method.
62
+ - **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.
63
+ - **BREAKING**: `CaseNode` has been split into `CaseNode` and `CaseMatchNode`, the latter is used for `case ... in` expressions.
64
+ - **BREAKING**: `StringConcatNode` has been removed in favor of using `InterpolatedStringNode` as a list.
65
+
9
66
  ## [0.17.1] - 2023-11-03
10
67
 
11
68
  ### Changed
@@ -239,7 +296,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
239
296
 
240
297
  - 🎉 Initial release! 🎉
241
298
 
242
- [unreleased]: https://github.com/ruby/prism/compare/v0.17.1...HEAD
299
+ [unreleased]: https://github.com/ruby/prism/compare/v0.19.0...HEAD
300
+ [0.19.0]: https://github.com/ruby/prism/compare/v0.18.0...v0.19.0
301
+ [0.18.0]: https://github.com/ruby/prism/compare/v0.17.1...v0.18.0
243
302
  [0.17.1]: https://github.com/ruby/prism/compare/v0.17.0...v0.17.1
244
303
  [0.17.0]: https://github.com/ruby/prism/compare/v0.16.0...v0.17.0
245
304
  [0.16.0]: https://github.com/ruby/prism/compare/v0.15.1...v0.16.0
data/Makefile CHANGED
@@ -11,7 +11,7 @@ FUZZ_OUTPUT_DIR = $(shell pwd)/fuzz/output
11
11
  SOEXT := $(shell ruby -e 'puts RbConfig::CONFIG["SOEXT"]')
12
12
 
13
13
  CPPFLAGS := -Iinclude
14
- CFLAGS := -g -O2 -std=c99 -Wall -Werror -Wextra -Wpedantic -Wundef -Wconversion -fPIC -fvisibility=hidden
14
+ CFLAGS := -g -O2 -std=c99 -Wall -Werror -Wextra -Wpedantic -Wundef -Wconversion -Wno-missing-braces -fPIC -fvisibility=hidden
15
15
  CC := cc
16
16
  WASI_SDK_PATH := /opt/wasi-sdk
17
17
 
@@ -22,15 +22,15 @@ STATIC_OBJECTS := $(subst src/,build/static/,$(SOURCES:.c=.o))
22
22
 
23
23
  all: shared static
24
24
 
25
- shared: build/librubyparser.$(SOEXT)
26
- static: build/librubyparser.a
25
+ shared: build/libprism.$(SOEXT)
26
+ static: build/libprism.a
27
27
  wasm: javascript/src/prism.wasm
28
28
 
29
- build/librubyparser.$(SOEXT): $(SHARED_OBJECTS)
29
+ build/libprism.$(SOEXT): $(SHARED_OBJECTS)
30
30
  $(ECHO) "linking $@"
31
31
  $(Q) $(CC) $(DEBUG_FLAGS) $(CFLAGS) -shared -o $@ $(SHARED_OBJECTS)
32
32
 
33
- build/librubyparser.a: $(STATIC_OBJECTS)
33
+ build/libprism.a: $(STATIC_OBJECTS)
34
34
  $(ECHO) "building $@"
35
35
  $(Q) $(AR) $(ARFLAGS) $@ $(STATIC_OBJECTS) $(Q1:0=>/dev/null)
36
36
 
data/README.md CHANGED
@@ -7,7 +7,7 @@ This is a parser for the Ruby programming language. It is designed to be portabl
7
7
 
8
8
  ## Overview
9
9
 
10
- The repository contains the infrastructure for both a shared library (librubyparser) and a native CRuby extension. The shared library has no bindings to CRuby itself, and so can be used by other projects. The native CRuby extension links against `ruby.h`, and so is suitable in the context of CRuby.
10
+ The repository contains the infrastructure for both a shared library (libprism) and a native CRuby extension. The shared library has no bindings to CRuby itself, and so can be used by other projects. The native CRuby extension links against `ruby.h`, and so is suitable in the context of CRuby.
11
11
 
12
12
  ```
13
13
  .
@@ -21,7 +21,7 @@ The repository contains the infrastructure for both a shared library (librubypar
21
21
  ├── ext
22
22
  │   └── prism
23
23
  │   ├── extconf.rb configuration to generate the Makefile for the native extension
24
- │   └── extension.c the native extension that interacts with librubyparser
24
+ │   └── extension.c the native extension that interacts with libprism
25
25
  ├── fuzz files related to fuzz testing
26
26
  ├── include
27
27
  │   ├── prism header files for the shared library
@@ -64,7 +64,7 @@ bundle install
64
64
  to fetch the Ruby dependencies. Finally, run:
65
65
 
66
66
  ```
67
- rake compile
67
+ bundle exec rake compile
68
68
  ```
69
69
 
70
70
  to compile the shared library. It will be built in the `build` directory. To test that everything is working, run:
@@ -86,6 +86,7 @@ See the [CONTRIBUTING.md](CONTRIBUTING.md) file for more information. We additio
86
86
  * [Fuzzing](docs/fuzzing.md)
87
87
  * [Heredocs](docs/heredocs.md)
88
88
  * [JavaScript](docs/javascript.md)
89
+ * [Local variable depth](docs/local_variable_depth.md)
89
90
  * [Mapping](docs/mapping.md)
90
91
  * [Releasing](docs/releasing.md)
91
92
  * [Ripper](docs/ripper.md)