Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate RE_EUNSUPPORTED syntax errors #473

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions include/re/re.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ enum re_errno {
RE_EERRNO = 1 | RE_MISC,
RE_EBADDIALECT = 2 | RE_MISC,
RE_EBADGROUP = 3 | RE_MISC,
RE_EUNSUPCAPTUR = 4 | RE_MISC,
RE_EUNSUPPPCRE = 5 | RE_MISC,

RE_ENEGRANGE = 0 | RE_MARK | RE_GROUP,
RE_ENEGCOUNT = 1 | RE_MARK | RE_GROUP,
Expand Down
20 changes: 9 additions & 11 deletions src/libre/ast_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ analysis_iter_anchoring(struct anchoring_env *env, struct ast_expr *n)
"%s: LITERAL: rejecting non-optional newline match after $ as unsupported\n",
__func__);
set_flags(n, AST_FLAG_UNSATISFIABLE);
return AST_ANALYSIS_ERROR_UNSUPPORTED_PCRE;
return AST_ANALYSIS_ERROR_UNSUPPORTED;
}
}
break;
Expand Down Expand Up @@ -1010,8 +1010,7 @@ analysis_iter_anchoring(struct anchoring_env *env, struct ast_expr *n)
all_set_past_always_consuming &= child_env.past_always_consuming;
any_sat = 1;
}
} else if (res == AST_ANALYSIS_ERROR_UNSUPPORTED_CAPTURE
|| res == AST_ANALYSIS_ERROR_UNSUPPORTED_PCRE) {
} else if (res == AST_ANALYSIS_ERROR_UNSUPPORTED) {
continue;
} else {
return res;
Expand Down Expand Up @@ -1201,7 +1200,7 @@ analysis_iter_anchoring(struct anchoring_env *env, struct ast_expr *n)
"%s: SUBTRACT: rejecting non-optional newline match after $ as unsupported\n",
__func__);
set_flags(n, AST_FLAG_UNSATISFIABLE);
return AST_ANALYSIS_ERROR_UNSUPPORTED_PCRE;
return AST_ANALYSIS_ERROR_UNSUPPORTED;
}

if (res != AST_ANALYSIS_OK) {
Expand Down Expand Up @@ -1287,9 +1286,9 @@ analysis_iter_reverse_anchoring(struct anchoring_env *env, struct ast_expr *n)
if (env->followed_by_consuming) {
if (env->followed_by_consuming_newline) {
LOG(3 - LOG_ANCHORING,
"%s: END anchor & followed_by_consuming, returning UNSUPPORTED_PCRE\n",
"%s: END anchor & followed_by_consuming, returning UNSUPPORTED\n",
__func__);
return AST_ANALYSIS_ERROR_UNSUPPORTED_PCRE;
return AST_ANALYSIS_ERROR_UNSUPPORTED;
} else {
LOG(3 - LOG_ANCHORING,
"%s: END anchor & followed_by_consuming, setting UNSATISFIABLE\n",
Expand Down Expand Up @@ -1446,9 +1445,8 @@ analysis_iter_reverse_anchoring(struct anchoring_env *env, struct ast_expr *n)
any_set_followed_by_consuming_newline |= child_env.followed_by_consuming_newline;
any_sat = 1;
}
} else if (res == AST_ANALYSIS_ERROR_UNSUPPORTED_CAPTURE
|| res == AST_ANALYSIS_ERROR_UNSUPPORTED_PCRE) {
LOG(3 - LOG_ANCHORING, "%s: got res of UNSUPPORTED_*, bubbling up\n", __func__);
} else if (res == AST_ANALYSIS_ERROR_UNSUPPORTED) {
LOG(3 - LOG_ANCHORING, "%s: got res of UNSUPPORTED, bubbling up\n", __func__);
return res;
} else {
return res;
Expand Down Expand Up @@ -1883,7 +1881,7 @@ analysis_iter_repetition(struct ast_expr *n, struct ast_expr *outermost_repeat_p
*
* An example input that triggers this is '^(($)|)+$' . */
set_flags(n, AST_FLAG_UNSATISFIABLE);
return AST_ANALYSIS_ERROR_UNSUPPORTED_PCRE;
return AST_ANALYSIS_ERROR_UNSUPPORTED;
}
}

Expand Down Expand Up @@ -1994,7 +1992,7 @@ analysis_iter_repetition(struct ast_expr *n, struct ast_expr *outermost_repeat_p
&& repeat_plus_ancestor->u.repeat.max == AST_COUNT_UNBOUNDED);
LOG(3 - LOG_REPETITION_CASES,
"%s: not yet implemented, skipping\n", __func__);
/* return AST_ANALYSIS_ERROR_UNSUPPORTED_PCRE; */
/* return AST_ANALYSIS_ERROR_UNSUPPORTED; */
}

res = analysis_iter_repetition(n->u.group.e, outermost_repeat_parent,
Expand Down
3 changes: 1 addition & 2 deletions src/libre/ast_analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ enum ast_analysis_res {

AST_ANALYSIS_ERROR_NULL = -1,
AST_ANALYSIS_ERROR_MEMORY = -2,
AST_ANALYSIS_ERROR_UNSUPPORTED_CAPTURE = -3,
AST_ANALYSIS_ERROR_UNSUPPORTED_PCRE = -4
AST_ANALYSIS_ERROR_UNSUPPORTED = -3
};

enum ast_analysis_res
Expand Down
2 changes: 1 addition & 1 deletion src/libre/dialect/comp.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ typedef struct ast *
re_dialect_parse_fun(re_getchar_fun *getchar, void *opaque,
const struct fsm_options *opt,
enum re_flags flags, int overlap,
struct re_err *err);
struct re_err *err, struct re_pos *end);

re_dialect_parse_fun parse_re_literal;
re_dialect_parse_fun parse_re_glob;
Expand Down
8 changes: 6 additions & 2 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: 6 additions & 2 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.

8 changes: 6 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.

8 changes: 6 additions & 2 deletions src/libre/dialect/native/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/native/parser.h

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

8 changes: 6 additions & 2 deletions src/libre/dialect/pcre/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/pcre/parser.h

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

8 changes: 6 additions & 2 deletions src/libre/dialect/sql/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/sql/parser.h

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

6 changes: 5 additions & 1 deletion src/libre/parser.act
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@
DIALECT_PARSE(re_getchar_fun *f, void *opaque,
const struct fsm_options *opt,
enum re_flags flags, int overlap,
struct re_err *err)
struct re_err *err, struct re_pos *end)
{
struct ast *ast;

Expand All @@ -1083,6 +1083,7 @@
struct LX_STATE *lx;

assert(f != NULL);
assert(end != NULL);

ast = ast_new();

Expand Down Expand Up @@ -1136,6 +1137,9 @@

DIALECT_ENTRY(&flags, lex_state, act_state, err, &ast->expr);

/* we output this for reporting errors found through AST analysis */
mark(end, &lx->end);

lx->free(lx->buf_opaque);

if (err->e != RE_ESUCCESS) {
Expand Down
Loading
Loading