[Lazarus] Using FPC parser/tokenizer for code formatting

Juha Manninen juha.manninen at phnet.fi
Mon May 31 12:21:11 CEST 2010


Adem, did you see my other mail earlier on this thread?
I suggested using codetools parser for the task and integrate the formatter in 
Lazarus.

I wrote:
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.


> If so, it brings us to the 'refactoring tool'; which --unless I am 
> mistaken-- there isn't one for FPC/Lazarus/others. If such a thing 
> doesn't exist, I can only guess it is simply because there isn't the 
> infrastructure suitably ready for it --how many of us would undertake 
> writing a fully-fledged parser engine before writing a refactoring tool 
> (which is hard enough) for non-commercial puposes? Same goes for code 
> analysis tools etc.

Codetools is a suitable infrastructure. It already implements some 
refactorings.
Learning it and integrating your formatter would be a challenging task but 
still more realistic and more sane than extracting the compiler's parser.
And it would be really cool to have such feature integrated in Lazarus.

What do you think?


Regards,
Juha




More information about the Lazarus mailing list