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
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
@@ -768,6 +836,26 @@ nodes:
768
836
 
769
837
  foo => [bar => baz]
770
838
  ^^^^^^^^^^^^
839
+ - name: CaseMatchNode
840
+ fields:
841
+ - name: predicate
842
+ type: node?
843
+ - name: conditions
844
+ type: node[]
845
+ - name: consequent
846
+ type: node?
847
+ kind: ElseNode
848
+ - name: case_keyword_loc
849
+ type: location
850
+ - name: end_keyword_loc
851
+ type: location
852
+ comment: |
853
+ Represents the use of a case statement for pattern matching.
854
+
855
+ case true
856
+ in false
857
+ end
858
+ ^^^^^^^^^
771
859
  - name: CaseNode
772
860
  fields:
773
861
  - name: predicate
@@ -1076,6 +1164,8 @@ nodes:
1076
1164
  type: node?
1077
1165
  - name: locals
1078
1166
  type: constant[]
1167
+ - name: locals_body_index
1168
+ type: uint32
1079
1169
  - name: def_keyword_loc
1080
1170
  type: location
1081
1171
  - name: operator_loc
@@ -1199,15 +1289,15 @@ nodes:
1199
1289
  ^^^^^^^^^^^^^^^^^^^^
1200
1290
  - name: FlipFlopNode
1201
1291
  fields:
1292
+ - name: flags
1293
+ type: flags
1294
+ kind: RangeFlags
1202
1295
  - name: left
1203
1296
  type: node?
1204
1297
  - name: right
1205
1298
  type: node?
1206
1299
  - name: operator_loc
1207
1300
  type: location
1208
- - name: flags
1209
- type: flags
1210
- kind: RangeFlags
1211
1301
  comment: |
1212
1302
  Represents the use of the `..` or `...` operators to create flip flops.
1213
1303
 
@@ -1385,6 +1475,8 @@ nodes:
1385
1475
  type: location?
1386
1476
  - name: predicate
1387
1477
  type: node
1478
+ - name: then_keyword_loc
1479
+ type: location?
1388
1480
  - name: statements
1389
1481
  type: node?
1390
1482
  kind: StatementsNode
@@ -1423,6 +1515,21 @@ nodes:
1423
1515
 
1424
1516
  { Foo: }
1425
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
+ ^
1426
1533
  - name: InNode
1427
1534
  fields:
1428
1535
  - name: pattern
@@ -1441,6 +1548,9 @@ nodes:
1441
1548
  ^^^^^^^^^^^
1442
1549
  - name: IndexAndWriteNode
1443
1550
  fields:
1551
+ - name: flags
1552
+ type: flags
1553
+ kind: CallNodeFlags
1444
1554
  - name: receiver
1445
1555
  type: node?
1446
1556
  - name: call_operator_loc
@@ -1454,9 +1564,6 @@ nodes:
1454
1564
  type: location
1455
1565
  - name: block
1456
1566
  type: node?
1457
- - name: flags
1458
- type: flags
1459
- kind: CallNodeFlags
1460
1567
  - name: operator_loc
1461
1568
  type: location
1462
1569
  - name: value
@@ -1468,6 +1575,9 @@ nodes:
1468
1575
  ^^^^^^^^^^^^^^^^^^^^^^
1469
1576
  - name: IndexOperatorWriteNode
1470
1577
  fields:
1578
+ - name: flags
1579
+ type: flags
1580
+ kind: CallNodeFlags
1471
1581
  - name: receiver
1472
1582
  type: node?
1473
1583
  - name: call_operator_loc
@@ -1481,9 +1591,6 @@ nodes:
1481
1591
  type: location
1482
1592
  - name: block
1483
1593
  type: node?
1484
- - name: flags
1485
- type: flags
1486
- kind: CallNodeFlags
1487
1594
  - name: operator
1488
1595
  type: constant
1489
1596
  - name: operator_loc
@@ -1497,6 +1604,9 @@ nodes:
1497
1604
  ^^^^^^^^^^^^^^^^^^^^^
1498
1605
  - name: IndexOrWriteNode
1499
1606
  fields:
1607
+ - name: flags
1608
+ type: flags
1609
+ kind: CallNodeFlags
1500
1610
  - name: receiver
1501
1611
  type: node?
1502
1612
  - name: call_operator_loc
@@ -1510,9 +1620,6 @@ nodes:
1510
1620
  type: location
