On 2010-05-31 14:36, Florian Klaempfl wrote:
Adem schrieb:
On 2010-05-31 05:36, Doug Chamberlin wrote:

Doug,

I have great interest in a parser-based code formatting tool. However,
I have doubt that using the compiler's parser is the best solution.

It may not be the best solution basically bexause it was written solely
for the compiler's needs. IOW, a very customized, special purpose one.

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.

And, it emits (or, could emit) events telling the calling module what went wrong and where (and get feedback whether to stop or continue).

If it does (can do) these basic things, it is good enough for non-compiler use. Is it not?

if something then begin
   something;
end else begin
   somethingelse;
end;

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?

--
Cheers,

Adem


--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to