Skip to content

Commit

Permalink
Refactoring: No need for <mark-expr>.
Browse files Browse the repository at this point in the history
This also removes struct ast_pos, with no remaining uses.
  • Loading branch information
katef committed May 29, 2024
1 parent c7740c2 commit a50f7f3
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 41 deletions.
12 changes: 0 additions & 12 deletions src/libre/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@
#ifndef RE_AST_H
#define RE_AST_H

/*
* This is a duplicate of struct lx_pos, but since we're linking to
* code with several distinct lexers, there isn't a clear lexer.h
* to include here. The parser sees both definitions, and will
* build a `struct ast_pos` in the appropriate places.
*/
struct ast_pos {
unsigned byte;
unsigned line;
unsigned col;
};

enum ast_expr_type {
/* Reserve one value (0) indicating a freed expression. This value is
* intentionally unnamed: code that switches on n->type should be able
Expand Down
1 change: 0 additions & 1 deletion src/libre/dialect/glob/parser.sid
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@
!<mark-group>: (:pos, :pos) -> ();
!<mark-range>: (:pos, :pos) -> ();
!<mark-count>: (:pos, :pos) -> ();
!<mark-expr>: (:ast_expr, :pos, :pos) -> ();

<class-any>: () -> (:ast_class_id);
!<class-bsr>: () -> (:ast_class_id);
Expand Down
1 change: 0 additions & 1 deletion src/libre/dialect/like/parser.sid
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@
!<mark-group>: (:pos, :pos) -> ();
!<mark-range>: (:pos, :pos) -> ();
!<mark-count>: (:pos, :pos) -> ();
!<mark-expr>: (:ast_expr, :pos, :pos) -> ();

<class-any>: () -> (:ast_class_id);
!<class-bsr>: () -> (:ast_class_id);
Expand Down
1 change: 0 additions & 1 deletion src/libre/dialect/literal/parser.sid
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@
!<mark-group>: (:pos, :pos) -> ();
!<mark-range>: (:pos, :pos) -> ();
!<mark-count>: (:pos, :pos) -> ();
!<mark-expr>: (:ast_expr, :pos, :pos) -> ();

!<class-any>: () -> (:ast_class_id);
!<class-bsr>: () -> (:ast_class_id);
Expand Down
3 changes: 0 additions & 3 deletions src/libre/dialect/native/parser.sid
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@
<mark-group>: (:pos, :pos) -> ();
<mark-range>: (:pos, :pos) -> ();
<mark-count>: (:pos, :pos) -> ();
<mark-expr>: (:ast_expr, :pos, :pos) -> ();

<class-any>: () -> (:ast_class_id);
!<class-bsr>: () -> (:ast_class_id);
Expand Down Expand Up @@ -352,8 +351,6 @@
<err-expected-closegroup>;
end = start; /* appease sid */
};

<mark-expr>(tmp, start, end);
};

piece: () -> (node :ast_expr) [
Expand Down
5 changes: 0 additions & 5 deletions src/libre/dialect/pcre/parser.sid
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@
<mark-group>: (:pos, :pos) -> ();
<mark-range>: (:pos, :pos) -> ();
<mark-count>: (:pos, :pos) -> ();
<mark-expr>: (:ast_expr, :pos, :pos) -> ();

<class-any>: () -> (:ast_class_id);
<class-bsr>: () -> (:ast_class_id);
Expand Down Expand Up @@ -380,17 +379,13 @@
<err-expected-closegroup>;
end = start; /* appease sid */
};

<mark-expr>(tmp, start, end);
};

type: () -> (node :ast_expr) = {
(class, start, end) = class-named;

node = <ast-make-alt>;
<ast-add-alt>(node, class);

<mark-expr>(node, start, end);
};

flags: () -> (node :ast_expr) [
Expand Down
10 changes: 2 additions & 8 deletions src/libre/dialect/sql/parser.sid
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
<mark-group>: (:pos, :pos) -> ();
<mark-range>: (:pos, :pos) -> ();
<mark-count>: (:pos, :pos) -> ();
<mark-expr>: (:ast_expr, :pos, :pos) -> ();

<class-any>: () -> (:ast_class_id);
!<class-bsr>: () -> (:ast_class_id);
Expand Down Expand Up @@ -253,9 +252,7 @@

{
(!, close_start, close_end) = CLOSEGROUP;
<mark-group>(open_start, open_end);

<mark-expr>(tmp, open_start, close_end);
<mark-group>(open_start, close_end);

node = class;
||
Expand Down Expand Up @@ -287,11 +284,8 @@

{
(!, close_start, close_end) = CLOSEGROUP;
<mark-group>(close_start, close_end);

/* TODO: would prefer to demark class and mask separately */
<mark-expr>(tmp, open_start, close_end);
<mark-expr>(mask_tmp, open_start, close_end);
<mark-group>(open_start, close_end);
##
<err-expected-closegroup>;
};
Expand Down
10 changes: 0 additions & 10 deletions src/libre/parser.act
Original file line number Diff line number Diff line change
Expand Up @@ -799,16 +799,6 @@
mark(&act_state->countend, &@end);
@};

<mark-expr>: (node :ast_expr, start :pos, end :pos) -> () = @{
(void) @start;
(void) @end;

/* TODO: reinstate this, applies to an expr node in general
@node->u.class.start = ast_start;
@node->u.class.end = ast_end;
*/
@};

<class-any>: () -> (c :ast_class_id) = @{
/* TODO: or the unicode equivalent */
@c = (*flags & RE_SINGLE) ? &class_any : &class_notnl;
Expand Down

0 comments on commit a50f7f3

Please sign in to comment.