1511
1621
  - name: block
1512
1622
  type: node?
1513
- - name: flags
1514
- type: flags
1515
- kind: CallNodeFlags
1516
1623
  - name: operator_loc
1517
1624
  type: location
1518
1625
  - name: value
@@ -1522,6 +1629,35 @@ nodes:
1522
1629
 
1523
1630
  foo.bar[baz] ||= value
1524
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
+ ^^^^^^^^
1525
1661
  - name: InstanceVariableAndWriteNode
1526
1662
  fields:
1527
1663
  - name: name
@@ -1614,15 +1750,15 @@ nodes:
1614
1750
  ^
1615
1751
  - name: InterpolatedMatchLastLineNode
1616
1752
  fields:
1753
+ - name: flags
1754
+ type: flags
1755
+ kind: RegularExpressionFlags
1617
1756
  - name: opening_loc
1618
1757
  type: location
1619
1758
  - name: parts
1620
1759
  type: node[]
1621
1760
  - name: closing_loc
1622
1761
  type: location
1623
- - name: flags
1624
- type: flags
1625
- kind: RegularExpressionFlags
1626
1762
  newline: parts
1627
1763
  comment: |
1628
1764
  Represents a regular expression literal that contains interpolation that
@@ -1633,15 +1769,15 @@ nodes:
1633
1769
  ^^^^^^^^^^^^^^^^
1634
1770
  - name: InterpolatedRegularExpressionNode
1635
1771
  fields:
1772
+ - name: flags
1773
+ type: flags
1774
+ kind: RegularExpressionFlags
1636
1775
  - name: opening_loc
1637
1776
  type: location
1638
1777
  - name: parts
1639
1778
  type: node[]
1640
1779
  - name: closing_loc
1641
1780
  type: location
1642
- - name: flags
1643
- type: flags
1644
- kind: RegularExpressionFlags
1645
1781
  newline: parts
1646
1782
  comment: |
1647
1783
  Represents a regular expression literal that contains interpolation.
@@ -1692,6 +1828,9 @@ nodes:
1692
1828
  ^^^^^^^^^^^^^^^^
1693
1829
  - name: KeywordHashNode
1694
1830
  fields:
1831
+ - name: flags
1832
+ type: flags
1833
+ kind: KeywordHashNodeFlags
1695
1834
  - name: elements
1696
1835
  type: node[]
1697
1836
  comment: |
@@ -1717,6 +1856,8 @@ nodes:
1717
1856
  fields:
1718
1857
  - name: locals
1719
1858
  type: constant[]
1859
+ - name: locals_body_index
1860
+ type: uint32
1720
1861
  - name: operator_loc
1721
1862
  type: location
1722
1863
  - name: opening_loc
@@ -1725,7 +1866,6 @@ nodes:
1725
1866
  type: location
1726
1867
  - name: parameters
1727
1868
  type: node?
1728
- kind: BlockParametersNode
1729
1869
  - name: body
1730
1870
  type: node?
1731
1871
  comment: |
@@ -1829,6 +1969,9 @@ nodes:
1829
1969
  ^^^^^^^
1830
1970
  - name: MatchLastLineNode
1831
1971
  fields:
1972
+ - name: flags
1973
+ type: flags
1974
+ kind: RegularExpressionFlags
1832
1975
  - name: opening_loc
1833
1976
  type: location
1834
1977
  - name: content_loc
@@ -1837,9 +1980,6 @@ nodes:
1837
1980
  type: location
1838
1981
  - name: unescaped
1839
1982
  type: string
1840
- - name: flags
1841
- type: flags
1842
- kind: RegularExpressionFlags
1843
1983
  comment: |
1844
1984
  Represents a regular expression literal used in the predicate of a
1845
1985
  conditional to implicitly match against the last line read by an IO
@@ -1878,8 +2018,8 @@ nodes:
1878
2018
  - name: call
1879
2019
  type: node
1880
2020
  kind: CallNode
1881
- - name: locals
1882
- type: constant[]
2021
+ - name: targets
2022
+ type: node[]
1883
2023
  comment: |
1884
2024
  Represents writing local variables using a regular expression match with
1885
2025
  named capture groups.
@@ -1977,6 +2117,16 @@ nodes:
1977
2117
  def a(**nil)
1978
2118
  ^^^^^
