[Lazarus] Using FPC parser/tokenizer for code formatting

Florian Klaempfl florian at freepascal.org
Mon May 31 13:57:08 CEST 2010


>>> Yet, as far as parser goes, it is the best solution. Because it is the
>>> originial source of information. Any new additions as well as
>>> corrections go in there --
>>>      
>> This is not necessarily true. Someone might hack in support for a new
>> procedure specifier. However, it is not guranteed that this one would be
>> exposed in any way to an external interface.
>>    
> But, the parser does produce a parse tree, doesn't it.

FPC doesn't produce a parse tree during compilation. The parser puts
declarations/definitions immediatly into the symtables, for code an
intermediate representation is created which is indeed a tree but no
more a parse tree because statements might already be transformed.

>>> it can also reorganize some comments in such constructs.
>>>      
>> The compiler simply discards comments and it has no infrastructure to
>> link comments in any way to code.
>>    
> Naturally, comments are no good for the compiler --so, I am assuming
> that the current parser does recognise comments but does not add them to
> the parse tree; if so, it is fine, all it will have to do is to add
> those nodes while the compiler still ignores them. Would that be too
> difficult to add?
> 

No idea, at least I expect a lot of pitfalls.




More information about the Lazarus mailing list