prism 0.18.0 → 0.19.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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -1
  3. data/README.md +2 -1
  4. data/config.yml +188 -55
  5. data/docs/building.md +9 -2
  6. data/docs/configuration.md +10 -9
  7. data/docs/encoding.md +24 -56
  8. data/docs/local_variable_depth.md +229 -0
  9. data/docs/ruby_api.md +2 -0
  10. data/docs/serialization.md +18 -13
  11. data/ext/prism/api_node.c +337 -195
  12. data/ext/prism/extconf.rb +13 -7
  13. data/ext/prism/extension.c +96 -32
  14. data/ext/prism/extension.h +1 -1
  15. data/include/prism/ast.h +340 -137
  16. data/include/prism/defines.h +17 -0
  17. data/include/prism/diagnostic.h +11 -5
  18. data/include/prism/encoding.h +248 -0
  19. data/include/prism/options.h +2 -2
  20. data/include/prism/parser.h +62 -42
  21. data/include/prism/regexp.h +2 -2
  22. data/include/prism/util/pm_buffer.h +9 -1
  23. data/include/prism/util/pm_memchr.h +2 -2
  24. data/include/prism/util/pm_strpbrk.h +3 -3
  25. data/include/prism/version.h +2 -2
  26. data/include/prism.h +13 -15
  27. data/lib/prism/compiler.rb +12 -0
  28. data/lib/prism/debug.rb +9 -4
  29. data/lib/prism/desugar_compiler.rb +3 -3
  30. data/lib/prism/dispatcher.rb +56 -0
  31. data/lib/prism/dot_visitor.rb +476 -198
  32. data/lib/prism/dsl.rb +66 -46
  33. data/lib/prism/ffi.rb +16 -3
  34. data/lib/prism/lex_compat.rb +19 -9
  35. data/lib/prism/mutation_compiler.rb +20 -0
  36. data/lib/prism/node.rb +1173 -450
  37. data/lib/prism/node_ext.rb +41 -16
  38. data/lib/prism/parse_result.rb +12 -15
  39. data/lib/prism/ripper_compat.rb +49 -34
  40. data/lib/prism/serialize.rb +242 -212
  41. data/lib/prism/visitor.rb +12 -0
  42. data/lib/prism.rb +20 -4
  43. data/prism.gemspec +4 -10
  44. data/rbi/prism.rbi +605 -230
  45. data/rbi/prism_static.rbi +3 -0
  46. data/sig/prism.rbs +379 -124
  47. data/sig/prism_static.rbs +1 -0
  48. data/src/diagnostic.c +228 -222
  49. data/src/encoding.c +5137 -0
  50. data/src/node.c +66 -0
  51. data/src/options.c +21 -2
  52. data/src/prettyprint.c +806 -406
  53. data/src/prism.c +1092 -700
  54. data/src/regexp.c +3 -3
  55. data/src/serialize.c +227 -157
  56. data/src/util/pm_buffer.c +10 -1
  57. data/src/util/pm_memchr.c +1 -1
  58. data/src/util/pm_strpbrk.c +4 -4
  59. metadata +5 -11
  60. data/include/prism/enc/pm_encoding.h +0 -227
  61. data/src/enc/pm_big5.c +0 -116
  62. data/src/enc/pm_cp51932.c +0 -57
  63. data/src/enc/pm_euc_jp.c +0 -69
  64. data/src/enc/pm_gbk.c +0 -65
  65. data/src/enc/pm_shift_jis.c +0 -57
  66. data/src/enc/pm_tables.c +0 -2073
  67. data/src/enc/pm_unicode.c +0 -2369
  68. data/src/enc/pm_windows_31j.c +0 -57
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec5c0e5a9423ea40bad7c6ea608cb43dc0250c4d7119b4960271f547697540c1
4
- data.tar.gz: d505901505b8c4eee195171721d68fe05dde76de171e5a80115a301ba030cc34
3
+ metadata.gz: 72e48ffbc7a58cb622a709f860470c4cf2178113a2ba6a2c9cd4f838229ccff8
4
+ data.tar.gz: 709ecc0c274a141a868661f94d28aad3fda3032e1b253b2f699a15ff71200c37
5
5
  SHA512:
