Build in a C compiler

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Build in a C compiler

Rainer Stratmann
That would be great.

It is not that difficult.

{ = begin
} = end

and the other stuff is quite similar.

Pascal and C are close related.

It could be made with a compiler switch to determine if the compiler is in the
Pascal or in the C compiling mode.

No more need to translate (huge amount of) C code. :-)
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Build in a C compiler

leledumbo
Administrator
> That would be great.

Nope

> It is not that difficult.
> { = begin
> } = end
>
> and the other stuff is quite similar.

Syntax is easy, well once you have fully working preprocessor too, but how about libraries? How will you convert scanf/printf/puts/etc? What if it uses 3rd party libraries?

> Pascal and C are close related.

Only at the surface. There are many semantics differences that's not convertible at all. e.g.: ALL C expressions are potentially a boolean expression which in turn has boolean value, while in Pascal, only boolean expression has boolean value. At syntax level, there's no Pascal equivalent of C's comma (sequence) operator. Argument evaluation in C is strictly right to left, in Pascal it's up to the compiler. A silly but valid C statement:

printf("%d%d%d\n",i++,++i,++i,i++);

would be hard to convert to Pascal automatically without blowing out the compiler.
Reply | Threaded
Open this post in threaded view
|

Re: Build in a C compiler

Mark Morgan Lloyd-5
In reply to this post by Rainer Stratmann
Rainer Stratmann wrote:

> That would be great.
>
> It is not that difficult.
>
> { = begin
> } = end
>
> and the other stuff is quite similar.
>
> Pascal and C are close related.

No. Pascal and ALGOL are closely related, C and ALGOL are closely
related. Pascal and C are not so closely related.

