[Lazarus] Using FPC parser/tokenizer for code formatting

Juha Manninen juha.manninen at phnet.fi
Sat May 29 13:19:23 CEST 2010


Adem,

fpc-passrc was recommended by many. Is there some reason you don't want to use 
it? It can parse all fcl sources which proves it is good. Or, maybe I have 
missed something here...

There is one more parser around, in codetools. It is scanning and parsing code 
in the background when you use Lazarus. It is optimized for recovering from 
invalid code (which is being edited) and would suit perfectly for a code 
formatting as well. That is, if you want to integrate the formatting with 
Lazarus. It was not mentioned in your mail.

The problem is that codetools is a big and complicated piece of code. It seems 
only Mattias Gärtner really understands its internals.
Still, I guess there must have been an idea to integrate code formatting with 
codetools. How is it, Mattias?
It would be logical because the parsing is done already and formatting would 
be quick. When you start an external JCF, it has to parse the code again.

So, you have at least 3 choices:

1. fpc-passrc, a parser "officially" supported by FPC project. Relatively easy 
to use I guess (although I haven't used it myself).

2. Codetools integration. More challenging but would be very cool in Lazarus. 
Besides, if you learned codetools internal code, it would make already 2 
people who know it. :-)

3. Extract the parser somehow from FPC. IMO, it doesn't make sense. I don't 
know the compiler code much but I know it is a big interdependent chunk of 
code. Besides, your task is not really related to a compiler but to visual 
appearance, which is more in a domain of Lazarus.


Regards,
Juha




More information about the Lazarus mailing list