From cc863987219639103264129b940b084d64680df0 Mon Sep 17 00:00:00 2001 From: Lily Lyons Date: Thu, 30 Nov 2023 21:21:57 -0800 Subject: [PATCH] fix: :pushpin: correctly vendor prism version 0.18.0 (somehow I provided prism from master) --- Cargo.lock | 30 ++ Cargo.toml | 3 + crates/components/Cargo.toml | 2 + .../vendor/prism-0.18.0/include/prism/ast.h | 195 ++++---- .../prism-0.18.0/include/prism/diagnostic.h | 5 - .../include/prism/enc/pm_encoding.h | 4 - .../prism-0.18.0/include/prism/options.h | 4 +- .../prism-0.18.0/include/prism/parser.h | 27 +- .../include/prism/util/pm_buffer.h | 10 +- .../vendor/prism-0.18.0/src/diagnostic.c | 439 +++++++++--------- .../vendor/prism-0.18.0/src/enc/pm_cp949.c | 57 --- .../vendor/prism-0.18.0/src/enc/pm_cp950.c | 57 --- .../prism-0.18.0/src/enc/pm_mac_japanese.c | 57 --- .../vendor/prism-0.18.0/src/enc/pm_tables.c | 39 +- .../prism-sys/vendor/prism-0.18.0/src/node.c | 12 - .../vendor/prism-0.18.0/src/options.c | 23 +- .../vendor/prism-0.18.0/src/prettyprint.c | 67 +-- .../prism-sys/vendor/prism-0.18.0/src/prism.c | 383 ++++----------- .../vendor/prism-0.18.0/src/serialize.c | 326 ++++++------- .../vendor/prism-0.18.0/src/util/pm_buffer.c | 11 +- 20 files changed, 613 insertions(+), 1138 deletions(-) delete mode 100644 crates/prism-sys/vendor/prism-0.18.0/src/enc/pm_cp949.c delete mode 100644 crates/prism-sys/vendor/prism-0.18.0/src/enc/pm_cp950.c delete mode 100644 crates/prism-sys/vendor/prism-0.18.0/src/enc/pm_mac_japanese.c diff --git a/Cargo.lock b/Cargo.lock index 950cf6cc..d4b6d4ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2778,6 +2778,7 @@ dependencies = [ "luminol-graphics", "once_cell", "parking_lot", + "prism", "serde", "slab", "strum", @@ -4047,6 +4048,16 @@ dependencies = [ "syn 2.0.39", ] +[[package]] +name = "prism" +version = "0.18.0" +source = "git+https://github.com/ruby/prism?rev=6ca8896#6ca8896fc660592af958542cebda06737ec3d58b" +dependencies = [ + "prism-sys", + "serde", + "serde_yaml", +] + [[package]] name = "prism-sys" version = "0.18.0" @@ -4603,6 +4614,19 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_yaml" +version = "0.9.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cc7a1570e38322cfe4154732e5110f887ea57e22b76f4bfd32b5bdd3368666c" +dependencies = [ + "indexmap 2.1.0", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + [[package]] name = "serial" version = "0.4.0" @@ -5536,6 +5560,12 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "unsafe-libyaml" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28467d3e1d3c6586d8f25fa243f544f5800fec42d97032474e17222c2b75cfa" + [[package]] name = "url" version = "2.4.1" diff --git a/Cargo.toml b/Cargo.toml index 8e89ad9a..3ae3be86 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -249,6 +249,9 @@ opt-level = 3 # is merged. cpal = { git = "https://github.com/DouglasDwyer/cpal.git", rev = "91aeb4d6b02c25791f636fdf92a73637597c077a" } +[patch.'https://github.com/ruby/prism'] +prism-sys = { path = "crates/prism-sys" } + # If you want to use the bleeding edge version of egui and eframe: # egui = { git = "https://github.com/emilk/egui", branch = "master" } # eframe = { git = "https://github.com/emilk/egui", branch = "master" } diff --git a/crates/components/Cargo.toml b/crates/components/Cargo.toml index 54bac418..a8c18982 100644 --- a/crates/components/Cargo.toml +++ b/crates/components/Cargo.toml @@ -39,3 +39,5 @@ once_cell.workspace = true slab.workspace = true anyhow.workspace = true + +prism = { version = "0.18.0", git = "https://github.com/ruby/prism", rev = "6ca8896" } diff --git a/crates/prism-sys/vendor/prism-0.18.0/include/prism/ast.h b/crates/prism-sys/vendor/prism-0.18.0/include/prism/ast.h index 10130c9a..c76ceca6 100644 --- a/crates/prism-sys/vendor/prism-0.18.0/include/prism/ast.h +++ b/crates/prism-sys/vendor/prism-0.18.0/include/prism/ast.h @@ -772,236 +772,233 @@ enum pm_node_type { /** ImplicitNode */ PM_IMPLICIT_NODE = 68, - /** ImplicitRestNode */ - PM_IMPLICIT_REST_NODE = 69, - /** InNode */ - PM_IN_NODE = 70, + PM_IN_NODE = 69, /** IndexAndWriteNode */ - PM_INDEX_AND_WRITE_NODE = 71, + PM_INDEX_AND_WRITE_NODE = 70, /** IndexOperatorWriteNode */ - PM_INDEX_OPERATOR_WRITE_NODE = 72, + PM_INDEX_OPERATOR_WRITE_NODE = 71, /** IndexOrWriteNode */ - PM_INDEX_OR_WRITE_NODE = 73, + PM_INDEX_OR_WRITE_NODE = 72, /** InstanceVariableAndWriteNode */ - PM_INSTANCE_VARIABLE_AND_WRITE_NODE = 74, + PM_INSTANCE_VARIABLE_AND_WRITE_NODE = 73, /** InstanceVariableOperatorWriteNode */ - PM_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE = 75, + PM_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE = 74, /** InstanceVariableOrWriteNode */ - PM_INSTANCE_VARIABLE_OR_WRITE_NODE = 76, + PM_INSTANCE_VARIABLE_OR_WRITE_NODE = 75, /** InstanceVariableReadNode */ - PM_INSTANCE_VARIABLE_READ_NODE = 77, + PM_INSTANCE_VARIABLE_READ_NODE = 76, /** InstanceVariableTargetNode */ - PM_INSTANCE_VARIABLE_TARGET_NODE = 78, + PM_INSTANCE_VARIABLE_TARGET_NODE = 77, /** InstanceVariableWriteNode */ - PM_INSTANCE_VARIABLE_WRITE_NODE = 79, + PM_INSTANCE_VARIABLE_WRITE_NODE = 78, /** IntegerNode */ - PM_INTEGER_NODE = 80, + PM_INTEGER_NODE = 79, /** InterpolatedMatchLastLineNode */ - PM_INTERPOLATED_MATCH_LAST_LINE_NODE = 81, + PM_INTERPOLATED_MATCH_LAST_LINE_NODE = 80, /** InterpolatedRegularExpressionNode */ - PM_INTERPOLATED_REGULAR_EXPRESSION_NODE = 82, + PM_INTERPOLATED_REGULAR_EXPRESSION_NODE = 81, /** InterpolatedStringNode */ - PM_INTERPOLATED_STRING_NODE = 83, + PM_INTERPOLATED_STRING_NODE = 82, /** InterpolatedSymbolNode */ - PM_INTERPOLATED_SYMBOL_NODE = 84, + PM_INTERPOLATED_SYMBOL_NODE = 83, /** InterpolatedXStringNode */ - PM_INTERPOLATED_X_STRING_NODE = 85, + PM_INTERPOLATED_X_STRING_NODE = 84, /** KeywordHashNode */ - PM_KEYWORD_HASH_NODE = 86, + PM_KEYWORD_HASH_NODE = 85, /** KeywordRestParameterNode */ - PM_KEYWORD_REST_PARAMETER_NODE = 87, + PM_KEYWORD_REST_PARAMETER_NODE = 86, /** LambdaNode */ - PM_LAMBDA_NODE = 88, + PM_LAMBDA_NODE = 87, /** LocalVariableAndWriteNode */ - PM_LOCAL_VARIABLE_AND_WRITE_NODE = 89, + PM_LOCAL_VARIABLE_AND_WRITE_NODE = 88, /** LocalVariableOperatorWriteNode */ - PM_LOCAL_VARIABLE_OPERATOR_WRITE_NODE = 90, + PM_LOCAL_VARIABLE_OPERATOR_WRITE_NODE = 89, /** LocalVariableOrWriteNode */ - PM_LOCAL_VARIABLE_OR_WRITE_NODE = 91, + PM_LOCAL_VARIABLE_OR_WRITE_NODE = 90, /** LocalVariableReadNode */ - PM_LOCAL_VARIABLE_READ_NODE = 92, + PM_LOCAL_VARIABLE_READ_NODE = 91, /** LocalVariableTargetNode */ - PM_LOCAL_VARIABLE_TARGET_NODE = 93, + PM_LOCAL_VARIABLE_TARGET_NODE = 92, /** LocalVariableWriteNode */ - PM_LOCAL_VARIABLE_WRITE_NODE = 94, + PM_LOCAL_VARIABLE_WRITE_NODE = 93, /** MatchLastLineNode */ - PM_MATCH_LAST_LINE_NODE = 95, + PM_MATCH_LAST_LINE_NODE = 94, /** MatchPredicateNode */ - PM_MATCH_PREDICATE_NODE = 96, + PM_MATCH_PREDICATE_NODE = 95, /** MatchRequiredNode */ - PM_MATCH_REQUIRED_NODE = 97, + PM_MATCH_REQUIRED_NODE = 96, /** MatchWriteNode */ - PM_MATCH_WRITE_NODE = 98, + PM_MATCH_WRITE_NODE = 97, /** MissingNode */ - PM_MISSING_NODE = 99, + PM_MISSING_NODE = 98, /** ModuleNode */ - PM_MODULE_NODE = 100, + PM_MODULE_NODE = 99, /** MultiTargetNode */ - PM_MULTI_TARGET_NODE = 101, + PM_MULTI_TARGET_NODE = 100, /** MultiWriteNode */ - PM_MULTI_WRITE_NODE = 102, + PM_MULTI_WRITE_NODE = 101, /** NextNode */ - PM_NEXT_NODE = 103, + PM_NEXT_NODE = 102, /** NilNode */ - PM_NIL_NODE = 104, + PM_NIL_NODE = 103, /** NoKeywordsParameterNode */ - PM_NO_KEYWORDS_PARAMETER_NODE = 105, + PM_NO_KEYWORDS_PARAMETER_NODE = 104, /** NumberedReferenceReadNode */ - PM_NUMBERED_REFERENCE_READ_NODE = 106, + PM_NUMBERED_REFERENCE_READ_NODE = 105, /** OptionalKeywordParameterNode */ - PM_OPTIONAL_KEYWORD_PARAMETER_NODE = 107, + PM_OPTIONAL_KEYWORD_PARAMETER_NODE = 106, /** OptionalParameterNode */ - PM_OPTIONAL_PARAMETER_NODE = 108, + PM_OPTIONAL_PARAMETER_NODE = 107, /** OrNode */ - PM_OR_NODE = 109, + PM_OR_NODE = 108, /** ParametersNode */ - PM_PARAMETERS_NODE = 110, + PM_PARAMETERS_NODE = 109, /** ParenthesesNode */ - PM_PARENTHESES_NODE = 111, + PM_PARENTHESES_NODE = 110, /** PinnedExpressionNode */ - PM_PINNED_EXPRESSION_NODE = 112, + PM_PINNED_EXPRESSION_NODE = 111, /** PinnedVariableNode */ - PM_PINNED_VARIABLE_NODE = 113, + PM_PINNED_VARIABLE_NODE = 112, /** PostExecutionNode */ - PM_POST_EXECUTION_NODE = 114, + PM_POST_EXECUTION_NODE = 113, /** PreExecutionNode */ - PM_PRE_EXECUTION_NODE = 115, + PM_PRE_EXECUTION_NODE = 114, /** ProgramNode */ - PM_PROGRAM_NODE = 116, + PM_PROGRAM_NODE = 115, /** RangeNode */ - PM_RANGE_NODE = 117, + PM_RANGE_NODE = 116, /** RationalNode */ - PM_RATIONAL_NODE = 118, + PM_RATIONAL_NODE = 117, /** RedoNode */ - PM_REDO_NODE = 119, + PM_REDO_NODE = 118, /** RegularExpressionNode */ - PM_REGULAR_EXPRESSION_NODE = 120, + PM_REGULAR_EXPRESSION_NODE = 119, /** RequiredKeywordParameterNode */ - PM_REQUIRED_KEYWORD_PARAMETER_NODE = 121, + PM_REQUIRED_KEYWORD_PARAMETER_NODE = 120, /** RequiredParameterNode */ - PM_REQUIRED_PARAMETER_NODE = 122, + PM_REQUIRED_PARAMETER_NODE = 121, /** RescueModifierNode */ - PM_RESCUE_MODIFIER_NODE = 123, + PM_RESCUE_MODIFIER_NODE = 122, /** RescueNode */ - PM_RESCUE_NODE = 124, + PM_RESCUE_NODE = 123, /** RestParameterNode */ - PM_REST_PARAMETER_NODE = 125, + PM_REST_PARAMETER_NODE = 124, /** RetryNode */ - PM_RETRY_NODE = 126, + PM_RETRY_NODE = 125, /** ReturnNode */ - PM_RETURN_NODE = 127, + PM_RETURN_NODE = 126, /** SelfNode */ - PM_SELF_NODE = 128, + PM_SELF_NODE = 127, /** SingletonClassNode */ - PM_SINGLETON_CLASS_NODE = 129, + PM_SINGLETON_CLASS_NODE = 128, /** SourceEncodingNode */ - PM_SOURCE_ENCODING_NODE = 130, + PM_SOURCE_ENCODING_NODE = 129, /** SourceFileNode */ - PM_SOURCE_FILE_NODE = 131, + PM_SOURCE_FILE_NODE = 130, /** SourceLineNode */ - PM_SOURCE_LINE_NODE = 132, + PM_SOURCE_LINE_NODE = 131, /** SplatNode */ - PM_SPLAT_NODE = 133, + PM_SPLAT_NODE = 132, /** StatementsNode */ - PM_STATEMENTS_NODE = 134, + PM_STATEMENTS_NODE = 133, /** StringNode */ - PM_STRING_NODE = 135, + PM_STRING_NODE = 134, /** SuperNode */ - PM_SUPER_NODE = 136, + PM_SUPER_NODE = 135, /** SymbolNode */ - PM_SYMBOL_NODE = 137, + PM_SYMBOL_NODE = 136, /** TrueNode */ - PM_TRUE_NODE = 138, + PM_TRUE_NODE = 137, /** UndefNode */ - PM_UNDEF_NODE = 139, + PM_UNDEF_NODE = 138, /** UnlessNode */ - PM_UNLESS_NODE = 140, + PM_UNLESS_NODE = 139, /** UntilNode */ - PM_UNTIL_NODE = 141, + PM_UNTIL_NODE = 140, /** WhenNode */ - PM_WHEN_NODE = 142, + PM_WHEN_NODE = 141, /** WhileNode */ - PM_WHILE_NODE = 143, + PM_WHILE_NODE = 142, /** XStringNode */ - PM_X_STRING_NODE = 144, + PM_X_STRING_NODE = 143, /** YieldNode */ - PM_YIELD_NODE = 145, + PM_YIELD_NODE = 144, /** A special kind of node used for compilation. */ PM_SCOPE_NODE @@ -1153,7 +1150,7 @@ typedef struct pm_and_node { * * Type: PM_ARGUMENTS_NODE * Flags: - * PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORD_SPLAT + * PM_ARGUMENTS_NODE_FLAGS_KEYWORD_SPLAT * * @extends pm_node_t */ @@ -1169,8 +1166,6 @@ typedef struct pm_arguments_node { * ArrayNode * * Type: PM_ARRAY_NODE - * Flags: - * PM_ARRAY_NODE_FLAGS_CONTAINS_SPLAT * * @extends pm_node_t */ @@ -1360,9 +1355,6 @@ typedef struct pm_block_node { /** BlockNode#closing_loc */ pm_location_t closing_loc; - - /** BlockNode#numbered_parameters */ - uint32_t numbered_parameters; } pm_block_node_t; /** @@ -1484,9 +1476,6 @@ typedef struct pm_call_node { /** CallNode#call_operator_loc */ pm_location_t call_operator_loc; - /** CallNode#name */ - pm_constant_id_t name; - /** CallNode#message_loc */ pm_location_t message_loc; @@ -1501,6 +1490,9 @@ typedef struct pm_call_node { /** CallNode#block */ struct pm_node *block; + + /** CallNode#name */ + pm_constant_id_t name; } pm_call_node_t; /** @@ -2615,18 +2607,6 @@ typedef struct pm_implicit_node { struct pm_node *value; } pm_implicit_node_t; -/** - * ImplicitRestNode - * - * Type: PM_IMPLICIT_REST_NODE - * - * @extends pm_node_t - */ -typedef struct pm_implicit_rest_node { - /** The embedded base node. */ - pm_node_t base; -} pm_implicit_rest_node_t; - /** * InNode * @@ -3104,9 +3084,6 @@ typedef struct pm_lambda_node { /** LambdaNode#body */ struct pm_node *body; - - /** LambdaNode#numbered_parameters */ - uint32_t numbered_parameters; } pm_lambda_node_t; /** @@ -3598,7 +3575,7 @@ typedef struct pm_parameters_node { struct pm_node_list optionals; /** ParametersNode#rest */ - struct pm_node *rest; + struct pm_rest_parameter_node *rest; /** ParametersNode#posts */ struct pm_node_list posts; @@ -4337,17 +4314,9 @@ typedef struct pm_yield_node { */ typedef enum pm_arguments_node_flags { /** if arguments contain keyword splat */ - PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORD_SPLAT = 1, + PM_ARGUMENTS_NODE_FLAGS_KEYWORD_SPLAT = 1, } pm_arguments_node_flags_t; -/** - * Flags for array nodes. - */ -typedef enum pm_array_node_flags { - /** if array contains splat nodes */ - PM_ARRAY_NODE_FLAGS_CONTAINS_SPLAT = 1, -} pm_array_node_flags_t; - /** * Flags for call nodes. */ diff --git a/crates/prism-sys/vendor/prism-0.18.0/include/prism/diagnostic.h b/crates/prism-sys/vendor/prism-0.18.0/include/prism/diagnostic.h index 3614a38a..68e50792 100644 --- a/crates/prism-sys/vendor/prism-0.18.0/include/prism/diagnostic.h +++ b/crates/prism-sys/vendor/prism-0.18.0/include/prism/diagnostic.h @@ -192,7 +192,6 @@ typedef enum { PM_ERR_OPERATOR_WRITE_BLOCK, PM_ERR_PARAMETER_ASSOC_SPLAT_MULTI, PM_ERR_PARAMETER_BLOCK_MULTI, - PM_ERR_PARAMETER_CIRCULAR, PM_ERR_PARAMETER_METHOD_NAME, PM_ERR_PARAMETER_NAME_REPEAT, PM_ERR_PARAMETER_NO_DEFAULT, @@ -227,10 +226,6 @@ typedef enum { PM_ERR_RESCUE_TERM, PM_ERR_RESCUE_VARIABLE, PM_ERR_RETURN_INVALID, - PM_ERR_STATEMENT_ALIAS, - PM_ERR_STATEMENT_POSTEXE_END, - PM_ERR_STATEMENT_PREEXE_BEGIN, - PM_ERR_STATEMENT_UNDEF, PM_ERR_STRING_CONCATENATION, PM_ERR_STRING_INTERPOLATED_TERM, PM_ERR_STRING_LITERAL_TERM, diff --git a/crates/prism-sys/vendor/prism-0.18.0/include/prism/enc/pm_encoding.h b/crates/prism-sys/vendor/prism-0.18.0/include/prism/enc/pm_encoding.h index 79702936..16deaefc 100644 --- a/crates/prism-sys/vendor/prism-0.18.0/include/prism/enc/pm_encoding.h +++ b/crates/prism-sys/vendor/prism-0.18.0/include/prism/enc/pm_encoding.h @@ -164,8 +164,6 @@ extern pm_encoding_t pm_encoding_cp51932; extern pm_encoding_t pm_encoding_cp850; extern pm_encoding_t pm_encoding_cp852; extern pm_encoding_t pm_encoding_cp855; -extern pm_encoding_t pm_encoding_cp949; -extern pm_encoding_t pm_encoding_cp950; extern pm_encoding_t pm_encoding_euc_jp; extern pm_encoding_t pm_encoding_gb1988; extern pm_encoding_t pm_encoding_gbk; @@ -200,13 +198,11 @@ extern pm_encoding_t pm_encoding_iso_8859_14; extern pm_encoding_t pm_encoding_iso_8859_15; extern pm_encoding_t pm_encoding_iso_8859_16; extern pm_encoding_t pm_encoding_koi8_r; -extern pm_encoding_t pm_encoding_koi8_u; extern pm_encoding_t pm_encoding_mac_cent_euro; extern pm_encoding_t pm_encoding_mac_croatian; extern pm_encoding_t pm_encoding_mac_cyrillic; extern pm_encoding_t pm_encoding_mac_greek; extern pm_encoding_t pm_encoding_mac_iceland; -extern pm_encoding_t pm_encoding_mac_japanese; extern pm_encoding_t pm_encoding_mac_roman; extern pm_encoding_t pm_encoding_mac_romania; extern pm_encoding_t pm_encoding_mac_thai; diff --git a/crates/prism-sys/vendor/prism-0.18.0/include/prism/options.h b/crates/prism-sys/vendor/prism-0.18.0/include/prism/options.h index 8608838d..2ea85c83 100644 --- a/crates/prism-sys/vendor/prism-0.18.0/include/prism/options.h +++ b/crates/prism-sys/vendor/prism-0.18.0/include/prism/options.h @@ -35,7 +35,7 @@ typedef struct { * The line within the file that the parse starts on. This value is * 0-indexed. */ - int32_t line; + uint32_t line; /** * The name of the encoding that the source file is in. Note that this must @@ -80,7 +80,7 @@ PRISM_EXPORTED_FUNCTION void pm_options_filepath_set(pm_options_t *options, cons * @param options The options struct to set the line on. * @param line The line to set. */ -PRISM_EXPORTED_FUNCTION void pm_options_line_set(pm_options_t *options, int32_t line); +PRISM_EXPORTED_FUNCTION void pm_options_line_set(pm_options_t *options, uint32_t line); /** * Set the encoding option on the given options struct. diff --git a/crates/prism-sys/vendor/prism-0.18.0/include/prism/parser.h b/crates/prism-sys/vendor/prism-0.18.0/include/prism/parser.h index dfc15e19..e3c93b42 100644 --- a/crates/prism-sys/vendor/prism-0.18.0/include/prism/parser.h +++ b/crates/prism-sys/vendor/prism-0.18.0/include/prism/parser.h @@ -297,9 +297,6 @@ typedef enum { /** an ensure statement */ PM_CONTEXT_ENSURE, - /** an ensure statement within a method definition */ - PM_CONTEXT_ENSURE_DEF, - /** a for loop */ PM_CONTEXT_FOR, @@ -336,15 +333,9 @@ typedef enum { /** a rescue else statement */ PM_CONTEXT_RESCUE_ELSE, - /** a rescue else statement within a method definition */ - PM_CONTEXT_RESCUE_ELSE_DEF, - /** a rescue statement */ PM_CONTEXT_RESCUE, - /** a rescue statement within a method definition */ - PM_CONTEXT_RESCUE_DEF, - /** a singleton class definition */ PM_CONTEXT_SCLASS, @@ -370,7 +361,8 @@ typedef struct pm_context_node { /** This is the type of a comment that we've found while parsing. */ typedef enum { PM_COMMENT_INLINE, - PM_COMMENT_EMBDOC + PM_COMMENT_EMBDOC, + PM_COMMENT___END__ } pm_comment_type_t; /** @@ -477,12 +469,11 @@ typedef struct pm_scope { bool explicit_params; /** - * An integer indicating the number of numbered parameters on this scope. + * A boolean indicating whether or not this scope has numbered parameters. * This is necessary to determine if child blocks are allowed to use - * numbered parameters, and to pass information to consumers of the AST - * about how many numbered parameters exist. + * numbered parameters. */ - uint32_t numbered_parameters; + bool numbered_params; /** * A transparent scope is a scope that cannot have locals set on itself. @@ -580,9 +571,6 @@ struct pm_parser { /** The list of magic comments that have been found while parsing. */ pm_list_t magic_comment_list; - /** The optional location of the __END__ keyword and its contents. */ - pm_location_t data_loc; - /** The list of warnings that have been found while parsing. */ pm_list_t warning_list; @@ -661,7 +649,7 @@ struct pm_parser { * The line number at the start of the parse. This will be used to offset * the line numbers of all of the locations. */ - int32_t start_line; + uint32_t start_line; /** Whether or not we're at the beginning of a command. */ bool command_start; @@ -685,9 +673,6 @@ struct pm_parser { /** This flag indicates that we are currently parsing a keyword argument. */ bool in_keyword_arg; - /** The current parameter name id on parsing its default value. */ - pm_constant_id_t current_param_name; - /** * Whether or not the parser has seen a token that has semantic meaning * (i.e., a token that is not a comment or whitespace). diff --git a/crates/prism-sys/vendor/prism-0.18.0/include/prism/util/pm_buffer.h b/crates/prism-sys/vendor/prism-0.18.0/include/prism/util/pm_buffer.h index ec11d05e..3c3a6fb6 100644 --- a/crates/prism-sys/vendor/prism-0.18.0/include/prism/util/pm_buffer.h +++ b/crates/prism-sys/vendor/prism-0.18.0/include/prism/util/pm_buffer.h @@ -118,15 +118,7 @@ void pm_buffer_append_byte(pm_buffer_t *buffer, uint8_t value); * @param buffer The buffer to append to. * @param value The integer to append. */ -void pm_buffer_append_varuint(pm_buffer_t *buffer, uint32_t value); - -/** - * Append a 32-bit signed integer to the buffer as a variable-length integer. - * - * @param buffer The buffer to append to. - * @param value The integer to append. - */ -void pm_buffer_append_varsint(pm_buffer_t *buffer, int32_t value); +void pm_buffer_append_varint(pm_buffer_t *buffer, uint32_t value); /** * Concatenate one buffer onto another. diff --git a/crates/prism-sys/vendor/prism-0.18.0/src/diagnostic.c b/crates/prism-sys/vendor/prism-0.18.0/src/diagnostic.c index 443ad35c..473960e3 100644 --- a/crates/prism-sys/vendor/prism-0.18.0/src/diagnostic.c +++ b/crates/prism-sys/vendor/prism-0.18.0/src/diagnostic.c @@ -5,33 +5,32 @@ * * When composing an error message, use sentence fragments. * - * Try describing the property of the code that caused the error, rather than - * the rule that is being violated. It may help to use a fragment that completes - * a sentence beginning, "the parser encountered (a) ...". If appropriate, add a - * description of the rule violation (or other helpful context) after a - * semicolon. + * Try describing the property of the code that caused the error, rather than the rule that is being + * violated. It may help to use a fragment that completes a sentence beginning, "The parser + * encountered (a) ...". If appropriate, add a description of the rule violation (or other helpful + * context) after a semicolon. * - * For example:, instead of "control escape sequence cannot be doubled", prefer: + * For example:, instead of "Control escape sequence cannot be doubled", prefer: * - * > "invalid control escape sequence; control cannot be repeated" + * > "Invalid control escape sequence; control cannot be repeated" * - * In some cases, where the failure is more general or syntax expectations are - * violated, it may make more sense to use a fragment that completes a sentence - * beginning, "the parser ...". + * In some cases, where the failure is more general or syntax expectations are violated, it may make + * more sense to use a fragment that completes a sentence beginning, "The parser ...". * * For example: * - * > "expected an expression after `(`" - * > "cannot parse the expression" + * > "Expected an expression after `(`" + * > "Cannot parse the expression" + * * * ## Message style guide * * - Use articles like "a", "an", and "the" when appropriate. - * - e.g., prefer "cannot parse the expression" to "cannot parse expression". + * - e.g., prefer "Cannot parse the expression" to "Cannot parse expression". * - Use the common name for tokens and nodes. * - e.g., prefer "keyword splat" to "assoc splat" * - e.g., prefer "embedded document" to "embdoc" - * - Do not capitalize the initial word of the message. + * - Capitalize the initial word of the message. * - Use back ticks around token literals * - e.g., "Expected a `=>` between the hash key and value" * - Do not use `.` or other punctuation at the end of the message. @@ -39,6 +38,7 @@ * - For tokens that can have multiple meanings, reference the token and its meaning. * - e.g., "`*` splat argument" is clearer and more complete than "splat argument" or "`*` argument" * + * * ## Error names (PM_ERR_*) * * - When appropriate, prefer node name to token name. @@ -51,216 +51,211 @@ * sorted. See PM_ERR_ARGUMENT_NO_FORWARDING_* for an example. */ static const char* const diagnostic_messages[PM_DIAGNOSTIC_ID_LEN] = { - [PM_ERR_ALIAS_ARGUMENT] = "invalid argument being passed to `alias`; expected a bare word, symbol, constant, or global variable", - [PM_ERR_AMPAMPEQ_MULTI_ASSIGN] = "unexpected `&&=` in a multiple assignment", - [PM_ERR_ARGUMENT_AFTER_BLOCK] = "unexpected argument after a block argument", - [PM_ERR_ARGUMENT_AFTER_FORWARDING_ELLIPSES] = "unexpected argument after `...`", - [PM_ERR_ARGUMENT_BARE_HASH] = "unexpected bare hash argument", - [PM_ERR_ARGUMENT_BLOCK_MULTI] = "multiple block arguments; only one block is allowed", - [PM_ERR_ARGUMENT_FORMAL_CLASS] = "invalid formal argument; formal argument cannot be a class variable", - [PM_ERR_ARGUMENT_FORMAL_CONSTANT] = "invalid formal argument; formal argument cannot be a constant", - [PM_ERR_ARGUMENT_FORMAL_GLOBAL] = "invalid formal argument; formal argument cannot be a global variable", - [PM_ERR_ARGUMENT_FORMAL_IVAR] = "invalid formal argument; formal argument cannot be an instance variable", - [PM_ERR_ARGUMENT_FORWARDING_UNBOUND] = "unexpected `...` in an non-parenthesized call", - [PM_ERR_ARGUMENT_NO_FORWARDING_AMP] = "unexpected `&` when the parent method is not forwarding", - [PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES] = "unexpected `...` when the parent method is not forwarding", - [PM_ERR_ARGUMENT_NO_FORWARDING_STAR] = "unexpected `*` when the parent method is not forwarding", - [PM_ERR_ARGUMENT_SPLAT_AFTER_ASSOC_SPLAT] = "unexpected `*` splat argument after a `**` keyword splat argument", - [PM_ERR_ARGUMENT_SPLAT_AFTER_SPLAT] = "unexpected `*` splat argument after a `*` splat argument", - [PM_ERR_ARGUMENT_TERM_PAREN] = "expected a `)` to close the arguments", - [PM_ERR_ARGUMENT_UNEXPECTED_BLOCK] = "unexpected `{` after a method call without parenthesis", - [PM_ERR_ARRAY_ELEMENT] = "expected an element for the array", - [PM_ERR_ARRAY_EXPRESSION] = "expected an expression for the array element", - [PM_ERR_ARRAY_EXPRESSION_AFTER_STAR] = "expected an expression after `*` in the array", - [PM_ERR_ARRAY_SEPARATOR] = "expected a `,` separator for the array elements", - [PM_ERR_ARRAY_TERM] = "expected a `]` to close the array", - [PM_ERR_BEGIN_LONELY_ELSE] = "unexpected `else` in `begin` block; a `rescue` clause must precede `else`", - [PM_ERR_BEGIN_TERM] = "expected an `end` to close the `begin` statement", - [PM_ERR_BEGIN_UPCASE_BRACE] = "expected a `{` after `BEGIN`", - [PM_ERR_BEGIN_UPCASE_TERM] = "expected a `}` to close the `BEGIN` statement", + [PM_ERR_ALIAS_ARGUMENT] = "Invalid argument being passed to `alias`; expected a bare word, symbol, constant, or global variable", + [PM_ERR_AMPAMPEQ_MULTI_ASSIGN] = "Unexpected `&&=` in a multiple assignment", + [PM_ERR_ARGUMENT_AFTER_BLOCK] = "Unexpected argument after a block argument", + [PM_ERR_ARGUMENT_AFTER_FORWARDING_ELLIPSES] = "Unexpected argument after `...`", + [PM_ERR_ARGUMENT_BARE_HASH] = "Unexpected bare hash argument", + [PM_ERR_ARGUMENT_BLOCK_MULTI] = "Multiple block arguments; only one block is allowed", + [PM_ERR_ARGUMENT_FORMAL_CLASS] = "Invalid formal argument; formal argument cannot be a class variable", + [PM_ERR_ARGUMENT_FORMAL_CONSTANT] = "Invalid formal argument; formal argument cannot be a constant", + [PM_ERR_ARGUMENT_FORMAL_GLOBAL] = "Invalid formal argument; formal argument cannot be a global variable", + [PM_ERR_ARGUMENT_FORMAL_IVAR] = "Invalid formal argument; formal argument cannot be an instance variable", + [PM_ERR_ARGUMENT_FORWARDING_UNBOUND] = "Unexpected `...` in an non-parenthesized call", + [PM_ERR_ARGUMENT_NO_FORWARDING_AMP] = "Unexpected `&` when the parent method is not forwarding", + [PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES] = "Unexpected `...` when the parent method is not forwarding", + [PM_ERR_ARGUMENT_NO_FORWARDING_STAR] = "Unexpected `*` when the parent method is not forwarding", + [PM_ERR_ARGUMENT_SPLAT_AFTER_ASSOC_SPLAT] = "Unexpected `*` splat argument after a `**` keyword splat argument", + [PM_ERR_ARGUMENT_SPLAT_AFTER_SPLAT] = "Unexpected `*` splat argument after a `*` splat argument", + [PM_ERR_ARGUMENT_TERM_PAREN] = "Expected a `)` to close the arguments", + [PM_ERR_ARGUMENT_UNEXPECTED_BLOCK] = "Unexpected `{` after a method call without parenthesis", + [PM_ERR_ARRAY_ELEMENT] = "Expected an element for the array", + [PM_ERR_ARRAY_EXPRESSION] = "Expected an expression for the array element", + [PM_ERR_ARRAY_EXPRESSION_AFTER_STAR] = "Expected an expression after `*` in the array", + [PM_ERR_ARRAY_SEPARATOR] = "Expected a `,` separator for the array elements", + [PM_ERR_ARRAY_TERM] = "Expected a `]` to close the array", + [PM_ERR_BEGIN_LONELY_ELSE] = "Unexpected `else` in `begin` block; a `rescue` clause must precede `else`", + [PM_ERR_BEGIN_TERM] = "Expected an `end` to close the `begin` statement", + [PM_ERR_BEGIN_UPCASE_BRACE] = "Expected a `{` after `BEGIN`", + [PM_ERR_BEGIN_UPCASE_TERM] = "Expected a `}` to close the `BEGIN` statement", [PM_ERR_BEGIN_UPCASE_TOPLEVEL] = "BEGIN is permitted only at toplevel", - [PM_ERR_BLOCK_PARAM_LOCAL_VARIABLE] = "expected a local variable name in the block parameters", - [PM_ERR_BLOCK_PARAM_PIPE_TERM] = "expected the block parameters to end with `|`", - [PM_ERR_BLOCK_TERM_BRACE] = "expected a block beginning with `{` to end with `}`", - [PM_ERR_BLOCK_TERM_END] = "expected a block beginning with `do` to end with `end`", - [PM_ERR_CANNOT_PARSE_EXPRESSION] = "cannot parse the expression", - [PM_ERR_CANNOT_PARSE_STRING_PART] = "cannot parse the string part", - [PM_ERR_CASE_EXPRESSION_AFTER_CASE] = "expected an expression after `case`", - [PM_ERR_CASE_EXPRESSION_AFTER_WHEN] = "expected an expression after `when`", - [PM_ERR_CASE_MATCH_MISSING_PREDICATE] = "expected a predicate for a case matching statement", - [PM_ERR_CASE_MISSING_CONDITIONS] = "expected a `when` or `in` clause after `case`", - [PM_ERR_CASE_TERM] = "expected an `end` to close the `case` statement", - [PM_ERR_CLASS_IN_METHOD] = "unexpected class definition in a method definition", - [PM_ERR_CLASS_NAME] = "expected a constant name after `class`", - [PM_ERR_CLASS_SUPERCLASS] = "expected a superclass after `<`", - [PM_ERR_CLASS_TERM] = "expected an `end` to close the `class` statement", - [PM_ERR_CLASS_UNEXPECTED_END] = "unexpected `end`, expecting ';' or '\n'", - [PM_ERR_CONDITIONAL_ELSIF_PREDICATE] = "expected a predicate expression for the `elsif` statement", - [PM_ERR_CONDITIONAL_IF_PREDICATE] = "expected a predicate expression for the `if` statement", - [PM_ERR_CONDITIONAL_PREDICATE_TERM] = "expected `then` or `;` or '\n'", - [PM_ERR_CONDITIONAL_TERM] = "expected an `end` to close the conditional clause", - [PM_ERR_CONDITIONAL_TERM_ELSE] = "expected an `end` to close the `else` clause", - [PM_ERR_CONDITIONAL_UNLESS_PREDICATE] = "expected a predicate expression for the `unless` statement", - [PM_ERR_CONDITIONAL_UNTIL_PREDICATE] = "expected a predicate expression for the `until` statement", - [PM_ERR_CONDITIONAL_WHILE_PREDICATE] = "expected a predicate expression for the `while` statement", - [PM_ERR_CONSTANT_PATH_COLON_COLON_CONSTANT] = "expected a constant after the `::` operator", - [PM_ERR_DEF_ENDLESS] = "could not parse the endless method body", - [PM_ERR_DEF_ENDLESS_SETTER] = "invalid method name; a setter method cannot be defined in an endless method definition", - [PM_ERR_DEF_NAME] = "expected a method name", - [PM_ERR_DEF_NAME_AFTER_RECEIVER] = "expected a method name after the receiver", - [PM_ERR_DEF_PARAMS_TERM] = "expected a delimiter to close the parameters", - [PM_ERR_DEF_PARAMS_TERM_PAREN] = "expected a `)` to close the parameters", - [PM_ERR_DEF_RECEIVER] = "expected a receiver for the method definition", - [PM_ERR_DEF_RECEIVER_TERM] = "expected a `.` or `::` after the receiver in a method definition", - [PM_ERR_DEF_TERM] = "expected an `end` to close the `def` statement", - [PM_ERR_DEFINED_EXPRESSION] = "expected an expression after `defined?`", - [PM_ERR_EMBDOC_TERM] = "could not find a terminator for the embedded document", - [PM_ERR_EMBEXPR_END] = "expected a `}` to close the embedded expression", - [PM_ERR_EMBVAR_INVALID] = "invalid embedded variable", - [PM_ERR_END_UPCASE_BRACE] = "expected a `{` after `END`", - [PM_ERR_END_UPCASE_TERM] = "expected a `}` to close the `END` statement", - [PM_ERR_ESCAPE_INVALID_CONTROL] = "invalid control escape sequence", - [PM_ERR_ESCAPE_INVALID_CONTROL_REPEAT] = "invalid control escape sequence; control cannot be repeated", - [PM_ERR_ESCAPE_INVALID_HEXADECIMAL] = "invalid hexadecimal escape sequence", - [PM_ERR_ESCAPE_INVALID_META] = "invalid meta escape sequence", - [PM_ERR_ESCAPE_INVALID_META_REPEAT] = "invalid meta escape sequence; meta cannot be repeated", - [PM_ERR_ESCAPE_INVALID_UNICODE] = "invalid Unicode escape sequence", - [PM_ERR_ESCAPE_INVALID_UNICODE_CM_FLAGS] = "invalid Unicode escape sequence; Unicode cannot be combined with control or meta flags", - [PM_ERR_ESCAPE_INVALID_UNICODE_LITERAL] = "invalid Unicode escape sequence; multiple codepoints are not allowed in a character literal", - [PM_ERR_ESCAPE_INVALID_UNICODE_LONG] = "invalid Unicode escape sequence; maximum length is 6 digits", - [PM_ERR_ESCAPE_INVALID_UNICODE_TERM] = "invalid Unicode escape sequence; needs closing `}`", - [PM_ERR_EXPECT_ARGUMENT] = "expected an argument", - [PM_ERR_EXPECT_EOL_AFTER_STATEMENT] = "expected a newline or semicolon after the statement", - [PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ] = "expected an expression after `&&=`", - [PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ] = "expected an expression after `||=`", - [PM_ERR_EXPECT_EXPRESSION_AFTER_COMMA] = "expected an expression after `,`", - [PM_ERR_EXPECT_EXPRESSION_AFTER_EQUAL] = "expected an expression after `=`", - [PM_ERR_EXPECT_EXPRESSION_AFTER_LESS_LESS] = "expected an expression after `<<`", - [PM_ERR_EXPECT_EXPRESSION_AFTER_LPAREN] = "expected an expression after `(`", - [PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR] = "expected an expression after the operator", - [PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT] = "expected an expression after `*` splat in an argument", - [PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT_HASH] = "expected an expression after `**` in a hash", - [PM_ERR_EXPECT_EXPRESSION_AFTER_STAR] = "expected an expression after `*`", - [PM_ERR_EXPECT_IDENT_REQ_PARAMETER] = "expected an identifier for the required parameter", - [PM_ERR_EXPECT_LPAREN_REQ_PARAMETER] = "expected a `(` to start a required parameter", - [PM_ERR_EXPECT_RBRACKET] = "expected a matching `]`", - [PM_ERR_EXPECT_RPAREN] = "expected a matching `)`", - [PM_ERR_EXPECT_RPAREN_AFTER_MULTI] = "expected a `)` after multiple assignment", - [PM_ERR_EXPECT_RPAREN_REQ_PARAMETER] = "expected a `)` to end a required parameter", - [PM_ERR_EXPECT_STRING_CONTENT] = "expected string content after opening string delimiter", - [PM_ERR_EXPECT_WHEN_DELIMITER] = "expected a delimiter after the predicates of a `when` clause", - [PM_ERR_EXPRESSION_BARE_HASH] = "unexpected bare hash in expression", - [PM_ERR_FOR_COLLECTION] = "expected a collection after the `in` in a `for` statement", - [PM_ERR_FOR_INDEX] = "expected an index after `for`", - [PM_ERR_FOR_IN] = "expected an `in` after the index in a `for` statement", - [PM_ERR_FOR_TERM] = "expected an `end` to close the `for` loop", - [PM_ERR_HASH_EXPRESSION_AFTER_LABEL] = "expected an expression after the label in a hash", - [PM_ERR_HASH_KEY] = "expected a key in the hash literal", - [PM_ERR_HASH_ROCKET] = "expected a `=>` between the hash key and value", - [PM_ERR_HASH_TERM] = "expected a `}` to close the hash literal", - [PM_ERR_HASH_VALUE] = "expected a value in the hash literal", - [PM_ERR_HEREDOC_TERM] = "could not find a terminator for the heredoc", - [PM_ERR_INCOMPLETE_QUESTION_MARK] = "incomplete expression at `?`", - [PM_ERR_INCOMPLETE_VARIABLE_CLASS] = "incomplete class variable", - [PM_ERR_INCOMPLETE_VARIABLE_INSTANCE] = "incomplete instance variable", - [PM_ERR_INVALID_ENCODING_MAGIC_COMMENT] = "unknown or invalid encoding in the magic comment", - [PM_ERR_INVALID_FLOAT_EXPONENT] = "invalid exponent", - [PM_ERR_INVALID_NUMBER_BINARY] = "invalid binary number", - [PM_ERR_INVALID_NUMBER_DECIMAL] = "invalid decimal number", - [PM_ERR_INVALID_NUMBER_HEXADECIMAL] = "invalid hexadecimal number", - [PM_ERR_INVALID_NUMBER_OCTAL] = "invalid octal number", - [PM_ERR_INVALID_NUMBER_UNDERSCORE] = "invalid underscore placement in number", - [PM_ERR_INVALID_PERCENT] = "invalid `%` token", // TODO WHAT? - [PM_ERR_INVALID_TOKEN] = "invalid token", // TODO WHAT? - [PM_ERR_INVALID_VARIABLE_GLOBAL] = "invalid global variable", - [PM_ERR_LAMBDA_OPEN] = "expected a `do` keyword or a `{` to open the lambda block", - [PM_ERR_LAMBDA_TERM_BRACE] = "expected a lambda block beginning with `{` to end with `}`", - [PM_ERR_LAMBDA_TERM_END] = "expected a lambda block beginning with `do` to end with `end`", - [PM_ERR_LIST_I_LOWER_ELEMENT] = "expected a symbol in a `%i` list", - [PM_ERR_LIST_I_LOWER_TERM] = "expected a closing delimiter for the `%i` list", - [PM_ERR_LIST_I_UPPER_ELEMENT] = "expected a symbol in a `%I` list", - [PM_ERR_LIST_I_UPPER_TERM] = "expected a closing delimiter for the `%I` list", - [PM_ERR_LIST_W_LOWER_ELEMENT] = "expected a string in a `%w` list", - [PM_ERR_LIST_W_LOWER_TERM] = "expected a closing delimiter for the `%w` list", - [PM_ERR_LIST_W_UPPER_ELEMENT] = "expected a string in a `%W` list", - [PM_ERR_LIST_W_UPPER_TERM] = "expected a closing delimiter for the `%W` list", - [PM_ERR_MALLOC_FAILED] = "failed to allocate memory", - [PM_ERR_MODULE_IN_METHOD] = "unexpected module definition in a method definition", - [PM_ERR_MODULE_NAME] = "expected a constant name after `module`", - [PM_ERR_MODULE_TERM] = "expected an `end` to close the `module` statement", - [PM_ERR_MULTI_ASSIGN_MULTI_SPLATS] = "multiple splats in multiple assignment", - [PM_ERR_NOT_EXPRESSION] = "expected an expression after `not`", - [PM_ERR_NUMBER_LITERAL_UNDERSCORE] = "number literal ending with a `_`", - [PM_ERR_NUMBERED_PARAMETER_NOT_ALLOWED] = "numbered parameters are not allowed alongside explicit parameters", - [PM_ERR_NUMBERED_PARAMETER_OUTER_SCOPE] = "numbered parameter is already used in outer scope", - [PM_ERR_OPERATOR_MULTI_ASSIGN] = "unexpected operator for a multiple assignment", - [PM_ERR_OPERATOR_WRITE_ARGUMENTS] = "unexpected operator after a call with arguments", - [PM_ERR_OPERATOR_WRITE_BLOCK] = "unexpected operator after a call with a block", - [PM_ERR_PARAMETER_ASSOC_SPLAT_MULTI] = "unexpected multiple `**` splat parameters", - [PM_ERR_PARAMETER_BLOCK_MULTI] = "multiple block parameters; only one block is allowed", - [PM_ERR_PARAMETER_CIRCULAR] = "parameter default value references itself", - [PM_ERR_PARAMETER_METHOD_NAME] = "unexpected name for a parameter", - [PM_ERR_PARAMETER_NAME_REPEAT] = "repeated parameter name", - [PM_ERR_PARAMETER_NO_DEFAULT] = "expected a default value for the parameter", - [PM_ERR_PARAMETER_NO_DEFAULT_KW] = "expected a default value for the keyword parameter", + [PM_ERR_BLOCK_PARAM_LOCAL_VARIABLE] = "Expected a local variable name in the block parameters", + [PM_ERR_BLOCK_PARAM_PIPE_TERM] = "Expected the block parameters to end with `|`", + [PM_ERR_BLOCK_TERM_BRACE] = "Expected a block beginning with `{` to end with `}`", + [PM_ERR_BLOCK_TERM_END] = "Expected a block beginning with `do` to end with `end`", + [PM_ERR_CANNOT_PARSE_EXPRESSION] = "Cannot parse the expression", + [PM_ERR_CANNOT_PARSE_STRING_PART] = "Cannot parse the string part", + [PM_ERR_CASE_EXPRESSION_AFTER_CASE] = "Expected an expression after `case`", + [PM_ERR_CASE_EXPRESSION_AFTER_WHEN] = "Expected an expression after `when`", + [PM_ERR_CASE_MATCH_MISSING_PREDICATE] = "Expected a predicate for a case matching statement", + [PM_ERR_CASE_MISSING_CONDITIONS] = "Expected a `when` or `in` clause after `case`", + [PM_ERR_CASE_TERM] = "Expected an `end` to close the `case` statement", + [PM_ERR_CLASS_IN_METHOD] = "Unexpected class definition in a method body", + [PM_ERR_CLASS_NAME] = "Expected a constant name after `class`", + [PM_ERR_CLASS_SUPERCLASS] = "Expected a superclass after `<`", + [PM_ERR_CLASS_TERM] = "Expected an `end` to close the `class` statement", + [PM_ERR_CLASS_UNEXPECTED_END] = "Unexpected `end`, expecting ';' or '\n'", + [PM_ERR_CONDITIONAL_ELSIF_PREDICATE] = "Expected a predicate expression for the `elsif` statement", + [PM_ERR_CONDITIONAL_IF_PREDICATE] = "Expected a predicate expression for the `if` statement", + [PM_ERR_CONDITIONAL_PREDICATE_TERM] = "Expected `then` or `;` or '\n'", + [PM_ERR_CONDITIONAL_TERM] = "Expected an `end` to close the conditional clause", + [PM_ERR_CONDITIONAL_TERM_ELSE] = "Expected an `end` to close the `else` clause", + [PM_ERR_CONDITIONAL_UNLESS_PREDICATE] = "Expected a predicate expression for the `unless` statement", + [PM_ERR_CONDITIONAL_UNTIL_PREDICATE] = "Expected a predicate expression for the `until` statement", + [PM_ERR_CONDITIONAL_WHILE_PREDICATE] = "Expected a predicate expression for the `while` statement", + [PM_ERR_CONSTANT_PATH_COLON_COLON_CONSTANT] = "Expected a constant after the `::` operator", + [PM_ERR_DEF_ENDLESS] = "Could not parse the endless method body", + [PM_ERR_DEF_ENDLESS_SETTER] = "Invalid method name; a setter method cannot be defined in an endless method definition", + [PM_ERR_DEF_NAME] = "Expected a method name", + [PM_ERR_DEF_NAME_AFTER_RECEIVER] = "Expected a method name after the receiver", + [PM_ERR_DEF_PARAMS_TERM] = "Expected a delimiter to close the parameters", + [PM_ERR_DEF_PARAMS_TERM_PAREN] = "Expected a `)` to close the parameters", + [PM_ERR_DEF_RECEIVER] = "Expected a receiver for the method definition", + [PM_ERR_DEF_RECEIVER_TERM] = "Expected a `.` or `::` after the receiver in a method definition", + [PM_ERR_DEF_TERM] = "Expected an `end` to close the `def` statement", + [PM_ERR_DEFINED_EXPRESSION] = "Expected an expression after `defined?`", + [PM_ERR_EMBDOC_TERM] = "Could not find a terminator for the embedded document", + [PM_ERR_EMBEXPR_END] = "Expected a `}` to close the embedded expression", + [PM_ERR_EMBVAR_INVALID] = "Invalid embedded variable", + [PM_ERR_END_UPCASE_BRACE] = "Expected a `{` after `END`", + [PM_ERR_END_UPCASE_TERM] = "Expected a `}` to close the `END` statement", + [PM_ERR_ESCAPE_INVALID_CONTROL] = "Invalid control escape sequence", + [PM_ERR_ESCAPE_INVALID_CONTROL_REPEAT] = "Invalid control escape sequence; control cannot be repeated", + [PM_ERR_ESCAPE_INVALID_HEXADECIMAL] = "Invalid hexadecimal escape sequence", + [PM_ERR_ESCAPE_INVALID_META] = "Invalid meta escape sequence", + [PM_ERR_ESCAPE_INVALID_META_REPEAT] = "Invalid meta escape sequence; meta cannot be repeated", + [PM_ERR_ESCAPE_INVALID_UNICODE] = "Invalid Unicode escape sequence", + [PM_ERR_ESCAPE_INVALID_UNICODE_CM_FLAGS] = "Invalid Unicode escape sequence; Unicode cannot be combined with control or meta flags", + [PM_ERR_ESCAPE_INVALID_UNICODE_LITERAL] = "Invalid Unicode escape sequence; multiple codepoints are not allowed in a character literal", + [PM_ERR_ESCAPE_INVALID_UNICODE_LONG] = "Invalid Unicode escape sequence; maximum length is 6 digits", + [PM_ERR_ESCAPE_INVALID_UNICODE_TERM] = "Invalid Unicode escape sequence; needs closing `}`", + [PM_ERR_EXPECT_ARGUMENT] = "Expected an argument", + [PM_ERR_EXPECT_EOL_AFTER_STATEMENT] = "Expected a newline or semicolon after the statement", + [PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ] = "Expected an expression after `&&=`", + [PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ] = "Expected an expression after `||=`", + [PM_ERR_EXPECT_EXPRESSION_AFTER_COMMA] = "Expected an expression after `,`", + [PM_ERR_EXPECT_EXPRESSION_AFTER_EQUAL] = "Expected an expression after `=`", + [PM_ERR_EXPECT_EXPRESSION_AFTER_LESS_LESS] = "Expected an expression after `<<`", + [PM_ERR_EXPECT_EXPRESSION_AFTER_LPAREN] = "Expected an expression after `(`", + [PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR] = "Expected an expression after the operator", + [PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT] = "Expected an expression after `*` splat in an argument", + [PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT_HASH] = "Expected an expression after `**` in a hash", + [PM_ERR_EXPECT_EXPRESSION_AFTER_STAR] = "Expected an expression after `*`", + [PM_ERR_EXPECT_IDENT_REQ_PARAMETER] = "Expected an identifier for the required parameter", + [PM_ERR_EXPECT_LPAREN_REQ_PARAMETER] = "Expected a `(` to start a required parameter", + [PM_ERR_EXPECT_RBRACKET] = "Expected a matching `]`", + [PM_ERR_EXPECT_RPAREN] = "Expected a matching `)`", + [PM_ERR_EXPECT_RPAREN_AFTER_MULTI] = "Expected a `)` after multiple assignment", + [PM_ERR_EXPECT_RPAREN_REQ_PARAMETER] = "Expected a `)` to end a required parameter", + [PM_ERR_EXPECT_STRING_CONTENT] = "Expected string content after opening string delimiter", + [PM_ERR_EXPECT_WHEN_DELIMITER] = "Expected a delimiter after the predicates of a `when` clause", + [PM_ERR_EXPRESSION_BARE_HASH] = "Unexpected bare hash in expression", + [PM_ERR_FOR_COLLECTION] = "Expected a collection after the `in` in a `for` statement", + [PM_ERR_FOR_INDEX] = "Expected an index after `for`", + [PM_ERR_FOR_IN] = "Expected an `in` after the index in a `for` statement", + [PM_ERR_FOR_TERM] = "Expected an `end` to close the `for` loop", + [PM_ERR_HASH_EXPRESSION_AFTER_LABEL] = "Expected an expression after the label in a hash", + [PM_ERR_HASH_KEY] = "Expected a key in the hash literal", + [PM_ERR_HASH_ROCKET] = "Expected a `=>` between the hash key and value", + [PM_ERR_HASH_TERM] = "Expected a `}` to close the hash literal", + [PM_ERR_HASH_VALUE] = "Expected a value in the hash literal", + [PM_ERR_HEREDOC_TERM] = "Could not find a terminator for the heredoc", + [PM_ERR_INCOMPLETE_QUESTION_MARK] = "Incomplete expression at `?`", + [PM_ERR_INCOMPLETE_VARIABLE_CLASS] = "Incomplete class variable", + [PM_ERR_INCOMPLETE_VARIABLE_INSTANCE] = "Incomplete instance variable", + [PM_ERR_INVALID_ENCODING_MAGIC_COMMENT] = "Unknown or invalid encoding in the magic comment", + [PM_ERR_INVALID_FLOAT_EXPONENT] = "Invalid exponent", + [PM_ERR_INVALID_NUMBER_BINARY] = "Invalid binary number", + [PM_ERR_INVALID_NUMBER_DECIMAL] = "Invalid decimal number", + [PM_ERR_INVALID_NUMBER_HEXADECIMAL] = "Invalid hexadecimal number", + [PM_ERR_INVALID_NUMBER_OCTAL] = "Invalid octal number", + [PM_ERR_INVALID_NUMBER_UNDERSCORE] = "Invalid underscore placement in number", + [PM_ERR_INVALID_PERCENT] = "Invalid `%` token", // TODO WHAT? + [PM_ERR_INVALID_TOKEN] = "Invalid token", // TODO WHAT? + [PM_ERR_INVALID_VARIABLE_GLOBAL] = "Invalid global variable", + [PM_ERR_LAMBDA_OPEN] = "Expected a `do` keyword or a `{` to open the lambda block", + [PM_ERR_LAMBDA_TERM_BRACE] = "Expected a lambda block beginning with `{` to end with `}`", + [PM_ERR_LAMBDA_TERM_END] = "Expected a lambda block beginning with `do` to end with `end`", + [PM_ERR_LIST_I_LOWER_ELEMENT] = "Expected a symbol in a `%i` list", + [PM_ERR_LIST_I_LOWER_TERM] = "Expected a closing delimiter for the `%i` list", + [PM_ERR_LIST_I_UPPER_ELEMENT] = "Expected a symbol in a `%I` list", + [PM_ERR_LIST_I_UPPER_TERM] = "Expected a closing delimiter for the `%I` list", + [PM_ERR_LIST_W_LOWER_ELEMENT] = "Expected a string in a `%w` list", + [PM_ERR_LIST_W_LOWER_TERM] = "Expected a closing delimiter for the `%w` list", + [PM_ERR_LIST_W_UPPER_ELEMENT] = "Expected a string in a `%W` list", + [PM_ERR_LIST_W_UPPER_TERM] = "Expected a closing delimiter for the `%W` list", + [PM_ERR_MALLOC_FAILED] = "Failed to allocate memory", + [PM_ERR_MODULE_IN_METHOD] = "Unexpected module definition in a method body", + [PM_ERR_MODULE_NAME] = "Expected a constant name after `module`", + [PM_ERR_MODULE_TERM] = "Expected an `end` to close the `module` statement", + [PM_ERR_MULTI_ASSIGN_MULTI_SPLATS] = "Multiple splats in multiple assignment", + [PM_ERR_NOT_EXPRESSION] = "Expected an expression after `not`", + [PM_ERR_NUMBER_LITERAL_UNDERSCORE] = "Number literal ending with a `_`", + [PM_ERR_NUMBERED_PARAMETER_NOT_ALLOWED] = "Numbered parameters are not allowed alongside explicit parameters", + [PM_ERR_NUMBERED_PARAMETER_OUTER_SCOPE] = "Numbered parameter is already used in outer scope", + [PM_ERR_OPERATOR_MULTI_ASSIGN] = "Unexpected operator for a multiple assignment", + [PM_ERR_OPERATOR_WRITE_ARGUMENTS] = "Unexpected operator after a call with arguments", + [PM_ERR_OPERATOR_WRITE_BLOCK] = "Unexpected operator after a call with a block", + [PM_ERR_PARAMETER_ASSOC_SPLAT_MULTI] = "Unexpected multiple `**` splat parameters", + [PM_ERR_PARAMETER_BLOCK_MULTI] = "Multiple block parameters; only one block is allowed", + [PM_ERR_PARAMETER_METHOD_NAME] = "Unexpected name for a parameter", + [PM_ERR_PARAMETER_NAME_REPEAT] = "Repeated parameter name", + [PM_ERR_PARAMETER_NO_DEFAULT] = "Expected a default value for the parameter", + [PM_ERR_PARAMETER_NO_DEFAULT_KW] = "Expected a default value for the keyword parameter", [PM_ERR_PARAMETER_NUMBERED_RESERVED] = "%.2s is reserved for a numbered parameter", - [PM_ERR_PARAMETER_ORDER] = "unexpected parameter order", - [PM_ERR_PARAMETER_SPLAT_MULTI] = "unexpected multiple `*` splat parameters", - [PM_ERR_PARAMETER_STAR] = "unexpected parameter `*`", - [PM_ERR_PARAMETER_UNEXPECTED_FWD] = "unexpected `...` in parameters", - [PM_ERR_PARAMETER_WILD_LOOSE_COMMA] = "unexpected `,` in parameters", - [PM_ERR_PATTERN_EXPRESSION_AFTER_BRACKET] = "expected a pattern expression after the `[` operator", - [PM_ERR_PATTERN_EXPRESSION_AFTER_COMMA] = "expected a pattern expression after `,`", - [PM_ERR_PATTERN_EXPRESSION_AFTER_HROCKET] = "expected a pattern expression after `=>`", - [PM_ERR_PATTERN_EXPRESSION_AFTER_IN] = "expected a pattern expression after the `in` keyword", - [PM_ERR_PATTERN_EXPRESSION_AFTER_KEY] = "expected a pattern expression after the key", - [PM_ERR_PATTERN_EXPRESSION_AFTER_PAREN] = "expected a pattern expression after the `(` operator", - [PM_ERR_PATTERN_EXPRESSION_AFTER_PIN] = "expected a pattern expression after the `^` pin operator", - [PM_ERR_PATTERN_EXPRESSION_AFTER_PIPE] = "expected a pattern expression after the `|` operator", - [PM_ERR_PATTERN_EXPRESSION_AFTER_RANGE] = "expected a pattern expression after the range operator", - [PM_ERR_PATTERN_HASH_KEY] = "expected a key in the hash pattern", - [PM_ERR_PATTERN_HASH_KEY_LABEL] = "expected a label as the key in the hash pattern", // TODO // THIS // AND // ABOVE // IS WEIRD - [PM_ERR_PATTERN_IDENT_AFTER_HROCKET] = "expected an identifier after the `=>` operator", - [PM_ERR_PATTERN_LABEL_AFTER_COMMA] = "expected a label after the `,` in the hash pattern", - [PM_ERR_PATTERN_REST] = "unexpected rest pattern", - [PM_ERR_PATTERN_TERM_BRACE] = "expected a `}` to close the pattern expression", - [PM_ERR_PATTERN_TERM_BRACKET] = "expected a `]` to close the pattern expression", - [PM_ERR_PATTERN_TERM_PAREN] = "expected a `)` to close the pattern expression", - [PM_ERR_PIPEPIPEEQ_MULTI_ASSIGN] = "unexpected `||=` in a multiple assignment", - [PM_ERR_REGEXP_TERM] = "expected a closing delimiter for the regular expression", - [PM_ERR_RESCUE_EXPRESSION] = "expected a rescued expression", - [PM_ERR_RESCUE_MODIFIER_VALUE] = "expected a value after the `rescue` modifier", - [PM_ERR_RESCUE_TERM] = "expected a closing delimiter for the `rescue` clause", - [PM_ERR_RESCUE_VARIABLE] = "expected an exception variable after `=>` in a rescue statement", - [PM_ERR_RETURN_INVALID] = "invalid `return` in a class or module body", - [PM_ERR_STATEMENT_ALIAS] = "unexpected an `alias` at a non-statement position", - [PM_ERR_STATEMENT_POSTEXE_END] = "unexpected an `END` at a non-statement position", - [PM_ERR_STATEMENT_PREEXE_BEGIN] = "unexpected a `BEGIN` at a non-statement position", - [PM_ERR_STATEMENT_UNDEF] = "unexpected an `undef` at a non-statement position", - [PM_ERR_STRING_CONCATENATION] = "expected a string for concatenation", - [PM_ERR_STRING_INTERPOLATED_TERM] = "expected a closing delimiter for the interpolated string", - [PM_ERR_STRING_LITERAL_TERM] = "expected a closing delimiter for the string literal", - [PM_ERR_SYMBOL_INVALID] = "invalid symbol", // TODO expected symbol? prism.c ~9719 - [PM_ERR_SYMBOL_TERM_DYNAMIC] = "expected a closing delimiter for the dynamic symbol", - [PM_ERR_SYMBOL_TERM_INTERPOLATED] = "expected a closing delimiter for the interpolated symbol", - [PM_ERR_TERNARY_COLON] = "expected a `:` after the true expression of a ternary operator", - [PM_ERR_TERNARY_EXPRESSION_FALSE] = "expected an expression after `:` in the ternary operator", - [PM_ERR_TERNARY_EXPRESSION_TRUE] = "expected an expression after `?` in the ternary operator", - [PM_ERR_UNDEF_ARGUMENT] = "invalid argument being passed to `undef`; expected a bare word, constant, or symbol argument", - [PM_ERR_UNARY_RECEIVER_BANG] = "expected a receiver for unary `!`", - [PM_ERR_UNARY_RECEIVER_MINUS] = "expected a receiver for unary `-`", - [PM_ERR_UNARY_RECEIVER_PLUS] = "expected a receiver for unary `+`", - [PM_ERR_UNARY_RECEIVER_TILDE] = "expected a receiver for unary `~`", - [PM_ERR_UNTIL_TERM] = "expected an `end` to close the `until` statement", - [PM_ERR_VOID_EXPRESSION] = "unexpected void value expression", - [PM_ERR_WHILE_TERM] = "expected an `end` to close the `while` statement", - [PM_ERR_WRITE_TARGET_READONLY] = "immutable variable as a write target", - [PM_ERR_WRITE_TARGET_UNEXPECTED] = "unexpected write target", - [PM_ERR_XSTRING_TERM] = "expected a closing delimiter for the `%x` or backtick string", - [PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_MINUS] = "ambiguous first argument; put parentheses or a space even after `-` operator", - [PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_PLUS] = "ambiguous first argument; put parentheses or a space even after `+` operator", - [PM_WARN_AMBIGUOUS_PREFIX_STAR] = "ambiguous `*` has been interpreted as an argument prefix", - [PM_WARN_AMBIGUOUS_SLASH] = "ambiguous `/`; wrap regexp in parentheses or add a space after `/` operator", + [PM_ERR_PARAMETER_ORDER] = "Unexpected parameter order", + [PM_ERR_PARAMETER_SPLAT_MULTI] = "Unexpected multiple `*` splat parameters", + [PM_ERR_PARAMETER_STAR] = "Unexpected parameter `*`", + [PM_ERR_PARAMETER_UNEXPECTED_FWD] = "Unexpected `...` in parameters", + [PM_ERR_PARAMETER_WILD_LOOSE_COMMA] = "Unexpected `,` in parameters", + [PM_ERR_PATTERN_EXPRESSION_AFTER_BRACKET] = "Expected a pattern expression after the `[` operator", + [PM_ERR_PATTERN_EXPRESSION_AFTER_COMMA] = "Expected a pattern expression after `,`", + [PM_ERR_PATTERN_EXPRESSION_AFTER_HROCKET] = "Expected a pattern expression after `=>`", + [PM_ERR_PATTERN_EXPRESSION_AFTER_IN] = "Expected a pattern expression after the `in` keyword", + [PM_ERR_PATTERN_EXPRESSION_AFTER_KEY] = "Expected a pattern expression after the key", + [PM_ERR_PATTERN_EXPRESSION_AFTER_PAREN] = "Expected a pattern expression after the `(` operator", + [PM_ERR_PATTERN_EXPRESSION_AFTER_PIN] = "Expected a pattern expression after the `^` pin operator", + [PM_ERR_PATTERN_EXPRESSION_AFTER_PIPE] = "Expected a pattern expression after the `|` operator", + [PM_ERR_PATTERN_EXPRESSION_AFTER_RANGE] = "Expected a pattern expression after the range operator", + [PM_ERR_PATTERN_HASH_KEY] = "Expected a key in the hash pattern", + [PM_ERR_PATTERN_HASH_KEY_LABEL] = "Expected a label as the key in the hash pattern", // TODO // THIS // AND // ABOVE // IS WEIRD + [PM_ERR_PATTERN_IDENT_AFTER_HROCKET] = "Expected an identifier after the `=>` operator", + [PM_ERR_PATTERN_LABEL_AFTER_COMMA] = "Expected a label after the `,` in the hash pattern", + [PM_ERR_PATTERN_REST] = "Unexpected rest pattern", + [PM_ERR_PATTERN_TERM_BRACE] = "Expected a `}` to close the pattern expression", + [PM_ERR_PATTERN_TERM_BRACKET] = "Expected a `]` to close the pattern expression", + [PM_ERR_PATTERN_TERM_PAREN] = "Expected a `)` to close the pattern expression", + [PM_ERR_PIPEPIPEEQ_MULTI_ASSIGN] = "Unexpected `||=` in a multiple assignment", + [PM_ERR_REGEXP_TERM] = "Expected a closing delimiter for the regular expression", + [PM_ERR_RESCUE_EXPRESSION] = "Expected a rescued expression", + [PM_ERR_RESCUE_MODIFIER_VALUE] = "Expected a value after the `rescue` modifier", + [PM_ERR_RESCUE_TERM] = "Expected a closing delimiter for the `rescue` clause", + [PM_ERR_RESCUE_VARIABLE] = "Expected an exception variable after `=>` in a rescue statement", + [PM_ERR_RETURN_INVALID] = "Invalid `return` in a class or module body", + [PM_ERR_STRING_CONCATENATION] = "Expected a string for concatenation", + [PM_ERR_STRING_INTERPOLATED_TERM] = "Expected a closing delimiter for the interpolated string", + [PM_ERR_STRING_LITERAL_TERM] = "Expected a closing delimiter for the string literal", + [PM_ERR_SYMBOL_INVALID] = "Invalid symbol", // TODO expected symbol? prism.c ~9719 + [PM_ERR_SYMBOL_TERM_DYNAMIC] = "Expected a closing delimiter for the dynamic symbol", + [PM_ERR_SYMBOL_TERM_INTERPOLATED] = "Expected a closing delimiter for the interpolated symbol", + [PM_ERR_TERNARY_COLON] = "Expected a `:` after the true expression of a ternary operator", + [PM_ERR_TERNARY_EXPRESSION_FALSE] = "Expected an expression after `:` in the ternary operator", + [PM_ERR_TERNARY_EXPRESSION_TRUE] = "Expected an expression after `?` in the ternary operator", + [PM_ERR_UNDEF_ARGUMENT] = "Invalid argument being passed to `undef`; expected a bare word, constant, or symbol argument", + [PM_ERR_UNARY_RECEIVER_BANG] = "Expected a receiver for unary `!`", + [PM_ERR_UNARY_RECEIVER_MINUS] = "Expected a receiver for unary `-`", + [PM_ERR_UNARY_RECEIVER_PLUS] = "Expected a receiver for unary `+`", + [PM_ERR_UNARY_RECEIVER_TILDE] = "Expected a receiver for unary `~`", + [PM_ERR_UNTIL_TERM] = "Expected an `end` to close the `until` statement", + [PM_ERR_VOID_EXPRESSION] = "Unexpected void value expression", + [PM_ERR_WHILE_TERM] = "Expected an `end` to close the `while` statement", + [PM_ERR_WRITE_TARGET_READONLY] = "Immutable variable as a write target", + [PM_ERR_WRITE_TARGET_UNEXPECTED] = "Unexpected write target", + [PM_ERR_XSTRING_TERM] = "Expected a closing delimiter for the `%x` or backtick string", + [PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_MINUS] = "Ambiguous first argument; put parentheses or a space even after `-` operator", + [PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_PLUS] = "Ambiguous first argument; put parentheses or a space even after `+` operator", + [PM_WARN_AMBIGUOUS_PREFIX_STAR] = "Ambiguous `*` has been interpreted as an argument prefix", + [PM_WARN_AMBIGUOUS_SLASH] = "Ambiguous `/`; wrap regexp in parentheses or add a space after `/` operator", [PM_WARN_END_IN_METHOD] = "END in method; use at_exit", }; diff --git a/crates/prism-sys/vendor/prism-0.18.0/src/enc/pm_cp949.c b/crates/prism-sys/vendor/prism-0.18.0/src/enc/pm_cp949.c deleted file mode 100644 index f3b5a50f..00000000 --- a/crates/prism-sys/vendor/prism-0.18.0/src/enc/pm_cp949.c +++ /dev/null @@ -1,57 +0,0 @@ -#include "prism/enc/pm_encoding.h" - -static size_t -pm_encoding_cp949_char_width(const uint8_t *b, ptrdiff_t n) { - // These are the single byte characters - if (*b < 0x81) { - return 1; - } - - // These are the double byte characters - if ( - (n > 1) && - (b[0] >= 0x81 && b[0] <= 0xfe) && - (b[1] >= 0x41 && b[1] <= 0xfe) - ) { - return 2; - } - - return 0; -} - -static size_t -pm_encoding_cp949_alpha_char(const uint8_t *b, ptrdiff_t n) { - if (pm_encoding_cp949_char_width(b, n) == 1) { - return pm_encoding_ascii_alpha_char(b, n); - } else { - return 0; - } -} - -static size_t -pm_encoding_cp949_alnum_char(const uint8_t *b, ptrdiff_t n) { - if (pm_encoding_cp949_char_width(b, n) == 1) { - return pm_encoding_ascii_alnum_char(b, n); - } else { - return 0; - } -} - -static bool -pm_encoding_cp949_isupper_char(const uint8_t *b, ptrdiff_t n) { - if (pm_encoding_cp949_char_width(b, n) == 1) { - return pm_encoding_ascii_isupper_char(b, n); - } else { - return 0; - } -} - -/** cp949 encoding */ -pm_encoding_t pm_encoding_cp949 = { - .name = "cp949", - .char_width = pm_encoding_cp949_char_width, - .alnum_char = pm_encoding_cp949_alnum_char, - .alpha_char = pm_encoding_cp949_alpha_char, - .isupper_char = pm_encoding_cp949_isupper_char, - .multibyte = true -}; diff --git a/crates/prism-sys/vendor/prism-0.18.0/src/enc/pm_cp950.c b/crates/prism-sys/vendor/prism-0.18.0/src/enc/pm_cp950.c deleted file mode 100644 index 1b7a0995..00000000 --- a/crates/prism-sys/vendor/prism-0.18.0/src/enc/pm_cp950.c +++ /dev/null @@ -1,57 +0,0 @@ -#include "prism/enc/pm_encoding.h" - -static size_t -pm_encoding_cp950_char_width(const uint8_t *b, ptrdiff_t n) { - // These are the single byte characters - if (*b < 0x80) { - return 1; - } - - // These are the double byte characters - if ( - (n > 1) && - ((b[0] >= 0x81 && b[0] <= 0xFE) && - ((b[1] >= 0x40 && b[1] <= 0x7E) || (b[1] >= 0xA1 && b[1] <= 0xFE))) - ) { - return 2; - } - - return 0; -} - -static size_t -pm_encoding_cp950_alpha_char(const uint8_t *b, ptrdiff_t n) { - if (pm_encoding_cp950_char_width(b, n) == 1) { - return pm_encoding_ascii_alpha_char(b, n); - } else { - return 0; - } -} - -static size_t -pm_encoding_cp950_alnum_char(const uint8_t *b, ptrdiff_t n) { - if (pm_encoding_cp950_char_width(b, n) == 1) { - return pm_encoding_ascii_alnum_char(b, n); - } else { - return 0; - } -} - -static bool -pm_encoding_cp950_isupper_char(const uint8_t *b, ptrdiff_t n) { - if (pm_encoding_cp950_char_width(b, n) == 1) { - return pm_encoding_ascii_isupper_char(b, n); - } else { - return 0; - } -} - -/** cp950 encoding */ -pm_encoding_t pm_encoding_cp950 = { - .name = "cp950", - .char_width = pm_encoding_cp950_char_width, - .alnum_char = pm_encoding_cp950_alnum_char, - .alpha_char = pm_encoding_cp950_alpha_char, - .isupper_char = pm_encoding_cp950_isupper_char, - .multibyte = true -}; diff --git a/crates/prism-sys/vendor/prism-0.18.0/src/enc/pm_mac_japanese.c b/crates/prism-sys/vendor/prism-0.18.0/src/enc/pm_mac_japanese.c deleted file mode 100644 index a5185f0e..00000000 --- a/crates/prism-sys/vendor/prism-0.18.0/src/enc/pm_mac_japanese.c +++ /dev/null @@ -1,57 +0,0 @@ -#include "prism/enc/pm_encoding.h" - -static size_t -pm_encoding_mac_japanese_char_width(const uint8_t *b, ptrdiff_t n) { - // These are the single byte characters. - if (*b < 0x80 || (*b >= 0xA1 && *b <= 0xDF)) { - return 1; - } - - // These are the double byte characters. - if ( - (n > 1) && - ((b[0] >= 0x81 && b[0] <= 0x9F) || (b[0] >= 0xE0 && b[0] <= 0xFC)) && - (b[1] >= 0x40 && b[1] <= 0xFC) - ) { - return 2; - } - - return 0; -} - -static size_t -pm_encoding_mac_japanese_alpha_char(const uint8_t *b, ptrdiff_t n) { - if (pm_encoding_mac_japanese_char_width(b, n) == 1) { - return pm_encoding_ascii_alpha_char(b, n); - } else { - return 0; - } -} - -static size_t -pm_encoding_mac_japanese_alnum_char(const uint8_t *b, ptrdiff_t n) { - if (pm_encoding_mac_japanese_char_width(b, n) == 1) { - return pm_encoding_ascii_alnum_char(b, n); - } else { - return 0; - } -} - -static bool -pm_encoding_mac_japanese_isupper_char(const uint8_t *b, ptrdiff_t n) { - if (pm_encoding_mac_japanese_char_width(b, n) == 1) { - return pm_encoding_ascii_isupper_char(b, n); - } else { - return 0; - } -} - -/** MacJapanese encoding */ -pm_encoding_t pm_encoding_mac_japanese = { - .name = "MacJapanese", - .char_width = pm_encoding_mac_japanese_char_width, - .alnum_char = pm_encoding_mac_japanese_alnum_char, - .alpha_char = pm_encoding_mac_japanese_alpha_char, - .isupper_char = pm_encoding_mac_japanese_isupper_char, - .multibyte = true -}; diff --git a/crates/prism-sys/vendor/prism-0.18.0/src/enc/pm_tables.c b/crates/prism-sys/vendor/prism-0.18.0/src/enc/pm_tables.c index 6eede35e..6a163315 100644 --- a/crates/prism-sys/vendor/prism-0.18.0/src/enc/pm_tables.c +++ b/crates/prism-sys/vendor/prism-0.18.0/src/enc/pm_tables.c @@ -864,30 +864,6 @@ static uint8_t pm_encoding_koi8_r_table[256] = { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Fx }; -/** - * Each element of the following table contains a bitfield that indicates a - * piece of information about the corresponding KOI8-U character. - */ -static uint8_t pm_encoding_koi8_u_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x - 0, 0, 0, 3, 3, 0, 3, 3, 0, 0, 0, 0, 0, 3, 0, 0, // Ax - 0, 0, 0, 7, 7, 0, 7, 7, 0, 0, 0, 0, 0, 7, 0, 0, // Bx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Cx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Dx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Ex - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Fx -}; - /** * Each element of the following table contains a bitfield that indicates a * piece of information about the corresponding macCentEuro character. @@ -1442,7 +1418,7 @@ pm_encoding_single_char_width(PRISM_ATTRIBUTE_UNUSED const uint8_t *b, PRISM_ATT * checking if it's a valid codepoint in KOI-8 and if it is returning 1. */ static size_t -pm_encoding_koi8_char_width(const uint8_t *b, PRISM_ATTRIBUTE_UNUSED ptrdiff_t n) { +pm_encoding_koi8_r_char_width(const uint8_t *b, PRISM_ATTRIBUTE_UNUSED ptrdiff_t n) { return ((*b >= 0x20 && *b <= 0x7E) || (*b >= 0x80)) ? 1 : 0; } @@ -1492,7 +1468,6 @@ PRISM_ENCODING_TABLE(iso_8859_14) PRISM_ENCODING_TABLE(iso_8859_15) PRISM_ENCODING_TABLE(iso_8859_16) PRISM_ENCODING_TABLE(koi8_r) -PRISM_ENCODING_TABLE(koi8_u) PRISM_ENCODING_TABLE(mac_cent_euro) PRISM_ENCODING_TABLE(mac_croatian) PRISM_ENCODING_TABLE(mac_cyrillic) @@ -1880,23 +1855,13 @@ pm_encoding_t pm_encoding_iso_8859_16 = { /** KOI8-R */ pm_encoding_t pm_encoding_koi8_r = { .name = "KOI8-R", - .char_width = pm_encoding_koi8_char_width, + .char_width = pm_encoding_koi8_r_char_width, .alnum_char = pm_encoding_koi8_r_alnum_char, .alpha_char = pm_encoding_koi8_r_alpha_char, .isupper_char = pm_encoding_koi8_r_isupper_char, .multibyte = false }; -/** KOI8-U */ -pm_encoding_t pm_encoding_koi8_u = { - .name = "KOI8-U", - .char_width = pm_encoding_koi8_char_width, - .alnum_char = pm_encoding_koi8_u_alnum_char, - .alpha_char = pm_encoding_koi8_u_alpha_char, - .isupper_char = pm_encoding_koi8_u_isupper_char, - .multibyte = false -}; - /** macCentEuro */ pm_encoding_t pm_encoding_mac_cent_euro = { .name = "macCentEuro", diff --git a/crates/prism-sys/vendor/prism-0.18.0/src/node.c b/crates/prism-sys/vendor/prism-0.18.0/src/node.c index 7e26a7c6..e03ee41e 100644 --- a/crates/prism-sys/vendor/prism-0.18.0/src/node.c +++ b/crates/prism-sys/vendor/prism-0.18.0/src/node.c @@ -572,10 +572,6 @@ pm_node_destroy(pm_parser_t *parser, pm_node_t *node) { pm_node_destroy(parser, (pm_node_t *)cast->value); break; } -#line 58 "node.c.erb" - case PM_IMPLICIT_REST_NODE: { - break; - } #line 58 "node.c.erb" case PM_IN_NODE: { pm_in_node_t *cast = (pm_in_node_t *) node; @@ -1747,12 +1743,6 @@ pm_node_memsize_node(pm_node_t *node, pm_memsize_t *memsize) { pm_node_memsize_node((pm_node_t *)cast->value, memsize); break; } -#line 103 "node.c.erb" - case PM_IMPLICIT_REST_NODE: { - pm_implicit_rest_node_t *cast = (pm_implicit_rest_node_t *) node; - memsize->memsize += sizeof(*cast); - break; - } #line 103 "node.c.erb" case PM_IN_NODE: { pm_in_node_t *cast = (pm_in_node_t *) node; @@ -2577,8 +2567,6 @@ pm_node_type_to_str(pm_node_type_t node_type) return "PM_IMAGINARY_NODE"; case PM_IMPLICIT_NODE: return "PM_IMPLICIT_NODE"; - case PM_IMPLICIT_REST_NODE: - return "PM_IMPLICIT_REST_NODE"; case PM_IN_NODE: return "PM_IN_NODE"; case PM_INDEX_AND_WRITE_NODE: diff --git a/crates/prism-sys/vendor/prism-0.18.0/src/options.c b/crates/prism-sys/vendor/prism-0.18.0/src/options.c index 85d04d62..84c1fcbb 100644 --- a/crates/prism-sys/vendor/prism-0.18.0/src/options.c +++ b/crates/prism-sys/vendor/prism-0.18.0/src/options.c @@ -20,7 +20,7 @@ pm_options_encoding_set(pm_options_t *options, const char *encoding) { * Set the line option on the given options struct. */ PRISM_EXPORTED_FUNCTION void -pm_options_line_set(pm_options_t *options, int32_t line) { +pm_options_line_set(pm_options_t *options, uint32_t line) { options->line = line; } @@ -114,22 +114,6 @@ pm_options_read_u32(const char *data) { } } -/** - * Read a 32-bit signed integer from a pointer. This function is used to read - * the options that are passed into the parser from the Ruby implementation. It - * handles aligned and unaligned reads. - */ -static int32_t -pm_options_read_s32(const char *data) { - if (((uintptr_t) data) % sizeof(int32_t) == 0) { - return *((int32_t *) data); - } else { - int32_t value; - memcpy(&value, data, sizeof(int32_t)); - return value; - } -} - /** * Deserialize an options struct from the given binary string. This is used to * pass options to the parser from an FFI call so that consumers of the library @@ -139,9 +123,6 @@ pm_options_read_s32(const char *data) { */ void pm_options_read(pm_options_t *options, const char *data) { - options->line = 1; // default - if (data == NULL) return; - uint32_t filepath_length = pm_options_read_u32(data); data += 4; @@ -150,7 +131,7 @@ pm_options_read(pm_options_t *options, const char *data) { data += filepath_length; } - options->line = pm_options_read_s32(data); + options->line = pm_options_read_u32(data); data += 4; uint32_t encoding_length = pm_options_read_u32(data); diff --git a/crates/prism-sys/vendor/prism-0.18.0/src/prettyprint.c b/crates/prism-sys/vendor/prism-0.18.0/src/prettyprint.c index 5c487bc6..61896195 100644 --- a/crates/prism-sys/vendor/prism-0.18.0/src/prettyprint.c +++ b/crates/prism-sys/vendor/prism-0.18.0/src/prettyprint.c @@ -281,9 +281,9 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm pm_buffer_concat(output_buffer, prefix_buffer); pm_buffer_append_string(output_buffer, "\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 flags:", 16); bool found = false; - if (cast->base.flags & PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORD_SPLAT) { + if (cast->base.flags & PM_ARGUMENTS_NODE_FLAGS_KEYWORD_SPLAT) { if (found) pm_buffer_append_byte(output_buffer, ','); - pm_buffer_append_string(output_buffer, " contains_keyword_splat", 23); + pm_buffer_append_string(output_buffer, " keyword_splat", 14); found = true; } if (!found) pm_buffer_append_string(output_buffer, " \xe2\x88\x85", 4); @@ -342,7 +342,7 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm // closing_loc { pm_buffer_concat(output_buffer, prefix_buffer); - pm_buffer_append_string(output_buffer, "\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 closing_loc:", 22); + pm_buffer_append_string(output_buffer, "\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 closing_loc:", 22); pm_location_t *location = &cast->closing_loc; if (location->start == NULL) { pm_buffer_append_string(output_buffer, " \xe2\x88\x85\n", 5); @@ -355,20 +355,6 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm } } - // flags - { - pm_buffer_concat(output_buffer, prefix_buffer); - pm_buffer_append_string(output_buffer, "\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 flags:", 16); - bool found = false; - if (cast->base.flags & PM_ARRAY_NODE_FLAGS_CONTAINS_SPLAT) { - if (found) pm_buffer_append_byte(output_buffer, ','); - pm_buffer_append_string(output_buffer, " contains_splat", 15); - found = true; - } - if (!found) pm_buffer_append_string(output_buffer, " \xe2\x88\x85", 4); - pm_buffer_append_byte(output_buffer, '\n'); - } - break; } case PM_ARRAY_PATTERN_NODE: { @@ -832,7 +818,7 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm // closing_loc { pm_buffer_concat(output_buffer, prefix_buffer); - pm_buffer_append_string(output_buffer, "\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 closing_loc:", 22); + pm_buffer_append_string(output_buffer, "\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 closing_loc:", 22); pm_location_t *location = &cast->closing_loc; pm_buffer_append_byte(output_buffer, ' '); prettyprint_location(output_buffer, parser, location); @@ -841,13 +827,6 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm pm_buffer_append_string(output_buffer, "\"\n", 2); } - // numbered_parameters - { - pm_buffer_concat(output_buffer, prefix_buffer); - pm_buffer_append_string(output_buffer, "\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 numbered_parameters:", 30); - pm_buffer_append_format(output_buffer, " %d\n", cast->numbered_parameters); - } - break; } case PM_BLOCK_PARAMETER_NODE: { @@ -1176,15 +1155,6 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm } } - // name - { - pm_buffer_concat(output_buffer, prefix_buffer); - pm_buffer_append_string(output_buffer, "\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 name:", 15); - pm_buffer_append_byte(output_buffer, ' '); - prettyprint_constant(output_buffer, parser, cast->name); - pm_buffer_append_byte(output_buffer, '\n'); - } - // message_loc { pm_buffer_concat(output_buffer, prefix_buffer); @@ -1270,7 +1240,7 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm // flags { pm_buffer_concat(output_buffer, prefix_buffer); - pm_buffer_append_string(output_buffer, "\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 flags:", 16); + pm_buffer_append_string(output_buffer, "\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 flags:", 16); bool found = false; if (cast->base.flags & PM_CALL_NODE_FLAGS_SAFE_NAVIGATION) { if (found) pm_buffer_append_byte(output_buffer, ','); @@ -1286,6 +1256,15 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm pm_buffer_append_byte(output_buffer, '\n'); } + // name + { + pm_buffer_concat(output_buffer, prefix_buffer); + pm_buffer_append_string(output_buffer, "\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 name:", 15); + pm_buffer_append_byte(output_buffer, ' '); + prettyprint_constant(output_buffer, parser, cast->name); + pm_buffer_append_byte(output_buffer, '\n'); + } + break; } case PM_CALL_OPERATOR_WRITE_NODE: { @@ -4019,13 +3998,6 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm break; } - case PM_IMPLICIT_REST_NODE: { - pm_buffer_append_string(output_buffer, "@ ImplicitRestNode (location: ", 30); - prettyprint_location(output_buffer, parser, &node->location); - pm_buffer_append_string(output_buffer, ")\n", 2); - - break; - } case PM_IN_NODE: { pm_in_node_t *cast = (pm_in_node_t *) node; pm_buffer_append_string(output_buffer, "@ InNode (location: ", 20); @@ -5381,27 +5353,20 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm // body { pm_buffer_concat(output_buffer, prefix_buffer); - pm_buffer_append_string(output_buffer, "\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 body:", 15); + pm_buffer_append_string(output_buffer, "\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 body:", 15); if (cast->body == NULL) { pm_buffer_append_string(output_buffer, " \xe2\x88\x85\n", 5); } else { pm_buffer_append_byte(output_buffer, '\n'); size_t prefix_length = prefix_buffer->length; - pm_buffer_append_string(prefix_buffer, "\xe2\x94\x82 ", 6); + pm_buffer_append_string(prefix_buffer, " ", 4); pm_buffer_concat(output_buffer, prefix_buffer); prettyprint_node(output_buffer, parser, (pm_node_t *) cast->body, prefix_buffer); prefix_buffer->length = prefix_length; } } - // numbered_parameters - { - pm_buffer_concat(output_buffer, prefix_buffer); - pm_buffer_append_string(output_buffer, "\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 numbered_parameters:", 30); - pm_buffer_append_format(output_buffer, " %d\n", cast->numbered_parameters); - } - break; } case PM_LOCAL_VARIABLE_AND_WRITE_NODE: { diff --git a/crates/prism-sys/vendor/prism-0.18.0/src/prism.c b/crates/prism-sys/vendor/prism-0.18.0/src/prism.c index 1e02752e..b6be2983 100644 --- a/crates/prism-sys/vendor/prism-0.18.0/src/prism.c +++ b/crates/prism-sys/vendor/prism-0.18.0/src/prism.c @@ -1151,10 +1151,6 @@ pm_array_node_elements_append(pm_array_node_t *node, pm_node_t *element) { if (PM_NODE_TYPE_P(element, PM_ARRAY_NODE) || PM_NODE_TYPE_P(element, PM_HASH_NODE) || PM_NODE_TYPE_P(element, PM_RANGE_NODE) || (element->flags & PM_NODE_FLAG_STATIC_LITERAL) == 0) { node->base.flags &= (pm_node_flags_t) ~PM_NODE_FLAG_STATIC_LITERAL; } - - if (PM_NODE_TYPE_P(element, PM_SPLAT_NODE)) { - node->base.flags |= PM_ARRAY_NODE_FLAGS_CONTAINS_SPLAT; - } } /** @@ -1197,7 +1193,7 @@ pm_array_pattern_node_node_list_create(pm_parser_t *parser, pm_node_list_t *node for (size_t index = 0; index < nodes->size; index++) { pm_node_t *child = nodes->nodes[index]; - if (!found_rest && (PM_NODE_TYPE_P(child, PM_SPLAT_NODE) || PM_NODE_TYPE_P(child, PM_IMPLICIT_REST_NODE))) { + if (!found_rest && PM_NODE_TYPE_P(child, PM_SPLAT_NODE)) { node->rest = child; found_rest = true; } else if (found_rest) { @@ -1465,7 +1461,7 @@ pm_block_argument_node_create(pm_parser_t *parser, const pm_token_t *operator, p * Allocate and initialize a new BlockNode node. */ static pm_block_node_t * -pm_block_node_create(pm_parser_t *parser, pm_constant_id_list_t *locals, const pm_token_t *opening, pm_block_parameters_node_t *parameters, pm_node_t *body, const pm_token_t *closing, uint32_t numbered_parameters) { +pm_block_node_create(pm_parser_t *parser, pm_constant_id_list_t *locals, const pm_token_t *opening, pm_block_parameters_node_t *parameters, pm_node_t *body, const pm_token_t *closing) { pm_block_node_t *node = PM_ALLOC_NODE(parser, pm_block_node_t); *node = (pm_block_node_t) { @@ -1476,7 +1472,6 @@ pm_block_node_create(pm_parser_t *parser, pm_constant_id_list_t *locals, const p .locals = *locals, .parameters = parameters, .body = body, - .numbered_parameters = numbered_parameters, .opening_loc = PM_LOCATION_TOKEN_VALUE(opening), .closing_loc = PM_LOCATION_TOKEN_VALUE(closing) }; @@ -1841,8 +1836,8 @@ pm_call_node_variable_call_p(pm_call_node_t *node) { } /** - * Returns whether or not this call is to the [] method in the index form without a block (as - * opposed to `foo.[]` and `foo[] { }`). + * Returns whether or not this call is to the [] method in the index form (as + * opposed to `foo.[]`). */ static inline bool pm_call_node_index_p(pm_call_node_t *node) { @@ -1850,8 +1845,7 @@ pm_call_node_index_p(pm_call_node_t *node) { (node->call_operator_loc.start == NULL) && (node->message_loc.start != NULL) && (node->message_loc.start[0] == '[') && - (node->message_loc.end[-1] == ']') && - (node->block == NULL || PM_NODE_TYPE_P(node->block, PM_BLOCK_ARGUMENT_NODE)) + (node->message_loc.end[-1] == ']') ); } @@ -2458,8 +2452,6 @@ pm_constant_path_or_write_node_create(pm_parser_t *parser, pm_constant_path_node */ static pm_constant_path_node_t * pm_constant_path_node_create(pm_parser_t *parser, pm_node_t *parent, const pm_token_t *delimiter, pm_node_t *child) { - pm_assert_value_expression(parser, parent); - pm_constant_path_node_t *node = PM_ALLOC_NODE(parser, pm_constant_path_node_t); *node = (pm_constant_path_node_t) { @@ -3424,25 +3416,6 @@ pm_implicit_node_create(pm_parser_t *parser, pm_node_t *value) { return node; } -/** - * Allocate and initialize a new ImplicitRestNode node. - */ -static pm_implicit_rest_node_t * -pm_implicit_rest_node_create(pm_parser_t *parser, const pm_token_t *token) { - assert(token->type == PM_TOKEN_COMMA); - - pm_implicit_rest_node_t *node = PM_ALLOC_NODE(parser, pm_implicit_rest_node_t); - - *node = (pm_implicit_rest_node_t) { - { - .type = PM_IMPLICIT_REST_NODE, - .location = PM_LOCATION_TOKEN_VALUE(token) - } - }; - - return node; -} - /** * Allocate and initialize a new IntegerNode node. */ @@ -3957,8 +3930,7 @@ pm_lambda_node_create( const pm_token_t *opening, const pm_token_t *closing, pm_block_parameters_node_t *parameters, - pm_node_t *body, - uint32_t numbered_parameters + pm_node_t *body ) { pm_lambda_node_t *node = PM_ALLOC_NODE(parser, pm_lambda_node_t); @@ -3975,8 +3947,7 @@ pm_lambda_node_create( .opening_loc = PM_LOCATION_TOKEN_VALUE(opening), .closing_loc = PM_LOCATION_TOKEN_VALUE(closing), .parameters = parameters, - .body = body, - .numbered_parameters = numbered_parameters + .body = body }; return node; @@ -4067,12 +4038,6 @@ pm_local_variable_or_write_node_create(pm_parser_t *parser, pm_node_t *target, c */ static pm_local_variable_read_node_t * pm_local_variable_read_node_create(pm_parser_t *parser, const pm_token_t *name, uint32_t depth) { - pm_constant_id_t name_id = pm_parser_constant_id_token(parser, name); - - if (parser->current_param_name == name_id) { - pm_parser_err_token(parser, name, PM_ERR_PARAMETER_CIRCULAR); - } - pm_local_variable_read_node_t *node = PM_ALLOC_NODE(parser, pm_local_variable_read_node_t); *node = (pm_local_variable_read_node_t) { @@ -4080,7 +4045,7 @@ pm_local_variable_read_node_create(pm_parser_t *parser, const pm_token_t *name, .type = PM_LOCAL_VARIABLE_READ_NODE, .location = PM_LOCATION_TOKEN_VALUE(name) }, - .name = name_id, + .name = pm_parser_constant_id_token(parser, name), .depth = depth }; @@ -4167,21 +4132,6 @@ pm_local_variable_target_node_create(pm_parser_t *parser, const pm_token_t *name ); } -/** - * Allocate and initialize a new LocalVariableTargetNode node with the given depth. - */ -static pm_local_variable_target_node_t * -pm_local_variable_target_node_create_depth(pm_parser_t *parser, const pm_token_t *name, uint32_t depth) { - pm_refute_numbered_parameter(parser, name->start, name->end); - - return pm_local_variable_target_node_create_values( - parser, - &(pm_location_t) { .start = name->start, .end = name->end }, - pm_parser_constant_id_token(parser, name), - depth - ); -} - /** * Allocate and initialize a new MatchPredicateNode node. */ @@ -4304,7 +4254,7 @@ pm_multi_target_node_create(pm_parser_t *parser) { */ static void pm_multi_target_node_targets_append(pm_parser_t *parser, pm_multi_target_node_t *node, pm_node_t *target) { - if (PM_NODE_TYPE_P(target, PM_SPLAT_NODE) || PM_NODE_TYPE_P(target, PM_IMPLICIT_REST_NODE)) { + if (PM_NODE_TYPE_P(target, PM_SPLAT_NODE)) { if (node->rest == NULL) { node->rest = target; } else { @@ -4580,8 +4530,9 @@ pm_parameters_node_posts_append(pm_parameters_node_t *params, pm_node_t *param) * Set the rest parameter on a ParametersNode node. */ static void -pm_parameters_node_rest_set(pm_parameters_node_t *params, pm_node_t *param) { - pm_parameters_node_location_set(params, param); +pm_parameters_node_rest_set(pm_parameters_node_t *params, pm_rest_parameter_node_t *param) { + assert(params->rest == NULL); + pm_parameters_node_location_set(params, (pm_node_t *) param); params->rest = param; } @@ -5767,7 +5718,7 @@ pm_parser_scope_push(pm_parser_t *parser, bool closed) { .previous = parser->current_scope, .closed = closed, .explicit_params = false, - .numbered_parameters = 0, + .numbered_params = false, .transparent = false }; @@ -5789,7 +5740,7 @@ pm_parser_scope_push_transparent(pm_parser_t *parser) { .previous = parser->current_scope, .closed = false, .explicit_params = false, - .numbered_parameters = 0, + .numbered_params = false, .transparent = true }; @@ -5842,18 +5793,6 @@ pm_parser_local_add(pm_parser_t *parser, pm_constant_id_t constant_id) { } } -/** - * Set the numbered_parameters value of the current scope. - */ -static inline void -pm_parser_numbered_parameters_set(pm_parser_t *parser, uint32_t numbered_parameters) { - pm_scope_t *scope = parser->current_scope; - while (scope && scope->transparent) scope = scope->previous; - - assert(scope != NULL); - scope->numbered_parameters = numbered_parameters; -} - /** * Add a local variable from a location to the current scope. */ @@ -5946,19 +5885,6 @@ char_is_identifier_start(pm_parser_t *parser, const uint8_t *b) { } } -/** - * Similar to char_is_identifier but this function assumes that the encoding - * has not been changed. - */ -static inline size_t -char_is_identifier_utf8(const uint8_t *b, const uint8_t *end) { - if (*b < 0x80) { - return (*b == '_') || (pm_encoding_unicode_table[*b] & PRISM_ENCODING_ALPHANUMERIC_BIT ? 1 : 0); - } else { - return (size_t) (pm_encoding_utf_8_alnum_char(b, end - b) || 1u); - } -} - /** * Like the above, this function is also used extremely frequently to lex all of * the identifiers in a source file once the first character has been found. So @@ -5977,8 +5903,11 @@ char_is_identifier(pm_parser_t *parser, const uint8_t *b) { } else { return 0; } + } else if (*b < 0x80) { + return (pm_encoding_unicode_table[*b] & PRISM_ENCODING_ALPHANUMERIC_BIT ? 1 : 0) || (*b == '_'); + } else { + return (size_t) (pm_encoding_utf_8_alnum_char(b, parser->end - b) || 1u); } - return char_is_identifier_utf8(b, parser->end); } // Here we're defining a perfect hash for the characters that are allowed in @@ -6232,8 +6161,6 @@ parser_lex_magic_comment_encoding_value(pm_parser_t *parser, const uint8_t *star ENCODING1("CP863", pm_encoding_ibm863); ENCODING2("CP932", "csWindows31J", pm_encoding_windows_31j); ENCODING1("CP936", pm_encoding_gbk); - ENCODING1("CP949", pm_encoding_cp949); - ENCODING1("CP950", pm_encoding_cp950); ENCODING1("CP1250", pm_encoding_windows_1250); ENCODING1("CP1251", pm_encoding_windows_1251); ENCODING1("CP1252", pm_encoding_windows_1252); @@ -6292,7 +6219,6 @@ parser_lex_magic_comment_encoding_value(pm_parser_t *parser, const uint8_t *star break; case 'K': case 'k': ENCODING1("KOI8-R", pm_encoding_koi8_r); - ENCODING1("KOI8-U", pm_encoding_koi8_u); break; case 'L': case 'l': ENCODING1("locale", pm_encoding_utf_8); @@ -6303,8 +6229,6 @@ parser_lex_magic_comment_encoding_value(pm_parser_t *parser, const uint8_t *star ENCODING1("macCyrillic", pm_encoding_mac_cyrillic); ENCODING1("macGreek", pm_encoding_mac_greek); ENCODING1("macIceland", pm_encoding_mac_iceland); - ENCODING1("MacJapanese", pm_encoding_mac_japanese); - ENCODING1("MacJapan", pm_encoding_mac_japanese); ENCODING1("macRoman", pm_encoding_mac_roman); ENCODING1("macRomania", pm_encoding_mac_romania); ENCODING1("macThai", pm_encoding_mac_thai); @@ -6606,7 +6530,6 @@ context_terminator(pm_context_t context, pm_token_t *token) { case PM_CONTEXT_ELSE: case PM_CONTEXT_FOR: case PM_CONTEXT_ENSURE: - case PM_CONTEXT_ENSURE_DEF: return token->type == PM_TOKEN_KEYWORD_END; case PM_CONTEXT_FOR_INDEX: return token->type == PM_TOKEN_KEYWORD_IN; @@ -6627,10 +6550,8 @@ context_terminator(pm_context_t context, pm_token_t *token) { return token->type == PM_TOKEN_PARENTHESIS_RIGHT; case PM_CONTEXT_BEGIN: case PM_CONTEXT_RESCUE: - case PM_CONTEXT_RESCUE_DEF: return token->type == PM_TOKEN_KEYWORD_ENSURE || token->type == PM_TOKEN_KEYWORD_RESCUE || token->type == PM_TOKEN_KEYWORD_ELSE || token->type == PM_TOKEN_KEYWORD_END; case PM_CONTEXT_RESCUE_ELSE: - case PM_CONTEXT_RESCUE_ELSE_DEF: return token->type == PM_TOKEN_KEYWORD_ENSURE || token->type == PM_TOKEN_KEYWORD_END; case PM_CONTEXT_LAMBDA_BRACES: return token->type == PM_TOKEN_BRACE_RIGHT; @@ -6696,10 +6617,6 @@ context_def_p(pm_parser_t *parser) { while (context_node != NULL) { switch (context_node->context) { case PM_CONTEXT_DEF: - case PM_CONTEXT_DEF_PARAMS: - case PM_CONTEXT_ENSURE_DEF: - case PM_CONTEXT_RESCUE_DEF: - case PM_CONTEXT_RESCUE_ELSE_DEF: return true; case PM_CONTEXT_CLASS: case PM_CONTEXT_MODULE: @@ -7062,16 +6979,9 @@ lex_identifier(pm_parser_t *parser, bool previous_command_start) { const uint8_t *end = parser->end; const uint8_t *current_start = parser->current.start; const uint8_t *current_end = parser->current.end; - bool encoding_changed = parser->encoding_changed; - if (encoding_changed) { - while (current_end < end && (width = char_is_identifier(parser, current_end)) > 0) { - current_end += width; - } - } else { - while (current_end < end && (width = char_is_identifier_utf8(current_end, end)) > 0) { - current_end += width; - } + while (current_end < end && (width = char_is_identifier(parser, current_end)) > 0) { + current_end += width; } parser->current.end = current_end; @@ -7189,7 +7099,7 @@ lex_identifier(pm_parser_t *parser, bool previous_command_start) { } } - if (encoding_changed) { + if (parser->encoding_changed) { return parser->encoding.isupper_char(current_start, end - current_start) ? PM_TOKEN_CONSTANT : PM_TOKEN_IDENTIFIER; } return pm_encoding_utf_8_isupper_char(current_start, end - current_start) ? PM_TOKEN_CONSTANT : PM_TOKEN_IDENTIFIER; @@ -9297,8 +9207,8 @@ parser_lex(pm_parser_t *parser) { parser->current.type = PM_TOKEN___END__; parser_lex_callback(parser); - parser->data_loc.start = parser->current.start; - parser->data_loc.end = parser->current.end; + pm_comment_t *comment = parser_comment(parser, PM_COMMENT___END__); + pm_list_append(&parser->comment_list, (pm_list_node_t *) comment); LEX(PM_TOKEN_EOF); } @@ -10286,8 +10196,6 @@ pm_binding_powers_t pm_binding_powers[PM_TOKEN_MAXIMUM] = { // .. ... [PM_TOKEN_DOT_DOT] = NON_ASSOCIATIVE(PM_BINDING_POWER_RANGE), [PM_TOKEN_DOT_DOT_DOT] = NON_ASSOCIATIVE(PM_BINDING_POWER_RANGE), - [PM_TOKEN_UDOT_DOT] = RIGHT_ASSOCIATIVE_UNARY(PM_BINDING_POWER_LOGICAL_OR), - [PM_TOKEN_UDOT_DOT_DOT] = RIGHT_ASSOCIATIVE_UNARY(PM_BINDING_POWER_LOGICAL_OR), // || [PM_TOKEN_PIPE_PIPE] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_LOGICAL_OR), @@ -10381,14 +10289,6 @@ match3(const pm_parser_t *parser, pm_token_type_t type1, pm_token_type_t type2, return match1(parser, type1) || match1(parser, type2) || match1(parser, type3); } -/** - * Returns true if the current token is any of the four given types. - */ -static inline bool -match4(const pm_parser_t *parser, pm_token_type_t type1, pm_token_type_t type2, pm_token_type_t type3, pm_token_type_t type4) { - return match1(parser, type1) || match1(parser, type2) || match1(parser, type3) || match1(parser, type4); -} - /** * Returns true if the current token is any of the five given types. */ @@ -10904,7 +10804,13 @@ parse_write(pm_parser_t *parser, pm_node_t *target, pm_token_t *operator, pm_nod // If there is no call operator and the message is "[]" then this is // an aref expression, and we can transform it into an aset // expression. - if (pm_call_node_index_p(call)) { + if ( + (call->call_operator_loc.start == NULL) && + (call->message_loc.start != NULL) && + (call->message_loc.start[0] == '[') && + (call->message_loc.end[-1] == ']') && + (call->block == NULL) + ) { if (call->arguments == NULL) { call->arguments = pm_arguments_node_create(parser); } @@ -10946,7 +10852,7 @@ parse_write(pm_parser_t *parser, pm_node_t *target, pm_token_t *operator, pm_nod */ static pm_node_t * parse_targets(pm_parser_t *parser, pm_node_t *first_target, pm_binding_power_t binding_power) { - bool has_rest = PM_NODE_TYPE_P(first_target, PM_SPLAT_NODE); + bool has_splat = PM_NODE_TYPE_P(first_target, PM_SPLAT_NODE); pm_multi_target_node_t *result = pm_multi_target_node_create(parser); pm_multi_target_node_targets_append(parser, result, parse_target(parser, first_target)); @@ -10956,7 +10862,7 @@ parse_targets(pm_parser_t *parser, pm_node_t *first_target, pm_binding_power_t b // Here we have a splat operator. It can have a name or be // anonymous. It can be the final target or be in the middle if // there haven't been any others yet. - if (has_rest) { + if (has_splat) { pm_parser_err_previous(parser, PM_ERR_MULTI_ASSIGN_MULTI_SPLATS); } @@ -10970,7 +10876,7 @@ parse_targets(pm_parser_t *parser, pm_node_t *first_target, pm_binding_power_t b pm_node_t *splat = (pm_node_t *) pm_splat_node_create(parser, &star_operator, name); pm_multi_target_node_targets_append(parser, result, splat); - has_rest = true; + has_splat = true; } else if (token_begins_expression_p(parser->current.type)) { pm_node_t *target = parse_expression(parser, binding_power, PM_ERR_EXPECT_EXPRESSION_AFTER_COMMA); target = parse_target(parser, target); @@ -10978,10 +10884,10 @@ parse_targets(pm_parser_t *parser, pm_node_t *first_target, pm_binding_power_t b pm_multi_target_node_targets_append(parser, result, target); } else if (!match1(parser, PM_TOKEN_EOF)) { // If we get here, then we have a trailing , in a multi target node. - // We'll set the implicit rest flag to indicate this. - pm_node_t *rest = (pm_node_t *) pm_implicit_rest_node_create(parser, &parser->previous); - pm_multi_target_node_targets_append(parser, result, rest); - has_rest = true; + // We need to indicate this somehow in the tree, so we'll add an + // anonymous splat. + pm_node_t *splat = (pm_node_t *) pm_splat_node_create(parser, &parser->previous, NULL); + pm_multi_target_node_targets_append(parser, result, splat); break; } } @@ -11078,7 +10984,7 @@ parse_statements(pm_parser_t *parser, pm_context_t context) { } /** - * Parse all of the elements of a hash. returns true if a double splat was found. + * Parse all of the elements of a hash. eturns true if a double splat was found. */ static bool parse_assocs(pm_parser_t *parser, pm_node_t *node) { @@ -11238,7 +11144,7 @@ parse_arguments(pm_parser_t *parser, pm_arguments_t *arguments, bool accepts_for parsed_bare_hash = true; parse_arguments_append(parser, arguments, argument); if (contains_keyword_splat) { - arguments->arguments->base.flags |= PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORD_SPLAT; + arguments->arguments->base.flags |= PM_ARGUMENTS_NODE_FLAGS_KEYWORD_SPLAT; } break; } @@ -11249,14 +11155,8 @@ parse_arguments(pm_parser_t *parser, pm_arguments_t *arguments, bool accepts_for if (token_begins_expression_p(parser->current.type)) { expression = parse_value_expression(parser, PM_BINDING_POWER_DEFINED, PM_ERR_EXPECT_ARGUMENT); - } else { - if (pm_parser_local_depth(parser, &operator) == -1) { - // A block forwarding in a method having `...` parameter (e.g. `def foo(...); bar(&); end`) is available. - pm_constant_id_t ellipsis_id = pm_parser_constant_id_constant(parser, "...", 3); - if (pm_parser_local_depth_constant_id(parser, ellipsis_id) == -1) { - pm_parser_err_token(parser, &operator, PM_ERR_ARGUMENT_NO_FORWARDING_AMP); - } - } + } else if (pm_parser_local_depth(parser, &operator) == -1) { + pm_parser_err_token(parser, &operator, PM_ERR_ARGUMENT_NO_FORWARDING_AMP); } argument = (pm_node_t *) pm_block_argument_node_create(parser, &operator, expression); @@ -11273,7 +11173,7 @@ parse_arguments(pm_parser_t *parser, pm_arguments_t *arguments, bool accepts_for parser_lex(parser); pm_token_t operator = parser->previous; - if (match4(parser, PM_TOKEN_PARENTHESIS_RIGHT, PM_TOKEN_COMMA, PM_TOKEN_SEMICOLON, PM_TOKEN_BRACKET_RIGHT)) { + if (match3(parser, PM_TOKEN_PARENTHESIS_RIGHT, PM_TOKEN_COMMA, PM_TOKEN_SEMICOLON)) { if (pm_parser_local_depth(parser, &parser->previous) == -1) { pm_parser_err_token(parser, &operator, PM_ERR_ARGUMENT_NO_FORWARDING_STAR); } @@ -11358,7 +11258,7 @@ parse_arguments(pm_parser_t *parser, pm_arguments_t *arguments, bool accepts_for parse_arguments_append(parser, arguments, argument); if (contains_keyword_splat) { - arguments->arguments->base.flags |= PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORD_SPLAT; + arguments->arguments->base.flags |= PM_ARGUMENTS_NODE_FLAGS_KEYWORD_SPLAT; } break; } @@ -11410,14 +11310,11 @@ parse_required_destructured_parameter(pm_parser_t *parser) { do { pm_node_t *param; - // If we get here then we have a trailing comma, which isn't allowed in - // the grammar. In other places, multi targets _do_ allow trailing - // commas, so here we'll assume this is a mistake of the user not - // knowing it's not allowed here. + // If we get here then we have a trailing comma. In this case we'll + // create an implicit splat node. if (node->lefts.size > 0 && match1(parser, PM_TOKEN_PARENTHESIS_RIGHT)) { - param = (pm_node_t *) pm_implicit_rest_node_create(parser, &parser->previous); + param = (pm_node_t *) pm_splat_node_create(parser, &parser->previous, NULL); pm_multi_target_node_targets_append(parser, node, param); - pm_parser_err_current(parser, PM_ERR_PARAMETER_WILD_LOOSE_COMMA); break; } @@ -11648,14 +11545,10 @@ parse_parameters( if (accept1(parser, PM_TOKEN_EQUAL)) { pm_token_t operator = parser->previous; context_push(parser, PM_CONTEXT_DEFAULT_PARAMS); - pm_constant_id_t old_param_name = parser->current_param_name; - parser->current_param_name = pm_parser_constant_id_token(parser, &name); pm_node_t *value = parse_value_expression(parser, binding_power, PM_ERR_PARAMETER_NO_DEFAULT); pm_optional_parameter_node_t *param = pm_optional_parameter_node_create(parser, &name, &operator, value); pm_parameters_node_optionals_append(params, param); - - parser->current_param_name = old_param_name; context_pop(parser); // If parsing the value of the parameter resulted in error recovery, @@ -11711,10 +11604,7 @@ parse_parameters( if (token_begins_expression_p(parser->current.type)) { context_push(parser, PM_CONTEXT_DEFAULT_PARAMS); - pm_constant_id_t old_param_name = parser->current_param_name; - parser->current_param_name = pm_parser_constant_id_token(parser, &local); pm_node_t *value = parse_value_expression(parser, binding_power, PM_ERR_PARAMETER_NO_DEFAULT_KW); - parser->current_param_name = old_param_name; context_pop(parser); param = (pm_node_t *) pm_optional_keyword_parameter_node_create(parser, &name, value); } @@ -11757,12 +11647,12 @@ parse_parameters( } } - pm_node_t *param = (pm_node_t *) pm_rest_parameter_node_create(parser, &operator, &name); + pm_rest_parameter_node_t *param = pm_rest_parameter_node_create(parser, &operator, &name); if (params->rest == NULL) { pm_parameters_node_rest_set(params, param); } else { - pm_parser_err_node(parser, param, PM_ERR_PARAMETER_SPLAT_MULTI); - pm_parameters_node_posts_append(params, param); + pm_parser_err_node(parser, (pm_node_t *) param, PM_ERR_PARAMETER_SPLAT_MULTI); + pm_parameters_node_posts_append(params, (pm_node_t *) param); } break; @@ -11807,9 +11697,11 @@ parse_parameters( default: if (parser->previous.type == PM_TOKEN_COMMA) { if (allows_trailing_comma) { - // If we get here, then we have a trailing comma in a - // block parameter list. - pm_node_t *param = (pm_node_t *) pm_implicit_rest_node_create(parser, &parser->previous); + // If we get here, then we have a trailing comma in a block + // parameter list. We need to create an anonymous rest parameter to + // represent it. + pm_token_t name = not_provided(parser); + pm_rest_parameter_node_t *param = pm_rest_parameter_node_create(parser, &parser->previous, &name); if (params->rest == NULL) { pm_parameters_node_rest_set(params, param); @@ -11847,7 +11739,7 @@ parse_parameters( * nodes pointing to each other from the top. */ static inline void -parse_rescues(pm_parser_t *parser, pm_begin_node_t *parent_node, bool def_p) { +parse_rescues(pm_parser_t *parser, pm_begin_node_t *parent_node) { pm_rescue_node_t *current = NULL; while (accept1(parser, PM_TOKEN_KEYWORD_RESCUE)) { @@ -11910,7 +11802,7 @@ parse_rescues(pm_parser_t *parser, pm_begin_node_t *parent_node, bool def_p) { if (!match3(parser, PM_TOKEN_KEYWORD_ELSE, PM_TOKEN_KEYWORD_ENSURE, PM_TOKEN_KEYWORD_END)) { pm_accepts_block_stack_push(parser, true); - pm_statements_node_t *statements = parse_statements(parser, def_p ? PM_CONTEXT_RESCUE_DEF : PM_CONTEXT_RESCUE); + pm_statements_node_t *statements = parse_statements(parser, PM_CONTEXT_RESCUE); if (statements) { pm_rescue_node_statements_set(rescue, statements); } @@ -11946,7 +11838,7 @@ parse_rescues(pm_parser_t *parser, pm_begin_node_t *parent_node, bool def_p) { pm_statements_node_t *else_statements = NULL; if (!match2(parser, PM_TOKEN_KEYWORD_END, PM_TOKEN_KEYWORD_ENSURE)) { pm_accepts_block_stack_push(parser, true); - else_statements = parse_statements(parser, def_p ? PM_CONTEXT_RESCUE_ELSE_DEF : PM_CONTEXT_RESCUE_ELSE); + else_statements = parse_statements(parser, PM_CONTEXT_RESCUE_ELSE); pm_accepts_block_stack_pop(parser); accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON); } @@ -11962,7 +11854,7 @@ parse_rescues(pm_parser_t *parser, pm_begin_node_t *parent_node, bool def_p) { pm_statements_node_t *ensure_statements = NULL; if (!match1(parser, PM_TOKEN_KEYWORD_END)) { pm_accepts_block_stack_push(parser, true); - ensure_statements = parse_statements(parser, def_p ? PM_CONTEXT_ENSURE_DEF : PM_CONTEXT_ENSURE); + ensure_statements = parse_statements(parser, PM_CONTEXT_ENSURE); pm_accepts_block_stack_pop(parser); accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON); } @@ -11980,10 +11872,10 @@ parse_rescues(pm_parser_t *parser, pm_begin_node_t *parent_node, bool def_p) { } static inline pm_begin_node_t * -parse_rescues_as_begin(pm_parser_t *parser, pm_statements_node_t *statements, bool def_p) { +parse_rescues_as_begin(pm_parser_t *parser, pm_statements_node_t *statements) { pm_token_t no_begin_token = not_provided(parser); pm_begin_node_t *begin_node = pm_begin_node_create(parser, &no_begin_token, statements); - parse_rescues(parser, begin_node, def_p); + parse_rescues(parser, begin_node); // All nodes within a begin node are optional, so we look // for the earliest possible node that we can use to set @@ -12088,7 +11980,7 @@ parse_block(pm_parser_t *parser) { if (match2(parser, PM_TOKEN_KEYWORD_RESCUE, PM_TOKEN_KEYWORD_ENSURE)) { assert(statements == NULL || PM_NODE_TYPE_P(statements, PM_STATEMENTS_NODE)); - statements = (pm_node_t *) parse_rescues_as_begin(parser, (pm_statements_node_t *) statements, false); + statements = (pm_node_t *) parse_rescues_as_begin(parser, (pm_statements_node_t *) statements); } } @@ -12096,10 +11988,9 @@ parse_block(pm_parser_t *parser) { } pm_constant_id_list_t locals = parser->current_scope->locals; - uint32_t numbered_parameters = parser->current_scope->numbered_parameters; pm_parser_scope_pop(parser); pm_accepts_block_stack_pop(parser); - return pm_block_node_create(parser, &locals, &opening, parameters, statements, &parser->previous, numbered_parameters); + return pm_block_node_create(parser, &locals, &opening, parameters, statements, &parser->previous); } /** @@ -12670,9 +12561,9 @@ parse_alias_argument(pm_parser_t *parser, bool first) { * numbered parameters. */ static bool -outer_scope_using_numbered_parameters_p(pm_parser_t *parser) { +outer_scope_using_numbered_params_p(pm_parser_t *parser) { for (pm_scope_t *scope = parser->current_scope->previous; scope != NULL && !scope->closed; scope = scope->previous) { - if (scope->numbered_parameters) return true; + if (scope->numbered_params) return true; } return false; @@ -12692,32 +12583,25 @@ parse_variable_call(pm_parser_t *parser) { } if (!parser->current_scope->closed && pm_token_is_numbered_parameter(parser->previous.start, parser->previous.end)) { + // Indicate that this scope is using numbered params so that child + // scopes cannot. + parser->current_scope->numbered_params = true; + // Now that we know we have a numbered parameter, we need to check // if it's allowed in this context. If it is, then we will create a // local variable read. If it's not, then we'll create a normal call // node but add an error. if (parser->current_scope->explicit_params) { pm_parser_err_previous(parser, PM_ERR_NUMBERED_PARAMETER_NOT_ALLOWED); - } else if (outer_scope_using_numbered_parameters_p(parser)) { + } else if (outer_scope_using_numbered_params_p(parser)) { pm_parser_err_previous(parser, PM_ERR_NUMBERED_PARAMETER_OUTER_SCOPE); } else { - // Indicate that this scope is using numbered params so that child - // scopes cannot. - uint8_t number = parser->previous.start[1]; - - // We subtract the value for the character '0' to get the actual - // integer value of the number (only _1 through _9 are valid) - uint32_t number_as_int = (uint32_t) (number - '0'); - if (number_as_int > parser->current_scope->numbered_parameters) { - parser->current_scope->numbered_parameters = number_as_int; - pm_parser_numbered_parameters_set(parser, number_as_int); - } - // When you use a numbered parameter, it implies the existence // of all of the locals that exist before it. For example, // referencing _2 means that _1 must exist. Therefore here we // loop through all of the possibilities and add them into the // constant pool. + uint8_t number = parser->previous.start[1]; uint8_t current = '1'; uint8_t *value; @@ -13105,13 +12989,8 @@ parse_pattern_primitive(pm_parser_t *parser, pm_diagnostic_id_t diag_id) { case PM_TOKEN_IDENTIFIER: case PM_TOKEN_METHOD_NAME: { parser_lex(parser); - pm_token_t name = parser->previous; - int depth = pm_parser_local_depth(parser, &name); - if (depth < 0) { - depth = 0; - pm_parser_local_add_token(parser, &name); - } - return (pm_node_t *) pm_local_variable_target_node_create_depth(parser, &name, (uint32_t) depth); + pm_parser_local_add_token(parser, &parser->previous); + return (pm_node_t *) pm_local_variable_target_node_create(parser, &parser->previous); } case PM_TOKEN_BRACKET_LEFT_ARRAY: { pm_token_t opening = parser->current; @@ -13428,13 +13307,9 @@ parse_pattern_primitives(pm_parser_t *parser, pm_diagnostic_id_t diag_id) { expect1(parser, PM_TOKEN_IDENTIFIER, PM_ERR_PATTERN_IDENT_AFTER_HROCKET); pm_token_t identifier = parser->previous; - int depth = pm_parser_local_depth(parser, &identifier); - if (depth < 0) { - depth = 0; - pm_parser_local_add_token(parser, &identifier); - } + pm_parser_local_add_token(parser, &identifier); - pm_node_t *target = (pm_node_t *) pm_local_variable_target_node_create_depth(parser, &identifier, (uint32_t) depth); + pm_node_t *target = (pm_node_t *) pm_local_variable_target_node_create(parser, &identifier); node = (pm_node_t *) pm_capture_pattern_node_create(parser, node, target, &operator); } @@ -13495,8 +13370,6 @@ parse_pattern(pm_parser_t *parser, bool top_pattern, pm_diagnostic_id_t diag_id) while (accept1(parser, PM_TOKEN_COMMA)) { // Break early here in case we have a trailing comma. if (match5(parser, PM_TOKEN_KEYWORD_THEN, PM_TOKEN_BRACE_RIGHT, PM_TOKEN_BRACKET_RIGHT, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON)) { - node = (pm_node_t *) pm_implicit_rest_node_create(parser, &parser->previous); - pm_node_list_append(&nodes, node); break; } @@ -14071,7 +13944,7 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { pm_token_t operator = parser->current; parser_lex(parser); - pm_node_t *right = parse_expression(parser, pm_binding_powers[operator.type].left, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR); + pm_node_t *right = parse_expression(parser, binding_power, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR); return (pm_node_t *) pm_range_node_create(parser, NULL, &operator, right); } case PM_TOKEN_FLOAT: @@ -14329,10 +14202,6 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { parser_lex(parser); return (pm_node_t *) pm_source_line_node_create(parser, &parser->previous); case PM_TOKEN_KEYWORD_ALIAS: { - if (binding_power != PM_BINDING_POWER_STATEMENT) { - pm_parser_err_current(parser, PM_ERR_STATEMENT_ALIAS); - } - parser_lex(parser); pm_token_t keyword = parser->previous; @@ -14557,7 +14426,7 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { } pm_begin_node_t *begin_node = pm_begin_node_create(parser, &begin_keyword, begin_statements); - parse_rescues(parser, begin_node, false); + parse_rescues(parser, begin_node); expect1(parser, PM_TOKEN_KEYWORD_END, PM_ERR_BEGIN_TERM); begin_node->base.location.end = parser->previous.end; @@ -14570,10 +14439,6 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { return (pm_node_t *) begin_node; } case PM_TOKEN_KEYWORD_BEGIN_UPCASE: { - if (binding_power != PM_BINDING_POWER_STATEMENT) { - pm_parser_err_current(parser, PM_ERR_STATEMENT_PREEXE_BEGIN); - } - parser_lex(parser); pm_token_t keyword = parser->previous; @@ -14659,10 +14524,8 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { if (accept1(parser, PM_TOKEN_LESS_LESS)) { pm_token_t operator = parser->previous; - pm_node_t *expression = parse_value_expression(parser, PM_BINDING_POWER_NOT, PM_ERR_EXPECT_EXPRESSION_AFTER_LESS_LESS); + pm_node_t *expression = parse_expression(parser, PM_BINDING_POWER_NOT, PM_ERR_EXPECT_EXPRESSION_AFTER_LESS_LESS); - pm_constant_id_t old_param_name = parser->current_param_name; - parser->current_param_name = 0; pm_parser_scope_push(parser, true); accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON); @@ -14675,14 +14538,13 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { if (match2(parser, PM_TOKEN_KEYWORD_RESCUE, PM_TOKEN_KEYWORD_ENSURE)) { assert(statements == NULL || PM_NODE_TYPE_P(statements, PM_STATEMENTS_NODE)); - statements = (pm_node_t *) parse_rescues_as_begin(parser, (pm_statements_node_t *) statements, false); + statements = (pm_node_t *) parse_rescues_as_begin(parser, (pm_statements_node_t *) statements); } expect1(parser, PM_TOKEN_KEYWORD_END, PM_ERR_CLASS_TERM); pm_constant_id_list_t locals = parser->current_scope->locals; pm_parser_scope_pop(parser); - parser->current_param_name = old_param_name; pm_do_loop_stack_pop(parser); return (pm_node_t *) pm_singleton_class_node_create(parser, &locals, &class_keyword, &operator, expression, statements, &parser->previous); } @@ -14709,8 +14571,6 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { superclass = NULL; } - pm_constant_id_t old_param_name = parser->current_param_name; - parser->current_param_name = 0; pm_parser_scope_push(parser, true); if (inheritance_operator.type != PM_TOKEN_NOT_PROVIDED) { expect2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON, PM_ERR_CLASS_UNEXPECTED_END); @@ -14727,7 +14587,7 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { if (match2(parser, PM_TOKEN_KEYWORD_RESCUE, PM_TOKEN_KEYWORD_ENSURE)) { assert(statements == NULL || PM_NODE_TYPE_P(statements, PM_STATEMENTS_NODE)); - statements = (pm_node_t *) parse_rescues_as_begin(parser, (pm_statements_node_t *) statements, false); + statements = (pm_node_t *) parse_rescues_as_begin(parser, (pm_statements_node_t *) statements); } expect1(parser, PM_TOKEN_KEYWORD_END, PM_ERR_CLASS_TERM); @@ -14738,7 +14598,6 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { pm_constant_id_list_t locals = parser->current_scope->locals; pm_parser_scope_pop(parser); - parser->current_param_name = old_param_name; pm_do_loop_stack_pop(parser); if (!PM_NODE_TYPE_P(constant_path, PM_CONSTANT_PATH_NODE) && !(PM_NODE_TYPE_P(constant_path, PM_CONSTANT_READ_NODE))) { @@ -14754,16 +14613,12 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { pm_token_t operator = not_provided(parser); pm_token_t name = (pm_token_t) { .type = PM_TOKEN_MISSING, .start = def_keyword.end, .end = def_keyword.end }; - // This context is necessary for lexing `...` in a bare params correctly. - // It must be pushed before lexing the first param, so it is here. context_push(parser, PM_CONTEXT_DEF_PARAMS); parser_lex(parser); - pm_constant_id_t old_param_name = parser->current_param_name; switch (parser->current.type) { case PM_CASE_OPERATOR: pm_parser_scope_push(parser, true); - parser->current_param_name = 0; lex_state_set(parser, PM_LEX_STATE_ENDFN); parser_lex(parser); name = parser->previous; @@ -14775,7 +14630,6 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { receiver = parse_variable_call(parser); pm_parser_scope_push(parser, true); - parser->current_param_name = 0; lex_state_set(parser, PM_LEX_STATE_FNAME); parser_lex(parser); @@ -14784,7 +14638,6 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { } else { pm_refute_numbered_parameter(parser, parser->previous.start, parser->previous.end); pm_parser_scope_push(parser, true); - parser->current_param_name = 0; name = parser->previous; } @@ -14802,7 +14655,6 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { case PM_TOKEN_KEYWORD___LINE__: case PM_TOKEN_KEYWORD___ENCODING__: { pm_parser_scope_push(parser, true); - parser->current_param_name = 0; parser_lex(parser); pm_token_t identifier = parser->previous; @@ -14856,12 +14708,7 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { break; } case PM_TOKEN_PARENTHESIS_LEFT: { - // The current context is `PM_CONTEXT_DEF_PARAMS`, however the inner expression - // of this parenthesis should not be processed under this context. - // Thus, the context is popped here. - context_pop(parser); parser_lex(parser); - pm_token_t lparen = parser->previous; pm_node_t *expression = parse_value_expression(parser, PM_BINDING_POWER_STATEMENT, PM_ERR_DEF_RECEIVER); @@ -14875,16 +14722,11 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { receiver = (pm_node_t *) pm_parentheses_node_create(parser, &lparen, expression, &rparen); pm_parser_scope_push(parser, true); - parser->current_param_name = 0; - - // To push `PM_CONTEXT_DEF_PARAMS` again is for the same reason as described the above. - context_push(parser, PM_CONTEXT_DEF_PARAMS); name = parse_method_definition_name(parser); break; } default: pm_parser_scope_push(parser, true); - parser->current_param_name = 0; name = parse_method_definition_name(parser); break; } @@ -14987,7 +14829,7 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { if (match2(parser, PM_TOKEN_KEYWORD_RESCUE, PM_TOKEN_KEYWORD_ENSURE)) { assert(statements == NULL || PM_NODE_TYPE_P(statements, PM_STATEMENTS_NODE)); - statements = (pm_node_t *) parse_rescues_as_begin(parser, (pm_statements_node_t *) statements, true); + statements = (pm_node_t *) parse_rescues_as_begin(parser, (pm_statements_node_t *) statements); } pm_accepts_block_stack_pop(parser); @@ -14997,7 +14839,6 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { } pm_constant_id_list_t locals = parser->current_scope->locals; - parser->current_param_name = old_param_name; pm_parser_scope_pop(parser); return (pm_node_t *) pm_def_node_create( @@ -15048,10 +14889,6 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { ); } case PM_TOKEN_KEYWORD_END_UPCASE: { - if (binding_power != PM_BINDING_POWER_STATEMENT) { - pm_parser_err_current(parser, PM_ERR_STATEMENT_POSTEXE_END); - } - parser_lex(parser); pm_token_t keyword = parser->previous; @@ -15134,10 +14971,6 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { parser_lex(parser); return parse_conditional(parser, PM_CONTEXT_IF); case PM_TOKEN_KEYWORD_UNDEF: { - if (binding_power != PM_BINDING_POWER_STATEMENT) { - pm_parser_err_current(parser, PM_ERR_STATEMENT_UNDEF); - } - parser_lex(parser); pm_undef_node_t *undef = pm_undef_node_create(parser, &parser->previous); pm_node_t *name = parse_undef_argument(parser); @@ -15228,8 +15061,6 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { pm_parser_err_token(parser, &name, PM_ERR_MODULE_NAME); } - pm_constant_id_t old_param_name = parser->current_param_name; - parser->current_param_name = 0; pm_parser_scope_push(parser, true); accept2(parser, PM_TOKEN_SEMICOLON, PM_TOKEN_NEWLINE); pm_node_t *statements = NULL; @@ -15242,12 +15073,11 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { if (match2(parser, PM_TOKEN_KEYWORD_RESCUE, PM_TOKEN_KEYWORD_ENSURE)) { assert(statements == NULL || PM_NODE_TYPE_P(statements, PM_STATEMENTS_NODE)); - statements = (pm_node_t *) parse_rescues_as_begin(parser, (pm_statements_node_t *) statements, false); + statements = (pm_node_t *) parse_rescues_as_begin(parser, (pm_statements_node_t *) statements); } pm_constant_id_list_t locals = parser->current_scope->locals; pm_parser_scope_pop(parser); - parser->current_param_name = old_param_name; expect1(parser, PM_TOKEN_KEYWORD_END, PM_ERR_MODULE_TERM); @@ -15913,17 +15743,16 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { if (match2(parser, PM_TOKEN_KEYWORD_RESCUE, PM_TOKEN_KEYWORD_ENSURE)) { assert(body == NULL || PM_NODE_TYPE_P(body, PM_STATEMENTS_NODE)); - body = (pm_node_t *) parse_rescues_as_begin(parser, (pm_statements_node_t *) body, false); + body = (pm_node_t *) parse_rescues_as_begin(parser, (pm_statements_node_t *) body); } expect1(parser, PM_TOKEN_KEYWORD_END, PM_ERR_LAMBDA_TERM_END); } pm_constant_id_list_t locals = parser->current_scope->locals; - uint32_t numbered_parameters = parser->current_scope->numbered_parameters; pm_parser_scope_pop(parser); pm_accepts_block_stack_pop(parser); - return (pm_node_t *) pm_lambda_node_create(parser, &locals, &operator, &opening, &parser->previous, params, body, numbered_parameters); + return (pm_node_t *) pm_lambda_node_create(parser, &locals, &operator, &opening, &parser->previous, params, body); } case PM_TOKEN_UPLUS: { parser_lex(parser); @@ -16911,35 +16740,12 @@ parse_expression(pm_parser_t *parser, pm_binding_power_t binding_power, pm_diagn pm_token_t recovery = parser->previous; pm_node_t *node = parse_expression_prefix(parser, binding_power); - switch (PM_NODE_TYPE(node)) { - case PM_MISSING_NODE: - // If we found a syntax error, then the type of node returned by - // parse_expression_prefix is going to be a missing node. In that - // case we need to add the error message to the parser's error list. - pm_parser_err(parser, recovery.end, recovery.end, diag_id); - return node; - case PM_PRE_EXECUTION_NODE: - case PM_POST_EXECUTION_NODE: - case PM_ALIAS_GLOBAL_VARIABLE_NODE: - case PM_ALIAS_METHOD_NODE: - case PM_UNDEF_NODE: - // These expressions are statements, and cannot be followed by - // operators (except modifiers). - if (pm_binding_powers[parser->current.type].left > PM_BINDING_POWER_MODIFIER_RESCUE) { - return node; - } - break; - case PM_RANGE_NODE: - // Range operators are non-associative, so that it does not - // associate with other range operators (i.e. `..1..` should be - // rejected.) For this reason, we check such a case for unary ranges - // here, and if so, it returns the node immediately, - if ((((pm_range_node_t *) node)->left == NULL) && pm_binding_powers[parser->current.type].left >= PM_BINDING_POWER_RANGE) { - return node; - } - break; - default: - break; + // If we found a syntax error, then the type of node returned by + // parse_expression_prefix is going to be a missing node. In that case we need + // to add the error message to the parser's error list. + if (PM_NODE_TYPE_P(node, PM_MISSING_NODE)) { + pm_parser_err(parser, recovery.end, recovery.end, diag_id); + return node; } // Otherwise we'll look and see if the next token can be parsed as an infix @@ -17035,7 +16841,6 @@ pm_parser_init(pm_parser_t *parser, const uint8_t *source, size_t size, const pm .encoding_changed = false, .pattern_matching_newlines = false, .in_keyword_arg = false, - .current_param_name = 0, .semantic_token_seen = false, .frozen_string_literal = false, .suppress_warnings = false @@ -17070,7 +16875,9 @@ pm_parser_init(pm_parser_t *parser, const uint8_t *source, size_t size, const pm parser->filepath_string = options->filepath; // line option - parser->start_line = options->line; + if (options->line > 0) { + parser->start_line = options->line; + } // encoding option size_t encoding_length = pm_string_length(&options->encoding); @@ -17239,7 +17046,7 @@ pm_serialize(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { PRISM_EXPORTED_FUNCTION void pm_serialize_parse(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data) { pm_options_t options = { 0 }; - pm_options_read(&options, data); + if (data != NULL) pm_options_read(&options, data); pm_parser_t parser; pm_parser_init(&parser, source, size, &options); @@ -17261,7 +17068,7 @@ pm_serialize_parse(pm_buffer_t *buffer, const uint8_t *source, size_t size, cons PRISM_EXPORTED_FUNCTION void pm_serialize_parse_comments(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data) { pm_options_t options = { 0 }; - pm_options_read(&options, data); + if (data != NULL) pm_options_read(&options, data); pm_parser_t parser; pm_parser_init(&parser, source, size, &options); @@ -17269,7 +17076,7 @@ pm_serialize_parse_comments(pm_buffer_t *buffer, const uint8_t *source, size_t s pm_node_t *node = pm_parse(&parser); pm_serialize_header(buffer); pm_serialize_encoding(&parser.encoding, buffer); - pm_buffer_append_varsint(buffer, parser.start_line); + pm_buffer_append_varint(buffer, parser.start_line); pm_serialize_comment_list(&parser, &parser.comment_list, buffer); pm_node_destroy(&parser, node); diff --git a/crates/prism-sys/vendor/prism-0.18.0/src/serialize.c b/crates/prism-sys/vendor/prism-0.18.0/src/serialize.c index ade73ba0..d8a2f6fd 100644 --- a/crates/prism-sys/vendor/prism-0.18.0/src/serialize.c +++ b/crates/prism-sys/vendor/prism-0.18.0/src/serialize.c @@ -22,13 +22,13 @@ pm_sizet_to_u32(size_t value) { } static void -pm_serialize_location(const pm_parser_t *parser, const pm_location_t *location, pm_buffer_t *buffer) { +pm_serialize_location(pm_parser_t *parser, pm_location_t *location, pm_buffer_t *buffer) { assert(location->start); assert(location->end); assert(location->start <= location->end); - pm_buffer_append_varuint(buffer, pm_ptrdifft_to_u32(location->start - parser->start)); - pm_buffer_append_varuint(buffer, pm_ptrdifft_to_u32(location->end - location->start)); + pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(location->start - parser->start)); + pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(location->end - location->start)); } static void @@ -36,15 +36,15 @@ pm_serialize_string(pm_parser_t *parser, pm_string_t *string, pm_buffer_t *buffe switch (string->type) { case PM_STRING_SHARED: { pm_buffer_append_byte(buffer, 1); - pm_buffer_append_varuint(buffer, pm_ptrdifft_to_u32(pm_string_source(string) - parser->start)); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(pm_string_length(string))); + pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(pm_string_source(string) - parser->start)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(pm_string_length(string))); break; } case PM_STRING_OWNED: case PM_STRING_CONSTANT: { uint32_t length = pm_sizet_to_u32(pm_string_length(string)); pm_buffer_append_byte(buffer, 2); - pm_buffer_append_varuint(buffer, length); + pm_buffer_append_varint(buffer, length); pm_buffer_append_bytes(buffer, pm_string_source(string), length); break; } @@ -93,16 +93,16 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { } case PM_ARGUMENTS_NODE: { uint32_t arguments_size = pm_sizet_to_u32(((pm_arguments_node_t *)node)->arguments.size); - pm_buffer_append_varuint(buffer, arguments_size); + pm_buffer_append_varint(buffer, arguments_size); for (uint32_t index = 0; index < arguments_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_arguments_node_t *)node)->arguments.nodes[index], buffer); } - pm_buffer_append_varuint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); + pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); break; } case PM_ARRAY_NODE: { uint32_t elements_size = pm_sizet_to_u32(((pm_array_node_t *)node)->elements.size); - pm_buffer_append_varuint(buffer, elements_size); + pm_buffer_append_varint(buffer, elements_size); for (uint32_t index = 0; index < elements_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_array_node_t *)node)->elements.nodes[index], buffer); } @@ -118,7 +118,6 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_buffer_append_byte(buffer, 1); pm_serialize_location(parser, &((pm_array_node_t *)node)->closing_loc, buffer); } - pm_buffer_append_varuint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); break; } case PM_ARRAY_PATTERN_NODE: { @@ -128,7 +127,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_node(parser, (pm_node_t *)((pm_array_pattern_node_t *)node)->constant, buffer); } uint32_t requireds_size = pm_sizet_to_u32(((pm_array_pattern_node_t *)node)->requireds.size); - pm_buffer_append_varuint(buffer, requireds_size); + pm_buffer_append_varint(buffer, requireds_size); for (uint32_t index = 0; index < requireds_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_array_pattern_node_t *)node)->requireds.nodes[index], buffer); } @@ -138,7 +137,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_node(parser, (pm_node_t *)((pm_array_pattern_node_t *)node)->rest, buffer); } uint32_t posts_size = pm_sizet_to_u32(((pm_array_pattern_node_t *)node)->posts.size); - pm_buffer_append_varuint(buffer, posts_size); + pm_buffer_append_varint(buffer, posts_size); for (uint32_t index = 0; index < posts_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_array_pattern_node_t *)node)->posts.nodes[index], buffer); } @@ -181,7 +180,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { break; } case PM_BACK_REFERENCE_READ_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_back_reference_read_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_back_reference_read_node_t *)node)->name)); break; } case PM_BEGIN_NODE: { @@ -229,14 +228,14 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { break; } case PM_BLOCK_LOCAL_VARIABLE_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_block_local_variable_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_block_local_variable_node_t *)node)->name)); break; } case PM_BLOCK_NODE: { uint32_t locals_size = pm_sizet_to_u32(((pm_block_node_t *)node)->locals.size); - pm_buffer_append_varuint(buffer, locals_size); + pm_buffer_append_varint(buffer, locals_size); for (uint32_t index = 0; index < locals_size; index++) { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_block_node_t *)node)->locals.ids[index])); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_block_node_t *)node)->locals.ids[index])); } if (((pm_block_node_t *)node)->parameters == NULL) { pm_buffer_append_byte(buffer, 0); @@ -250,11 +249,10 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { } pm_serialize_location(parser, &((pm_block_node_t *)node)->opening_loc, buffer); pm_serialize_location(parser, &((pm_block_node_t *)node)->closing_loc, buffer); - pm_buffer_append_varuint(buffer, ((pm_block_node_t *)node)->numbered_parameters); break; } case PM_BLOCK_PARAMETER_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_block_parameter_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_block_parameter_node_t *)node)->name)); if (((pm_block_parameter_node_t *)node)->name_loc.start == NULL) { pm_buffer_append_byte(buffer, 0); } else { @@ -271,7 +269,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_node(parser, (pm_node_t *)((pm_block_parameters_node_t *)node)->parameters, buffer); } uint32_t locals_size = pm_sizet_to_u32(((pm_block_parameters_node_t *)node)->locals.size); - pm_buffer_append_varuint(buffer, locals_size); + pm_buffer_append_varint(buffer, locals_size); for (uint32_t index = 0; index < locals_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_block_parameters_node_t *)node)->locals.nodes[index], buffer); } @@ -316,9 +314,9 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_buffer_append_byte(buffer, 1); pm_serialize_location(parser, &((pm_call_and_write_node_t *)node)->message_loc, buffer); } - pm_buffer_append_varuint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_call_and_write_node_t *)node)->read_name)); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_call_and_write_node_t *)node)->write_name)); + pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_call_and_write_node_t *)node)->read_name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_call_and_write_node_t *)node)->write_name)); pm_serialize_location(parser, &((pm_call_and_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_call_and_write_node_t *)node)->value, buffer); break; @@ -335,7 +333,6 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_buffer_append_byte(buffer, 1); pm_serialize_location(parser, &((pm_call_node_t *)node)->call_operator_loc, buffer); } - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_call_node_t *)node)->name)); if (((pm_call_node_t *)node)->message_loc.start == NULL) { pm_buffer_append_byte(buffer, 0); } else { @@ -364,7 +361,8 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { } else { pm_serialize_node(parser, (pm_node_t *)((pm_call_node_t *)node)->block, buffer); } - pm_buffer_append_varuint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); + pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_call_node_t *)node)->name)); break; } case PM_CALL_OPERATOR_WRITE_NODE: { @@ -385,10 +383,10 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_buffer_append_byte(buffer, 1); pm_serialize_location(parser, &((pm_call_operator_write_node_t *)node)->message_loc, buffer); } - pm_buffer_append_varuint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_call_operator_write_node_t *)node)->read_name)); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_call_operator_write_node_t *)node)->write_name)); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_call_operator_write_node_t *)node)->operator)); + pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_call_operator_write_node_t *)node)->read_name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_call_operator_write_node_t *)node)->write_name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_call_operator_write_node_t *)node)->operator)); pm_serialize_location(parser, &((pm_call_operator_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_call_operator_write_node_t *)node)->value, buffer); break; @@ -411,9 +409,9 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_buffer_append_byte(buffer, 1); pm_serialize_location(parser, &((pm_call_or_write_node_t *)node)->message_loc, buffer); } - pm_buffer_append_varuint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_call_or_write_node_t *)node)->read_name)); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_call_or_write_node_t *)node)->write_name)); + pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_call_or_write_node_t *)node)->read_name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_call_or_write_node_t *)node)->write_name)); pm_serialize_location(parser, &((pm_call_or_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_call_or_write_node_t *)node)->value, buffer); break; @@ -431,7 +429,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_node(parser, (pm_node_t *)((pm_case_match_node_t *)node)->predicate, buffer); } uint32_t conditions_size = pm_sizet_to_u32(((pm_case_match_node_t *)node)->conditions.size); - pm_buffer_append_varuint(buffer, conditions_size); + pm_buffer_append_varint(buffer, conditions_size); for (uint32_t index = 0; index < conditions_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_case_match_node_t *)node)->conditions.nodes[index], buffer); } @@ -451,7 +449,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_node(parser, (pm_node_t *)((pm_case_node_t *)node)->predicate, buffer); } uint32_t conditions_size = pm_sizet_to_u32(((pm_case_node_t *)node)->conditions.size); - pm_buffer_append_varuint(buffer, conditions_size); + pm_buffer_append_varint(buffer, conditions_size); for (uint32_t index = 0; index < conditions_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_case_node_t *)node)->conditions.nodes[index], buffer); } @@ -466,9 +464,9 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { } case PM_CLASS_NODE: { uint32_t locals_size = pm_sizet_to_u32(((pm_class_node_t *)node)->locals.size); - pm_buffer_append_varuint(buffer, locals_size); + pm_buffer_append_varint(buffer, locals_size); for (uint32_t index = 0; index < locals_size; index++) { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_class_node_t *)node)->locals.ids[index])); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_class_node_t *)node)->locals.ids[index])); } pm_serialize_location(parser, &((pm_class_node_t *)node)->class_keyword_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_class_node_t *)node)->constant_path, buffer); @@ -489,41 +487,41 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_node(parser, (pm_node_t *)((pm_class_node_t *)node)->body, buffer); } pm_serialize_location(parser, &((pm_class_node_t *)node)->end_keyword_loc, buffer); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_class_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_class_node_t *)node)->name)); break; } case PM_CLASS_VARIABLE_AND_WRITE_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_class_variable_and_write_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_class_variable_and_write_node_t *)node)->name)); pm_serialize_location(parser, &((pm_class_variable_and_write_node_t *)node)->name_loc, buffer); pm_serialize_location(parser, &((pm_class_variable_and_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_class_variable_and_write_node_t *)node)->value, buffer); break; } case PM_CLASS_VARIABLE_OPERATOR_WRITE_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_class_variable_operator_write_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_class_variable_operator_write_node_t *)node)->name)); pm_serialize_location(parser, &((pm_class_variable_operator_write_node_t *)node)->name_loc, buffer); pm_serialize_location(parser, &((pm_class_variable_operator_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_class_variable_operator_write_node_t *)node)->value, buffer); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_class_variable_operator_write_node_t *)node)->operator)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_class_variable_operator_write_node_t *)node)->operator)); break; } case PM_CLASS_VARIABLE_OR_WRITE_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_class_variable_or_write_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_class_variable_or_write_node_t *)node)->name)); pm_serialize_location(parser, &((pm_class_variable_or_write_node_t *)node)->name_loc, buffer); pm_serialize_location(parser, &((pm_class_variable_or_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_class_variable_or_write_node_t *)node)->value, buffer); break; } case PM_CLASS_VARIABLE_READ_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_class_variable_read_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_class_variable_read_node_t *)node)->name)); break; } case PM_CLASS_VARIABLE_TARGET_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_class_variable_target_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_class_variable_target_node_t *)node)->name)); break; } case PM_CLASS_VARIABLE_WRITE_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_class_variable_write_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_class_variable_write_node_t *)node)->name)); pm_serialize_location(parser, &((pm_class_variable_write_node_t *)node)->name_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_class_variable_write_node_t *)node)->value, buffer); if (((pm_class_variable_write_node_t *)node)->operator_loc.start == NULL) { @@ -535,22 +533,22 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { break; } case PM_CONSTANT_AND_WRITE_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_constant_and_write_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_constant_and_write_node_t *)node)->name)); pm_serialize_location(parser, &((pm_constant_and_write_node_t *)node)->name_loc, buffer); pm_serialize_location(parser, &((pm_constant_and_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_constant_and_write_node_t *)node)->value, buffer); break; } case PM_CONSTANT_OPERATOR_WRITE_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_constant_operator_write_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_constant_operator_write_node_t *)node)->name)); pm_serialize_location(parser, &((pm_constant_operator_write_node_t *)node)->name_loc, buffer); pm_serialize_location(parser, &((pm_constant_operator_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_constant_operator_write_node_t *)node)->value, buffer); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_constant_operator_write_node_t *)node)->operator)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_constant_operator_write_node_t *)node)->operator)); break; } case PM_CONSTANT_OR_WRITE_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_constant_or_write_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_constant_or_write_node_t *)node)->name)); pm_serialize_location(parser, &((pm_constant_or_write_node_t *)node)->name_loc, buffer); pm_serialize_location(parser, &((pm_constant_or_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_constant_or_write_node_t *)node)->value, buffer); @@ -576,7 +574,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_node(parser, (pm_node_t *)((pm_constant_path_operator_write_node_t *)node)->target, buffer); pm_serialize_location(parser, &((pm_constant_path_operator_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_constant_path_operator_write_node_t *)node)->value, buffer); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_constant_path_operator_write_node_t *)node)->operator)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_constant_path_operator_write_node_t *)node)->operator)); break; } case PM_CONSTANT_PATH_OR_WRITE_NODE: { @@ -602,15 +600,15 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { break; } case PM_CONSTANT_READ_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_constant_read_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_constant_read_node_t *)node)->name)); break; } case PM_CONSTANT_TARGET_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_constant_target_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_constant_target_node_t *)node)->name)); break; } case PM_CONSTANT_WRITE_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_constant_write_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_constant_write_node_t *)node)->name)); pm_serialize_location(parser, &((pm_constant_write_node_t *)node)->name_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_constant_write_node_t *)node)->value, buffer); pm_serialize_location(parser, &((pm_constant_write_node_t *)node)->operator_loc, buffer); @@ -621,7 +619,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { // encoding of location u32s make us need to save this offset. size_t length_offset = buffer->length; pm_buffer_append_string(buffer, "\0\0\0\0", 4); /* consume 4 bytes, updated below */ - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_def_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_def_node_t *)node)->name)); pm_serialize_location(parser, &((pm_def_node_t *)node)->name_loc, buffer); if (((pm_def_node_t *)node)->receiver == NULL) { pm_buffer_append_byte(buffer, 0); @@ -639,9 +637,9 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_node(parser, (pm_node_t *)((pm_def_node_t *)node)->body, buffer); } uint32_t locals_size = pm_sizet_to_u32(((pm_def_node_t *)node)->locals.size); - pm_buffer_append_varuint(buffer, locals_size); + pm_buffer_append_varint(buffer, locals_size); for (uint32_t index = 0; index < locals_size; index++) { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_def_node_t *)node)->locals.ids[index])); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_def_node_t *)node)->locals.ids[index])); } pm_serialize_location(parser, &((pm_def_node_t *)node)->def_keyword_loc, buffer); if (((pm_def_node_t *)node)->operator_loc.start == NULL) { @@ -747,7 +745,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { } pm_serialize_node(parser, (pm_node_t *)((pm_find_pattern_node_t *)node)->left, buffer); uint32_t requireds_size = pm_sizet_to_u32(((pm_find_pattern_node_t *)node)->requireds.size); - pm_buffer_append_varuint(buffer, requireds_size); + pm_buffer_append_varint(buffer, requireds_size); for (uint32_t index = 0; index < requireds_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_find_pattern_node_t *)node)->requireds.nodes[index], buffer); } @@ -778,7 +776,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_node(parser, (pm_node_t *)((pm_flip_flop_node_t *)node)->right, buffer); } pm_serialize_location(parser, &((pm_flip_flop_node_t *)node)->operator_loc, buffer); - pm_buffer_append_varuint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); + pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); break; } case PM_FLOAT_NODE: { @@ -818,37 +816,37 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { break; } case PM_GLOBAL_VARIABLE_AND_WRITE_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_global_variable_and_write_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_global_variable_and_write_node_t *)node)->name)); pm_serialize_location(parser, &((pm_global_variable_and_write_node_t *)node)->name_loc, buffer); pm_serialize_location(parser, &((pm_global_variable_and_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_global_variable_and_write_node_t *)node)->value, buffer); break; } case PM_GLOBAL_VARIABLE_OPERATOR_WRITE_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_global_variable_operator_write_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_global_variable_operator_write_node_t *)node)->name)); pm_serialize_location(parser, &((pm_global_variable_operator_write_node_t *)node)->name_loc, buffer); pm_serialize_location(parser, &((pm_global_variable_operator_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_global_variable_operator_write_node_t *)node)->value, buffer); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_global_variable_operator_write_node_t *)node)->operator)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_global_variable_operator_write_node_t *)node)->operator)); break; } case PM_GLOBAL_VARIABLE_OR_WRITE_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_global_variable_or_write_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_global_variable_or_write_node_t *)node)->name)); pm_serialize_location(parser, &((pm_global_variable_or_write_node_t *)node)->name_loc, buffer); pm_serialize_location(parser, &((pm_global_variable_or_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_global_variable_or_write_node_t *)node)->value, buffer); break; } case PM_GLOBAL_VARIABLE_READ_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_global_variable_read_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_global_variable_read_node_t *)node)->name)); break; } case PM_GLOBAL_VARIABLE_TARGET_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_global_variable_target_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_global_variable_target_node_t *)node)->name)); break; } case PM_GLOBAL_VARIABLE_WRITE_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_global_variable_write_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_global_variable_write_node_t *)node)->name)); pm_serialize_location(parser, &((pm_global_variable_write_node_t *)node)->name_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_global_variable_write_node_t *)node)->value, buffer); pm_serialize_location(parser, &((pm_global_variable_write_node_t *)node)->operator_loc, buffer); @@ -857,7 +855,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { case PM_HASH_NODE: { pm_serialize_location(parser, &((pm_hash_node_t *)node)->opening_loc, buffer); uint32_t elements_size = pm_sizet_to_u32(((pm_hash_node_t *)node)->elements.size); - pm_buffer_append_varuint(buffer, elements_size); + pm_buffer_append_varint(buffer, elements_size); for (uint32_t index = 0; index < elements_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_hash_node_t *)node)->elements.nodes[index], buffer); } @@ -871,7 +869,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_node(parser, (pm_node_t *)((pm_hash_pattern_node_t *)node)->constant, buffer); } uint32_t elements_size = pm_sizet_to_u32(((pm_hash_pattern_node_t *)node)->elements.size); - pm_buffer_append_varuint(buffer, elements_size); + pm_buffer_append_varint(buffer, elements_size); for (uint32_t index = 0; index < elements_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_hash_pattern_node_t *)node)->elements.nodes[index], buffer); } @@ -934,9 +932,6 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_node(parser, (pm_node_t *)((pm_implicit_node_t *)node)->value, buffer); break; } - case PM_IMPLICIT_REST_NODE: { - break; - } case PM_IN_NODE: { pm_serialize_node(parser, (pm_node_t *)((pm_in_node_t *)node)->pattern, buffer); if (((pm_in_node_t *)node)->statements == NULL) { @@ -977,7 +972,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { } else { pm_serialize_node(parser, (pm_node_t *)((pm_index_and_write_node_t *)node)->block, buffer); } - pm_buffer_append_varuint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); + pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); pm_serialize_location(parser, &((pm_index_and_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_index_and_write_node_t *)node)->value, buffer); break; @@ -1006,8 +1001,8 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { } else { pm_serialize_node(parser, (pm_node_t *)((pm_index_operator_write_node_t *)node)->block, buffer); } - pm_buffer_append_varuint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_index_operator_write_node_t *)node)->operator)); + pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_index_operator_write_node_t *)node)->operator)); pm_serialize_location(parser, &((pm_index_operator_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_index_operator_write_node_t *)node)->value, buffer); break; @@ -1036,72 +1031,72 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { } else { pm_serialize_node(parser, (pm_node_t *)((pm_index_or_write_node_t *)node)->block, buffer); } - pm_buffer_append_varuint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); + pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); pm_serialize_location(parser, &((pm_index_or_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_index_or_write_node_t *)node)->value, buffer); break; } case PM_INSTANCE_VARIABLE_AND_WRITE_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_instance_variable_and_write_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_instance_variable_and_write_node_t *)node)->name)); pm_serialize_location(parser, &((pm_instance_variable_and_write_node_t *)node)->name_loc, buffer); pm_serialize_location(parser, &((pm_instance_variable_and_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_instance_variable_and_write_node_t *)node)->value, buffer); break; } case PM_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_instance_variable_operator_write_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_instance_variable_operator_write_node_t *)node)->name)); pm_serialize_location(parser, &((pm_instance_variable_operator_write_node_t *)node)->name_loc, buffer); pm_serialize_location(parser, &((pm_instance_variable_operator_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_instance_variable_operator_write_node_t *)node)->value, buffer); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_instance_variable_operator_write_node_t *)node)->operator)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_instance_variable_operator_write_node_t *)node)->operator)); break; } case PM_INSTANCE_VARIABLE_OR_WRITE_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_instance_variable_or_write_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_instance_variable_or_write_node_t *)node)->name)); pm_serialize_location(parser, &((pm_instance_variable_or_write_node_t *)node)->name_loc, buffer); pm_serialize_location(parser, &((pm_instance_variable_or_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_instance_variable_or_write_node_t *)node)->value, buffer); break; } case PM_INSTANCE_VARIABLE_READ_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_instance_variable_read_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_instance_variable_read_node_t *)node)->name)); break; } case PM_INSTANCE_VARIABLE_TARGET_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_instance_variable_target_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_instance_variable_target_node_t *)node)->name)); break; } case PM_INSTANCE_VARIABLE_WRITE_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_instance_variable_write_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_instance_variable_write_node_t *)node)->name)); pm_serialize_location(parser, &((pm_instance_variable_write_node_t *)node)->name_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_instance_variable_write_node_t *)node)->value, buffer); pm_serialize_location(parser, &((pm_instance_variable_write_node_t *)node)->operator_loc, buffer); break; } case PM_INTEGER_NODE: { - pm_buffer_append_varuint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); + pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); break; } case PM_INTERPOLATED_MATCH_LAST_LINE_NODE: { pm_serialize_location(parser, &((pm_interpolated_match_last_line_node_t *)node)->opening_loc, buffer); uint32_t parts_size = pm_sizet_to_u32(((pm_interpolated_match_last_line_node_t *)node)->parts.size); - pm_buffer_append_varuint(buffer, parts_size); + pm_buffer_append_varint(buffer, parts_size); for (uint32_t index = 0; index < parts_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_interpolated_match_last_line_node_t *)node)->parts.nodes[index], buffer); } pm_serialize_location(parser, &((pm_interpolated_match_last_line_node_t *)node)->closing_loc, buffer); - pm_buffer_append_varuint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); + pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); break; } case PM_INTERPOLATED_REGULAR_EXPRESSION_NODE: { pm_serialize_location(parser, &((pm_interpolated_regular_expression_node_t *)node)->opening_loc, buffer); uint32_t parts_size = pm_sizet_to_u32(((pm_interpolated_regular_expression_node_t *)node)->parts.size); - pm_buffer_append_varuint(buffer, parts_size); + pm_buffer_append_varint(buffer, parts_size); for (uint32_t index = 0; index < parts_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_interpolated_regular_expression_node_t *)node)->parts.nodes[index], buffer); } pm_serialize_location(parser, &((pm_interpolated_regular_expression_node_t *)node)->closing_loc, buffer); - pm_buffer_append_varuint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); + pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); break; } case PM_INTERPOLATED_STRING_NODE: { @@ -1112,7 +1107,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_location(parser, &((pm_interpolated_string_node_t *)node)->opening_loc, buffer); } uint32_t parts_size = pm_sizet_to_u32(((pm_interpolated_string_node_t *)node)->parts.size); - pm_buffer_append_varuint(buffer, parts_size); + pm_buffer_append_varint(buffer, parts_size); for (uint32_t index = 0; index < parts_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_interpolated_string_node_t *)node)->parts.nodes[index], buffer); } @@ -1132,7 +1127,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_location(parser, &((pm_interpolated_symbol_node_t *)node)->opening_loc, buffer); } uint32_t parts_size = pm_sizet_to_u32(((pm_interpolated_symbol_node_t *)node)->parts.size); - pm_buffer_append_varuint(buffer, parts_size); + pm_buffer_append_varint(buffer, parts_size); for (uint32_t index = 0; index < parts_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_interpolated_symbol_node_t *)node)->parts.nodes[index], buffer); } @@ -1147,7 +1142,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { case PM_INTERPOLATED_X_STRING_NODE: { pm_serialize_location(parser, &((pm_interpolated_x_string_node_t *)node)->opening_loc, buffer); uint32_t parts_size = pm_sizet_to_u32(((pm_interpolated_x_string_node_t *)node)->parts.size); - pm_buffer_append_varuint(buffer, parts_size); + pm_buffer_append_varint(buffer, parts_size); for (uint32_t index = 0; index < parts_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_interpolated_x_string_node_t *)node)->parts.nodes[index], buffer); } @@ -1156,14 +1151,14 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { } case PM_KEYWORD_HASH_NODE: { uint32_t elements_size = pm_sizet_to_u32(((pm_keyword_hash_node_t *)node)->elements.size); - pm_buffer_append_varuint(buffer, elements_size); + pm_buffer_append_varint(buffer, elements_size); for (uint32_t index = 0; index < elements_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_keyword_hash_node_t *)node)->elements.nodes[index], buffer); } break; } case PM_KEYWORD_REST_PARAMETER_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_keyword_rest_parameter_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_keyword_rest_parameter_node_t *)node)->name)); if (((pm_keyword_rest_parameter_node_t *)node)->name_loc.start == NULL) { pm_buffer_append_byte(buffer, 0); } else { @@ -1175,9 +1170,9 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { } case PM_LAMBDA_NODE: { uint32_t locals_size = pm_sizet_to_u32(((pm_lambda_node_t *)node)->locals.size); - pm_buffer_append_varuint(buffer, locals_size); + pm_buffer_append_varint(buffer, locals_size); for (uint32_t index = 0; index < locals_size; index++) { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_lambda_node_t *)node)->locals.ids[index])); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_lambda_node_t *)node)->locals.ids[index])); } pm_serialize_location(parser, &((pm_lambda_node_t *)node)->operator_loc, buffer); pm_serialize_location(parser, &((pm_lambda_node_t *)node)->opening_loc, buffer); @@ -1192,47 +1187,46 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { } else { pm_serialize_node(parser, (pm_node_t *)((pm_lambda_node_t *)node)->body, buffer); } - pm_buffer_append_varuint(buffer, ((pm_lambda_node_t *)node)->numbered_parameters); break; } case PM_LOCAL_VARIABLE_AND_WRITE_NODE: { pm_serialize_location(parser, &((pm_local_variable_and_write_node_t *)node)->name_loc, buffer); pm_serialize_location(parser, &((pm_local_variable_and_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_local_variable_and_write_node_t *)node)->value, buffer); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_local_variable_and_write_node_t *)node)->name)); - pm_buffer_append_varuint(buffer, ((pm_local_variable_and_write_node_t *)node)->depth); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_local_variable_and_write_node_t *)node)->name)); + pm_buffer_append_varint(buffer, ((pm_local_variable_and_write_node_t *)node)->depth); break; } case PM_LOCAL_VARIABLE_OPERATOR_WRITE_NODE: { pm_serialize_location(parser, &((pm_local_variable_operator_write_node_t *)node)->name_loc, buffer); pm_serialize_location(parser, &((pm_local_variable_operator_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_local_variable_operator_write_node_t *)node)->value, buffer); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_local_variable_operator_write_node_t *)node)->name)); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_local_variable_operator_write_node_t *)node)->operator)); - pm_buffer_append_varuint(buffer, ((pm_local_variable_operator_write_node_t *)node)->depth); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_local_variable_operator_write_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_local_variable_operator_write_node_t *)node)->operator)); + pm_buffer_append_varint(buffer, ((pm_local_variable_operator_write_node_t *)node)->depth); break; } case PM_LOCAL_VARIABLE_OR_WRITE_NODE: { pm_serialize_location(parser, &((pm_local_variable_or_write_node_t *)node)->name_loc, buffer); pm_serialize_location(parser, &((pm_local_variable_or_write_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_local_variable_or_write_node_t *)node)->value, buffer); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_local_variable_or_write_node_t *)node)->name)); - pm_buffer_append_varuint(buffer, ((pm_local_variable_or_write_node_t *)node)->depth); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_local_variable_or_write_node_t *)node)->name)); + pm_buffer_append_varint(buffer, ((pm_local_variable_or_write_node_t *)node)->depth); break; } case PM_LOCAL_VARIABLE_READ_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_local_variable_read_node_t *)node)->name)); - pm_buffer_append_varuint(buffer, ((pm_local_variable_read_node_t *)node)->depth); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_local_variable_read_node_t *)node)->name)); + pm_buffer_append_varint(buffer, ((pm_local_variable_read_node_t *)node)->depth); break; } case PM_LOCAL_VARIABLE_TARGET_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_local_variable_target_node_t *)node)->name)); - pm_buffer_append_varuint(buffer, ((pm_local_variable_target_node_t *)node)->depth); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_local_variable_target_node_t *)node)->name)); + pm_buffer_append_varint(buffer, ((pm_local_variable_target_node_t *)node)->depth); break; } case PM_LOCAL_VARIABLE_WRITE_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_local_variable_write_node_t *)node)->name)); - pm_buffer_append_varuint(buffer, ((pm_local_variable_write_node_t *)node)->depth); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_local_variable_write_node_t *)node)->name)); + pm_buffer_append_varint(buffer, ((pm_local_variable_write_node_t *)node)->depth); pm_serialize_location(parser, &((pm_local_variable_write_node_t *)node)->name_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_local_variable_write_node_t *)node)->value, buffer); pm_serialize_location(parser, &((pm_local_variable_write_node_t *)node)->operator_loc, buffer); @@ -1243,7 +1237,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_location(parser, &((pm_match_last_line_node_t *)node)->content_loc, buffer); pm_serialize_location(parser, &((pm_match_last_line_node_t *)node)->closing_loc, buffer); pm_serialize_string(parser, &((pm_match_last_line_node_t *)node)->unescaped, buffer); - pm_buffer_append_varuint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); + pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); break; } case PM_MATCH_PREDICATE_NODE: { @@ -1261,7 +1255,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { case PM_MATCH_WRITE_NODE: { pm_serialize_node(parser, (pm_node_t *)((pm_match_write_node_t *)node)->call, buffer); uint32_t targets_size = pm_sizet_to_u32(((pm_match_write_node_t *)node)->targets.size); - pm_buffer_append_varuint(buffer, targets_size); + pm_buffer_append_varint(buffer, targets_size); for (uint32_t index = 0; index < targets_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_match_write_node_t *)node)->targets.nodes[index], buffer); } @@ -1272,9 +1266,9 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { } case PM_MODULE_NODE: { uint32_t locals_size = pm_sizet_to_u32(((pm_module_node_t *)node)->locals.size); - pm_buffer_append_varuint(buffer, locals_size); + pm_buffer_append_varint(buffer, locals_size); for (uint32_t index = 0; index < locals_size; index++) { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_module_node_t *)node)->locals.ids[index])); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_module_node_t *)node)->locals.ids[index])); } pm_serialize_location(parser, &((pm_module_node_t *)node)->module_keyword_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_module_node_t *)node)->constant_path, buffer); @@ -1284,12 +1278,12 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_node(parser, (pm_node_t *)((pm_module_node_t *)node)->body, buffer); } pm_serialize_location(parser, &((pm_module_node_t *)node)->end_keyword_loc, buffer); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_module_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_module_node_t *)node)->name)); break; } case PM_MULTI_TARGET_NODE: { uint32_t lefts_size = pm_sizet_to_u32(((pm_multi_target_node_t *)node)->lefts.size); - pm_buffer_append_varuint(buffer, lefts_size); + pm_buffer_append_varint(buffer, lefts_size); for (uint32_t index = 0; index < lefts_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_multi_target_node_t *)node)->lefts.nodes[index], buffer); } @@ -1299,7 +1293,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_node(parser, (pm_node_t *)((pm_multi_target_node_t *)node)->rest, buffer); } uint32_t rights_size = pm_sizet_to_u32(((pm_multi_target_node_t *)node)->rights.size); - pm_buffer_append_varuint(buffer, rights_size); + pm_buffer_append_varint(buffer, rights_size); for (uint32_t index = 0; index < rights_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_multi_target_node_t *)node)->rights.nodes[index], buffer); } @@ -1319,7 +1313,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { } case PM_MULTI_WRITE_NODE: { uint32_t lefts_size = pm_sizet_to_u32(((pm_multi_write_node_t *)node)->lefts.size); - pm_buffer_append_varuint(buffer, lefts_size); + pm_buffer_append_varint(buffer, lefts_size); for (uint32_t index = 0; index < lefts_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_multi_write_node_t *)node)->lefts.nodes[index], buffer); } @@ -1329,7 +1323,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_node(parser, (pm_node_t *)((pm_multi_write_node_t *)node)->rest, buffer); } uint32_t rights_size = pm_sizet_to_u32(((pm_multi_write_node_t *)node)->rights.size); - pm_buffer_append_varuint(buffer, rights_size); + pm_buffer_append_varint(buffer, rights_size); for (uint32_t index = 0; index < rights_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_multi_write_node_t *)node)->rights.nodes[index], buffer); } @@ -1367,17 +1361,17 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { break; } case PM_NUMBERED_REFERENCE_READ_NODE: { - pm_buffer_append_varuint(buffer, ((pm_numbered_reference_read_node_t *)node)->number); + pm_buffer_append_varint(buffer, ((pm_numbered_reference_read_node_t *)node)->number); break; } case PM_OPTIONAL_KEYWORD_PARAMETER_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_optional_keyword_parameter_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_optional_keyword_parameter_node_t *)node)->name)); pm_serialize_location(parser, &((pm_optional_keyword_parameter_node_t *)node)->name_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_optional_keyword_parameter_node_t *)node)->value, buffer); break; } case PM_OPTIONAL_PARAMETER_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_optional_parameter_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_optional_parameter_node_t *)node)->name)); pm_serialize_location(parser, &((pm_optional_parameter_node_t *)node)->name_loc, buffer); pm_serialize_location(parser, &((pm_optional_parameter_node_t *)node)->operator_loc, buffer); pm_serialize_node(parser, (pm_node_t *)((pm_optional_parameter_node_t *)node)->value, buffer); @@ -1391,12 +1385,12 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { } case PM_PARAMETERS_NODE: { uint32_t requireds_size = pm_sizet_to_u32(((pm_parameters_node_t *)node)->requireds.size); - pm_buffer_append_varuint(buffer, requireds_size); + pm_buffer_append_varint(buffer, requireds_size); for (uint32_t index = 0; index < requireds_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_parameters_node_t *)node)->requireds.nodes[index], buffer); } uint32_t optionals_size = pm_sizet_to_u32(((pm_parameters_node_t *)node)->optionals.size); - pm_buffer_append_varuint(buffer, optionals_size); + pm_buffer_append_varint(buffer, optionals_size); for (uint32_t index = 0; index < optionals_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_parameters_node_t *)node)->optionals.nodes[index], buffer); } @@ -1406,12 +1400,12 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_node(parser, (pm_node_t *)((pm_parameters_node_t *)node)->rest, buffer); } uint32_t posts_size = pm_sizet_to_u32(((pm_parameters_node_t *)node)->posts.size); - pm_buffer_append_varuint(buffer, posts_size); + pm_buffer_append_varint(buffer, posts_size); for (uint32_t index = 0; index < posts_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_parameters_node_t *)node)->posts.nodes[index], buffer); } uint32_t keywords_size = pm_sizet_to_u32(((pm_parameters_node_t *)node)->keywords.size); - pm_buffer_append_varuint(buffer, keywords_size); + pm_buffer_append_varint(buffer, keywords_size); for (uint32_t index = 0; index < keywords_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_parameters_node_t *)node)->keywords.nodes[index], buffer); } @@ -1473,9 +1467,9 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { } case PM_PROGRAM_NODE: { uint32_t locals_size = pm_sizet_to_u32(((pm_program_node_t *)node)->locals.size); - pm_buffer_append_varuint(buffer, locals_size); + pm_buffer_append_varint(buffer, locals_size); for (uint32_t index = 0; index < locals_size; index++) { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_program_node_t *)node)->locals.ids[index])); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_program_node_t *)node)->locals.ids[index])); } pm_serialize_node(parser, (pm_node_t *)((pm_program_node_t *)node)->statements, buffer); break; @@ -1492,7 +1486,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_node(parser, (pm_node_t *)((pm_range_node_t *)node)->right, buffer); } pm_serialize_location(parser, &((pm_range_node_t *)node)->operator_loc, buffer); - pm_buffer_append_varuint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); + pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); break; } case PM_RATIONAL_NODE: { @@ -1507,16 +1501,16 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_location(parser, &((pm_regular_expression_node_t *)node)->content_loc, buffer); pm_serialize_location(parser, &((pm_regular_expression_node_t *)node)->closing_loc, buffer); pm_serialize_string(parser, &((pm_regular_expression_node_t *)node)->unescaped, buffer); - pm_buffer_append_varuint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); + pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); break; } case PM_REQUIRED_KEYWORD_PARAMETER_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_required_keyword_parameter_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_required_keyword_parameter_node_t *)node)->name)); pm_serialize_location(parser, &((pm_required_keyword_parameter_node_t *)node)->name_loc, buffer); break; } case PM_REQUIRED_PARAMETER_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_required_parameter_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_required_parameter_node_t *)node)->name)); break; } case PM_RESCUE_MODIFIER_NODE: { @@ -1528,7 +1522,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { case PM_RESCUE_NODE: { pm_serialize_location(parser, &((pm_rescue_node_t *)node)->keyword_loc, buffer); uint32_t exceptions_size = pm_sizet_to_u32(((pm_rescue_node_t *)node)->exceptions.size); - pm_buffer_append_varuint(buffer, exceptions_size); + pm_buffer_append_varint(buffer, exceptions_size); for (uint32_t index = 0; index < exceptions_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_rescue_node_t *)node)->exceptions.nodes[index], buffer); } @@ -1556,7 +1550,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { break; } case PM_REST_PARAMETER_NODE: { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_rest_parameter_node_t *)node)->name)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_rest_parameter_node_t *)node)->name)); if (((pm_rest_parameter_node_t *)node)->name_loc.start == NULL) { pm_buffer_append_byte(buffer, 0); } else { @@ -1583,9 +1577,9 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { } case PM_SINGLETON_CLASS_NODE: { uint32_t locals_size = pm_sizet_to_u32(((pm_singleton_class_node_t *)node)->locals.size); - pm_buffer_append_varuint(buffer, locals_size); + pm_buffer_append_varint(buffer, locals_size); for (uint32_t index = 0; index < locals_size; index++) { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_singleton_class_node_t *)node)->locals.ids[index])); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_singleton_class_node_t *)node)->locals.ids[index])); } pm_serialize_location(parser, &((pm_singleton_class_node_t *)node)->class_keyword_loc, buffer); pm_serialize_location(parser, &((pm_singleton_class_node_t *)node)->operator_loc, buffer); @@ -1619,14 +1613,14 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { } case PM_STATEMENTS_NODE: { uint32_t body_size = pm_sizet_to_u32(((pm_statements_node_t *)node)->body.size); - pm_buffer_append_varuint(buffer, body_size); + pm_buffer_append_varint(buffer, body_size); for (uint32_t index = 0; index < body_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_statements_node_t *)node)->body.nodes[index], buffer); } break; } case PM_STRING_NODE: { - pm_buffer_append_varuint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); + pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); if (((pm_string_node_t *)node)->opening_loc.start == NULL) { pm_buffer_append_byte(buffer, 0); } else { @@ -1696,7 +1690,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { } case PM_UNDEF_NODE: { uint32_t names_size = pm_sizet_to_u32(((pm_undef_node_t *)node)->names.size); - pm_buffer_append_varuint(buffer, names_size); + pm_buffer_append_varint(buffer, names_size); for (uint32_t index = 0; index < names_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_undef_node_t *)node)->names.nodes[index], buffer); } @@ -1744,13 +1738,13 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { } else { pm_serialize_node(parser, (pm_node_t *)((pm_until_node_t *)node)->statements, buffer); } - pm_buffer_append_varuint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); + pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); break; } case PM_WHEN_NODE: { pm_serialize_location(parser, &((pm_when_node_t *)node)->keyword_loc, buffer); uint32_t conditions_size = pm_sizet_to_u32(((pm_when_node_t *)node)->conditions.size); - pm_buffer_append_varuint(buffer, conditions_size); + pm_buffer_append_varint(buffer, conditions_size); for (uint32_t index = 0; index < conditions_size; index++) { pm_serialize_node(parser, (pm_node_t *) ((pm_when_node_t *)node)->conditions.nodes[index], buffer); } @@ -1775,7 +1769,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { } else { pm_serialize_node(parser, (pm_node_t *)((pm_while_node_t *)node)->statements, buffer); } - pm_buffer_append_varuint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); + pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK)); break; } case PM_X_STRING_NODE: { @@ -1815,8 +1809,8 @@ pm_serialize_comment(pm_parser_t *parser, pm_comment_t *comment, pm_buffer_t *bu pm_buffer_append_byte(buffer, (uint8_t) comment->type); // serialize location - pm_buffer_append_varuint(buffer, pm_ptrdifft_to_u32(comment->start - parser->start)); - pm_buffer_append_varuint(buffer, pm_ptrdifft_to_u32(comment->end - comment->start)); + pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(comment->start - parser->start)); + pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(comment->end - comment->start)); } /** @@ -1824,7 +1818,7 @@ pm_serialize_comment(pm_parser_t *parser, pm_comment_t *comment, pm_buffer_t *bu */ void pm_serialize_comment_list(pm_parser_t *parser, pm_list_t *list, pm_buffer_t *buffer) { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(pm_list_size(list))); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(pm_list_size(list))); pm_comment_t *comment; for (comment = (pm_comment_t *) list->head; comment != NULL; comment = (pm_comment_t *) comment->node.next) { @@ -1835,17 +1829,17 @@ pm_serialize_comment_list(pm_parser_t *parser, pm_list_t *list, pm_buffer_t *buf static void pm_serialize_magic_comment(pm_parser_t *parser, pm_magic_comment_t *magic_comment, pm_buffer_t *buffer) { // serialize key location - pm_buffer_append_varuint(buffer, pm_ptrdifft_to_u32(magic_comment->key_start - parser->start)); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(magic_comment->key_length)); + pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(magic_comment->key_start - parser->start)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(magic_comment->key_length)); // serialize value location - pm_buffer_append_varuint(buffer, pm_ptrdifft_to_u32(magic_comment->value_start - parser->start)); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(magic_comment->value_length)); + pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(magic_comment->value_start - parser->start)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(magic_comment->value_length)); } static void pm_serialize_magic_comment_list(pm_parser_t *parser, pm_list_t *list, pm_buffer_t *buffer) { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(pm_list_size(list))); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(pm_list_size(list))); pm_magic_comment_t *magic_comment; for (magic_comment = (pm_magic_comment_t *) list->head; magic_comment != NULL; magic_comment = (pm_magic_comment_t *) magic_comment->node.next) { @@ -1853,31 +1847,21 @@ pm_serialize_magic_comment_list(pm_parser_t *parser, pm_list_t *list, pm_buffer_ } } -static void -pm_serialize_data_loc(const pm_parser_t *parser, pm_buffer_t *buffer) { - if (parser->data_loc.end == NULL) { - pm_buffer_append_byte(buffer, 0); - } else { - pm_buffer_append_byte(buffer, 1); - pm_serialize_location(parser, &parser->data_loc, buffer); - } -} - static void pm_serialize_diagnostic(pm_parser_t *parser, pm_diagnostic_t *diagnostic, pm_buffer_t *buffer) { // serialize message size_t message_length = strlen(diagnostic->message); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(message_length)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(message_length)); pm_buffer_append_string(buffer, diagnostic->message, message_length); // serialize location - pm_buffer_append_varuint(buffer, pm_ptrdifft_to_u32(diagnostic->start - parser->start)); - pm_buffer_append_varuint(buffer, pm_ptrdifft_to_u32(diagnostic->end - diagnostic->start)); + pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(diagnostic->start - parser->start)); + pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(diagnostic->end - diagnostic->start)); } static void pm_serialize_diagnostic_list(pm_parser_t *parser, pm_list_t *list, pm_buffer_t *buffer) { - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(pm_list_size(list))); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(pm_list_size(list))); pm_diagnostic_t *diagnostic; for (diagnostic = (pm_diagnostic_t *) list->head; diagnostic != NULL; diagnostic = (pm_diagnostic_t *) diagnostic->node.next) { @@ -1891,21 +1875,20 @@ pm_serialize_diagnostic_list(pm_parser_t *parser, pm_list_t *list, pm_buffer_t * void pm_serialize_encoding(pm_encoding_t *encoding, pm_buffer_t *buffer) { size_t encoding_length = strlen(encoding->name); - pm_buffer_append_varuint(buffer, pm_sizet_to_u32(encoding_length)); + pm_buffer_append_varint(buffer, pm_sizet_to_u32(encoding_length)); pm_buffer_append_string(buffer, encoding->name, encoding_length); } -#line 216 "serialize.c.erb" +#line 206 "serialize.c.erb" /** * Serialize the encoding, metadata, nodes, and constant pool. */ void pm_serialize_content(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) { pm_serialize_encoding(&parser->encoding, buffer); - pm_buffer_append_varsint(buffer, parser->start_line); + pm_buffer_append_varint(buffer, parser->start_line); pm_serialize_comment_list(parser, &parser->comment_list, buffer); pm_serialize_magic_comment_list(parser, &parser->magic_comment_list, buffer); - pm_serialize_data_loc(parser, buffer); pm_serialize_diagnostic_list(parser, &parser->error_list, buffer); pm_serialize_diagnostic_list(parser, &parser->warning_list, buffer); @@ -1915,7 +1898,7 @@ pm_serialize_content(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) pm_buffer_append_zeroes(buffer, 4); // Next, encode the length of the constant pool. - pm_buffer_append_varuint(buffer, parser->constant_pool.size); + pm_buffer_append_varint(buffer, parser->constant_pool.size); // Now we're going to serialize the content of the node. pm_serialize_node(parser, node, buffer); @@ -1970,10 +1953,10 @@ static void serialize_token(void *data, pm_parser_t *parser, pm_token_t *token) { pm_buffer_t *buffer = (pm_buffer_t *) data; - pm_buffer_append_varuint(buffer, token->type); - pm_buffer_append_varuint(buffer, pm_ptrdifft_to_u32(token->start - parser->start)); - pm_buffer_append_varuint(buffer, pm_ptrdifft_to_u32(token->end - token->start)); - pm_buffer_append_varuint(buffer, parser->lex_state); + pm_buffer_append_varint(buffer, token->type); + pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(token->start - parser->start)); + pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(token->end - token->start)); + pm_buffer_append_varint(buffer, parser->lex_state); } /** @@ -1982,7 +1965,7 @@ serialize_token(void *data, pm_parser_t *parser, pm_token_t *token) { PRISM_EXPORTED_FUNCTION void pm_serialize_lex(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data) { pm_options_t options = { 0 }; - pm_options_read(&options, data); + if (data != NULL) pm_options_read(&options, data); pm_parser_t parser; pm_parser_init(&parser, source, size, &options); @@ -1999,10 +1982,9 @@ pm_serialize_lex(pm_buffer_t *buffer, const uint8_t *source, size_t size, const pm_buffer_append_byte(buffer, 0); pm_serialize_encoding(&parser.encoding, buffer); - pm_buffer_append_varsint(buffer, parser.start_line); + pm_buffer_append_varint(buffer, parser.start_line); pm_serialize_comment_list(&parser, &parser.comment_list, buffer); pm_serialize_magic_comment_list(&parser, &parser.magic_comment_list, buffer); - pm_serialize_data_loc(&parser, buffer); pm_serialize_diagnostic_list(&parser, &parser.error_list, buffer); pm_serialize_diagnostic_list(&parser, &parser.warning_list, buffer); @@ -2018,7 +2000,7 @@ pm_serialize_lex(pm_buffer_t *buffer, const uint8_t *source, size_t size, const PRISM_EXPORTED_FUNCTION void pm_serialize_parse_lex(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data) { pm_options_t options = { 0 }; - pm_options_read(&options, data); + if (data != NULL) pm_options_read(&options, data); pm_parser_t parser; pm_parser_init(&parser, source, size, &options); diff --git a/crates/prism-sys/vendor/prism-0.18.0/src/util/pm_buffer.c b/crates/prism-sys/vendor/prism-0.18.0/src/util/pm_buffer.c index 307b55d0..acc6cad7 100644 --- a/crates/prism-sys/vendor/prism-0.18.0/src/util/pm_buffer.c +++ b/crates/prism-sys/vendor/prism-0.18.0/src/util/pm_buffer.c @@ -138,7 +138,7 @@ pm_buffer_append_byte(pm_buffer_t *buffer, uint8_t value) { * Append a 32-bit unsigned integer to the buffer as a variable-length integer. */ void -pm_buffer_append_varuint(pm_buffer_t *buffer, uint32_t value) { +pm_buffer_append_varint(pm_buffer_t *buffer, uint32_t value) { if (value < 128) { pm_buffer_append_byte(buffer, (uint8_t) value); } else { @@ -151,15 +151,6 @@ pm_buffer_append_varuint(pm_buffer_t *buffer, uint32_t value) { } } -/** - * Append a 32-bit signed integer to the buffer as a variable-length integer. - */ -void -pm_buffer_append_varsint(pm_buffer_t *buffer, int32_t value) { - uint32_t unsigned_int = ((uint32_t)(value) << 1) ^ ((uint32_t)(value >> 31)); - pm_buffer_append_varuint(buffer, unsigned_int); -} - /** * Concatenate one buffer onto another. */