6
- metadata.gz: 3f3a4b92227885288d47e147f72b5cd2a27886222339ac08426a32ffe980b5b1397cf0356db93fcbdb2f6a3d16b1aa8db7185acbfe2a92473ef6adcf2aeda93e
7
- data.tar.gz: 20528ed404ebdfb5e2093054cd7d1b28fed5f8d95c84df217eee9759ca25603cbd381943db985e17b8e4851756605aa1fb2fe9d41c0d050dfee9d770ffd915d7
6
+ metadata.gz: 42a21574ff5ca1ce62c836839a8c54ed7d6a3f943cfbbd13d860aa30f3d1cf2b6fd5add3082d7622b30e3403ecbf98a404f3c9ef831744e60d40deabeae44ba2
7
+ data.tar.gz: 8ef39e9818ba2f13808a0e1131514709e6c7cbbbf2a0c784d047637d56b0024d35951a852c91d8f29c72477b5e923a6cc2687335cf44ccc761ab2e8e5eb5e521
data/CHANGELOG.md CHANGED
@@ -6,6 +6,35 @@ 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
+
9
38
  ## [0.18.0] - 2023-11-21
10
39
 
11
40
  ### Added
@@ -267,7 +296,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
267
296
 
268
297
  - 🎉 Initial release! 🎉
269
298
 
270
- [unreleased]: https://github.com/ruby/prism/compare/v0.18.0...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
271
301
  [0.18.0]: https://github.com/ruby/prism/compare/v0.17.1...v0.18.0
272
302
  [0.17.1]: https://github.com/ruby/prism/compare/v0.17.0...v0.17.1
273
303
  [0.17.0]: https://github.com/ruby/prism/compare/v0.16.0...v0.17.0
data/README.md CHANGED
@@ -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)
data/config.yml CHANGED
@@ -331,27 +331,46 @@ tokens:
331
331
  flags:
332
332
  - name: ArgumentsNodeFlags
333
333
  values:
334
- - name: KEYWORD_SPLAT
334
+ - name: CONTAINS_KEYWORD_SPLAT
335
335
  comment: "if arguments contain keyword splat"
336
336
  comment: Flags for arguments nodes.
337
+ - name: ArrayNodeFlags
338
+ values:
339
+ - name: CONTAINS_SPLAT
340
+ comment: "if array contains splat nodes"
341
+ comment: Flags for array nodes.
337
342
  - name: CallNodeFlags
338
343
  values:
339
344
  - name: SAFE_NAVIGATION
340
345
  comment: "&. operator"
341
346
  - name: VARIABLE_CALL
342
347
  comment: "a call that could have been a local variable"
348
+ - name: ATTRIBUTE_WRITE
349
+ comment: "a call that is an attribute write, so the value being written should be returned"
343
350
  comment: Flags for call nodes.
351
+ - name: EncodingFlags
352
+ values:
353
+ - name: FORCED_UTF8_ENCODING
354
+ comment: "internal bytes forced the encoding to UTF-8"
355
+ - name: FORCED_BINARY_ENCODING
356
+ comment: "internal bytes forced the encoding to binary"
357
+ comment: Flags for nodes that have unescaped content.
344
358
  - name: IntegerBaseFlags
345
359
  values:
346
360
  - name: BINARY
347
361
  comment: "0b prefix"
348
- - name: OCTAL
349
- comment: "0o or 0 prefix"
350
362
  - name: DECIMAL
351
363
  comment: "0d or no prefix"
364
+ - name: OCTAL
365
+ comment: "0o or 0 prefix"
352
366
  - name: HEXADECIMAL
353
367
  comment: "0x prefix"
