prism 0.24.0 → 0.26.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/BSDmakefile +58 -0
- data/CHANGELOG.md +69 -1
- data/Makefile +22 -16
- data/README.md +45 -6
- data/config.yml +510 -4
- data/docs/build_system.md +31 -0
- data/docs/configuration.md +3 -0
- data/docs/cruby_compilation.md +1 -1
- data/docs/parser_translation.md +14 -9
- data/docs/releasing.md +7 -9
- data/docs/ripper_translation.md +50 -0
- data/docs/ruby_api.md +1 -0
- data/docs/serialization.md +26 -5
- data/ext/prism/api_node.c +911 -815
- data/ext/prism/api_pack.c +9 -0
- data/ext/prism/extconf.rb +34 -13
- data/ext/prism/extension.c +341 -68
- data/ext/prism/extension.h +5 -4
- data/include/prism/ast.h +213 -64
- data/include/prism/defines.h +106 -2
- data/include/prism/diagnostic.h +146 -72
- data/include/prism/encoding.h +22 -4
- data/include/prism/node.h +93 -0
- data/include/prism/options.h +82 -7
- data/include/prism/pack.h +11 -0
- data/include/prism/parser.h +203 -54
- data/include/prism/prettyprint.h +8 -0
- data/include/prism/static_literals.h +118 -0
- data/include/prism/util/pm_buffer.h +65 -2
- data/include/prism/util/pm_constant_pool.h +18 -1
- data/include/prism/util/pm_integer.h +119 -0
- data/include/prism/util/pm_list.h +1 -1
- data/include/prism/util/pm_newline_list.h +8 -0
- data/include/prism/util/pm_string.h +26 -2
- data/include/prism/version.h +2 -2
- data/include/prism.h +59 -1
- data/lib/prism/compiler.rb +8 -1
- data/lib/prism/debug.rb +46 -3
- data/lib/prism/desugar_compiler.rb +4 -2
- data/lib/prism/dispatcher.rb +29 -0
- data/lib/prism/dot_visitor.rb +87 -16
- data/lib/prism/dsl.rb +24 -12
- data/lib/prism/ffi.rb +77 -12
- data/lib/prism/lex_compat.rb +17 -15
- data/lib/prism/mutation_compiler.rb +11 -0
- data/lib/prism/node.rb +2112 -2499
- data/lib/prism/node_ext.rb +77 -29
- data/lib/prism/pack.rb +4 -0
- data/lib/prism/parse_result/comments.rb +34 -17
- data/lib/prism/parse_result/newlines.rb +3 -1
- data/lib/prism/parse_result.rb +83 -32
- data/lib/prism/pattern.rb +16 -4
- data/lib/prism/polyfill/string.rb +12 -0
- data/lib/prism/reflection.rb +421 -0
- data/lib/prism/serialize.rb +450 -102
- data/lib/prism/translation/parser/compiler.rb +189 -50
- data/lib/prism/translation/parser/lexer.rb +103 -22
- data/lib/prism/translation/parser/rubocop.rb +41 -13
- data/lib/prism/translation/parser.rb +119 -7
- data/lib/prism/translation/parser33.rb +1 -1
- data/lib/prism/translation/parser34.rb +1 -1
- data/lib/prism/translation/ripper/sexp.rb +125 -0
- data/lib/prism/translation/ripper/shim.rb +5 -0
- data/lib/prism/translation/ripper.rb +3212 -462
- data/lib/prism/translation/ruby_parser.rb +35 -18
- data/lib/prism/translation.rb +3 -1
- data/lib/prism/visitor.rb +10 -0
- data/lib/prism.rb +9 -18
- data/prism.gemspec +39 -6
- data/rbi/prism/compiler.rbi +14 -0
- data/rbi/prism/desugar_compiler.rbi +5 -0
- data/rbi/prism/mutation_compiler.rbi +5 -0
- data/rbi/prism/node.rbi +8674 -0
- data/rbi/prism/node_ext.rbi +102 -0
- data/rbi/prism/parse_result.rbi +307 -0
- data/rbi/prism/reflection.rbi +64 -0
- data/rbi/prism/translation/parser/compiler.rbi +13 -0
- data/rbi/prism/translation/parser.rbi +11 -0
- data/rbi/prism/translation/parser33.rbi +6 -0
- data/rbi/prism/translation/parser34.rbi +6 -0
- data/rbi/prism/translation/ripper/ripper_compiler.rbi +5 -0
- data/rbi/prism/translation/ripper.rbi +25 -0
- data/rbi/prism/translation/ruby_parser.rbi +11 -0
- data/rbi/prism/visitor.rbi +470 -0
- data/rbi/prism.rbi +38 -7748
- data/sig/prism/compiler.rbs +9 -0
- data/sig/prism/dispatcher.rbs +16 -0
- data/sig/prism/dot_visitor.rbs +6 -0
- data/sig/prism/dsl.rbs +462 -0
- data/sig/prism/mutation_compiler.rbs +158 -0
- data/sig/prism/node.rbs +3538 -0
- data/sig/prism/node_ext.rbs +78 -0
- data/sig/prism/pack.rbs +43 -0
- data/sig/prism/parse_result.rbs +128 -0
- data/sig/prism/pattern.rbs +13 -0
- data/sig/prism/reflection.rbs +56 -0
- data/sig/prism/serialize.rbs +7 -0
- data/sig/prism/visitor.rbs +168 -0
- data/sig/prism.rbs +188 -4767
- data/src/diagnostic.c +597 -230
- data/src/encoding.c +211 -108
- data/src/node.c +7526 -447
- data/src/options.c +66 -31
- data/src/pack.c +33 -17
- data/src/prettyprint.c +1294 -1385
- data/src/prism.c +4015 -1149
- data/src/regexp.c +17 -2
- data/src/serialize.c +47 -28
- data/src/static_literals.c +552 -0
- data/src/token_type.c +4 -3
- data/src/util/pm_buffer.c +147 -20
- data/src/util/pm_char.c +4 -4
- data/src/util/pm_constant_pool.c +35 -11
- data/src/util/pm_integer.c +635 -0
- data/src/util/pm_list.c +1 -1
- data/src/util/pm_newline_list.c +14 -5
- data/src/util/pm_string.c +134 -5
- data/src/util/pm_string_list.c +2 -2
- metadata +41 -8
- data/docs/ripper.md +0 -36
- data/include/prism/util/pm_state_stack.h +0 -42
- data/rbi/prism_static.rbi +0 -207
- data/sig/prism_static.rbs +0 -201
- data/src/util/pm_state_stack.c +0 -25
data/include/prism/ast.h
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
/* if you are looking to modify the */
|
6
6
|
/* template */
|
7
7
|
/******************************************************************************/
|
8
|
+
|
8
9
|
/**
|
9
10
|
* @file ast.h
|
10
11
|
*
|
@@ -15,6 +16,7 @@
|
|
15
16
|
|
16
17
|
#include "prism/defines.h"
|
17
18
|
#include "prism/util/pm_constant_pool.h"
|
19
|
+
#include "prism/util/pm_integer.h"
|
18
20
|
#include "prism/util/pm_string.h"
|
19
21
|
|
20
22
|
#include <assert.h>
|
@@ -829,188 +831,194 @@ enum pm_node_type {
|
|
829
831
|
/** InterpolatedXStringNode */
|
830
832
|
PM_INTERPOLATED_X_STRING_NODE = 87,
|
831
833
|
|
834
|
+
/** ItParametersNode */
|
835
|
+
PM_IT_PARAMETERS_NODE = 88,
|
836
|
+
|
832
837
|
/** KeywordHashNode */
|
833
|
-
PM_KEYWORD_HASH_NODE =
|
838
|
+
PM_KEYWORD_HASH_NODE = 89,
|
834
839
|
|
835
840
|
/** KeywordRestParameterNode */
|
836
|
-
PM_KEYWORD_REST_PARAMETER_NODE =
|
841
|
+
PM_KEYWORD_REST_PARAMETER_NODE = 90,
|
837
842
|
|
838
843
|
/** LambdaNode */
|
839
|
-
PM_LAMBDA_NODE =
|
844
|
+
PM_LAMBDA_NODE = 91,
|
840
845
|
|
841
846
|
/** LocalVariableAndWriteNode */
|
842
|
-
PM_LOCAL_VARIABLE_AND_WRITE_NODE =
|
847
|
+
PM_LOCAL_VARIABLE_AND_WRITE_NODE = 92,
|
843
848
|
|
844
849
|
/** LocalVariableOperatorWriteNode */
|
845
|
-
PM_LOCAL_VARIABLE_OPERATOR_WRITE_NODE =
|
850
|
+
PM_LOCAL_VARIABLE_OPERATOR_WRITE_NODE = 93,
|
846
851
|
|
847
852
|
/** LocalVariableOrWriteNode */
|
848
|
-
PM_LOCAL_VARIABLE_OR_WRITE_NODE =
|
853
|
+
PM_LOCAL_VARIABLE_OR_WRITE_NODE = 94,
|
849
854
|
|
850
855
|
/** LocalVariableReadNode */
|
851
|
-
PM_LOCAL_VARIABLE_READ_NODE =
|
856
|
+
PM_LOCAL_VARIABLE_READ_NODE = 95,
|
852
857
|
|
853
858
|
/** LocalVariableTargetNode */
|
854
|
-
PM_LOCAL_VARIABLE_TARGET_NODE =
|
859
|
+
PM_LOCAL_VARIABLE_TARGET_NODE = 96,
|
855
860
|
|
856
861
|
/** LocalVariableWriteNode */
|
857
|
-
PM_LOCAL_VARIABLE_WRITE_NODE =
|
862
|
+
PM_LOCAL_VARIABLE_WRITE_NODE = 97,
|
858
863
|
|
859
864
|
/** MatchLastLineNode */
|
860
|
-
PM_MATCH_LAST_LINE_NODE =
|
865
|
+
PM_MATCH_LAST_LINE_NODE = 98,
|
861
866
|
|
862
867
|
/** MatchPredicateNode */
|
863
|
-
PM_MATCH_PREDICATE_NODE =
|
868
|
+
PM_MATCH_PREDICATE_NODE = 99,
|
864
869
|
|
865
870
|
/** MatchRequiredNode */
|
866
|
-
PM_MATCH_REQUIRED_NODE =
|
871
|
+
PM_MATCH_REQUIRED_NODE = 100,
|
867
872
|
|
868
873
|
/** MatchWriteNode */
|
869
|
-
PM_MATCH_WRITE_NODE =
|
874
|
+
PM_MATCH_WRITE_NODE = 101,
|
870
875
|
|
871
876
|
/** MissingNode */
|
872
|
-
PM_MISSING_NODE =
|
877
|
+
PM_MISSING_NODE = 102,
|
873
878
|
|
874
879
|
/** ModuleNode */
|
875
|
-
PM_MODULE_NODE =
|
880
|
+
PM_MODULE_NODE = 103,
|
876
881
|
|
877
882
|
/** MultiTargetNode */
|
878
|
-
PM_MULTI_TARGET_NODE =
|
883
|
+
PM_MULTI_TARGET_NODE = 104,
|
879
884
|
|
880
885
|
/** MultiWriteNode */
|
881
|
-
PM_MULTI_WRITE_NODE =
|
886
|
+
PM_MULTI_WRITE_NODE = 105,
|
882
887
|
|
883
888
|
/** NextNode */
|
884
|
-
PM_NEXT_NODE =
|
889
|
+
PM_NEXT_NODE = 106,
|
885
890
|
|
886
891
|
/** NilNode */
|
887
|
-
PM_NIL_NODE =
|
892
|
+
PM_NIL_NODE = 107,
|
888
893
|
|
889
894
|
/** NoKeywordsParameterNode */
|
890
|
-
PM_NO_KEYWORDS_PARAMETER_NODE =
|
895
|
+
PM_NO_KEYWORDS_PARAMETER_NODE = 108,
|
891
896
|
|
892
897
|
/** NumberedParametersNode */
|
893
|
-
PM_NUMBERED_PARAMETERS_NODE =
|
898
|
+
PM_NUMBERED_PARAMETERS_NODE = 109,
|
894
899
|
|
895
900
|
/** NumberedReferenceReadNode */
|
896
|
-
PM_NUMBERED_REFERENCE_READ_NODE =
|
901
|
+
PM_NUMBERED_REFERENCE_READ_NODE = 110,
|
897
902
|
|
898
903
|
/** OptionalKeywordParameterNode */
|
899
|
-
PM_OPTIONAL_KEYWORD_PARAMETER_NODE =
|
904
|
+
PM_OPTIONAL_KEYWORD_PARAMETER_NODE = 111,
|
900
905
|
|
901
906
|
/** OptionalParameterNode */
|
902
|
-
PM_OPTIONAL_PARAMETER_NODE =
|
907
|
+
PM_OPTIONAL_PARAMETER_NODE = 112,
|
903
908
|
|
904
909
|
/** OrNode */
|
905
|
-
PM_OR_NODE =
|
910
|
+
PM_OR_NODE = 113,
|
906
911
|
|
907
912
|
/** ParametersNode */
|
908
|
-
PM_PARAMETERS_NODE =
|
913
|
+
PM_PARAMETERS_NODE = 114,
|
909
914
|
|
910
915
|
/** ParenthesesNode */
|
911
|
-
PM_PARENTHESES_NODE =
|
916
|
+
PM_PARENTHESES_NODE = 115,
|
912
917
|
|
913
918
|
/** PinnedExpressionNode */
|
914
|
-
PM_PINNED_EXPRESSION_NODE =
|
919
|
+
PM_PINNED_EXPRESSION_NODE = 116,
|
915
920
|
|
916
921
|
/** PinnedVariableNode */
|
917
|
-
PM_PINNED_VARIABLE_NODE =
|
922
|
+
PM_PINNED_VARIABLE_NODE = 117,
|
918
923
|
|
919
924
|
/** PostExecutionNode */
|
920
|
-
PM_POST_EXECUTION_NODE =
|
925
|
+
PM_POST_EXECUTION_NODE = 118,
|
921
926
|
|
922
927
|
/** PreExecutionNode */
|
923
|
-
PM_PRE_EXECUTION_NODE =
|
928
|
+
PM_PRE_EXECUTION_NODE = 119,
|
924
929
|
|
925
930
|
/** ProgramNode */
|
926
|
-
PM_PROGRAM_NODE =
|
931
|
+
PM_PROGRAM_NODE = 120,
|
927
932
|
|
928
933
|
/** RangeNode */
|
929
|
-
PM_RANGE_NODE =
|
934
|
+
PM_RANGE_NODE = 121,
|
930
935
|
|
931
936
|
/** RationalNode */
|
932
|
-
PM_RATIONAL_NODE =
|
937
|
+
PM_RATIONAL_NODE = 122,
|
933
938
|
|
934
939
|
/** RedoNode */
|
935
|
-
PM_REDO_NODE =
|
940
|
+
PM_REDO_NODE = 123,
|
936
941
|
|
937
942
|
/** RegularExpressionNode */
|
938
|
-
PM_REGULAR_EXPRESSION_NODE =
|
943
|
+
PM_REGULAR_EXPRESSION_NODE = 124,
|
939
944
|
|
940
945
|
/** RequiredKeywordParameterNode */
|
941
|
-
PM_REQUIRED_KEYWORD_PARAMETER_NODE =
|
946
|
+
PM_REQUIRED_KEYWORD_PARAMETER_NODE = 125,
|
942
947
|
|
943
948
|
/** RequiredParameterNode */
|
944
|
-
PM_REQUIRED_PARAMETER_NODE =
|
949
|
+
PM_REQUIRED_PARAMETER_NODE = 126,
|
945
950
|
|
946
951
|
/** RescueModifierNode */
|
947
|
-
PM_RESCUE_MODIFIER_NODE =
|
952
|
+
PM_RESCUE_MODIFIER_NODE = 127,
|
948
953
|
|
949
954
|
/** RescueNode */
|
950
|
-
PM_RESCUE_NODE =
|
955
|
+
PM_RESCUE_NODE = 128,
|
951
956
|
|
952
957
|
/** RestParameterNode */
|
953
|
-
PM_REST_PARAMETER_NODE =
|
958
|
+
PM_REST_PARAMETER_NODE = 129,
|
954
959
|
|
955
960
|
/** RetryNode */
|
956
|
-
PM_RETRY_NODE =
|
961
|
+
PM_RETRY_NODE = 130,
|
957
962
|
|
958
963
|
/** ReturnNode */
|
959
|
-
PM_RETURN_NODE =
|
964
|
+
PM_RETURN_NODE = 131,
|
960
965
|
|
961
966
|
/** SelfNode */
|
962
|
-
PM_SELF_NODE =
|
967
|
+
PM_SELF_NODE = 132,
|
968
|
+
|
969
|
+
/** ShareableConstantNode */
|
970
|
+
PM_SHAREABLE_CONSTANT_NODE = 133,
|
963
971
|
|
964
972
|
/** SingletonClassNode */
|
965
|
-
PM_SINGLETON_CLASS_NODE =
|
973
|
+
PM_SINGLETON_CLASS_NODE = 134,
|
966
974
|
|
967
975
|
/** SourceEncodingNode */
|
968
|
-
PM_SOURCE_ENCODING_NODE =
|
976
|
+
PM_SOURCE_ENCODING_NODE = 135,
|
969
977
|
|
970
978
|
/** SourceFileNode */
|
971
|
-
PM_SOURCE_FILE_NODE =
|
979
|
+
PM_SOURCE_FILE_NODE = 136,
|
972
980
|
|
973
981
|
/** SourceLineNode */
|
974
|
-
PM_SOURCE_LINE_NODE =
|
982
|
+
PM_SOURCE_LINE_NODE = 137,
|
975
983
|
|
976
984
|
/** SplatNode */
|
977
|
-
PM_SPLAT_NODE =
|
985
|
+
PM_SPLAT_NODE = 138,
|
978
986
|
|
979
987
|
/** StatementsNode */
|
980
|
-
PM_STATEMENTS_NODE =
|
988
|
+
PM_STATEMENTS_NODE = 139,
|
981
989
|
|
982
990
|
/** StringNode */
|
983
|
-
PM_STRING_NODE =
|
991
|
+
PM_STRING_NODE = 140,
|
984
992
|
|
985
993
|
/** SuperNode */
|
986
|
-
PM_SUPER_NODE =
|
994
|
+
PM_SUPER_NODE = 141,
|
987
995
|
|
988
996
|
/** SymbolNode */
|
989
|
-
PM_SYMBOL_NODE =
|
997
|
+
PM_SYMBOL_NODE = 142,
|
990
998
|
|
991
999
|
/** TrueNode */
|
992
|
-
PM_TRUE_NODE =
|
1000
|
+
PM_TRUE_NODE = 143,
|
993
1001
|
|
994
1002
|
/** UndefNode */
|
995
|
-
PM_UNDEF_NODE =
|
1003
|
+
PM_UNDEF_NODE = 144,
|
996
1004
|
|
997
1005
|
/** UnlessNode */
|
998
|
-
PM_UNLESS_NODE =
|
1006
|
+
PM_UNLESS_NODE = 145,
|
999
1007
|
|
1000
1008
|
/** UntilNode */
|
1001
|
-
PM_UNTIL_NODE =
|
1009
|
+
PM_UNTIL_NODE = 146,
|
1002
1010
|
|
1003
1011
|
/** WhenNode */
|
1004
|
-
PM_WHEN_NODE =
|
1012
|
+
PM_WHEN_NODE = 147,
|
1005
1013
|
|
1006
1014
|
/** WhileNode */
|
1007
|
-
PM_WHILE_NODE =
|
1015
|
+
PM_WHILE_NODE = 148,
|
1008
1016
|
|
1009
1017
|
/** XStringNode */
|
1010
|
-
PM_X_STRING_NODE =
|
1018
|
+
PM_X_STRING_NODE = 149,
|
1011
1019
|
|
1012
1020
|
/** YieldNode */
|
1013
|
-
PM_YIELD_NODE =
|
1021
|
+
PM_YIELD_NODE = 150,
|
1014
1022
|
|
1015
1023
|
/** A special kind of node used for compilation. */
|
1016
1024
|
PM_SCOPE_NODE
|
@@ -2179,21 +2187,46 @@ typedef struct pm_class_variable_write_node {
|
|
2179
2187
|
|
2180
2188
|
/**
|
2181
2189
|
* ClassVariableWriteNode#name
|
2190
|
+
*
|
2191
|
+
* The name of the class variable, which is a `@@` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
|
2192
|
+
*
|
2193
|
+
* @@abc = 123 # name `@@abc`
|
2194
|
+
*
|
2195
|
+
* @@_test = :test # name `@@_test`
|
2182
2196
|
*/
|
2183
2197
|
pm_constant_id_t name;
|
2184
2198
|
|
2185
2199
|
/**
|
2186
2200
|
* ClassVariableWriteNode#name_loc
|
2201
|
+
*
|
2202
|
+
* The location of the variable name.
|
2203
|
+
*
|
2204
|
+
* @@foo = :bar
|
2205
|
+
* ^^^^^
|
2187
2206
|
*/
|
2188
2207
|
pm_location_t name_loc;
|
2189
2208
|
|
2190
2209
|
/**
|
2191
2210
|
* ClassVariableWriteNode#value
|
2211
|
+
*
|
2212
|
+
* The value to assign to the class variable. Can be any node that
|
2213
|
+
* represents a non-void expression.
|
2214
|
+
*
|
2215
|
+
* @@foo = :bar
|
2216
|
+
* ^^^^
|
2217
|
+
*
|
2218
|
+
* @@_xyz = 123
|
2219
|
+
* ^^^
|
2192
2220
|
*/
|
2193
2221
|
struct pm_node *value;
|
2194
2222
|
|
2195
2223
|
/**
|
2196
2224
|
* ClassVariableWriteNode#operator_loc
|
2225
|
+
*
|
2226
|
+
* The location of the `=` operator.
|
2227
|
+
*
|
2228
|
+
* @@foo = :bar
|
2229
|
+
* ^
|
2197
2230
|
*/
|
2198
2231
|
pm_location_t operator_loc;
|
2199
2232
|
} pm_class_variable_write_node_t;
|
@@ -2838,6 +2871,13 @@ typedef struct pm_flip_flop_node {
|
|
2838
2871
|
typedef struct pm_float_node {
|
2839
2872
|
/** The embedded base node. */
|
2840
2873
|
pm_node_t base;
|
2874
|
+
|
2875
|
+
/**
|
2876
|
+
* FloatNode#value
|
2877
|
+
*
|
2878
|
+
* The value of the floating point number as a Float.
|
2879
|
+
*/
|
2880
|
+
double value;
|
2841
2881
|
} pm_float_node_t;
|
2842
2882
|
|
2843
2883
|
/**
|
@@ -3675,21 +3715,46 @@ typedef struct pm_instance_variable_write_node {
|
|
3675
3715
|
|
3676
3716
|
/**
|
3677
3717
|
* InstanceVariableWriteNode#name
|
3718
|
+
*
|
3719
|
+
* The name of the instance variable, which is a `@` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
|
3720
|
+
*
|
3721
|
+
* @x = :y # name `:@x`
|
3722
|
+
*
|
3723
|
+
* @_foo = "bar" # name `@_foo`
|
3678
3724
|
*/
|
3679
3725
|
pm_constant_id_t name;
|
3680
3726
|
|
3681
3727
|
/**
|
3682
3728
|
* InstanceVariableWriteNode#name_loc
|
3729
|
+
*
|
3730
|
+
* The location of the variable name.
|
3731
|
+
*
|
3732
|
+
* @_x = 1
|
3733
|
+
* ^^^
|
3683
3734
|
*/
|
3684
3735
|
pm_location_t name_loc;
|
3685
3736
|
|
3686
3737
|
/**
|
3687
3738
|
* InstanceVariableWriteNode#value
|
3739
|
+
*
|
3740
|
+
* The value to assign to the instance variable. Can be any node that
|
3741
|
+
* represents a non-void expression.
|
3742
|
+
*
|
3743
|
+
* @foo = :bar
|
3744
|
+
* ^^^^
|
3745
|
+
*
|
3746
|
+
* @_x = 1234
|
3747
|
+
* ^^^^
|
3688
3748
|
*/
|
3689
3749
|
struct pm_node *value;
|
3690
3750
|
|
3691
3751
|
/**
|
3692
3752
|
* InstanceVariableWriteNode#operator_loc
|
3753
|
+
*
|
3754
|
+
* The location of the `=` operator.
|
3755
|
+
*
|
3756
|
+
* @x = y
|
3757
|
+
* ^
|
3693
3758
|
*/
|
3694
3759
|
pm_location_t operator_loc;
|
3695
3760
|
} pm_instance_variable_write_node_t;
|
@@ -3709,6 +3774,13 @@ typedef struct pm_instance_variable_write_node {
|
|
3709
3774
|
typedef struct pm_integer_node {
|
3710
3775
|
/** The embedded base node. */
|
3711
3776
|
pm_node_t base;
|
3777
|
+
|
3778
|
+
/**
|
3779
|
+
* IntegerNode#value
|
3780
|
+
*
|
3781
|
+
* The value of the integer literal as a number.
|
3782
|
+
*/
|
3783
|
+
pm_integer_t value;
|
3712
3784
|
} pm_integer_node_t;
|
3713
3785
|
|
3714
3786
|
/**
|
@@ -3793,6 +3865,9 @@ typedef struct pm_interpolated_regular_expression_node {
|
|
3793
3865
|
* InterpolatedStringNode
|
3794
3866
|
*
|
3795
3867
|
* Type: PM_INTERPOLATED_STRING_NODE
|
3868
|
+
* Flags:
|
3869
|
+
* PM_INTERPOLATED_STRING_NODE_FLAGS_FROZEN
|
3870
|
+
* PM_INTERPOLATED_STRING_NODE_FLAGS_MUTABLE
|
3796
3871
|
*
|
3797
3872
|
* @extends pm_node_t
|
3798
3873
|
*/
|
@@ -3870,6 +3945,18 @@ typedef struct pm_interpolated_x_string_node {
|
|
3870
3945
|
pm_location_t closing_loc;
|
3871
3946
|
} pm_interpolated_x_string_node_t;
|
3872
3947
|
|
3948
|
+
/**
|
3949
|
+
* ItParametersNode
|
3950
|
+
*
|
3951
|
+
* Type: PM_IT_PARAMETERS_NODE
|
3952
|
+
*
|
3953
|
+
* @extends pm_node_t
|
3954
|
+
*/
|
3955
|
+
typedef struct pm_it_parameters_node {
|
3956
|
+
/** The embedded base node. */
|
3957
|
+
pm_node_t base;
|
3958
|
+
} pm_it_parameters_node_t;
|
3959
|
+
|
3873
3960
|
/**
|
3874
3961
|
* KeywordHashNode
|
3875
3962
|
*
|
@@ -4524,13 +4611,13 @@ typedef struct pm_numbered_reference_read_node {
|
|
4524
4611
|
/**
|
4525
4612
|
* NumberedReferenceReadNode#number
|
4526
4613
|
*
|
4527
|
-
* The (1-indexed, from the left) number of the capture group. Numbered references that
|
4614
|
+
* The (1-indexed, from the left) number of the capture group. Numbered references that are too large result in this value being `0`.
|
4528
4615
|
*
|
4529
4616
|
* $1 # number `1`
|
4530
4617
|
*
|
4531
4618
|
* $5432 # number `5432`
|
4532
4619
|
*
|
4533
|
-
* $4294967296 # number `
|
4620
|
+
* $4294967296 # number `0`
|
4534
4621
|
*/
|
4535
4622
|
uint32_t number;
|
4536
4623
|
} pm_numbered_reference_read_node_t;
|
@@ -5168,6 +5255,29 @@ typedef struct pm_self_node {
|
|
5168
5255
|
pm_node_t base;
|
5169
5256
|
} pm_self_node_t;
|
5170
5257
|
|
5258
|
+
/**
|
5259
|
+
* ShareableConstantNode
|
5260
|
+
*
|
5261
|
+
* Type: PM_SHAREABLE_CONSTANT_NODE
|
5262
|
+
* Flags:
|
5263
|
+
* PM_SHAREABLE_CONSTANT_NODE_FLAGS_LITERAL
|
5264
|
+
* PM_SHAREABLE_CONSTANT_NODE_FLAGS_EXPERIMENTAL_EVERYTHING
|
5265
|
+
* PM_SHAREABLE_CONSTANT_NODE_FLAGS_EXPERIMENTAL_COPY
|
5266
|
+
*
|
5267
|
+
* @extends pm_node_t
|
5268
|
+
*/
|
5269
|
+
typedef struct pm_shareable_constant_node {
|
5270
|
+
/** The embedded base node. */
|
5271
|
+
pm_node_t base;
|
5272
|
+
|
5273
|
+
/**
|
5274
|
+
* ShareableConstantNode#write
|
5275
|
+
*
|
5276
|
+
* The constant write that should be modified with the shareability state.
|
5277
|
+
*/
|
5278
|
+
struct pm_node *write;
|
5279
|
+
} pm_shareable_constant_node_t;
|
5280
|
+
|
5171
5281
|
/**
|
5172
5282
|
* SingletonClassNode
|
5173
5283
|
*
|
@@ -5226,6 +5336,11 @@ typedef struct pm_source_encoding_node {
|
|
5226
5336
|
* SourceFileNode
|
5227
5337
|
*
|
5228
5338
|
* Type: PM_SOURCE_FILE_NODE
|
5339
|
+
* Flags:
|
5340
|
+
* PM_STRING_FLAGS_FORCED_UTF8_ENCODING
|
5341
|
+
* PM_STRING_FLAGS_FORCED_BINARY_ENCODING
|
5342
|
+
* PM_STRING_FLAGS_FROZEN
|
5343
|
+
* PM_STRING_FLAGS_MUTABLE
|
5229
5344
|
*
|
5230
5345
|
* @extends pm_node_t
|
5231
5346
|
*/
|
@@ -5298,6 +5413,7 @@ typedef struct pm_statements_node {
|
|
5298
5413
|
* PM_STRING_FLAGS_FORCED_UTF8_ENCODING
|
5299
5414
|
* PM_STRING_FLAGS_FORCED_BINARY_ENCODING
|
5300
5415
|
* PM_STRING_FLAGS_FROZEN
|
5416
|
+
* PM_STRING_FLAGS_MUTABLE
|
5301
5417
|
*
|
5302
5418
|
* @extends pm_node_t
|
5303
5419
|
*/
|
@@ -5530,6 +5646,11 @@ typedef struct pm_when_node {
|
|
5530
5646
|
*/
|
5531
5647
|
struct pm_node_list conditions;
|
5532
5648
|
|
5649
|
+
/**
|
5650
|
+
* WhenNode#then_keyword_loc
|
5651
|
+
*/
|
5652
|
+
pm_location_t then_keyword_loc;
|
5653
|
+
|
5533
5654
|
/**
|
5534
5655
|
* WhenNode#statements
|
5535
5656
|
*/
|
@@ -5698,6 +5819,17 @@ typedef enum pm_integer_base_flags {
|
|
5698
5819
|
PM_INTEGER_BASE_FLAGS_HEXADECIMAL = 8,
|
5699
5820
|
} pm_integer_base_flags_t;
|
5700
5821
|
|
5822
|
+
/**
|
5823
|
+
* Flags for interpolated string nodes that indicated mutability if they are also marked as literals.
|
5824
|
+
*/
|
5825
|
+
typedef enum pm_interpolated_string_node_flags {
|
5826
|
+
/** frozen by virtue of a `frozen_string_literal: true` comment or `--enable-frozen-string-literal`; only for adjacent string literals like `'a' 'b'` */
|
5827
|
+
PM_INTERPOLATED_STRING_NODE_FLAGS_FROZEN = 1,
|
5828
|
+
|
5829
|
+
/** mutable by virtue of a `frozen_string_literal: false` comment or `--disable-frozen-string-literal`; only for adjacent string literals like `'a' 'b'` */
|
5830
|
+
PM_INTERPOLATED_STRING_NODE_FLAGS_MUTABLE = 2,
|
5831
|
+
} pm_interpolated_string_node_flags_t;
|
5832
|
+
|
5701
5833
|
/**
|
5702
5834
|
* Flags for keyword hash nodes.
|
5703
5835
|
*/
|
@@ -5768,6 +5900,20 @@ typedef enum pm_regular_expression_flags {
|
|
5768
5900
|
PM_REGULAR_EXPRESSION_FLAGS_FORCED_US_ASCII_ENCODING = 1024,
|
5769
5901
|
} pm_regular_expression_flags_t;
|
5770
5902
|
|
5903
|
+
/**
|
5904
|
+
* Flags for shareable constant nodes.
|
5905
|
+
*/
|
5906
|
+
typedef enum pm_shareable_constant_node_flags {
|
5907
|
+
/** constant writes that should be modified with shareable constant value literal */
|
5908
|
+
PM_SHAREABLE_CONSTANT_NODE_FLAGS_LITERAL = 1,
|
5909
|
+
|
5910
|
+
/** constant writes that should be modified with shareable constant value experimental everything */
|
5911
|
+
PM_SHAREABLE_CONSTANT_NODE_FLAGS_EXPERIMENTAL_EVERYTHING = 2,
|
5912
|
+
|
5913
|
+
/** constant writes that should be modified with shareable constant value experimental copy */
|
5914
|
+
PM_SHAREABLE_CONSTANT_NODE_FLAGS_EXPERIMENTAL_COPY = 4,
|
5915
|
+
} pm_shareable_constant_node_flags_t;
|
5916
|
+
|
5771
5917
|
/**
|
5772
5918
|
* Flags for string nodes.
|
5773
5919
|
*/
|
@@ -5778,8 +5924,11 @@ typedef enum pm_string_flags {
|
|
5778
5924
|
/** internal bytes forced the encoding to binary */
|
5779
5925
|
PM_STRING_FLAGS_FORCED_BINARY_ENCODING = 2,
|
5780
5926
|
|
5781
|
-
/** frozen by virtue of a `frozen_string_literal` comment */
|
5927
|
+
/** frozen by virtue of a `frozen_string_literal: true` comment or `--enable-frozen-string-literal` */
|
5782
5928
|
PM_STRING_FLAGS_FROZEN = 4,
|
5929
|
+
|
5930
|
+
/** mutable by virtue of a `frozen_string_literal: false` comment or `--disable-frozen-string-literal` */
|
5931
|
+
PM_STRING_FLAGS_MUTABLE = 8,
|
5783
5932
|
} pm_string_flags_t;
|
5784
5933
|
|
5785
5934
|
/**
|
data/include/prism/defines.h
CHANGED
@@ -10,6 +10,8 @@
|
|
10
10
|
#define PRISM_DEFINES_H
|
11
11
|
|
12
12
|
#include <ctype.h>
|
13
|
+
#include <limits.h>
|
14
|
+
#include <math.h>
|
13
15
|
#include <stdarg.h>
|
14
16
|
#include <stddef.h>
|
15
17
|
#include <stdint.h>
|
@@ -21,7 +23,6 @@
|
|
21
23
|
* some platforms they aren't included unless this is already defined.
|
22
24
|
*/
|
23
25
|
#define __STDC_FORMAT_MACROS
|
24
|
-
|
25
26
|
#include <inttypes.h>
|
26
27
|
|
27
28
|
/**
|
@@ -48,7 +49,11 @@
|
|
48
49
|
* compiler-agnostic way.
|
49
50
|
*/
|
50
51
|
#if defined(__GNUC__)
|
51
|
-
#
|
52
|
+
# if defined(__MINGW_PRINTF_FORMAT)
|
53
|
+
# define PRISM_ATTRIBUTE_FORMAT(string_index, argument_index) __attribute__((format(__MINGW_PRINTF_FORMAT, string_index, argument_index)))
|
54
|
+
# else
|
55
|
+
# define PRISM_ATTRIBUTE_FORMAT(string_index, argument_index) __attribute__((format(printf, string_index, argument_index)))
|
56
|
+
# endif
|
52
57
|
#elif defined(__clang__)
|
53
58
|
# define PRISM_ATTRIBUTE_FORMAT(string_index, argument_index) __attribute__((__format__(__printf__, string_index, argument_index)))
|
54
59
|
#else
|
@@ -99,4 +104,103 @@
|
|
99
104
|
# define PM_STATIC_ASSERT(line, condition, message) typedef char PM_CONCATENATE(static_assert_, line)[(condition) ? 1 : -1]
|
100
105
|
#endif
|
101
106
|
|
107
|
+
/**
|
108
|
+
* In general, libc for embedded systems does not support memory-mapped files.
|
109
|
+
* If the target platform is POSIX or Windows, we can map a file in memory and
|
110
|
+
* read it in a more efficient manner.
|
111
|
+
*/
|
112
|
+
#ifdef _WIN32
|
113
|
+
# define PRISM_HAS_MMAP
|
114
|
+
#else
|
115
|
+
# include <unistd.h>
|
116
|
+
# ifdef _POSIX_MAPPED_FILES
|
117
|
+
# define PRISM_HAS_MMAP
|
118
|
+
# endif
|
119
|
+
#endif
|
120
|
+
|
121
|
+
/**
|
122
|
+
* isinf on Windows is defined as accepting a float, but on POSIX systems it
|
123
|
+
* accepts a float, a double, or a long double. We want to mirror this behavior
|
124
|
+
* on windows.
|
125
|
+
*/
|
126
|
+
#ifdef _WIN32
|
127
|
+
# include <float.h>
|
128
|
+
# undef isinf
|
129
|
+
# define isinf(x) (sizeof(x) == sizeof(float) ? !_finitef(x) : !_finite(x))
|
130
|
+
#endif
|
131
|
+
|
132
|
+
/**
|
133
|
+
* If you build prism with a custom allocator, configure it with
|
134
|
+
* "-D PRISM_XALLOCATOR" to use your own allocator that defines xmalloc,
|
135
|
+
* xrealloc, xcalloc, and xfree.
|
136
|
+
*
|
137
|
+
* For example, your `prism_xallocator.h` file could look like this:
|
138
|
+
*
|
139
|
+
* ```
|
140
|
+
* #ifndef PRISM_XALLOCATOR_H
|
141
|
+
* #define PRISM_XALLOCATOR_H
|
142
|
+
* #define xmalloc my_malloc
|
143
|
+
* #define xrealloc my_realloc
|
144
|
+
* #define xcalloc my_calloc
|
145
|
+
* #define xfree my_free
|
146
|
+
* #endif
|
147
|
+
* ```
|
148
|
+
*/
|
149
|
+
#ifdef PRISM_XALLOCATOR
|
150
|
+
#include "prism_xallocator.h"
|
151
|
+
#else
|
152
|
+
#ifndef xmalloc
|
153
|
+
/**
|
154
|
+
* The malloc function that should be used. This can be overridden with
|
155
|
+
* the PRISM_XALLOCATOR define.
|
156
|
+
*/
|
157
|
+
#define xmalloc malloc
|
158
|
+
#endif
|
159
|
+
|
160
|
+
#ifndef xrealloc
|
161
|
+
/**
|
162
|
+
* The realloc function that should be used. This can be overridden with
|
163
|
+
* the PRISM_XALLOCATOR define.
|
164
|
+
*/
|
165
|
+
#define xrealloc realloc
|
166
|
+
#endif
|
167
|
+
|
168
|
+
#ifndef xcalloc
|
169
|
+
/**
|
170
|
+
* The calloc function that should be used. This can be overridden with
|
171
|
+
* the PRISM_XALLOCATOR define.
|
172
|
+
*/
|
173
|
+
#define xcalloc calloc
|
174
|
+
#endif
|
175
|
+
|
176
|
+
#ifndef xfree
|
177
|
+
/**
|
178
|
+
* The free function that should be used. This can be overridden with the
|
179
|
+
* PRISM_XALLOCATOR define.
|
180
|
+
*/
|
181
|
+
#define xfree free
|
182
|
+
#endif
|
183
|
+
#endif
|
184
|
+
|
185
|
+
/**
|
186
|
+
* If PRISM_BUILD_MINIMAL is defined, then we're going to define every possible
|
187
|
+
* switch that will turn off certain features of prism.
|
188
|
+
*/
|
189
|
+
#ifdef PRISM_BUILD_MINIMAL
|
190
|
+
/** Exclude the serialization API. */
|
191
|
+
#define PRISM_EXCLUDE_SERIALIZATION
|
192
|
+
|
193
|
+
/** Exclude the JSON serialization API. */
|
194
|
+
#define PRISM_EXCLUDE_JSON
|
195
|
+
|
196
|
+
/** Exclude the Array#pack parser API. */
|
197
|
+
#define PRISM_EXCLUDE_PACK
|
198
|
+
|
199
|
+
/** Exclude the prettyprint API. */
|
200
|
+
#define PRISM_EXCLUDE_PRETTYPRINT
|
201
|
+
|
202
|
+
/** Exclude the full set of encodings, using the minimal only. */
|
203
|
+
#define PRISM_ENCODING_EXCLUDE_FULL
|
204
|
+
#endif
|
205
|
+
|
102
206
|
#endif
|