[Lazarus] PScanner tkComment token type

Frederic Da Vitoria davitofrg at gmail.com
Thu Nov 20 23:39:59 CET 2014


Hello,

I am starting to use fpprofiler. Because I did not know what parameters
should be sent to fpc, I decided to use fppinsert. At least one type of
"instrumented" code fails to compile:
// some code { some comment }
is wrongly changed into
{ some code { some comment }  }
which does not compile.

AFAICS the issue comes from the fact that PScanner only has the tkComment
type, so that when fppinsert tries to rebuild the code, it has no way to
know if it should use '//' or '{ }'.

Of course, I can't simply replace tkComment with 2 new distinct types,
there is probably some other code somewhere, not even in the Lazarus
repository, which uses the current set of token types.

I see at least 3 ways to solve my issue
1 - change fppinsert so that if it finds a bracket in the token, it should
use '//' - I don't like much this solution
2 - use a flag in TPascalScanner (something like CommentType) allowing to
know the type of comment if needed
3 - add 2 types tkCommentSlash and tkCommentBrackets into TToken plus an
option to TPOptions so that the calling code could choose to use the simple
tkComment or the more specific tkCommentSlash and tkCommentBrackets

I like the third method best, but I may be missing some drawbacks in these
options, so what would be the preferred way to do it? Maybe a fourth idea?

-- 
Frederic Da Vitoria
(davitof)

Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20141120/8dd0349b/attachment-0002.html>


More information about the Lazarus mailing list