prism 0.17.1 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -1
  3. data/Makefile +5 -5
  4. data/README.md +2 -2
  5. data/config.yml +26 -13
  6. data/docs/build_system.md +6 -6
  7. data/docs/building.md +1 -1
  8. data/docs/configuration.md +1 -0
  9. data/docs/encoding.md +68 -32
  10. data/docs/heredocs.md +1 -1
  11. data/docs/javascript.md +29 -1
  12. data/docs/ruby_api.md +14 -0
  13. data/ext/prism/api_node.c +74 -45
  14. data/ext/prism/extconf.rb +91 -127
  15. data/ext/prism/extension.c +1 -1
  16. data/ext/prism/extension.h +1 -1
  17. data/include/prism/ast.h +148 -133
  18. data/include/prism/diagnostic.h +27 -1
  19. data/include/prism/enc/pm_encoding.h +42 -1
  20. data/include/prism/parser.h +6 -0
  21. data/include/prism/version.h +3 -3
  22. data/lib/prism/compiler.rb +3 -3
  23. data/lib/prism/debug.rb +4 -0
  24. data/lib/prism/desugar_compiler.rb +1 -0
  25. data/lib/prism/dispatcher.rb +14 -14
  26. data/lib/prism/dot_visitor.rb +4334 -0
  27. data/lib/prism/dsl.rb +11 -11
  28. data/lib/prism/ffi.rb +3 -3
  29. data/lib/prism/mutation_compiler.rb +6 -6
  30. data/lib/prism/node.rb +182 -113
  31. data/lib/prism/node_ext.rb +61 -3
  32. data/lib/prism/parse_result.rb +46 -12
  33. data/lib/prism/serialize.rb +125 -131
  34. data/lib/prism/visitor.rb +3 -3
  35. data/lib/prism.rb +1 -0
  36. data/prism.gemspec +5 -1
  37. data/rbi/prism.rbi +83 -54
  38. data/sig/prism.rbs +47 -32
  39. data/src/diagnostic.c +61 -3
  40. data/src/enc/pm_big5.c +63 -0
  41. data/src/enc/pm_cp51932.c +57 -0
  42. data/src/enc/pm_euc_jp.c +10 -0
  43. data/src/enc/pm_gbk.c +5 -2
  44. data/src/enc/pm_tables.c +1478 -148
  45. data/src/node.c +33 -21
  46. data/src/prettyprint.c +1027 -925
  47. data/src/prism.c +925 -374
  48. data/src/regexp.c +12 -12
  49. data/src/serialize.c +36 -9
  50. metadata +6 -2
