DosWorld / ppro

Pascal Pro - free 32-bit pascal compiler
GNU General Public License v3.0
10 stars 2 forks source link

Two or three questions and some suggestions #1

Open electric-socket opened 2 years ago

electric-socket commented 2 years ago

I've been fascinated by Pascal compiler sources literally for decades (I started back around 1979). So when I found yours - among a few others - I was quite excited and I am quite impressed. I would like to ask a few questions.

  1. Was your intent to make the program "self-hosting," i.e. capable of compiling itself?
  2. The way you have {$IFDEF PPRO to insert () after procedure calls seems to imply that.
  3. I have seen other your code invoke procedures using naked procedure calls without the () at the end, and I was curious why.
  4. Free Pascal will allow () at the end of a procedure call, e.g,
  5. I think the procedure tScanner.SkipComments in file scanner.pas . I felt the way you did that, implementing a means to both handle compiler directives and nested comments, was absolutely brilliant.
  6. I am wondering why you only handle the newer { brace comment }, but not supporting the older ( block style ) comments; most compilers handle both, because people use both.
  7. If you want to handle the older style block comment, it does take a bit of work. You have three options: have the system internally convert ( to { (and ) to } before it is processed (probably way too much work); handle (* as two characters in the check routine; do a bit of finagling in the (second) where loop in that procedure.
  8. If you're interested in how I would implement this if you would consider using it, let me know; if not, fair enough.
  9. There is one thing in the code I am curious about. It's in function ReadSwitchName at line 419:
      C := UpCase(NextChar);
      while ((C >= 'A') and (C <= 'Z')) or (C = '_') do
        begin
          Str := Str + C;
          C := NextChar{$IFDEF PPRO}(){$ENDIF};
        end
  10. I presume switches are not case sensitive. Looking at the code above, it will capitalize the first letter and exits at the first character that's not an upper-case letter. Is it that switches are only one letter, or if more than one, anything after that that isn't in upper case is not part of the swirch? I would think {$ifdef should work same as {$IFDEF. If that was your intent, change
          C := NextChar{$IFDEF PPRO}(){$ENDIF};

    to

          C := UpCase(NextChar{$IFDEF PPRO}(){$ENDIF});
  11. I have a couple of others to recommend that you might look at for ideas.
  12. First is Mad-Pascal https://github.com/tebe6502/Mad-Pascal that has a cross-compiler for the 6502 similar to yours in terms of functionality. it is a monolithic single application file that numbers over 45,000 lines of code (about 1MB for that file alone, not counting some include files it uses. I'm thinking that program might also be useful as a self-compiling application.
  13. My own app,https://github.com/electric-socket/xdpw , a fork of Vasily Tereskov's XDPascal for Wundows, which is self-hosting (it will compile itself) and even builds applications directly, producing an .EXE file. Since it generates an executable directly, you can see how it does it. I’ve made a few changes and some fixes, but I had to set it aside to work on a different program.
  14. Fact is, where your compiler is at is the direction I wanted to go with XDPascal, and having seen what you and MadPascal (and others) have done, I think I'm going to look into them and see if I can learn something.

Thank you for your attention. Paul

"Understanding of things by me is only made possible by people — who read my comments — like you."

Thank you. Paul Robinson paul@paul-robinson.us .

DosWorld commented 2 years ago

At first, i must say - this is not my compiler, i am not author. I find it on russian file storages and publish it. Small problem with license - i known only "Pascal Pro is 32-bit free compile. You didn't need to pay for using that". So, i dont make design - will continue work with it or stop.

My own research. Yes, i want create compiler for HLL (high level language) like Pascal (or Basic). I am try to do it many times and have a fail. So, now, I go in reverse way - i am start work from investigation output file formats (see https://github.com/DosWorld/rtools ) because output file (like obj and exe) can make limitation from first steps. Rtools is work but not enough clean, so i am in progress.