1979
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
+ ^^^^^^^^^^^^^^
1980
2130
  - name: NumberedReferenceReadNode
1981
2131
  fields:
1982
2132
  - name: number
@@ -2037,7 +2187,6 @@ nodes:
2037
2187
  type: node[]
2038
2188
  - name: rest
2039
2189
  type: node?
2040
- kind: RestParameterNode
2041
2190
  - name: posts
2042
2191
  type: node[]
2043
2192
  - name: keywords
@@ -2137,15 +2286,15 @@ nodes:
2137
2286
  comment: The top level node of any parse tree.
2138
2287
  - name: RangeNode
2139
2288
  fields:
2289
+ - name: flags
2290
+ type: flags
2291
+ kind: RangeFlags
2140
2292
  - name: left
2141
2293
  type: node?
2142
2294
  - name: right
2143
2295
  type: node?
2144
2296
  - name: operator_loc
2145
2297
  type: location
2146
- - name: flags
2147
- type: flags
2148
- kind: RangeFlags
2149
2298
  comment: |
2150
2299
  Represents the use of the `..` or `...` operators.
2151
2300
 
@@ -2171,6 +2320,9 @@ nodes:
2171
2320
  ^^^^
2172
2321
  - name: RegularExpressionNode
2173
2322
  fields:
2323
+ - name: flags
2324
+ type: flags
2325
+ kind: RegularExpressionFlags
2174
2326
  - name: opening_loc
2175
2327
  type: location
2176
2328
  - name: content_loc
@@ -2179,9 +2331,6 @@ nodes:
2179
2331
  type: location
2180
2332
  - name: unescaped
2181
2333
  type: string
2182
- - name: flags
2183
- type: flags
2184
- kind: RegularExpressionFlags
2185
2334
  comment: |
2186
2335
  Represents a regular expression literal with no interpolation.
2187
2336
 
@@ -2348,17 +2497,6 @@ nodes:
2348
2497
 
2349
2498
  foo; bar; baz
2350
2499
  ^^^^^^^^^^^^^
2351
- - name: StringConcatNode
2352
- fields:
2353
- - name: left
2354
- type: node
2355
- - name: right
2356
- type: node
2357
- comment: |
2358
- Represents the use of compile-time string concatenation.
2359
-
2360
- "foo" "bar"
2361
- ^^^^^^^^^^^
2362
2500
  - name: StringNode
2363
2501
  fields:
2364
2502
  - name: flags
@@ -2407,6 +2545,9 @@ nodes:
2407
2545
  ^^^^^^^^^^^^^^
2408
2546
  - name: SymbolNode
2409
2547
  fields:
2548
+ - name: flags
2549
+ type: flags
2550
+ kind: SymbolFlags
2410
2551
  - name: opening_loc
2411
2552
  type: location?
2412
2553
  - name: value_loc
@@ -2446,6 +2587,8 @@ nodes:
2446
2587
  type: location
2447
2588
  - name: predicate
2448
2589
  type: node
2590
+ - name: then_keyword_loc
2591
+ type: location?
2449
2592
  - name: statements
2450
2593
  type: node?
2451
2594
  kind: StatementsNode
@@ -2465,6 +2608,9 @@ nodes:
2465
2608
  ^^^^^^^^^^^^^^^^^^^^^^^
2466
2609
  - name: UntilNode
2467
2610
  fields:
2611
+ - name: flags
2612
+ type: flags
2613
+ kind: LoopFlags
2468
2614
  - name: keyword_loc
2469
2615
  type: location
2470
2616
  - name: closing_loc
@@ -2474,9 +2620,6 @@ nodes:
2474
2620
  - name: statements
2475
2621
  type: node?
2476
2622
  kind: StatementsNode
2477
- - name: flags
2478
- type: flags
2479
- kind: LoopFlags
2480
2623
  newline: predicate
2481
2624
  comment: |
2482
2625
  Represents the use of the `until` keyword, either in the block form or the modifier form.
@@ -2504,6 +2647,9 @@ nodes:
2504
2647
  end
2505
2648
  - name: WhileNode
2506
2649
  fields:
2650
+ - name: flags
2651
+ type: flags
2652
+ kind: LoopFlags
2507
2653
  - name: keyword_loc
2508
2654
  type: location
2509
2655
  - name: closing_loc
@@ -2513,9 +2659,6 @@ nodes:
2513
2659
  - name: statements
2514
2660
  type: node?
