зеркало из https://github.com/github/ruby.git
[PRISM] Emit parse warnings
This commit is contained in:
Родитель
b47d43fa9b
Коммит
332d2c92d8
|
@ -626,7 +626,7 @@ struct pm_parser {
|
|||
* This is the path of the file being parsed. We use the filepath when
|
||||
* constructing SourceFileNodes.
|
||||
*/
|
||||
pm_string_t filepath_string;
|
||||
pm_string_t filepath;
|
||||
|
||||
/**
|
||||
* This constant pool keeps all of the constants defined throughout the file
|
||||
|
|
|
@ -5430,7 +5430,7 @@ pm_source_file_node_create(pm_parser_t *parser, const pm_token_t *file_keyword)
|
|||
.flags = PM_NODE_FLAG_STATIC_LITERAL,
|
||||
.location = PM_LOCATION_TOKEN_VALUE(file_keyword),
|
||||
},
|
||||
.filepath = parser->filepath_string,
|
||||
.filepath = parser->filepath,
|
||||
};
|
||||
|
||||
return node;
|
||||
|
@ -17752,7 +17752,7 @@ pm_parser_init(pm_parser_t *parser, const uint8_t *source, size_t size, const pm
|
|||
.encoding_changed_callback = NULL,
|
||||
.encoding_comment_start = source,
|
||||
.lex_callback = NULL,
|
||||
.filepath_string = { 0 },
|
||||
.filepath = { 0 },
|
||||
.constant_pool = { 0 },
|
||||
.newline_list = { 0 },
|
||||
.integer_base = 0,
|
||||
|
@ -17795,7 +17795,7 @@ pm_parser_init(pm_parser_t *parser, const uint8_t *source, size_t size, const pm
|
|||
// If options were provided to this parse, establish them here.
|
||||
if (options != NULL) {
|
||||
// filepath option
|
||||
parser->filepath_string = options->filepath;
|
||||
parser->filepath = options->filepath;
|
||||
|
||||
// line option
|
||||
parser->start_line = options->line;
|
||||
|
@ -17897,7 +17897,7 @@ pm_magic_comment_list_free(pm_list_t *list) {
|
|||
*/
|
||||
PRISM_EXPORTED_FUNCTION void
|
||||
pm_parser_free(pm_parser_t *parser) {
|
||||
pm_string_free(&parser->filepath_string);
|
||||
pm_string_free(&parser->filepath);
|
||||
pm_diagnostic_list_free(&parser->error_list);
|
||||
pm_diagnostic_list_free(&parser->warning_list);
|
||||
pm_comment_list_free(&parser->comment_list);
|
||||
|
|
|
@ -7620,7 +7620,20 @@ pm_parse_input(pm_parse_result_t *result, VALUE filepath)
|
|||
return error;
|
||||
}
|
||||
|
||||
// TODO: we should be emitting warnings here as well.
|
||||
// Emit all of the various warnings from the parse.
|
||||
const pm_diagnostic_t *warning;
|
||||
const char *warning_filepath = (const char *) pm_string_source(&result->parser.filepath);
|
||||
|
||||
for (warning = (pm_diagnostic_t *) result->parser.warning_list.head; warning != NULL; warning = (pm_diagnostic_t *) warning->node.next) {
|
||||
int line = (int) pm_newline_list_line_column(&result->parser.newline_list, warning->location.start).line;
|
||||
|
||||
if (warning->level == PM_WARNING_LEVEL_VERBOSE) {
|
||||
rb_compile_warning(warning_filepath, line, "%s", warning->message);
|
||||
}
|
||||
else {
|
||||
rb_compile_warn(warning_filepath, line, "%s", warning->message);
|
||||
}
|
||||
}
|
||||
|
||||
// Now set up the constant pool and intern all of the various constants into
|
||||
// their corresponding IDs.
|
||||
|
|
Загрузка…
Ссылка в новой задаче