354
368
  comment: Flags for integer nodes that correspond to the base of the integer.
369
+ - name: KeywordHashNodeFlags
370
+ values:
371
+ - name: STATIC_KEYS
372
+ comment: "a keyword hash which only has `AssocNode` elements all with static literal keys, which means the elements can be treated as keyword arguments"
373
+ comment: Flags for keyword hash nodes.
355
374
  - name: LoopFlags
356
375
  values:
357
376
  - name: BEGIN_MODIFIER
@@ -380,12 +399,31 @@ flags:
380
399
  comment: "s - forces the Windows-31J encoding"
381
400
  - name: UTF_8
382
401
  comment: "u - forces the UTF-8 encoding"
402
+ - name: FORCED_UTF8_ENCODING
403
+ comment: "internal bytes forced the encoding to UTF-8"
404
+ - name: FORCED_BINARY_ENCODING
405
+ comment: "internal bytes forced the encoding to binary"
406
+ - name: FORCED_US_ASCII_ENCODING
407
+ comment: "internal bytes forced the encoding to US-ASCII"
383
408
  comment: Flags for regular expression and match last line nodes.
384
409
  - name: StringFlags
385
410
  values:
411
+ - name: FORCED_UTF8_ENCODING
412
+ comment: "internal bytes forced the encoding to UTF-8"
413
+ - name: FORCED_BINARY_ENCODING
414
+ comment: "internal bytes forced the encoding to binary"
386
415
  - name: FROZEN
387
416
  comment: "frozen by virtue of a `frozen_string_literal` comment"
388
417
  comment: Flags for string nodes.
418
+ - name: SymbolFlags
419
+ values:
420
+ - name: FORCED_UTF8_ENCODING
421
+ comment: "internal bytes forced the encoding to UTF-8"
422
+ - name: FORCED_BINARY_ENCODING
423
+ comment: "internal bytes forced the encoding to binary"
424
+ - name: FORCED_US_ASCII_ENCODING
425
+ comment: "internal bytes forced the encoding to US-ASCII"
426
+ comment: Flags for symbol nodes.
389
427
  nodes:
390
428
  - name: AliasGlobalVariableNode
391
429
  fields:
@@ -441,11 +479,11 @@ nodes:
441
479
  ^^^^^^^^^^^^^^
442
480
  - name: ArgumentsNode
443
481
  fields:
444
- - name: arguments
445
- type: node[]
446
482
  - name: flags
447
483
  type: flags
448
484
  kind: ArgumentsNodeFlags
485
+ - name: arguments
486
+ type: node[]
449
487
  comment: |
450
488
  Represents a set of arguments to a method or a keyword.
451
489
 
@@ -453,6 +491,9 @@ nodes:
453
491
  ^^^^^^^^^^^^^
454
492
  - name: ArrayNode
455
493
  fields:
494
+ - name: flags
495
+ type: flags
496
+ kind: ArrayNodeFlags
456
497
  - name: elements
457
498
  type: node[]
458
499
  - name: opening_loc
@@ -579,9 +620,10 @@ nodes:
579
620
  fields:
580
621
  - name: locals
581
622
  type: constant[]
623
+ - name: locals_body_index
624
+ type: uint32
582
625
  - name: parameters
583
626
  type: node?
584
- kind: BlockParametersNode
585
627
  - name: body
586
628
  type: node?
587
629
  - name: opening_loc
@@ -641,15 +683,15 @@ nodes:
641
683
  ^^^^^^^^^
642
684
  - name: CallAndWriteNode
643
685
  fields:
686
+ - name: flags
687
+ type: flags
688
+ kind: CallNodeFlags
644
689
  - name: receiver
645
690
  type: node?
646
691
  - name: call_operator_loc
647
692
  type: location?
648
693
  - name: message_loc
649
694
  type: location?
650
- - name: flags
651
- type: flags
652
- kind: CallNodeFlags
653
695
  - name: read_name
654
696
  type: constant
655
697
  - name: write_name
