h2pas.pas 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. {
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; either version 2 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  13. ****************************************************************************
  14. }
  15. program h2pas;
  16. {$H+}
  17. uses
  18. {$ifdef unix}
  19. cwstring,
  20. {$endif}
  21. classes, h2poptions, scan, h2pconst, scanbase,
  22. h2pbase, h2pparse, h2pout, h2ptypes;
  23. var
  24. SS : string;
  25. headerfile: Text;
  26. finaloutfile: Text;
  27. begin
  28. pointerprefix:=false;
  29. { Initialize }
  30. InitGlobals;
  31. EnableDebug;
  32. aktspace:='';
  33. block_type:=bt_no;
  34. IsExtern:=false;
  35. { Read commandline options }
  36. ProcessOptions;
  37. if not CompactMode then
  38. aktspace:=' ';
  39. { open input and output files }
  40. OpenInputFile;
  41. OpenOutputFiles;
  42. { Parse! }
  43. yyparse;
  44. { Write implementation if needed }
  45. if not(includefile) then
  46. begin
  47. writeln(outfile);
  48. writeln(outfile,'implementation');
  49. writeln(outfile);
  50. end;
  51. { here we have a problem if a line is longer than 255 chars !! }
  52. reset(implemfile);
  53. while not eof(implemfile) do
  54. begin
  55. readln(implemfile,SS);
  56. writeln(outfile,SS);
  57. end;
  58. if createdynlib then
  59. WriteLibraryInitialization;
  60. { write end of file }
  61. writeln(outfile);
  62. if not(includefile) then
  63. writeln(outfile,'end.');
  64. { close and erase tempfiles }
  65. CloseTempFiles;
  66. flush(outfile);
  67. {**** generate full file ****}
  68. assign(headerfile, 'ext4.tmp');
  69. {$I-}
  70. rewrite(headerfile);
  71. {$I+}
  72. if ioresult<>0 then
  73. begin
  74. writeln('file ext4.tmp could not be created!');
  75. halt(1);
  76. end;
  77. WriteFileHeader(HeaderFile);
  78. { Final output filename }
  79. assign(finaloutfile, outputfilename);
  80. {$I-}
  81. rewrite(finaloutfile);
  82. {$I+}
  83. if ioresult<>0 then
  84. begin
  85. writeln('file ',outputfilename,' could not be created!');
  86. halt(1);
  87. end;
  88. writeln(finaloutfile);
  89. { Read unit header file }
  90. reset(headerfile);
  91. while not eof(headerfile) do
  92. begin
  93. readln(headerfile,SS);
  94. writeln(finaloutfile,SS);
  95. end;
  96. { Read interface and implementation file }
  97. reset(outfile);
  98. while not eof(outfile) do
  99. begin
  100. readln(outfile,SS);
  101. writeln(finaloutfile,SS);
  102. end;
  103. close(HeaderFile);
  104. close(outfile);
  105. close(finaloutfile);
  106. erase(outfile);
  107. erase(headerfile);
  108. PTypeList.Free;
  109. freedynlibproc.free;
  110. loaddynlibproc.free;
  111. end.