Open mingodad opened 1 week ago
The problem of start repeating again is due to output to both stdout
and stderr
but probably we only want stderr
see the complete possible fix bellow:
-------------------------- src/include/lrstar_lexer.h --------------------------
index f02d187..8e42cc5 100644
@@ -88,7 +88,6 @@ public:
char *ls;
if (linenumb > linenumb_printed) {
if (linenumb == 1) {
- printf ( "\n");
fprintf (stderr, "\nInput File ...\n\n");
}
@@ -96,8 +95,9 @@ public:
linenumb_printed = linenumb;
if (*ls != 26) { // Not end of file?
- printf("%6d %s\n", linenumb, ls);
- fprintf(stderr, "%6d %s\n", linenumb, ls);
+ char *eol = ls;
+ while(*eol && *eol != '\n' && *eol != 26 ) ++eol;
+ fprintf(stderr, "%6d %.*s\n", linenumb, eol - ls, ls);
}
}
}
When testing
grammars/ANTLR
we get incorrect output fromlrstar_lexer::print_line
due to missing line termination/length see bello a possible fix for it: Possible fix:Using the https://github.com/thutt/lrstar/blob/24.0.018/grammars/ANTLR/test.input.txt :
With the fix:
But still there is something else going on because after line 118 it start repeating again once more: