Skip to content

Commit

Permalink
struct rb_parser_errors is not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
yui-knk committed Apr 27, 2024
1 parent 8501932 commit 3eff2ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
19 changes: 9 additions & 10 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ struct parser_params {
unsigned int keep_tokens: 1;
unsigned int main_context: 1;

rb_parser_errors_t errors;
rb_parser_ary_t *errors;
rb_parser_ary_t *debug_lines;
/*
* Store specific keyword locations to generate dummy end token.
Expand Down Expand Up @@ -7729,12 +7729,12 @@ append_error_message_to_str(struct parser_params *p, VALUE str, const char *file
}

static void
append_error_message(struct parser_params *p, rb_parser_errors_t *errors, VALUE str)
append_error_message(struct parser_params *p, rb_parser_ary_t *errors, VALUE str)
{
const char *fn = NIL_P(p->ruby_sourcefile_string) ? NULL : RSTRING_PTR(p->ruby_sourcefile_string);

for (long i = 0; i < errors->errors->len; i++) {
rb_parser_error_t *error = errors->errors->data[i];
for (long i = 0; i < errors->len; i++) {
rb_parser_error_t *error = errors->data[i];

append_error_message_to_str(p, str, fn, error);
if (error->lastline) {
Expand Down Expand Up @@ -7781,7 +7781,7 @@ yycompile0(VALUE arg)
else {
VALUE mesg;
exc = rb_syntax_error_with_path(Qnil, p->ruby_sourcefile_string, &mesg, p->enc);
append_error_message(p, &p->errors, mesg);
append_error_message(p, p->errors, mesg);
}
if (!p->error_tolerant) {
rb_set_errinfo(exc);
Expand Down Expand Up @@ -15820,8 +15820,7 @@ parser_initialize(struct parser_params *p)
p->delayed.token = NULL;
p->frozen_string_literal = -1; /* not specified */
#ifndef RIPPER
/* TODO: Set errors.path ? */
p->errors.errors = rb_parser_ary_new_capa_for_error(p, 10);
p->errors = rb_parser_ary_new_capa_for_error(p, 10);
p->end_expect_token_locations = NULL;
p->token_id = 0;
p->tokens = NULL;
Expand Down Expand Up @@ -15873,8 +15872,8 @@ rb_ruby_parser_free(void *ptr)
rb_parser_ary_free(p, p->tokens);
}

if (p->errors.errors) {
rb_parser_ary_free(p, p->errors.errors);
if (p->errors) {
rb_parser_ary_free(p, p->errors);
}
#endif

Expand Down Expand Up @@ -16211,7 +16210,7 @@ parser_append_error(struct parser_params *p, int lineno, int column, rb_code_loc
error->loc = loc;
error->message = message;
error->lastline = lastline;
rb_parser_ary_push_error(p, p->errors.errors, error);
rb_parser_ary_push_error(p, p->errors, error);
}

static void
Expand Down
5 changes: 0 additions & 5 deletions rubyparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,6 @@ typedef struct rb_parser_ary {
long capa; // capacity
} rb_parser_ary_t;

typedef struct rb_parser_errors {
struct rb_parser_string *path;
rb_parser_ary_t *errors;
} rb_parser_errors_t;

/* Header part of AST Node */
typedef struct RNode {
VALUE flags;
Expand Down

0 comments on commit 3eff2ae

Please sign in to comment.