@@ -665,10 +707,15 @@ nodes:
665
707
  ^^^^^^^^^^^^^^^^^
666
708
  - name: CallNode
667
709
  fields:
710
+ - name: flags
711
+ type: flags
712
+ kind: CallNodeFlags
668
713
  - name: receiver
669
714
  type: node?
670
715
  - name: call_operator_loc
671
716
  type: location?
717
+ - name: name
718
+ type: constant
672
719
  - name: message_loc
673
720
  type: location?
674
721
  - name: opening_loc
@@ -680,11 +727,6 @@ nodes:
680
727
  type: location?
681
728
  - name: block
682
729
  type: node?
683
- - name: flags
684
- type: flags
685
- kind: CallNodeFlags
686
- - name: name
687
- type: constant
688
730
  comment: |
689
731
  Represents a method call, in all of the various forms that can take.
690
732
 
@@ -707,15 +749,15 @@ nodes:
707
749
  ^^^^^^^^
708
750
  - name: CallOperatorWriteNode
709
751
  fields:
752
+ - name: flags
753
+ type: flags
754
+ kind: CallNodeFlags
710
755
  - name: receiver
711
756
  type: node?
712
757
  - name: call_operator_loc
713
758
  type: location?
714
759
  - name: message_loc
715
760
  type: location?
716
- - name: flags
717
- type: flags
718
- kind: CallNodeFlags
719
761
  - name: read_name
720
762
  type: constant
721
763
  - name: write_name
@@ -733,15 +775,15 @@ nodes:
733
775
  ^^^^^^^^^^^^^^
734
776
  - name: CallOrWriteNode
735
777
  fields:
778
+ - name: flags
779
+ type: flags
780
+ kind: CallNodeFlags
736
781
  - name: receiver
737
782
  type: node?
738
783
  - name: call_operator_loc
739
784
  type: location?
740
785
  - name: message_loc
741
786
  type: location?
742
- - name: flags
743
- type: flags
744
- kind: CallNodeFlags
745
787
  - name: read_name
746
788
  type: constant
747
789
  - name: write_name
@@ -755,6 +797,32 @@ nodes:
755
797
 
756
798
  foo.bar ||= value
757
799
  ^^^^^^^^^^^^^^^^^
800
+ - name: CallTargetNode
801
+ fields:
802
+ - name: flags
803
+ type: flags
804
+ kind: CallNodeFlags
805
+ - name: receiver
806
+ type: node
807
+ - name: call_operator_loc
808
+ type: location
809
+ - name: name
810
+ type: constant
811
+ - name: message_loc
812
+ type: location
813
+ comment: |
814
+ Represents assigning to a method call.
815
+
816
+ foo.bar, = 1
817
+ ^^^^^^^
818
+
819
+ begin
820
+ rescue => foo.bar
821
+ ^^^^^^^
822
+ end
823
+
824
+ for foo.bar in baz do end
825
+ ^^^^^^^
758
826
  - name: CapturePatternNode
759
827
  fields:
760
828
  - name: value
@@ -1096,6 +1164,8 @@ nodes:
1096
1164
  type: node?
1097
1165
  - name: locals
1098
1166
  type: constant[]
1167
+ - name: locals_body_index
1168
+ type: uint32
1099
1169
  - name: def_keyword_loc
1100
1170
  type: location
1101
1171
  - name: operator_loc
@@ -1219,15 +1289,15 @@ nodes:
1219
1289
  ^^^^^^^^^^^^^^^^^^^^
1220
1290
  - name: FlipFlopNode
1221
1291
  fields:
1292
+ - name: flags
1293
+ type: flags
1294
+ kind: RangeFlags
1222
1295
  - name: left
1223
1296
  type: node?
1224
1297
  - name: right
1225
1298
  type: node?
1226
1299
  - name: operator_loc
1227
1300
  type: location
1228
- - name: flags
1229
- type: flags
1230
- kind: RangeFlags
1231
1301
  comment: |
