mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 05:25:34 +02:00
Sync to latest prism
This commit is contained in:
parent
ef427123ad
commit
e9f1324464
10 changed files with 7 additions and 55 deletions
|
@ -311,9 +311,6 @@ module Prism
|
||||||
template << "C"
|
template << "C"
|
||||||
values << (options.fetch(:frozen_string_literal, false) ? 1 : 0)
|
values << (options.fetch(:frozen_string_literal, false) ? 1 : 0)
|
||||||
|
|
||||||
template << "C"
|
|
||||||
values << (options.fetch(:verbose, true) ? 0 : 1)
|
|
||||||
|
|
||||||
template << "C"
|
template << "C"
|
||||||
values << { nil => 0, "3.3.0" => 1, "latest" => 0 }.fetch(options[:version])
|
values << { nil => 0, "3.3.0" => 1, "latest" => 0 }.fetch(options[:version])
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
Gem::Specification.new do |spec|
|
Gem::Specification.new do |spec|
|
||||||
spec.name = "prism"
|
spec.name = "prism"
|
||||||
spec.version = "0.19.0"
|
spec.version = "0.20.0"
|
||||||
spec.authors = ["Shopify"]
|
spec.authors = ["Shopify"]
|
||||||
spec.email = ["ruby@shopify.com"]
|
spec.email = ["ruby@shopify.com"]
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ ID rb_option_id_filepath;
|
||||||
ID rb_option_id_encoding;
|
ID rb_option_id_encoding;
|
||||||
ID rb_option_id_line;
|
ID rb_option_id_line;
|
||||||
ID rb_option_id_frozen_string_literal;
|
ID rb_option_id_frozen_string_literal;
|
||||||
ID rb_option_id_verbose;
|
|
||||||
ID rb_option_id_version;
|
ID rb_option_id_version;
|
||||||
ID rb_option_id_scopes;
|
ID rb_option_id_scopes;
|
||||||
|
|
||||||
|
@ -130,8 +129,6 @@ build_options_i(VALUE key, VALUE value, VALUE argument) {
|
||||||
if (!NIL_P(value)) pm_options_line_set(options, NUM2INT(value));
|
if (!NIL_P(value)) pm_options_line_set(options, NUM2INT(value));
|
||||||
} else if (key_id == rb_option_id_frozen_string_literal) {
|
} else if (key_id == rb_option_id_frozen_string_literal) {
|
||||||
if (!NIL_P(value)) pm_options_frozen_string_literal_set(options, value == Qtrue);
|
if (!NIL_P(value)) pm_options_frozen_string_literal_set(options, value == Qtrue);
|
||||||
} else if (key_id == rb_option_id_verbose) {
|
|
||||||
pm_options_suppress_warnings_set(options, value != Qtrue);
|
|
||||||
} else if (key_id == rb_option_id_version) {
|
} else if (key_id == rb_option_id_version) {
|
||||||
if (!NIL_P(value)) {
|
if (!NIL_P(value)) {
|
||||||
const char *version = check_string(value);
|
const char *version = check_string(value);
|
||||||
|
@ -667,8 +664,6 @@ parse_input(pm_string_t *input, const pm_options_t *options) {
|
||||||
* integer or nil. Note that this is 1-indexed.
|
* integer or nil. Note that this is 1-indexed.
|
||||||
* * `frozen_string_literal` - whether or not the frozen string literal pragma
|
* * `frozen_string_literal` - whether or not the frozen string literal pragma
|
||||||
* has been set. This should be a boolean or nil.
|
* has been set. This should be a boolean or nil.
|
||||||
* * `verbose` - the current level of verbosity. This controls whether or not
|
|
||||||
* the parser emits warnings. This should be a boolean or nil.
|
|
||||||
* * `version` - the version of prism that should be used to parse Ruby code. By
|
* * `version` - the version of prism that should be used to parse Ruby code. By
|
||||||
* default prism assumes you want to parse with the latest vesion of
|
* default prism assumes you want to parse with the latest vesion of
|
||||||
* prism (which you can trigger with `nil` or `"latest"`). If you want to
|
* prism (which you can trigger with `nil` or `"latest"`). If you want to
|
||||||
|
@ -1079,7 +1074,6 @@ Init_prism(void) {
|
||||||
rb_option_id_encoding = rb_intern_const("encoding");
|
rb_option_id_encoding = rb_intern_const("encoding");
|
||||||
rb_option_id_line = rb_intern_const("line");
|
rb_option_id_line = rb_intern_const("line");
|
||||||
rb_option_id_frozen_string_literal = rb_intern_const("frozen_string_literal");
|
rb_option_id_frozen_string_literal = rb_intern_const("frozen_string_literal");
|
||||||
rb_option_id_verbose = rb_intern_const("verbose");
|
|
||||||
rb_option_id_version = rb_intern_const("version");
|
rb_option_id_version = rb_intern_const("version");
|
||||||
rb_option_id_scopes = rb_intern_const("scopes");
|
rb_option_id_scopes = rb_intern_const("scopes");
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef PRISM_EXT_NODE_H
|
#ifndef PRISM_EXT_NODE_H
|
||||||
#define PRISM_EXT_NODE_H
|
#define PRISM_EXT_NODE_H
|
||||||
|
|
||||||
#define EXPECTED_PRISM_VERSION "0.19.0"
|
#define EXPECTED_PRISM_VERSION "0.20.0"
|
||||||
|
|
||||||
#include <ruby.h>
|
#include <ruby.h>
|
||||||
#include <ruby/encoding.h>
|
#include <ruby/encoding.h>
|
||||||
|
|
|
@ -32,14 +32,6 @@ pm_options_frozen_string_literal_set(pm_options_t *options, bool frozen_string_l
|
||||||
options->frozen_string_literal = frozen_string_literal;
|
options->frozen_string_literal = frozen_string_literal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the suppress warnings option on the given options struct.
|
|
||||||
*/
|
|
||||||
PRISM_EXPORTED_FUNCTION void
|
|
||||||
pm_options_suppress_warnings_set(pm_options_t *options, bool suppress_warnings) {
|
|
||||||
options->suppress_warnings = suppress_warnings;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the version option on the given options struct by parsing the given
|
* Set the version option on the given options struct by parsing the given
|
||||||
* string. If the string contains an invalid option, this returns false.
|
* string. If the string contains an invalid option, this returns false.
|
||||||
|
@ -189,7 +181,6 @@ pm_options_read(pm_options_t *options, const char *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
options->frozen_string_literal = *data++;
|
options->frozen_string_literal = *data++;
|
||||||
options->suppress_warnings = *data++;
|
|
||||||
options->version = (pm_options_version_t) *data++;
|
options->version = (pm_options_version_t) *data++;
|
||||||
|
|
||||||
uint32_t scopes_count = pm_options_read_u32(data);
|
uint32_t scopes_count = pm_options_read_u32(data);
|
||||||
|
|
|
@ -78,13 +78,6 @@ typedef struct {
|
||||||
|
|
||||||
/** Whether or not the frozen string literal option has been set. */
|
/** Whether or not the frozen string literal option has been set. */
|
||||||
bool frozen_string_literal;
|
bool frozen_string_literal;
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether or not we should suppress warnings. This is purposefully negated
|
|
||||||
* so that the default is to not suppress warnings, which allows us to still
|
|
||||||
* create an options struct with zeroed memory.
|
|
||||||
*/
|
|
||||||
bool suppress_warnings;
|
|
||||||
} pm_options_t;
|
} pm_options_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -119,14 +112,6 @@ PRISM_EXPORTED_FUNCTION void pm_options_encoding_set(pm_options_t *options, cons
|
||||||
*/
|
*/
|
||||||
PRISM_EXPORTED_FUNCTION void pm_options_frozen_string_literal_set(pm_options_t *options, bool frozen_string_literal);
|
PRISM_EXPORTED_FUNCTION void pm_options_frozen_string_literal_set(pm_options_t *options, bool frozen_string_literal);
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the suppress warnings option on the given options struct.
|
|
||||||
*
|
|
||||||
* @param options The options struct to set the suppress warnings value on.
|
|
||||||
* @param suppress_warnings The suppress warnings value to set.
|
|
||||||
*/
|
|
||||||
PRISM_EXPORTED_FUNCTION void pm_options_suppress_warnings_set(pm_options_t *options, bool suppress_warnings);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the version option on the given options struct by parsing the given
|
* Set the version option on the given options struct by parsing the given
|
||||||
* string. If the string contains an invalid option, this returns false.
|
* string. If the string contains an invalid option, this returns false.
|
||||||
|
|
|
@ -727,13 +727,6 @@ struct pm_parser {
|
||||||
* a true value.
|
* a true value.
|
||||||
*/
|
*/
|
||||||
bool frozen_string_literal;
|
bool frozen_string_literal;
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether or not we should emit warnings. This will be set to false if the
|
|
||||||
* consumer of the library specified it, usually because they are parsing
|
|
||||||
* when $VERBOSE is nil.
|
|
||||||
*/
|
|
||||||
bool suppress_warnings;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -553,10 +553,8 @@ pm_parser_err_token(pm_parser_t *parser, const pm_token_t *token, pm_diagnostic_
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void
|
||||||
pm_parser_warn(pm_parser_t *parser, const uint8_t *start, const uint8_t *end, pm_diagnostic_id_t diag_id) {
|
pm_parser_warn(pm_parser_t *parser, const uint8_t *start, const uint8_t *end, pm_diagnostic_id_t diag_id) {
|
||||||
if (!parser->suppress_warnings) {
|
|
||||||
pm_diagnostic_list_append(&parser->warning_list, start, end, diag_id);
|
pm_diagnostic_list_append(&parser->warning_list, start, end, diag_id);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append a warning to the list of warnings on the parser using the location of
|
* Append a warning to the list of warnings on the parser using the location of
|
||||||
|
@ -17767,8 +17765,7 @@ pm_parser_init(pm_parser_t *parser, const uint8_t *source, size_t size, const pm
|
||||||
.in_keyword_arg = false,
|
.in_keyword_arg = false,
|
||||||
.current_param_name = 0,
|
.current_param_name = 0,
|
||||||
.semantic_token_seen = false,
|
.semantic_token_seen = false,
|
||||||
.frozen_string_literal = false,
|
.frozen_string_literal = false
|
||||||
.suppress_warnings = false
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Initialize the constant pool. We're going to completely guess as to the
|
// Initialize the constant pool. We're going to completely guess as to the
|
||||||
|
@ -17814,11 +17811,6 @@ pm_parser_init(pm_parser_t *parser, const uint8_t *source, size_t size, const pm
|
||||||
parser->frozen_string_literal = true;
|
parser->frozen_string_literal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// suppress_warnings option
|
|
||||||
if (options->suppress_warnings) {
|
|
||||||
parser->suppress_warnings = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// version option
|
// version option
|
||||||
parser->version = options->version;
|
parser->version = options->version;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ module Prism
|
||||||
|
|
||||||
# The minor version of prism that we are expecting to find in the serialized
|
# The minor version of prism that we are expecting to find in the serialized
|
||||||
# strings.
|
# strings.
|
||||||
MINOR_VERSION = 19
|
MINOR_VERSION = 20
|
||||||
|
|
||||||
# The patch version of prism that we are expecting to find in the serialized
|
# The patch version of prism that we are expecting to find in the serialized
|
||||||
# strings.
|
# strings.
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
/**
|
/**
|
||||||
* The minor version of the Prism library as an int.
|
* The minor version of the Prism library as an int.
|
||||||
*/
|
*/
|
||||||
#define PRISM_VERSION_MINOR 19
|
#define PRISM_VERSION_MINOR 20
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The patch version of the Prism library as an int.
|
* The patch version of the Prism library as an int.
|
||||||
|
@ -24,6 +24,6 @@
|
||||||
/**
|
/**
|
||||||
* The version of the Prism library as a constant string.
|
* The version of the Prism library as a constant string.
|
||||||
*/
|
*/
|
||||||
#define PRISM_VERSION "0.19.0"
|
#define PRISM_VERSION "0.20.0"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue