Skip to content

Commit

Permalink
Warn about repeat/atleast body with known signal
Browse files Browse the repository at this point in the history
If the body of repeat/atleast always signals `t` then it will loop
forever, which is not desirable behaviour for a stemming algorithm.

If the body of repeat/atleast always signals `f` then it will never
loop, which seems clearly not what was intended.
  • Loading branch information
ojwb committed Oct 13, 2024
1 parent 4a88499 commit fdbf060
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions compiler/generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,13 @@ static void generate_repeat_or_atleast(struct generator * g, struct node * p, in
g->failure_label = new_label(g);
g->label_used = 0;
g->failure_keep_count = 0;

int possible_signals = check_possible_signals_list(g, p->left, p->type, 0);
if (possible_signals != -1) {
fprintf(stderr, "%s:%d: warning: body of '%s' always signals '%c'\n",
g->analyser->tokeniser->file, p->line_number,
atleast_case ? "atleast" : "repeat", possible_signals ? 't' : 'f');
}
generate(g, p->left);

if (atleast_case) w(g, "~Mi--;~N");
Expand Down

0 comments on commit fdbf060

Please sign in to comment.