Skip to content

Commit

Permalink
Refactoring: No need to carry lexical positions in the ast_expr .rang…
Browse files Browse the repository at this point in the history
…e node.
  • Loading branch information
katef committed May 29, 2024
1 parent 08adac2 commit b5acc20
Show file tree
Hide file tree
Showing 15 changed files with 279 additions and 326 deletions.
8 changes: 2 additions & 6 deletions src/libre/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -784,8 +784,7 @@ ast_make_expr_subtract(struct ast_expr_pool **poolp, enum re_flags re_flags, str

struct ast_expr *
ast_make_expr_range(struct ast_expr_pool **poolp, enum re_flags re_flags,
const struct ast_endpoint *from, struct ast_pos start,
const struct ast_endpoint *to, struct ast_pos end)
const struct ast_endpoint *from, const struct ast_endpoint *to)
{
struct ast_expr *res;

Expand All @@ -800,9 +799,7 @@ ast_make_expr_range(struct ast_expr_pool **poolp, enum re_flags re_flags,
res->type = AST_EXPR_RANGE;
res->re_flags = re_flags;
res->u.range.from = *from;
res->u.range.start = start;
res->u.range.to = *to;
res->u.range.end = end;

return res;
}
Expand Down Expand Up @@ -842,7 +839,6 @@ ast_make_expr_named(struct ast_expr_pool **poolp, enum re_flags re_flags, const
}
} else {
struct ast_endpoint from, to;
struct ast_pos pos = { 0, 0, 0 }; /* XXX: pass in pos */

from.type = AST_ENDPOINT_LITERAL;
if (class->ranges[i].a <= UCHAR_MAX) {
Expand All @@ -858,7 +854,7 @@ ast_make_expr_named(struct ast_expr_pool **poolp, enum re_flags re_flags, const
to.u.codepoint.u = class->ranges[i].b;
}

res->u.alt.n[i] = ast_make_expr_range(poolp, re_flags, &from, pos, &to, pos);
res->u.alt.n[i] = ast_make_expr_range(poolp, re_flags, &from, &to);
if (res->u.alt.n[i] == NULL) {
goto error;
}
Expand Down
5 changes: 1 addition & 4 deletions src/libre/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,7 @@ struct ast_expr {

struct {
struct ast_endpoint from;
struct ast_pos start;
struct ast_endpoint to;
struct ast_pos end;
} range;

struct {
Expand Down Expand Up @@ -319,8 +317,7 @@ ast_add_expr_concat(struct ast_expr *cat, struct ast_expr *node);

struct ast_expr *
ast_make_expr_range(struct ast_expr_pool **poolp, enum re_flags re_flags,
const struct ast_endpoint *from, struct ast_pos start,
const struct ast_endpoint *to, struct ast_pos end);
const struct ast_endpoint *from, const struct ast_endpoint *to);

struct ast_expr *
ast_make_expr_named(struct ast_expr_pool **poolp, enum re_flags re_flags, const struct class *class);
Expand Down
8 changes: 4 additions & 4 deletions src/libre/dialect/glob/parser.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/libre/dialect/glob/parser.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/libre/dialect/like/parser.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/libre/dialect/like/parser.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/libre/dialect/literal/parser.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/libre/dialect/literal/parser.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b5acc20

Please sign in to comment.