h2pas.pas 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. (* Yacc parser template (TP Yacc V3.0), V1.2 6-17-91 AG *)
  2. (* global definitions: *)
  3. program h2pas;
  4. {$H+}
  5. uses
  6. {$ifdef unix}
  7. cwstring,
  8. {$endif}
  9. classes, h2poptions, scan, h2pconst, scanbase,
  10. h2pbase, h2pparse, h2pout, h2ptypes;
  11. var
  12. SS : string;
  13. headerfile: Text;
  14. finaloutfile: Text;
  15. begin
  16. pointerprefix:=false;
  17. { Initialize }
  18. InitGlobals;
  19. EnableDebug;
  20. aktspace:='';
  21. block_type:=bt_no;
  22. { Read commandline options }
  23. ProcessOptions;
  24. if not CompactMode then
  25. aktspace:=' ';
  26. { open input and output files }
  27. OpenInputFile;
  28. OpenOutputFiles;
  29. { Parse! }
  30. yyparse;
  31. { Write implementation if needed }
  32. if not(includefile) then
  33. begin
  34. writeln(outfile);
  35. writeln(outfile,'implementation');
  36. writeln(outfile);
  37. end;
  38. { here we have a problem if a line is longer than 255 chars !! }
  39. reset(implemfile);
  40. while not eof(implemfile) do
  41. begin
  42. readln(implemfile,SS);
  43. writeln(outfile,SS);
  44. end;
  45. if createdynlib then
  46. WriteLibraryInitialization;
  47. { write end of file }
  48. writeln(outfile);
  49. if not(includefile) then
  50. writeln(outfile,'end.');
  51. { close and erase tempfiles }
  52. CloseTempFiles;
  53. flush(outfile);
  54. {**** generate full file ****}
  55. assign(headerfile, 'ext4.tmp');
  56. {$I-}
  57. rewrite(headerfile);
  58. {$I+}
  59. if ioresult<>0 then
  60. begin
  61. writeln('file ext4.tmp could not be created!');
  62. halt(1);
  63. end;
  64. WriteFileHeader(HeaderFile);
  65. { Final output filename }
  66. assign(finaloutfile, outputfilename);
  67. {$I-}
  68. rewrite(finaloutfile);
  69. {$I+}
  70. if ioresult<>0 then
  71. begin
  72. writeln('file ',outputfilename,' could not be created!');
  73. halt(1);
  74. end;
  75. writeln(finaloutfile);
  76. { Read unit header file }
  77. reset(headerfile);
  78. while not eof(headerfile) do
  79. begin
  80. readln(headerfile,SS);
  81. writeln(finaloutfile,SS);
  82. end;
  83. { Read interface and implementation file }
  84. reset(outfile);
  85. while not eof(outfile) do
  86. begin
  87. readln(outfile,SS);
  88. writeln(finaloutfile,SS);
  89. end;
  90. close(HeaderFile);
  91. close(outfile);
  92. close(finaloutfile);
  93. erase(outfile);
  94. erase(headerfile);
  95. PTypeList.Free;
  96. freedynlibproc.free;
  97. loaddynlibproc.free;
  98. end.