data/include/prism/ast.h CHANGED
@@ -634,338 +634,338 @@ enum pm_node_type {
634
634
  /** CapturePatternNode */
635
635
  PM_CAPTURE_PATTERN_NODE = 22,
636
636
 
637
+ /** CaseMatchNode */
638
+ PM_CASE_MATCH_NODE = 23,
639
+
637
640
  /** CaseNode */
638
- PM_CASE_NODE = 23,
641
+ PM_CASE_NODE = 24,
639
642
 
640
643
  /** ClassNode */
641
- PM_CLASS_NODE = 24,
644
+ PM_CLASS_NODE = 25,
642
645
 
643
646
  /** ClassVariableAndWriteNode */
644
- PM_CLASS_VARIABLE_AND_WRITE_NODE = 25,
647
+ PM_CLASS_VARIABLE_AND_WRITE_NODE = 26,
645
648
 
646
649
  /** ClassVariableOperatorWriteNode */
647
- PM_CLASS_VARIABLE_OPERATOR_WRITE_NODE = 26,
650
+ PM_CLASS_VARIABLE_OPERATOR_WRITE_NODE = 27,
648
651
 
649
652
  /** ClassVariableOrWriteNode */
650
- PM_CLASS_VARIABLE_OR_WRITE_NODE = 27,
653
+ PM_CLASS_VARIABLE_OR_WRITE_NODE = 28,
651
654
 
652
655
  /** ClassVariableReadNode */
653
- PM_CLASS_VARIABLE_READ_NODE = 28,
656
+ PM_CLASS_VARIABLE_READ_NODE = 29,
654
657
 
655
658
  /** ClassVariableTargetNode */
656
- PM_CLASS_VARIABLE_TARGET_NODE = 29,
659
+ PM_CLASS_VARIABLE_TARGET_NODE = 30,
657
660
 
658
661
  /** ClassVariableWriteNode */
659
- PM_CLASS_VARIABLE_WRITE_NODE = 30,
662
+ PM_CLASS_VARIABLE_WRITE_NODE = 31,
660
663
 
661
664
  /** ConstantAndWriteNode */
662
- PM_CONSTANT_AND_WRITE_NODE = 31,
665
+ PM_CONSTANT_AND_WRITE_NODE = 32,
663
666
 
664
667
  /** ConstantOperatorWriteNode */
665
- PM_CONSTANT_OPERATOR_WRITE_NODE = 32,
668
+ PM_CONSTANT_OPERATOR_WRITE_NODE = 33,
666
669
 
667
670
  /** ConstantOrWriteNode */
668
- PM_CONSTANT_OR_WRITE_NODE = 33,
671
+ PM_CONSTANT_OR_WRITE_NODE = 34,
669
672
 
670
673
  /** ConstantPathAndWriteNode */
671
- PM_CONSTANT_PATH_AND_WRITE_NODE = 34,
674
+ PM_CONSTANT_PATH_AND_WRITE_NODE = 35,
672
675
 
673
676
  /** ConstantPathNode */
674
- PM_CONSTANT_PATH_NODE = 35,
677
+ PM_CONSTANT_PATH_NODE = 36,
675
678
 
676
679
  /** ConstantPathOperatorWriteNode */
677
- PM_CONSTANT_PATH_OPERATOR_WRITE_NODE = 36,
680
+ PM_CONSTANT_PATH_OPERATOR_WRITE_NODE = 37,
678
681
 
679
682
  /** ConstantPathOrWriteNode */
680
- PM_CONSTANT_PATH_OR_WRITE_NODE = 37,
683
+ PM_CONSTANT_PATH_OR_WRITE_NODE = 38,
681
684
 
682
685
  /** ConstantPathTargetNode */
683
- PM_CONSTANT_PATH_TARGET_NODE = 38,
686
+ PM_CONSTANT_PATH_TARGET_NODE = 39,
684
687
 
685
688
  /** ConstantPathWriteNode */
686
- PM_CONSTANT_PATH_WRITE_NODE = 39,
689
+ PM_CONSTANT_PATH_WRITE_NODE = 40,
687
690
 
688
691
  /** ConstantReadNode */
689
- PM_CONSTANT_READ_NODE = 40,
692
+ PM_CONSTANT_READ_NODE = 41,
690
693
 
691
694
  /** ConstantTargetNode */
692
- PM_CONSTANT_TARGET_NODE = 41,
695
+ PM_CONSTANT_TARGET_NODE = 42,
693
696
 
694
697
  /** ConstantWriteNode */
695
- PM_CONSTANT_WRITE_NODE = 42,
698
+ PM_CONSTANT_WRITE_NODE = 43,
696
699
 
697
700
  /** DefNode */
698
- PM_DEF_NODE = 43,
701
+ PM_DEF_NODE = 44,
699
702
 
700
703
  /** DefinedNode */
701
- PM_DEFINED_NODE = 44,
704
+ PM_DEFINED_NODE = 45,
702
705
 
703
706
  /** ElseNode */
704
- PM_ELSE_NODE = 45,
707
+ PM_ELSE_NODE = 46,
705
708
 
706
709
  /** EmbeddedStatementsNode */
707
- PM_EMBEDDED_STATEMENTS_NODE = 46,
710
+ PM_EMBEDDED_STATEMENTS_NODE = 47,
708
711
 
709
712
  /** EmbeddedVariableNode */
710
- PM_EMBEDDED_VARIABLE_NODE = 47,
713
+ PM_EMBEDDED_VARIABLE_NODE = 48,
711
714
 
712
715
  /** EnsureNode */
713
- PM_ENSURE_NODE = 48,
716
+ PM_ENSURE_NODE = 49,
714
717
 
715
718
  /** FalseNode */
716
- PM_FALSE_NODE = 49,
719
+ PM_FALSE_NODE = 50,
717
720
 
718
721
  /** FindPatternNode */
719
- PM_FIND_PATTERN_NODE = 50,
722
+ PM_FIND_PATTERN_NODE = 51,
720
723
 
721
724
  /** FlipFlopNode */
722
- PM_FLIP_FLOP_NODE = 51,
725
+ PM_FLIP_FLOP_NODE = 52,
723
726
 
724
727
  /** FloatNode */
725
- PM_FLOAT_NODE = 52,
728
+ PM_FLOAT_NODE = 53,
726
729
 
727
730
  /** ForNode */
728
- PM_FOR_NODE = 53,
731
+ PM_FOR_NODE = 54,
729
732
 
730
733
  /** ForwardingArgumentsNode */
731
- PM_FORWARDING_ARGUMENTS_NODE = 54,
734
+ PM_FORWARDING_ARGUMENTS_NODE = 55,
732
735
 
733
736
  /** ForwardingParameterNode */
734
- PM_FORWARDING_PARAMETER_NODE = 55,
737
+ PM_FORWARDING_PARAMETER_NODE = 56,
735
738
 
736
739
  /** ForwardingSuperNode */
737
- PM_FORWARDING_SUPER_NODE = 56,
740
+ PM_FORWARDING_SUPER_NODE = 57,
738
741
 
739
742
  /** GlobalVariableAndWriteNode */
740
- PM_GLOBAL_VARIABLE_AND_WRITE_NODE = 57,
743
+ PM_GLOBAL_VARIABLE_AND_WRITE_NODE = 58,
741
744
 
742
745
  /** GlobalVariableOperatorWriteNode */
743
- PM_GLOBAL_VARIABLE_OPERATOR_WRITE_NODE = 58,
746
+ PM_GLOBAL_VARIABLE_OPERATOR_WRITE_NODE = 59,
744
747
 
745
748
  /** GlobalVariableOrWriteNode */
746
- PM_GLOBAL_VARIABLE_OR_WRITE_NODE = 59,
749
+ PM_GLOBAL_VARIABLE_OR_WRITE_NODE = 60,
747
750
 
748
751
  /** GlobalVariableReadNode */
749
- PM_GLOBAL_VARIABLE_READ_NODE = 60,
752
+ PM_GLOBAL_VARIABLE_READ_NODE = 61,
750
753
 
751
754
  /** GlobalVariableTargetNode */
752
- PM_GLOBAL_VARIABLE_TARGET_NODE = 61,
755
+ PM_GLOBAL_VARIABLE_TARGET_NODE = 62,
753
756
 
754
757
  /** GlobalVariableWriteNode */
755
- PM_GLOBAL_VARIABLE_WRITE_NODE = 62,
758
+ PM_GLOBAL_VARIABLE_WRITE_NODE = 63,
756
759
 
757
760
  /** HashNode */
758
- PM_HASH_NODE = 63,
761
+ PM_HASH_NODE = 64,
759
762
 
760
763
  /** HashPatternNode */
761
- PM_HASH_PATTERN_NODE = 64,
764
+ PM_HASH_PATTERN_NODE = 65,
762
765
 
763
766
  /** IfNode */
764
- PM_IF_NODE = 65,
767
+ PM_IF_NODE = 66,
765
768
 
766
769
  /** ImaginaryNode */
767
- PM_IMAGINARY_NODE = 66,
770
+ PM_IMAGINARY_NODE = 67,
768
771
 
769
772
  /** ImplicitNode */
770
- PM_IMPLICIT_NODE = 67,
773
+ PM_IMPLICIT_NODE = 68,
771
774
 
772
775
  /** InNode */
773
- PM_IN_NODE = 68,
776
+ PM_IN_NODE = 69,
774
777
 
775
778
  /** IndexAndWriteNode */
776
- PM_INDEX_AND_WRITE_NODE = 69,
779
+ PM_INDEX_AND_WRITE_NODE = 70,
777
780
 
778
781
  /** IndexOperatorWriteNode */
779
- PM_INDEX_OPERATOR_WRITE_NODE = 70,
782
+ PM_INDEX_OPERATOR_WRITE_NODE = 71,
780
783
 
781
784
  /** IndexOrWriteNode */
782
- PM_INDEX_OR_WRITE_NODE = 71,
785
+ PM_INDEX_OR_WRITE_NODE = 72,
783
786
 
784
787
  /** InstanceVariableAndWriteNode */
785
- PM_INSTANCE_VARIABLE_AND_WRITE_NODE = 72,
788
+ PM_INSTANCE_VARIABLE_AND_WRITE_NODE = 73,
786
789
 
787
790
  /** InstanceVariableOperatorWriteNode */
788
- PM_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE = 73,
791
+ PM_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE = 74,
789
792
 
790
793
  /** InstanceVariableOrWriteNode */
791
- PM_INSTANCE_VARIABLE_OR_WRITE_NODE = 74,
794
+ PM_INSTANCE_VARIABLE_OR_WRITE_NODE = 75,
792
795
 
793
796
  /** InstanceVariableReadNode */
794
- PM_INSTANCE_VARIABLE_READ_NODE = 75,
797
+ PM_INSTANCE_VARIABLE_READ_NODE = 76,
795
798
 
796
799
  /** InstanceVariableTargetNode */
797
- PM_INSTANCE_VARIABLE_TARGET_NODE = 76,
800
+ PM_INSTANCE_VARIABLE_TARGET_NODE = 77,
798
801
 
799
802
  /** InstanceVariableWriteNode */
800
- PM_INSTANCE_VARIABLE_WRITE_NODE = 77,
803
+ PM_INSTANCE_VARIABLE_WRITE_NODE = 78,
801
804
 
802
805
  /** IntegerNode */
803
- PM_INTEGER_NODE = 78,
806
+ PM_INTEGER_NODE = 79,
804
807
 
805
808
  /** InterpolatedMatchLastLineNode */
806
- PM_INTERPOLATED_MATCH_LAST_LINE_NODE = 79,
809
+ PM_INTERPOLATED_MATCH_LAST_LINE_NODE = 80,
807
810
 
808
811
  /** InterpolatedRegularExpressionNode */
809
- PM_INTERPOLATED_REGULAR_EXPRESSION_NODE = 80,
812
+ PM_INTERPOLATED_REGULAR_EXPRESSION_NODE = 81,
810
813
 
811
814
  /** InterpolatedStringNode */
812
- PM_INTERPOLATED_STRING_NODE = 81,
815
+ PM_INTERPOLATED_STRING_NODE = 82,
813
816
 
814
817
  /** InterpolatedSymbolNode */
815
- PM_INTERPOLATED_SYMBOL_NODE = 82,
818
+ PM_INTERPOLATED_SYMBOL_NODE = 83,
816
819
 
817
820
  /** InterpolatedXStringNode */
818
- PM_INTERPOLATED_X_STRING_NODE = 83,
821
+ PM_INTERPOLATED_X_STRING_NODE = 84,
819
822
 
820
823
  /** KeywordHashNode */
821
- PM_KEYWORD_HASH_NODE = 84,
824
+ PM_KEYWORD_HASH_NODE = 85,
822
825
 
823
826
  /** KeywordRestParameterNode */
824
- PM_KEYWORD_REST_PARAMETER_NODE = 85,
827
+ PM_KEYWORD_REST_PARAMETER_NODE = 86,
825
828
 
826
829
  /** LambdaNode */
827
- PM_LAMBDA_NODE = 86,
830
+ PM_LAMBDA_NODE = 87,
828
831
 
829
832
  /** LocalVariableAndWriteNode */
830
- PM_LOCAL_VARIABLE_AND_WRITE_NODE = 87,
833
+ PM_LOCAL_VARIABLE_AND_WRITE_NODE = 88,
831
834
 
832
835
  /** LocalVariableOperatorWriteNode */
833
- PM_LOCAL_VARIABLE_OPERATOR_WRITE_NODE = 88,
836
+ PM_LOCAL_VARIABLE_OPERATOR_WRITE_NODE = 89,
834
837
 
835
838
  /** LocalVariableOrWriteNode */
836
- PM_LOCAL_VARIABLE_OR_WRITE_NODE = 89,
839
+ PM_LOCAL_VARIABLE_OR_WRITE_NODE = 90,
837
840
 
838
841
  /** LocalVariableReadNode */
839
- PM_LOCAL_VARIABLE_READ_NODE = 90,
842
+ PM_LOCAL_VARIABLE_READ_NODE = 91,
840
843
 
841
844
  /** LocalVariableTargetNode */
842
- PM_LOCAL_VARIABLE_TARGET_NODE = 91,
845
+ PM_LOCAL_VARIABLE_TARGET_NODE = 92,
843
846
 
844
847
  /** LocalVariableWriteNode */
845
- PM_LOCAL_VARIABLE_WRITE_NODE = 92,
848
+ PM_LOCAL_VARIABLE_WRITE_NODE = 93,
846
849
 
847
850
  /** MatchLastLineNode */
848
- PM_MATCH_LAST_LINE_NODE = 93,
851
+ PM_MATCH_LAST_LINE_NODE = 94,
849
852
 
850
853
  /** MatchPredicateNode */
851
- PM_MATCH_PREDICATE_NODE = 94,
854
+ PM_MATCH_PREDICATE_NODE = 95,
852
855
 
853
856
  /** MatchRequiredNode */
854
- PM_MATCH_REQUIRED_NODE = 95,
857
+ PM_MATCH_REQUIRED_NODE = 96,
855
858
 
856
859
  /** MatchWriteNode */
857
- PM_MATCH_WRITE_NODE = 96,
860
+ PM_MATCH_WRITE_NODE = 97,
858
861
 
859
862
  /** MissingNode */
860
- PM_MISSING_NODE = 97,
863
+ PM_MISSING_NODE = 98,
861
864
 
862
865
  /** ModuleNode */
863
- PM_MODULE_NODE = 98,
866
+ PM_MODULE_NODE = 99,
864
867
 
865
868
  /** MultiTargetNode */
866
- PM_MULTI_TARGET_NODE = 99,
869
+ PM_MULTI_TARGET_NODE = 100,
867
870
 
868
871
  /** MultiWriteNode */
869
- PM_MULTI_WRITE_NODE = 100,
872
+ PM_MULTI_WRITE_NODE = 101,
870
873
 
871
874
  /** NextNode */
872
- PM_NEXT_NODE = 101,
875
+ PM_NEXT_NODE = 102,
873
876
 
874
877
  /** NilNode */
875
- PM_NIL_NODE = 102,
878
+ PM_NIL_NODE = 103,
876
879
 
877
880
  /** NoKeywordsParameterNode */
878
- PM_NO_KEYWORDS_PARAMETER_NODE = 103,
881
+ PM_NO_KEYWORDS_PARAMETER_NODE = 104,
879
882
 
880
883
  /** NumberedReferenceReadNode */
881
- PM_NUMBERED_REFERENCE_READ_NODE = 104,
884
+ PM_NUMBERED_REFERENCE_READ_NODE = 105,
882
885
 
883
886
  /** OptionalKeywordParameterNode */
884
- PM_OPTIONAL_KEYWORD_PARAMETER_NODE = 105,
887
+ PM_OPTIONAL_KEYWORD_PARAMETER_NODE = 106,
885
888
 
886
889
  /** OptionalParameterNode */
887
- PM_OPTIONAL_PARAMETER_NODE = 106,
890
+ PM_OPTIONAL_PARAMETER_NODE = 107,
888
891
 
889
892
  /** OrNode */
890
- PM_OR_NODE = 107,
893
+ PM_OR_NODE = 108,
891
894
 
892
895
  /** ParametersNode */
893
- PM_PARAMETERS_NODE = 108,
896
+ PM_PARAMETERS_NODE = 109,
894
897
 
895
898
  /** ParenthesesNode */
896
- PM_PARENTHESES_NODE = 109,
899
+ PM_PARENTHESES_NODE = 110,
897
900
 
898
901
  /** PinnedExpressionNode */
899
- PM_PINNED_EXPRESSION_NODE = 110,
902
+ PM_PINNED_EXPRESSION_NODE = 111,
900
903
 
901
904
  /** PinnedVariableNode */
902
- PM_PINNED_VARIABLE_NODE = 111,
905
+ PM_PINNED_VARIABLE_NODE = 112,
903
906
 
904
907
  /** PostExecutionNode */
905
- PM_POST_EXECUTION_NODE = 112,
908
+ PM_POST_EXECUTION_NODE = 113,
906
909
 
907
910
  /** PreExecutionNode */
908
- PM_PRE_EXECUTION_NODE = 113,
911
+ PM_PRE_EXECUTION_NODE = 114,
909
912
 
910
913
  /** ProgramNode */
911
- PM_PROGRAM_NODE = 114,
914
+ PM_PROGRAM_NODE = 115,
912
915
 
913
916
  /** RangeNode */
914
- PM_RANGE_NODE = 115,
917
+ PM_RANGE_NODE = 116,
915
918
 
916
919
  /** RationalNode */
917
- PM_RATIONAL_NODE = 116,
920
+ PM_RATIONAL_NODE = 117,
918
921
 
919
922
  /** RedoNode */
920
- PM_REDO_NODE = 117,
923
+ PM_REDO_NODE = 118,
921
924
 
922
925
  /** RegularExpressionNode */
923
- PM_REGULAR_EXPRESSION_NODE = 118,
926
+ PM_REGULAR_EXPRESSION_NODE = 119,
924
927
 
925
928
  /** RequiredKeywordParameterNode */
926
- PM_REQUIRED_KEYWORD_PARAMETER_NODE = 119,
929
+ PM_REQUIRED_KEYWORD_PARAMETER_NODE = 120,
927
930
 
928
931
  /** RequiredParameterNode */
929
- PM_REQUIRED_PARAMETER_NODE = 120,
932
+ PM_REQUIRED_PARAMETER_NODE = 121,
930
933
 
931
934
  /** RescueModifierNode */
932
- PM_RESCUE_MODIFIER_NODE = 121,
935
+ PM_RESCUE_MODIFIER_NODE = 122,
933
936
 
934
937
  /** RescueNode */
935
- PM_RESCUE_NODE = 122,
938
+ PM_RESCUE_NODE = 123,
936
939
 
937
940
  /** RestParameterNode */
938
- PM_REST_PARAMETER_NODE = 123,
941
+ PM_REST_PARAMETER_NODE = 124,
939
942
 
940
943
  /** RetryNode */
941
- PM_RETRY_NODE = 124,
944
+ PM_RETRY_NODE = 125,
942
945
 
943
946
  /** ReturnNode */
944
- PM_RETURN_NODE = 125,
947
+ PM_RETURN_NODE = 126,
945
948
 
946
949
  /** SelfNode */
947
- PM_SELF_NODE = 126,
950
+ PM_SELF_NODE = 127,
948
951
 
949
952
  /** SingletonClassNode */
950
- PM_SINGLETON_CLASS_NODE = 127,
953
+ PM_SINGLETON_CLASS_NODE = 128,
951
954
 
952
955
  /** SourceEncodingNode */
953
- PM_SOURCE_ENCODING_NODE = 128,
956
+ PM_SOURCE_ENCODING_NODE = 129,
954
957
 
955
958
  /** SourceFileNode */
956
- PM_SOURCE_FILE_NODE = 129,
959
+ PM_SOURCE_FILE_NODE = 130,
957
960
 
958
961
  /** SourceLineNode */
959
- PM_SOURCE_LINE_NODE = 130,
962
+ PM_SOURCE_LINE_NODE = 131,
960
963
 
961
964
  /** SplatNode */
962
- PM_SPLAT_NODE = 131,
965
+ PM_SPLAT_NODE = 132,
963
966
 
964
967
  /** StatementsNode */
965
- PM_STATEMENTS_NODE = 132,
966
-
967
- /** StringConcatNode */
968
- PM_STRING_CONCAT_NODE = 133,
968
+ PM_STATEMENTS_NODE = 133,
969
969
 
970
970
  /** StringNode */
971
971
  PM_STRING_NODE = 134,
@@ -1591,6 +1591,33 @@ typedef struct pm_capture_pattern_node {
1591
1591
  pm_location_t operator_loc;
1592
1592
  } pm_capture_pattern_node_t;
1593
1593
 
1594
+ /**
1595
+ * CaseMatchNode
1596
+ *
1597
+ * Type: PM_CASE_MATCH_NODE
1598
+ *
1599
+ * @extends pm_node_t
1600
+ */
1601
+ typedef struct pm_case_match_node {
1602
+ /** The embedded base node. */
1603
+ pm_node_t base;
1604
+
1605
+ /** CaseMatchNode#predicate */
1606
+ struct pm_node *predicate;
1607
+
1608
+ /** CaseMatchNode#conditions */
1609
+ struct pm_node_list conditions;
1610
+
1611
+ /** CaseMatchNode#consequent */
1612
+ struct pm_else_node *consequent;
1613
+
1614
+ /** CaseMatchNode#case_keyword_loc */
1615
+ pm_location_t case_keyword_loc;
1616
+
1617
+ /** CaseMatchNode#end_keyword_loc */
1618
+ pm_location_t end_keyword_loc;
1619
+ } pm_case_match_node_t;
1620
+
1594
1621
  /**
1595
1622
  * CaseNode
1596
1623
  *
@@ -2537,6 +2564,9 @@ typedef struct pm_if_node {
2537
2564
  /** IfNode#predicate */
2538
2565
  struct pm_node *predicate;
2539
2566
 
2567
+ /** IfNode#then_keyword_loc */
2568
+ pm_location_t then_keyword_loc;
2569
+
2540
2570
  /** IfNode#statements */
2541
2571
  struct pm_statements_node *statements;
2542
2572
 
@@ -3292,8 +3322,8 @@ typedef struct pm_match_write_node {
3292
3322
  /** MatchWriteNode#call */
3293
3323
  struct pm_call_node *call;
3294
3324
 
3295
- /** MatchWriteNode#locals */
3296
- pm_constant_id_list_t locals;
3325
+ /** MatchWriteNode#targets */
3326
+ struct pm_node_list targets;
3297
3327
  } pm_match_write_node_t;
3298
3328
 
3299
3329
  /**
@@ -4021,24 +4051,6 @@ typedef struct pm_statements_node {
4021
4051
  struct pm_node_list body;
4022
4052
  } pm_statements_node_t;
4023
4053
 
4024
- /**
4025
- * StringConcatNode
4026
- *
4027
- * Type: PM_STRING_CONCAT_NODE
4028
- *
4029
- * @extends pm_node_t
4030
- */
4031
- typedef struct pm_string_concat_node {
4032
- /** The embedded base node. */
4033
- pm_node_t base;
4034
-
4035
- /** StringConcatNode#left */
4036
- struct pm_node *left;
4037
-
4038
- /** StringConcatNode#right */
4039
- struct pm_node *right;
4040
- } pm_string_concat_node_t;
4041
-
4042
4054
  /**
4043
4055
  * StringNode
4044
4056
  *
@@ -4163,6 +4175,9 @@ typedef struct pm_unless_node {
4163
4175
  /** UnlessNode#predicate */
4164
4176
  struct pm_node *predicate;
4165
4177
 
4178
+ /** UnlessNode#then_keyword_loc */
4179
+ pm_location_t then_keyword_loc;
4180
+
4166
4181
  /** UnlessNode#statements */
4167
4182
  struct pm_statements_node *statements;
4168
4183
 
@@ -30,6 +30,13 @@ typedef struct {
30
30
 
31
31
  /** The message associated with the diagnostic. */
32
32
  const char *message;
33
+
34
+ /**
35
+ * Whether or not the memory related to the message of this diagnostic is
36
+ * owned by this diagnostic. If it is, it needs to be freed when the
37
+ * diagnostic is freed.
38
+ */
39
+ bool owned;
33
40
  } pm_diagnostic_t;
34
41
 
35
42
  /**
@@ -40,12 +47,14 @@ typedef enum {
40
47
  PM_ERR_ALIAS_ARGUMENT,
41
48
  PM_ERR_AMPAMPEQ_MULTI_ASSIGN,
42
49
  PM_ERR_ARGUMENT_AFTER_BLOCK,
50
+ PM_ERR_ARGUMENT_AFTER_FORWARDING_ELLIPSES,
43
51
  PM_ERR_ARGUMENT_BARE_HASH,
44
52
  PM_ERR_ARGUMENT_BLOCK_MULTI,
45
53
  PM_ERR_ARGUMENT_FORMAL_CLASS,
46
54
  PM_ERR_ARGUMENT_FORMAL_CONSTANT,
47
55
  PM_ERR_ARGUMENT_FORMAL_GLOBAL,
48
56
  PM_ERR_ARGUMENT_FORMAL_IVAR,
57
+ PM_ERR_ARGUMENT_FORWARDING_UNBOUND,
49
58
  PM_ERR_ARGUMENT_NO_FORWARDING_AMP,
50
59
  PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES,
51
60
  PM_ERR_ARGUMENT_NO_FORWARDING_STAR,
@@ -71,6 +80,7 @@ typedef enum {
71
80
  PM_ERR_CANNOT_PARSE_STRING_PART,
72
81
  PM_ERR_CASE_EXPRESSION_AFTER_CASE,
73
82
  PM_ERR_CASE_EXPRESSION_AFTER_WHEN,
83
+ PM_ERR_CASE_MATCH_MISSING_PREDICATE,
74
84
  PM_ERR_CASE_MISSING_CONDITIONS,
75
85
  PM_ERR_CASE_TERM,
76
86
  PM_ERR_CLASS_IN_METHOD,
@@ -231,6 +241,7 @@ typedef enum {
231
241
  PM_ERR_UNARY_RECEIVER_TILDE,
232
242
  PM_ERR_UNDEF_ARGUMENT,
233
243
  PM_ERR_UNTIL_TERM,
244
+ PM_ERR_VOID_EXPRESSION,
234
245
  PM_ERR_WHILE_TERM,
235
246
  PM_ERR_WRITE_TARGET_READONLY,
236
247
  PM_ERR_WRITE_TARGET_UNEXPECTED,
@@ -239,13 +250,15 @@ typedef enum {
239
250
  PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_PLUS,
240
251
  PM_WARN_AMBIGUOUS_PREFIX_STAR,
241
252
  PM_WARN_AMBIGUOUS_SLASH,
253
+ PM_WARN_END_IN_METHOD,
242
254
 
243
255
  /* This must be the last member. */
244
256
  PM_DIAGNOSTIC_ID_LEN,
245
257
  } pm_diagnostic_id_t;