If you're looking for commonality go and use ALGOL, rather than making
suggestions that are bound to result in a lot of sound and fury :-(

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Build in a C compiler

Maciej Izak
In reply to this post by leledumbo
2016-04-20 8:58 GMT+02:00 leledumbo <[hidden email]>:
At syntax level, there's no Pascal equivalent
of C's comma (sequence) operator. Argument evaluation in C is strictly right
to left, in Pascal it's up to the compiler. A silly but valid C statement:

printf("%d%d%d\n",i++,++i,++i,i++);

would be hard to convert to Pascal automatically without blowing out the
compiler.

C's comma (sequence) operator is possible to use in Pascal:

function printf(fmt: PAnsiChar): Integer; cdecl; varargs; external 'msvcrt.dll' name 'printf';

begin
  printf('%d%d%d'#10,1,2,3,4);
end.

--
Best regards,
Maciej Izak

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Build in a C compiler

leledumbo
Administrator
> C's comma (sequence) operator is possible to use in Pascal

But your example doesn't show its use, probabyl you don't understand which comma operator I mean. Comma is used both as operator and argument/parameter separator in C, what I mean is the former, what you show is the latter. Here's the wikipedia article to make you understand: https://en.wikipedia.org/wiki/Comma_operator
Reply | Threaded
Open this post in threaded view
|

Re: Build in a C compiler

Maciej Izak
2016-04-20 9:32 GMT+02:00 leledumbo <[hidden email]>:
But your example doesn't show its use, probabyl you don't understand which
comma operator I mean. Comma is used both as operator and argument/parameter
separator in C, what I mean is the former, what you show is the latter.
Here's the wikipedia article to make you understand:
https://en.wikipedia.org/wiki/Comma_operator

In that case you are right.

--
Best regards,
Maciej Izak

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Build in a C compiler

Marco van de Voort
In reply to this post by Mark Morgan Lloyd-5
In our previous episode, Mark Morgan Lloyd said:
> >
> > Pascal and C are close related.
>
> No. Pascal and ALGOL are closely related, C and ALGOL are closely
> related. Pascal and C are not so closely related.

Did ALGOL standarize the preprocessor? The high reliance on preprocessor is
often a hinderance in automated C conversion.
 
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Build in a C compiler

Rainer Stratmann
In reply to this post by Mark Morgan Lloyd-5
Am Mittwoch, 20. April 2016, 07:05:10 schrieb Mark Morgan Lloyd:
> No. Pascal and ALGOL are closely related, C and ALGOL are closely
> related. Pascal and C are not so closely related.

As you can see here Pascal, C, and Basic are very close related.

http://www.mikroe.com/compilers
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Build in a C compiler

Sven Barth-2

Am 20.04.2016 13:29 schrieb "Rainer Stratmann" <[hidden email]>:
>
> Am Mittwoch, 20. April 2016, 07:05:10 schrieb Mark Morgan Lloyd:
> > No. Pascal and ALGOL are closely related, C and ALGOL are closely
> > related. Pascal and C are not so closely related.
>
> As you can see here Pascal, C, and Basic are very close related.
>
> http://www.mikroe.com/compilers

By that logic C#, C++, VB.net and F# must be closely related as well, because Microsoft is providing compilers for all four...

No, C and Pascal are *not* closely related. And it surely isn't done with replacing begin and end with curly brackets!

Regards,
Sven


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Build in a C compiler

Mark Morgan Lloyd-5
In reply to this post by Rainer Stratmann
Rainer Stratmann wrote:
> Am Mittwoch, 20. April 2016, 07:05:10 schrieb Mark Morgan Lloyd:
>> No. Pascal and ALGOL are closely related, C and ALGOL are closely
>> related. Pascal and C are not so closely related.
>
> As you can see here Pascal, C, and Basic are very close related.
>
> http://www.mikroe.com/compilers

If you want to believe that BASIC- as originally implemented- and ALGOL
are related then go ahead and do so. But the politest thing I can say is
that it doesn't make you look particularly well-informed.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Build in a C compiler

Mark Morgan Lloyd-5
In reply to this post by Marco van de Voort
Marco van de Voort wrote:
> In our previous episode, Mark Morgan Lloyd said:
>>> Pascal and C are close related.
>> No. Pascal and ALGOL are closely related, C and ALGOL are closely
>> related. Pascal and C are not so closely related.
>
> Did ALGOL standarize the preprocessor? The high reliance on preprocessor is
> often a hinderance in automated C conversion.

Burroughs ALGOL (-60 implied) had include and define as part of the
language. I think they were later moved into a preprocessor to make it
possible to implement them on smaller computers.

Sorry, having a bad day so rushed.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Build in a C compiler

Rainer Stratmann
In reply to this post by Mark Morgan Lloyd-5
Am Mittwoch, 20. April 2016, 12:40:19 schrieb Mark Morgan Lloyd:
> > http://www.mikroe.com/compilers
>
> If you want to believe that BASIC- as originally implemented- and ALGOL
> are related then go ahead and do so. But the politest thing I can say is
> that it doesn't make you look particularly well-informed.

You can go to the company and say poliltely to them that they are not well
informed. I don't know if they take you serious.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Build in a C compiler

Jonas Maebe-2
In reply to this post by Rainer Stratmann
Hi.

Please continue this thread to the fpc-other list.

Thanks,


Jonas
FPC mailing lists admin
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Build in a C compiler

Ralf Quint
In reply to this post by Rainer Stratmann
On 4/20/2016 4:29 AM, Rainer Stratmann wrote:
> Am Mittwoch, 20. April 2016, 07:05:10 schrieb Mark Morgan Lloyd:
>> No. Pascal and ALGOL are closely related, C and ALGOL are closely
>> related. Pascal and C are not so closely related.
> As you can see here Pascal, C, and Basic are very close related.
>
> http://www.mikroe.com/compilers
>
I think you are jumping to conclusion here.
It is more likely that they spend the time in the past (they are around
for quite a while) to build their specific Basic, Pascal and C compiler
front end and just have to replace the actual code generator for each
architecture they support.
Just because a company offers compilers for various languages, with a
common IDE, doesn't mean that those compilers are "closely related".
Just take Borland of old, Turbo Pascal, Turbo C, Turbo Basic, Turbo
Prolog, they all used a very similar IDE but the actual compiler had all
completely different origins...

Ralf

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Build in a C compiler

el_es
In reply to this post by Rainer Stratmann
On 20/04/16 15:04, Rainer Stratmann wrote:
> Am Mittwoch, 20. April 2016, 12:40:19 schrieb Mark Morgan Lloyd:
>>> http://www.mikroe.com/compilers
>>
>> If you want to believe that BASIC- as originally implemented- and ALGOL
>> are related then go ahead and do so. But the politest thing I can say is
>> that it doesn't make you look particularly well-informed.
>
> You can go to the company and say poliltely to them that they are not well
> informed. I don't know if they take you serious.

Existence of Pascal front-end / parser/ IR creator for any compiler suite (e.g. clang, GNU, whatever)
does /not/ /really/ prove anything of the sort of you are implying.

-L.






_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal