2
0

h2pas.pas 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. { Read commandline options }
  35. ProcessOptions;
  36. if not CompactMode then
  37. aktspace:=' ';
  38. { open input and output files }
  39. OpenInputFile;
  40. OpenOutputFiles;
  41. { Parse! }
  42. yyparse;
  43. { Write implementation if needed }
  44. if not(includefile) then
  45. begin
  46. writeln(outfile);
  47. writeln(outfile,'implementation');
  48. writeln(outfile);
  49. end;
  50. { here we have a problem if a line is longer than 255 chars !! }
  51. reset(implemfile);
  52. while not eof(implemfile) do
  53. begin
  54. readln(implemfile,SS);
  55. writeln(outfile,SS);
  56. end;
  57. if createdynlib then
  58. WriteLibraryInitialization;
  59. { write end of file }
  60. writeln(outfile);
  61. if not(includefile) then
  62. writeln(outfile,'end.');
  63. { close and erase tempfiles }
  64. CloseTempFiles;
  65. flush(outfile);
  66. {**** generate full file ****}
  67. assign(headerfile, 'ext4.tmp');
  68. {$I-}
  69. rewrite(headerfile);
  70. {$I+}
  71. if ioresult<>0 then
  72. begin
  73. writeln('file ext4.tmp could not be created!');
  74. halt(1);
  75. end;
  76. WriteFileHeader(HeaderFile);
  77. { Final output filename }
  78. assign(finaloutfile, outputfilename);
  79. {$I-}
  80. rewrite(finaloutfile);
  81. {$I+}
  82. if ioresult<>0 then
  83. begin
  84. writeln('file ',outputfilename,' could not be created!');
  85. halt(1);
  86. end;
  87. writeln(finaloutfile);
  88. { Read unit header file }
  89. reset(headerfile);
  90. while not eof(headerfile) do
  91. begin
  92. readln(headerfile,SS);
  93. writeln(finaloutfile,SS);
  94. end;
  95. { Read interface and implementation file }
  96. reset(outfile);
  97. while not eof(outfile) do
  98. begin
  99. readln(outfile,SS);
  100. writeln(finaloutfile,SS);
  101. end;
  102. close(HeaderFile);
  103. close(outfile);
  104. close(finaloutfile);
  105. erase(outfile);
  106. erase(headerfile);
  107. PTypeList.Free;
  108. freedynlibproc.free;
  109. loaddynlibproc.free;
  110. end.