2515
2661
  kind: StatementsNode
2516
- - name: flags
2517
- type: flags
2518
- kind: LoopFlags
2519
2662
  newline: predicate
2520
2663
  comment: |
2521
2664
  Represents the use of the `while` keyword, either in the block form or the modifier form.
@@ -2527,6 +2670,9 @@ nodes:
2527
2670
  ^^^^^^^^^^^^^^^^^^^^
2528
2671
  - name: XStringNode
2529
2672
  fields:
2673
+ - name: flags
2674
+ type: flags
2675
+ kind: EncodingFlags
2530
2676
  - name: opening_loc
2531
2677
  type: location
2532
2678
  - name: content_loc
data/docs/build_system.md CHANGED
@@ -16,14 +16,14 @@ The main solution for the second point seems a Makefile, otherwise many of the u
16
16
  ## General Design
17
17
 
18
18
  1. Templates are generated by `templates/template.rb`
19
- 4. The `Makefile` compiles both `librubyparser.a` and `librubyparser.{so,dylib,dll}` from the `src/**/*.c` and `include/**/*.h` files
19
+ 4. The `Makefile` compiles both `libprism.a` and `libprism.{so,dylib,dll}` from the `src/**/*.c` and `include/**/*.h` files
20
20
  5. The `Rakefile` `:compile` task ensures the above prerequisites are done, then calls `make`,
21
- and uses `Rake::ExtensionTask` to compile the C extension (using its `extconf.rb`), which uses `librubyparser.a`
21
+ and uses `Rake::ExtensionTask` to compile the C extension (using its `extconf.rb`), which uses `libprism.a`
22
22
 
23
23
  This way there is minimal duplication, and each layer builds on the previous one and has its own responsibilities.
24
24
 
25
25
  The static library exports no symbols, to avoid any conflict.
26
- The shared library exports some symbols, and this is fine since there should only be one librubyparser shared library
26
+ The shared library exports some symbols, and this is fine since there should only be one libprism shared library
27
27
  loaded per process (i.e., at most one version of the prism *gem* loaded in a process, only the gem uses the shared library).
28
28
 
29
29
  ## The various ways to build prism
@@ -36,11 +36,11 @@ loaded per process (i.e., at most one version of the prism *gem* loaded in a pro
36
36
 
37
37
  The gem contains the pre-generated templates.
38
38
  When installing the gem, `extconf.rb` is used and that:
39
- * runs `make build/librubyparser.a`
39
+ * runs `make build/libprism.a`
40
40
  * compiles the C extension with mkmf
41
41
 
42
42
  When installing the gem on JRuby and TruffleRuby, no C extension is built, so instead of the last step,
43
- there is Ruby code using FFI which uses `librubyparser.{so,dylib,dll}`
43
+ there is Ruby code using FFI which uses `libprism.{so,dylib,dll}`
44
44
  to implement the same methods as the C extension, but using serialization instead of many native calls/accesses
45
45
  (JRuby does not support C extensions, serialization is faster on TruffleRuby than the C extension).
46
46
 
@@ -67,7 +67,7 @@ The script generates the templates when importing.
67
67
  Then when `mx build` builds TruffleRuby and the `prism` mx project inside, it runs `make`.
68
68
 
69
69
  Then the `prism bindings` mx project is built, which contains the [bindings](https://github.com/oracle/truffleruby/blob/master/src/main/c/prism_bindings/src/prism_bindings.c)
70
- and links to `librubyparser.a` (to avoid exporting symbols, so no conflict when installing the prism gem).
70
+ and links to `libprism.a` (to avoid exporting symbols, so no conflict when installing the prism gem).
71
71
 
72
72
  ### Building prism as part of JRuby
73
73
 
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
 
@@ -10,7 +9,7 @@ All of the source files match `src/**/*.c` and all of the headers match `include
10
9
  The following flags should be used to compile prism:
11
10
 
12
11
  * `-std=c99` - Use the C99 standard
13
- * `-Wall -Wconversion -Wextra -Wpedantic -Wundef` - Enable the warnings we care about
12
+ * `-Wall -Wconversion -Wextra -Wpedantic -Wundef -Wno-missing-braces` - Enable the warnings we care about
14
13
  * `-Werror` - Treat warnings as errors
15
14
  * `-fvisibility=hidden` - Hide all symbols by default
16
15
 
@@ -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
+ ```