When testing grammars/ANTLR we get incorrect output from lrstar_lexer::print_line due to missing line termination/length see bello a possible fix for it:
Possible fix:
-------------------------- src/include/lrstar_lexer.h --------------------------
index f02d187..57d3802 100644
@@ -96,8 +96,10 @@ 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;
+ printf("%6d %.*s\n", linenumb, eol - ls, ls);
+ fprintf(stderr, "%6d %.*s\n", linenumb, eol - ls, ls);
}
}
}
Using the https://github.com/thutt/lrstar/blob/24.0.018/grammars/ANTLR/test.input.txt :
./antlr --output /dev/null test.input.txt
==26303==
Input File ...
ANTLR parser.
1 /*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 Sam Harwell
* All rights reserved.
...
With the fix:
./antlr --output /dev/null test.input.txt
==26804==
Input File ...
1 /*
2 * [The "BSD license"]
3 * Copyright (c) 2013 Terence Parr
4 * Copyright (c) 2013 Sam Harwell
5 * All rights reserved.
...
But still there is something else going on because after line 118 it start repeating again once more:
114 : AT (actionScopeName COLONCOLON)? identifier actionBlock
115 ;
116
117 // Scope names could collide with keywords; allow them as ids for action scopes
118 actionScopeName
ANTLR parser.
1 /*
2 * [The "BSD license"]
3 * Copyright (c) 2013 Terence Parr
4 * Copyright (c) 2013 Sam Harwell
5 * All rights reserved.
When testing
grammars/ANTLRwe get incorrect output fromlrstar_lexer::print_linedue 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: