On Sat, 21 Aug 2010, Graeme Geldenhuys wrote:

Hi,

I'm working on a project where I parse source code, then use the token
tree to modify the source code, and write new units out again.

I found a few limitation in fcl-passrc which prevents rebuilding
source code from a token tree, but it was easy to fix by introducing a
few new tokens. I'll submit a patch for this on Monday.

Anyway, while working with fcl-passrc I noticed something really
strange. The token list is in reverse order! Why is that?  So to
insert for instance a new uses clause in the Interface section, I have
to do something like this:

 for i := tokenlist.Count-1 downto 0 do
 begin
    if tokenlist[i].token = tkUses then
       ....
 end;

Otherwise it finds the Implemenation section's uses clause first.
It's not hard to work with it like this (if you know about it), I just
find it odd and wondered if there is any technical reason why the
token tree is in reverse.

Ehm. Are you sure this is about fcl-passrc ?

Where do you see the token list ? I searched for tokenlist, but didn't
see it anywhere ? The scanner doesnt produce a list, and the parser is
private.

Michael.

_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to