Certain grammars result in the generation of a parser which may enter an infinite loop. I've noticed that in version 1.2.2 (but not in 1.2.1), a warning is shown: packcc: Warning: Infinite loop detected in generated code.
Also, certain grammars result in the generation of a parser which may quickly exhaust memory and then terminate. I saw no warning this time.
Can these be fixed? Needless to say these possibilities are offputting.
Here's a minimal example to recreate both:
Usage: echo -n -e "aaaa" | ./kaboom
%prefix "kaboom"
%header
{
static void my_pcc_error(void);
#define PCC_ERROR(auxil) my_pcc_error()
}
# top <- ( "a" ([ \t]*) * ) ## Infinite loop
top <- ( "a" ws * ) ## Out-of-memory error
ws <- [ \t]*
%%
// #include <stdlib.h>
#include <stdio.h>
static void my_pcc_error(void) {
fputs("Syntax error.\n", stderr);
}
int main(int argc, char *argv[]) {
kaboom_context_t *ctx = kaboom_create(NULL);
puts("Time to call kaboom_parse...");
const int textRemains = kaboom_parse(ctx, NULL);
/* We never get this far */
puts(textRemains ? "Text remains" : "No text remains");
kaboom_destroy(ctx);
return 0;
}
Certain grammars result in the generation of a parser which may enter an infinite loop. I've noticed that in version 1.2.2 (but not in 1.2.1), a warning is shown: packcc: Warning: Infinite loop detected in generated code.
Also, certain grammars result in the generation of a parser which may quickly exhaust memory and then terminate. I saw no warning this time.
Can these be fixed? Needless to say these possibilities are offputting.
Here's a minimal example to recreate both:
Usage:
echo -n -e "aaaa" | ./kaboom
edit: enabled syntax highlighting