From: Hans-Bernhard B. <br...@ph...> - 2000-10-02 17:43:20
|
On Mon, 2 Oct 2000, Petr Sorfa wrote: > Great work. We need to make sure that all your changes are a-ok with > some testing. I _know_ that not all of them are cosher. > Please commit your work so we can get down to it. Will do, but please expect it to cause problems. It definitely does, currently. One of them is that it breaks compatibility with 'lex' (by use of the exclusive initial states, if nothing else). I put some more work into it, over this weekend (but again forgot to bring the resulting scanner.l in, for showing it). Here's some points to be considered: *) The interactive vs. batch mode problems are gone, now, I think. *) -Cf mode still doesn't work. If it backs up, it sometimes will kill the contents of yytext conserved by previous yymore() calls. *) I haven't checked recently, but I doubt %pointer mode can ever be made to work by anything but a rewrite from scratch. *) part of the apparent speedup was due to a bug: the modified #include rule caused all Files included by <> not to be found, and thus they were left out of the cscope.out file. *) We have at least one major problem with this scanner, at large: yymore() usage and yyleng modifications in the same action. 'flex' explicitly disallows that. You can do either one, in a rule, but not both. But scanner.l relies very heavily on yymore(), in order to memorize all previously scanned text in yytext, where putcrossref() will read it as the end-of-line is processed. Actually, just about all the rules either 'goto more;' or 'goto eol;', eventually. *) Part of the problems stem from how we switch input methods between at least three different ones (normal mode, in-comment, and multicharconstant()). flex doesn't seem to deal with that very well, causing problems in the #include "file.h" handling, among others. It seems that it doesn't like us calling skipcomment_input() ourselvesy, rather than the full input(). That was where the "ytext"y problem in batch scanners I mentioned came from --- discarded readahead was re-delivered in incorrect order. *) My latest version uses lex rules to treat comments and string/char constants, too, but that confuses some of the search patterns, and there seems to be no way to just discard comments from yytext, this way. --> they end up in cscope.out, currently. It may be fundamentally impossible to parse C in a single pass, as scanner.l is trying to do. At the very least, we would need an input() method that unifies all three current input modes, properly, i.e. a 'pre-scanner' disguised as an input() routine. > > And endif with no #if right after it now needs special treatment (an > > #endif with nothing between it and the EOF causes a little glitch because > > of this rule --> will be echoed to stdout) This glitch is removed, now, I think, along with an incorrectness in line number counting, introduced by the same change. Hans-Bernhard Broeker (br...@ph...) Even if all the snow were burnt, ashes would remain. |