On Fri, 1 May 2020 12:31:26 +0700 Ryan Joseph via fpc-pascal <fpc-pascal@lists.freepascal.org> wrote:
> Stuck on another code tools problem. > > I've been using code like this to find words at node offsets and this > works well until there are $ifdefs in the file and then the text > position getting offset and fail to return the correct identifiers. > > GetIdentifier(@Code.Source[Node.StartPos]); The Node.StartPos are referring to the Tool.Scanner.CleanedSrc, which is the code stripped of skipped $ifdef ranges and include files included. > How should this be resolved? I don't see there is a copy of the > actual text parsed (without ifdefs) so I don't know how to reference > the text that the parser actually used. You can convert the cleanpos to actual file position using Tool.CleanPosToCodePos Mattias _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal