Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2016-04

Build in a C compiler

15 messages · 9 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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. :-)

Reply by email

leledumbo
to Rainer Stratmann
That would be great.

Nope

Show quoted text 5 lines
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 .: 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.

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Build-in-a-C-compiler-tp5725008p5725010.html Sent from the Free Pascal - General mailing list .

Reply by email

Mark Morgan Lloyd
to Rainer Stratmann: That would be great. It is not that difficult. { = begin } = end and the other stuff is…
Rainer Stratmann wrote 10 lines
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]

Reply by email

Maciej Izak
to leledumbo: Nope Syntax is easy, well once you have fully working preprocessor too, but how about…

2016-04-20 8:58 GMT+02:00 leledumbo :

Show quoted text 10 lines
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

Reply by email

leledumbo
to Maciej Izak
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

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Build-in-a-C-compiler-tp5725008p5725013.html Sent from the Free Pascal - General mailing list .

Reply by email

Maciej Izak
to leledumbo

2016-04-20 9:32 GMT+02:00 leledumbo :

Show quoted text 6 lines
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

Reply by email

Marco van de Voort
to Mark Morgan Lloyd: No. Pascal and ALGOL are closely related, C and ALGOL are closely related. Pascal and C…

In our previous episode, Mark Morgan Lloyd said:

Show quoted text 5 lines
> > 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.

Reply by email

Sven Barth
to Rainer Stratmann

Am 20.04.2016 13:29 schrieb "Rainer Stratmann" <

Show quoted text 9 lines
: 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

Reply by email

Mark Morgan Lloyd
to Rainer Stratmann: As you can see here Pascal, C, and Basic are very close related.…
Rainer Stratmann wrote 7 lines
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]

Reply by email

Mark Morgan Lloyd
to Marco van de Voort: In our previous episode, Mark Morgan Lloyd said: Did ALGOL standarize the preprocessor?…
Marco van de Voort wrote 7 lines
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]

Reply by email

Rainer Stratmann
to Mark Morgan Lloyd: If you want to believe that BASIC- as originally implemented- and ALGOL are related then…
Mark Morgan Lloyd wrote 5 lines
> 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.

Reply by email

Ralf Quint
to Rainer Stratmann: As you can see here Pascal, C, and Basic are very close related.…
Rainer Stratmann wrote 7 lines
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

Reply by email

Lukasz Sokol
to Rainer Stratmann: You can go to the company and say poliltely to them that they are not well informed. I…
Rainer Stratmann wrote 9 lines
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.

Reply by email