1232
1302
  Represents the use of the `..` or `...` operators to create flip flops.
1233
1303
 
@@ -1445,6 +1515,21 @@ nodes:
1445
1515
 
1446
1516
  { Foo: }
1447
1517
  ^^^^
1518
+ - name: ImplicitRestNode
1519
+ comment: |
1520
+ Represents using a trailing comma to indicate an implicit rest parameter.
1521
+
1522
+ foo { |bar,| }
1523
+ ^
1524
+
1525
+ foo in [bar,]
1526
+ ^
1527
+
1528
+ for foo, in bar do end
1529
+ ^
1530
+
1531
+ foo, = bar
1532
+ ^
1448
1533
  - name: InNode
1449
1534
  fields:
1450
1535
  - name: pattern
@@ -1463,6 +1548,9 @@ nodes:
1463
1548
  ^^^^^^^^^^^
1464
1549
  - name: IndexAndWriteNode
1465
1550
  fields:
1551
+ - name: flags
1552
+ type: flags
1553
+ kind: CallNodeFlags
1466
1554
  - name: receiver
1467
1555
  type: node?
1468
1556
  - name: call_operator_loc
@@ -1476,9 +1564,6 @@ nodes:
1476
1564
  type: location
1477
1565
  - name: block
1478
1566
  type: node?
1479
- - name: flags
1480
- type: flags
1481
- kind: CallNodeFlags
1482
1567
  - name: operator_loc
1483
1568
  type: location
1484
1569
  - name: value
@@ -1490,6 +1575,9 @@ nodes:
1490
1575
  ^^^^^^^^^^^^^^^^^^^^^^
1491
1576
  - name: IndexOperatorWriteNode
1492
1577
  fields:
1578
+ - name: flags
1579
+ type: flags
1580
+ kind: CallNodeFlags
1493
1581
  - name: receiver
1494
1582
  type: node?
1495
1583
  - name: call_operator_loc
@@ -1503,9 +1591,6 @@ nodes:
1503
1591
  type: location
1504
1592
  - name: block
1505
1593
  type: node?
1506
- - name: flags
1507
- type: flags
1508
- kind: CallNodeFlags
1509
1594
  - name: operator
1510
1595
  type: constant
1511
1596
  - name: operator_loc
@@ -1519,6 +1604,9 @@ nodes:
1519
1604
  ^^^^^^^^^^^^^^^^^^^^^
1520
1605
  - name: IndexOrWriteNode
1521
1606
  fields:
1607
+ - name: flags
1608
+ type: flags
1609
+ kind: CallNodeFlags
1522
1610
  - name: receiver
1523
1611
  type: node?
1524
1612
  - name: call_operator_loc
@@ -1532,9 +1620,6 @@ nodes:
1532
1620
  type: location
1533
1621
  - name: block
1534
1622
  type: node?
1535
- - name: flags
1536
- type: flags
1537
- kind: CallNodeFlags
1538
1623
  - name: operator_loc
1539
1624
  type: location
1540
1625
  - name: value
@@ -1544,6 +1629,35 @@ nodes:
1544
1629
 
1545
1630
  foo.bar[baz] ||= value
1546
1631
  ^^^^^^^^^^^^^^^^^^^^^^
1632
+ - name: IndexTargetNode
1633
+ fields:
1634
+ - name: flags
1635
+ type: flags
1636
+ kind: CallNodeFlags
1637
+ - name: receiver
1638
+ type: node
1639
+ - name: opening_loc
1640
+ type: location
1641
+ - name: arguments
1642
+ type: node?
1643
+ kind: ArgumentsNode
1644
+ - name: closing_loc
1645
+ type: location
1646
+ - name: block
1647
+ type: node?
1648
+ comment: |
1649
+ Represents assigning to an index.
1650
+
1651
+ foo[bar], = 1
1652
+ ^^^^^^^^
1653
+
1654
+ begin
1655
+ rescue => foo[bar]
1656
+ ^^^^^^^^
1657
+ end
1658
+
1659
+ for foo[bar] in baz do end
1660
+ ^^^^^^^^
1547
1661
  - name: InstanceVariableAndWriteNode
1548
1662
  fields:
1549
1663
  - name: name
@@ -1636,15 +1750,15 @@ nodes:
1636
1750
  ^
1637
1751
  - name: InterpolatedMatchLastLineNode
1638
1752
  fields:
1753
+ - name: flags
1754
+ type: flags
1755
+ kind: RegularExpressionFlags
1639
1756
  - name: opening_loc
1640
1757
  type: location
1641
1758
  - name: parts
1642
1759
  type: node[]
1643
1760
  - name: closing_loc
1644
1761
  type: location
1645
- - name: flags
1646
- type: flags
1647
- kind: RegularExpressionFlags
1648
1762
  newline: parts
1649
1763
  comment: |
1650
1764
  Represents a regular expression literal that contains interpolation that
@@ -1655,15 +1769,15 @@ nodes:
1655
1769
  ^^^^^^^^^^^^^^^^
1656
1770
  - name: InterpolatedRegularExpressionNode
1657
1771
  fields:
1772
+ - name: flags
1773
+ type: flags
1774
+ kind: RegularExpressionFlags
1658
1775
  - name: opening_loc
1659
1776
  type: location
1660
1777
  - name: parts
1661
1778
  type: node[]
1662
1779
  - name: closing_loc
1663
1780
  type: location
1664
- - name: flags
1665
- type: flags
1666
- kind: RegularExpressionFlags
1667
1781
  newline: parts
1668
1782
  comment: |
1669
1783
  Represents a regular expression literal that contains interpolation.
@@ -1714,6 +1828,9 @@ nodes:
1714
1828
  ^^^^^^^^^^^^^^^^
1715
1829
  - name: KeywordHashNode
1716
1830
  fields:
1831
+ - name: flags
1832
+ type: flags
1833
+ kind: KeywordHashNodeFlags
1717
1834
  - name: elements
1718
1835
  type: node[]
1719
1836
  comment: |
@@ -1739,6 +1856,8 @@ nodes:
1739
1856
  fields:
1740
1857
  - name: locals
1741
1858
  type: constant[]
1859
+ - name: locals_body_index
1860
+ type: uint32
1742
1861
  - name: operator_loc
1743
1862
  type: location
1744
1863
  - name: opening_loc
@@ -1747,7 +1866,6 @@ nodes:
1747
1866
  type: location
1748
1867
  - name: parameters
1749
1868
  type: node?
1750
- kind: BlockParametersNode
1751
1869
  - name: body
1752
1870
  type: node?
1753
1871
  comment: |
@@ -1851,6 +1969,9 @@ nodes:
1851
1969
  ^^^^^^^
1852
1970
  - name: MatchLastLineNode
1853
1971
  fields:
1972
+ - name: flags
1973
+ type: flags
1974
+ kind: RegularExpressionFlags
1854
1975
  - name: opening_loc
1855
1976
  type: location
1856
1977
  - name: content_loc
@@ -1859,9 +1980,6 @@ nodes:
1859
1980
  type: location
1860
1981
  - name: unescaped
1861
1982
  type: string
1862
- - name: flags
1863
- type: flags
1864
- kind: RegularExpressionFlags
1865
1983
  comment: |
1866
1984
  Represents a regular expression literal used in the predicate of a
1867
1985
  conditional to implicitly match against the last line read by an IO
@@ -1999,6 +2117,16 @@ nodes:
1999
2117
  def a(**nil)
2000
2118
  ^^^^^
2001
2119
  end
2120
+ - name: NumberedParametersNode
2121
+ fields:
2122
+ - name: maximum
2123
+ type: uint8
2124
+ comment: |
2125
+ Represents an implicit set of parameters through the use of numbered
2126
+ parameters within a block or lambda.
2127
+
2128
+ -> { _1 + _2 }
2129
+ ^^^^^^^^^^^^^^
2002
2130
  - name: NumberedReferenceReadNode
2003
2131
  fields:
2004
2132
  - name: number
@@ -2059,7 +2187,6 @@ nodes:
2059
2187
  type: node[]
2060
2188
  - name: rest
2061
2189
  type: node?
2062
- kind: RestParameterNode
2063
2190
  - name: posts
2064
2191
  type: node[]
2065
2192
  - name: keywords
@@ -2159,15 +2286,15 @@ nodes:
2159
2286
  comment: The top level node of any parse tree.
2160
2287
  - name: RangeNode
2161
2288
  fields:
2289
+ - name: flags
2290
+ type: flags
2291
+ kind: RangeFlags
2162
2292
  - name: left
2163
2293
  type: node?
2164
2294
  - name: right
2165
2295
  type: node?
2166
2296
  - name: operator_loc
2167
2297
  type: location
2168
- - name: flags
2169
- type: flags
2170
- kind: RangeFlags
2171
2298
  comment: |
2172
2299
  Represents the use of the `..` or `...` operators.
2173
2300
 
@@ -2193,6 +2320,9 @@ nodes:
2193
2320
  ^^^^
2194
2321
  - name: RegularExpressionNode
2195
2322
  fields:
2323
+ - name: flags
2324
+ type: flags
2325
+ kind: RegularExpressionFlags
2196
2326
  - name: opening_loc
2197
2327
  type: location
2198
2328
  - name: content_loc
@@ -2201,9 +2331,6 @@ nodes:
2201
2331
  type: location
2202
2332
  - name: unescaped
2203
2333
  type: string
2204
- - name: flags
2205
- type: flags
2206
- kind: RegularExpressionFlags
2207
2334
  comment: |
2208
2335
  Represents a regular expression literal with no interpolation.
2209
2336
 
@@ -2418,6 +2545,9 @@ nodes:
2418
2545
  ^^^^^^^^^^^^^^
2419
2546
  - name: SymbolNode
2420
2547
  fields:
2548
+ - name: flags
2549
+ type: flags
2550
+ kind: SymbolFlags
2421
2551
  - name: opening_loc
2422
2552
  type: location?
2423
2553
  - name: value_loc
@@ -2478,6 +2608,9 @@ nodes:
2478
2608
  ^^^^^^^^^^^^^^^^^^^^^^^
2479
2609
  - name: UntilNode
2480
2610
  fields:
2611
+ - name: flags
2612
+ type: flags
2613
+ kind: LoopFlags
2481
2614
  - name: keyword_loc
2482
2615
  type: location
2483
2616
  - name: closing_loc
@@ -2487,9 +2620,6 @@ nodes:
2487
2620
  - name: statements
2488
2621
  type: node?
2489
2622
  kind: StatementsNode
2490
- - name: flags
2491
- type: flags
2492
- kind: LoopFlags
2493
2623
  newline: predicate
2494
2624
  comment: |
2495
2625
  Represents the use of the `until` keyword, either in the block form or the modifier form.
@@ -2517,6 +2647,9 @@ nodes:
2517
2647
  end
2518
2648
  - name: WhileNode
2519
2649
  fields:
2650
+ - name: flags
2651
+ type: flags
2652
+ kind: LoopFlags
2520
2653
  - name: keyword_loc
2521
2654
  type: location
2522
2655
  - name: closing_loc
@@ -2526,9 +2659,6 @@ nodes:
2526
2659
  - name: statements
2527
2660
  type: node?
2528
2661
  kind: StatementsNode
2529
- - name: flags
2530
- type: flags
2531
- kind: LoopFlags
2532
2662
  newline: predicate
2533
2663
  comment: |
2534
2664
  Represents the use of the `while` keyword, either in the block form or the modifier form.
@@ -2540,6 +2670,9 @@ nodes:
2540
2670
  ^^^^^^^^^^^^^^^^^^^^
2541
2671
  - name: XStringNode
2542
2672
  fields:
2673
+ - name: flags
2674
+ type: flags
2675
+ kind: EncodingFlags
2543
2676
  - name: opening_loc
2544
2677
  type: location
2545
2678
  - name: content_loc
data/docs/building.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Building
2
2
 
3
- The following describes how to build prism from source.
4
- This comes directly from the [Makefile](../Makefile).
3
+ The following describes how to build prism from source. This comes directly from the [Makefile](../Makefile).
5
4
 
6
5
  ## Common
7
6
 
@@ -20,3 +19,11 @@ If you want to build prism as a shared library and link against it, you should c
20
19
 
21
20
  * `-fPIC -shared` - Compile as a shared library
22
21
  * `-DPRISM_EXPORT_SYMBOLS` - Export the symbols (by default nothing is exported)
22
+
23
+ ## Flags
24
+
25
+ `make` respects the `MAKEFLAGS` environment variable. As such, to speed up the build you can run:
26
+
27
+ ```
28
+ MAKEFLAGS="-j10" bundle exec rake compile
29
+ ```
@@ -50,14 +50,15 @@ Optionally, every node can define a `child_nodes` key that is an array. This arr
50
50
 
51
51
  The available values for `type` are:
52
52
 
53
- * `node` - A child node that is a node itself. This is a `pm_node_t *` in C.
54
- * `node?` - A child node that is optionally present. This is also a `pm_node_t *` in C, but can be `NULL`.
55
- * `node[]` - A child node that is an array of nodes. This is a `pm_node_list_t` in C.
56
- * `string` - A child node that is a string. For example, this is used as the name of the method in a call node, since it cannot directly reference the source string (as in `@-` or `foo=`). This is a `pm_string_t` in C.
57
- * `constant` - A variable-length integer that represents an index in the constant pool. This is a `pm_constant_id_t` in C.
58
- * `constant[]` - A child node that is an array of constants. This is a `pm_constant_id_list_t` in C.
59
- * `location` - A child node that is a location. This is a `pm_location_t` in C.
60
- * `location?` - A child node that is a location that is optionally present. This is a `pm_location_t` in C, but if the value is not present then the `start` and `end` fields will be `NULL`.
61
- * `uint32` - A child node that is a 32-bit unsigned integer. This is a `uint32_t` in C.
53
+ * `node` - A field that is a node. This is a `pm_node_t *` in C.
54
+ * `node?` - A field that is a node that is optionally present. This is also a `pm_node_t *` in C, but can be `NULL`.
55
+ * `node[]` - A field that is an array of nodes. This is a `pm_node_list_t` in C.
56
+ * `string` - A field that is a string. For example, this is used as the name of the method in a call node, since it cannot directly reference the source string (as in `@-` or `foo=`). This is a `pm_string_t` in C.
57
+ * `constant` - A field that is an integer that represents an index in the constant pool. This is a `pm_constant_id_t` in C.
58
+ * `constant[]` - A field that is an array of constants. This is a `pm_constant_id_list_t` in C.
59
+ * `location` - A field that is a location. This is a `pm_location_t` in C.
60
+ * `location?` - A field that is a location that is optionally present. This is a `pm_location_t` in C, but if the value is not present then the `start` and `end` fields will be `NULL`.
61
+ * `uint8` - A field that is an 8-bit unsigned integer. This is a `uint8_t` in C.
62
+ * `uint32` - A field that is a 32-bit unsigned integer. This is a `uint32_t` in C.
62
63
 
63
64
  If the type is `node` or `node?` then the value also accepts an optional `kind` key (a string). This key is expected to match to the name of another node type within `config.yml`. This changes a couple of places where code is templated out to use the more specific struct name instead of the generic `pm_node_t`. For example, with `kind: StatementsNode` the `pm_node_t *` in C becomes a `pm_statements_node_t *`.