246
258
 
247
259
  /**
248
- * Append a diagnostic to the given list of diagnostics.
260
+ * Append a diagnostic to the given list of diagnostics that is using shared
261
+ * memory for its message.
249
262
  *
250
263
  * @param list The list to append to.
251
264
  * @param start The start of the diagnostic.
@@ -255,6 +268,19 @@ typedef enum {
255
268
  */
256
269
  bool pm_diagnostic_list_append(pm_list_t *list, const uint8_t *start, const uint8_t *end, pm_diagnostic_id_t diag_id);
257
270
 
271
+ /**
272
+ * Append a diagnostic to the given list of diagnostics that is using a format
273
+ * string for its message.
274
+ *
275
+ * @param list The list to append to.
276
+ * @param start The start of the diagnostic.
277
+ * @param end The end of the diagnostic.
278
+ * @param diag_id The diagnostic ID.
279
+ * @param ... The arguments to the format string for the message.
280
+ * @return Whether the diagnostic was successfully appended.
281
+ */
282
+ bool pm_diagnostic_list_append_format(pm_list_t *list, const uint8_t *start, const uint8_t *end, pm_diagnostic_id_t diag_id, ...);
283
+
258
284
  /**
259
285
  * Deallocate the internal state of the given diagnostic list.
260
286
  *
@@ -158,8 +158,30 @@ extern const uint8_t pm_encoding_unicode_table[256];
158
158
  extern pm_encoding_t pm_encoding_ascii;
159
159
  extern pm_encoding_t pm_encoding_ascii_8bit;
160
160
  extern pm_encoding_t pm_encoding_big5;
161
+ extern pm_encoding_t pm_encoding_big5_hkscs;
162
+ extern pm_encoding_t pm_encoding_big5_uao;
163
+ extern pm_encoding_t pm_encoding_cp51932;
164
+ extern pm_encoding_t pm_encoding_cp850;
165
+ extern pm_encoding_t pm_encoding_cp852;
166
+ extern pm_encoding_t pm_encoding_cp855;
161
167
  extern pm_encoding_t pm_encoding_euc_jp;
168
+ extern pm_encoding_t pm_encoding_gb1988;
162
169
  extern pm_encoding_t pm_encoding_gbk;
170
+ extern pm_encoding_t pm_encoding_ibm437;
171
+ extern pm_encoding_t pm_encoding_ibm720;
172
+ extern pm_encoding_t pm_encoding_ibm737;
173
+ extern pm_encoding_t pm_encoding_ibm775;
174
+ extern pm_encoding_t pm_encoding_ibm852;
175
+ extern pm_encoding_t pm_encoding_ibm855;
176
+ extern pm_encoding_t pm_encoding_ibm857;
177
+ extern pm_encoding_t pm_encoding_ibm860;
178
+ extern pm_encoding_t pm_encoding_ibm861;
179
+ extern pm_encoding_t pm_encoding_ibm862;
180
+ extern pm_encoding_t pm_encoding_ibm863;
181
+ extern pm_encoding_t pm_encoding_ibm864;
182
+ extern pm_encoding_t pm_encoding_ibm865;
183
+ extern pm_encoding_t pm_encoding_ibm866;
184
+ extern pm_encoding_t pm_encoding_ibm869;
163
185
  extern pm_encoding_t pm_encoding_iso_8859_1;
164
186
  extern pm_encoding_t pm_encoding_iso_8859_2;
165
187
  extern pm_encoding_t pm_encoding_iso_8859_3;
@@ -176,11 +198,30 @@ extern pm_encoding_t pm_encoding_iso_8859_14;
176
198
  extern pm_encoding_t pm_encoding_iso_8859_15;
177
199
  extern pm_encoding_t pm_encoding_iso_8859_16;
178
200
  extern pm_encoding_t pm_encoding_koi8_r;
201
+ extern pm_encoding_t pm_encoding_mac_cent_euro;
202
+ extern pm_encoding_t pm_encoding_mac_croatian;
203
+ extern pm_encoding_t pm_encoding_mac_cyrillic;
204
+ extern pm_encoding_t pm_encoding_mac_greek;
205
+ extern pm_encoding_t pm_encoding_mac_iceland;
206
+ extern pm_encoding_t pm_encoding_mac_roman;
207
+ extern pm_encoding_t pm_encoding_mac_romania;
208
+ extern pm_encoding_t pm_encoding_mac_thai;
209
+ extern pm_encoding_t pm_encoding_mac_turkish;
210
+ extern pm_encoding_t pm_encoding_mac_ukraine;
179
211
  extern pm_encoding_t pm_encoding_shift_jis;
212
+ extern pm_encoding_t pm_encoding_tis_620;
180
213
  extern pm_encoding_t pm_encoding_utf_8;
181
214
  extern pm_encoding_t pm_encoding_utf8_mac;
182
- extern pm_encoding_t pm_encoding_windows_31j;
215
+ extern pm_encoding_t pm_encoding_windows_1250;
183
216
  extern pm_encoding_t pm_encoding_windows_1251;
184
217
  extern pm_encoding_t pm_encoding_windows_1252;
218
+ extern pm_encoding_t pm_encoding_windows_1253;
219
+ extern pm_encoding_t pm_encoding_windows_1254;
220
+ extern pm_encoding_t pm_encoding_windows_1255;
221
+ extern pm_encoding_t pm_encoding_windows_1256;
222
+ extern pm_encoding_t pm_encoding_windows_1257;
223
+ extern pm_encoding_t pm_encoding_windows_1258;
224
+ extern pm_encoding_t pm_encoding_windows_31j;
225
+ extern pm_encoding_t pm_encoding_windows_874;
185
226
 
186
227
  #endif
@@ -532,6 +532,12 @@ struct pm_parser {
532
532
  size_t index;
533
533
  } lex_modes;
534
534
 
535
+ /**
536
+ * The common_whitespace value from the most-recently-popped heredoc mode of the lexer, so we
537
+ * can dedent the heredoc after popping the lex mode.
538
+ */
539
+ size_t current_string_common_whitespace;
540
+
535
541
  /** The pointer to the start of the source. */
536
542
  const uint8_t *start;
537
543