[Lazarus] Parser

Michael Van Canneyt michael at freepascal.org
Thu Jul 1 09:23:08 CEST 2010



On Thu, 1 Jul 2010, Hans-Peter Diettrich wrote:

> Michael Van Canneyt schrieb:
>
>>> ... because it increases the maintainance work on fpc. Even with one
>>> front end only we are almost unable to keep the issue count under
>>> control. I'am pretty sure that more front ends will be rejected without
>>> more people working on bug fixing in fpc.
>> 
>> Exactly. We can barely cope as it is. If we compiled C as well, we'd get 
>> bug reports about glibc or whatever C library fails to compile.
>
> I've already translated a couple of available C libraries into Pascal, using 
> ToPas. There exist only a few constructs that do not translate into Pascal 
> directly (bitfields...), but their addition to the compiler (code generators) 
> should not be a problem - in the easiest case they can be emulated in pure 
> OPL, not affecting the code generators at all. At statement and procedure 
> level most languages don't differ much, and FPC even has the C operators 
> already implemented. Since the ToPas C parser is written in OPL, its 
> adaptation should be easy. This may become my next project, after the 
> parser...

You are missing the point. The point is not DOING it. the point is the
support afterwards. After 15 years of FPC support, I have some experience.
Even now, bugs creep up that are seemingly SO basic:
W : word;
begin
   w:=0;
   for i:=0 to pred(w) do // What to do ?
end;

The compiler's behaviour is different from Delphi. This is a bug, we must
deal with it. After 15 years. So, if the compiler produces different code
in some C library, then we'll have to deal with it. People will report it.
So no, thank you.

And frankly, I would not use topas as a reference. I tried it on some - to
my taste - simple C code and it failed horribly. I was unable to solve it, 
also because it lacks all documentation. This is not the kind of standard 
I would like to see in FPC.

So I'd say that you already failed on something more simple than FPC
compiling all languages. First get topas to convert all C code out 
there without a glitch, then we'll talk again.

Do not get me wrong: I think topas is a technically nice product. I admire
that you can write the code to do it, to make it work (more or less). That is
not the point; The point is that writing the code is actually the least of
the problems. It's what comes afterwards.

>
>> And, frankly, the project is called "Free Pascal" for a simple reason: it 
>> is a *Pascal* compiler and a *Pascal* project.
>
> Microsoft started with a couple of compilers, until they implemented a common 
> back-end for all "Visual" languages, and later they invented the CLR. gcc 
> also allows to add FEs for a certain class of languages, so why should FPC 
> not become another Free Portable Compiler?

Because Microsoft has 1500 people, GCC has several companies behind it.
FPC has 4 people technically savvy in compiler matters.

>
> I wonder how somebody can say "it's hard to do", without having even tried 
> ;-)

I didn't say it is hard. I say that the support for it would kill us and the
project.

This is the problem of most open source out there:  Enthousiasts write
it. And then the good is separated from the bad: supporting it for many 
years. Patiently fixing all bugs. And there will be lots.

FPC existed before the term 'Open Source' existed.  That means something.

Michael.




More information about the Lazarus mailing list