yarp 0.11.0 → 0.12.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d096d8bdda05ec360a58c8c6d98d1aeb6680b95a983a7d10d916d4a941be1c8
4
- data.tar.gz: 7833c692ae2547f6628d15972b539484e06804179277d8f73a33cf448687f48b
3
+ metadata.gz: 9afbc3b5f4c070c404f0421f1814d5a1200cb849ef9bf38b2ae23f50ba738fdf
4
+ data.tar.gz: bed121fb1ac414cf5918a2bcf7df2a9b1318df2f46dff9863cc5b4427ce79409
5
5
  SHA512:
6
- metadata.gz: 6c42795d64e15210922249c5b81a7bd8a4f04f6589f8266aaf73341afbd72bde016aeafa879eddb12dd0ae75b6e2b91bba7c28599495f31030031117d12be9cf
7
- data.tar.gz: 6534173b9aa41bf180358750198c16749279723575045fffb819040509f6ca2e4f264653ad7857af152f64f7bdb16e95cbdedaab474bb62d86f9f920c5e44d83
6
+ metadata.gz: 3fd5831ab86ca1ca299e86ca5f2ca184164fa56de353cfa0d9b51d2ece522c2f5bebfadd1896222e4b7e1e984604be414ee8900b1a5bbc0b8eb3b6ee7bb738dc
7
+ data.tar.gz: 6fa02c77777391a1c4b5dc47445d905fee835213c7c02687cac432a4b566bbae8ead26467609066e83bf030ce19e09f46cf553fc0acdd8f7ef977074568b7061
data/CHANGELOG.md CHANGED
@@ -6,6 +6,30 @@ 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.12.0] - 2023-09-15
10
+
11
+ ### Added
12
+
13
+ - `RegularExpressionNode#options` and `InterpolatedRegularExpressionNode#options` are now provided. These return integers that match up to the `Regexp#options` API.
14
+ - Greatly improved `Node#inspect` and `Node#pretty_print` APIs.
15
+ - `MatchLastLineNode` and `InterpolatedMatchLastLineNode` are introduced to represent using a regular expression as the predicate of an `if` or `unless` statement.
16
+ - `IntegerNode` now has a base flag on it.
17
+ - Heredocs that were previously `InterpolatedStringNode` and `InterpolatedXStringNode` nodes without any actual interpolation are now `StringNode` and `XStringNode`, respectively.
18
+ - `StringNode` now has a `frozen?` flag on it, which respects the `frozen_string_literal` magic comment.
19
+ - Numbered parameters are now supported, and are properly represented using `LocalVariableReadNode` nodes.
20
+ - `ImplicitNode` is introduced, which wraps implicit calls, local variable reads, or constant reads in omitted hash values.
21
+ - `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.
22
+
23
+ ### Changed
24
+
25
+ - **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.
26
+ - **BREAKING**: `AliasNode` is now split into `AliasMethodNode` and `AliasGlobalVariableNode`.
27
+ - Method definitions on local variables is now correctly handled.
28
+ - Unary minus precedence has been fixed.
29
+ - Concatenating character literals with string literals is now fixed.
30
+ - Many more invalid syntaxes are now properly rejected.
31
+ - **BREAKING**: Comments now no longer include their trailing newline.
32
+
9
33
  ## [0.11.0] - 2023-09-08
10
34
 
11
35
  ### Added
@@ -117,7 +141,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
117
141
 
118
142
  - 🎉 Initial release! 🎉
119
143
 
120
- [unreleased]: https://github.com/ruby/yarp/compare/v0.11.0...HEAD
144
+ [unreleased]: https://github.com/ruby/yarp/compare/v0.12.0...HEAD
145
+ [0.12.0]: https://github.com/ruby/yarp/compare/v0.11.0...v0.12.0
121
146
  [0.11.0]: https://github.com/ruby/yarp/compare/v0.10.0...v0.11.0
122
147
  [0.10.0]: https://github.com/ruby/yarp/compare/v0.9.0...v0.10.0
123
148
  [0.9.0]: https://github.com/ruby/yarp/compare/v0.8.0...v0.9.0
data/config.yml CHANGED
@@ -333,6 +333,16 @@ flags:
333
333
  comment: "&. operator"
334
334
  - name: VARIABLE_CALL
335
335
  comment: "a call that could have been a local variable"
336
+ - name: IntegerBaseFlags
337
+ values:
338
+ - name: BINARY
339
+ comment: "0b prefix"
340
+ - name: OCTAL
341
+ comment: "0o or 0 prefix"
342
+ - name: DECIMAL
343
+ comment: "0d or no prefix"
344
+ - name: HEXADECIMAL
345
+ comment: "0x prefix"
336
346
  - name: LoopFlags
337
347
  values:
338
348
  - name: BEGIN_MODIFIER
@@ -345,10 +355,10 @@ flags:
345
355
  values:
346
356
  - name: IGNORE_CASE
347
357
  comment: "i - ignores the case of characters when matching"
348
- - name: MULTI_LINE
349
- comment: "m - allows $ to match the end of lines within strings"
350
358
  - name: EXTENDED
351
359
  comment: "x - ignores whitespace and allows comments in regular expressions"
360
+ - name: MULTI_LINE
361
+ comment: "m - allows $ to match the end of lines within strings"
352
362
  - name: EUC_JP
353
363
  comment: "e - forces the EUC-JP encoding"
354
364
  - name: ASCII_8BIT
@@ -359,8 +369,12 @@ flags:
359
369
  comment: "u - forces the UTF-8 encoding"
360
370
  - name: ONCE
361
371
  comment: "o - only interpolates values into the regular expression once"
372
+ - name: StringFlags
373
+ values:
374
+ - name: FROZEN
375
+ comment: "frozen by virtue of a frozen_string_literal comment"
362
376
  nodes:
363
- - name: AliasNode
377
+ - name: AliasGlobalVariableNode
364
378
  fields:
365
379
  - name: new_name
366
380
  type: node
@@ -369,7 +383,20 @@ nodes:
369
383
  - name: keyword_loc
370
384
  type: location
371
385
  comment: |
372
- Represents the use of the `alias` keyword.
386
+ Represents the use of the `alias` keyword to alias a global variable.
387
+
388
+ alias $foo $bar
389
+ ^^^^^^^^^^^^^^^
390
+ - name: AliasMethodNode
391
+ fields:
392
+ - name: new_name
393
+ type: node
394
+ - name: old_name
395
+ type: node
396
+ - name: keyword_loc
397
+ type: location
398
+ comment: |
399
+ Represents the use of the `alias` keyword to alias a method.
373
400
 
374
401
  alias foo bar
375
402
  ^^^^^^^^^^^^^
@@ -1386,6 +1413,19 @@ nodes:
1386
1413
 
1387
1414
  1.0i
1388
1415
  ^^^^
1416
+ - name: ImplicitNode
1417
+ fields:
1418
+ - name: value
1419
+ type: node
1420
+ comment: |
1421
+ Represents a node that is implicitly being added to the tree but doesn't
1422
+ correspond directly to a node in the source.
1423
+
1424
+ { foo: }
1425
+ ^^^^
1426
+
1427
+ { Foo: }
1428
+ ^^^^
1389
1429
  - name: InNode
1390
1430
  fields:
1391
1431
  - name: pattern
@@ -1483,11 +1523,34 @@ nodes:
1483
1523
  @foo = 1
1484
1524
  ^^^^^^^^
1485
1525
  - name: IntegerNode
1526
+ fields:
1527
+ - name: flags
1528
+ type: flags
1529
+ kind: IntegerBaseFlags
1486
1530
  comment: |
1487
1531
  Represents an integer number literal.
1488
1532
 
1489
1533
  1
1490
1534
  ^
1535
+ - name: InterpolatedMatchLastLineNode
1536
+ fields:
1537
+ - name: opening_loc
1538
+ type: location
1539
+ - name: parts
1540
+ type: node[]
1541
+ - name: closing_loc
1542
+ type: location
1543
+ - name: flags
1544
+ type: flags
1545
+ kind: RegularExpressionFlags
1546
+ newline: parts
1547
+ comment: |
1548
+ Represents a regular expression literal that contains interpolation that
1549
+ is being used in the predicate of a conditional to implicitly match
1550
+ against the last line read by an IO object.
1551
+
1552
+ if /foo #{bar} baz/ then end
1553
+ ^^^^^^^^^^^^^^^^
1491
1554
  - name: InterpolatedRegularExpressionNode
1492
1555
  fields:
1493
1556
  - name: opening_loc
@@ -1702,6 +1765,26 @@ nodes:
1702
1765
 
1703
1766
  foo = 1
1704
1767
  ^^^^^^^
1768
+ - name: MatchLastLineNode
1769
+ fields:
1770
+ - name: opening_loc
1771
+ type: location
1772
+ - name: content_loc
1773
+ type: location
1774
+ - name: closing_loc
1775
+ type: location
1776
+ - name: unescaped
1777
+ type: string
1778
+ - name: flags
1779
+ type: flags
1780
+ kind: RegularExpressionFlags
1781
+ comment: |
1782
+ Represents a regular expression literal used in the predicate of a
1783
+ conditional to implicitly match against the last line read by an IO
1784
+ object.
1785
+
1786
+ if /foo/i then end
1787
+ ^^^^^^
1705
1788
  - name: MatchPredicateNode
1706
1789
  fields:
1707
1790
  - name: value
@@ -1728,6 +1811,19 @@ nodes:
1728
1811
 
1729
1812
  foo => bar
1730
1813
  ^^^^^^^^^^
1814
+ - name: MatchWriteNode
1815
+ fields:
1816
+ - name: call
1817
+ type: node
1818
+ kind: CallNode
1819
+ - name: locals
1820
+ type: constant[]
1821
+ comment: |
1822
+ Represents writing local variables using a regular expression match with
1823
+ named capture groups.
1824
+
1825
+ /(?<foo>bar)/ =~ baz
1826
+ ^^^^^^^^^^^^^^^^^^^^
1731
1827
  - name: MissingNode
1732
1828
  comment: |
1733
1829
  Represents a node that is missing from the source and results in a syntax
@@ -1855,11 +1951,11 @@ nodes:
1855
1951
  type: node[]
1856
1952
  - name: optionals
1857
1953
  type: node[]
1858
- - name: posts
1859
- type: node[]
1860
1954
  - name: rest
1861
1955
  type: node?
1862
1956
  kind: RestParameterNode
1957
+ - name: posts
1958
+ type: node[]
1863
1959
  - name: keywords
1864
1960
  type: node[]
1865
1961
  - name: keyword_rest
@@ -2183,6 +2279,9 @@ nodes:
2183
2279
  ^^^^^^^^^^^
2184
2280
  - name: StringNode
2185
2281
  fields:
2282
+ - name: flags
2283
+ type: flags
2284
+ kind: StringFlags
2186
2285
  - name: opening_loc
2187
2286
  type: location?
2188
2287
  - name: content_loc