home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Developer / flex-2.4.6 / MISC / Macintosh / THINK_C_notes < prev    next >
Encoding:
Text File  |  1994-07-23  |  4.3 KB  |  95 lines  |  [TEXT/KAHL]

  1. Notes on the THINK C version of Flex 2.4.6
  2. Scott Hofmann 23-JUL-94
  3. Internet: scotth@visix.com
  4.  
  5. The only changes needed to compile Flex 2.4.6 under Symantec C++ 6.0 was
  6. to #include <console.h> in main.c and call ccommand() just before flexinit()
  7. in main(). The notes below are mostly of historical significance only; most
  8. of the workarounds below were to get around restrictions/problems in earlier
  9. versions of THINK C. The only section which still applies is Russell Finn's 
  10. description of how to make Flex generate output of type 'KAHL'. Also, 4-byte
  11. ints must be used by any project which uses Flex output.
  12.  
  13.  
  14. Notes on the THINK C version of Flex 2.3.7
  15. Jonas Barklund, 25-JAN-92
  16. Internet: jonas@csd.uu.se
  17.  
  18. I have merged the sources for Flex version 2.3.7 with the older version
  19. which was hacked for THINK C version 4. I have conditionalized the code
  20. so that I think it should work with both THINK C version 4 and 5 (for
  21. those of you who don't know: the THINK_C symbol is defined as 1 in version
  22. 4 and as 5 in version 5). I have put in some missing prototypes, so it
  23. compiles also with "require prototypes" on.
  24.  
  25. Most of the notes below still apply, in particular that about the MakeRes
  26. program.
  27.  
  28.  
  29. Notes on the THINK C version of Flex
  30. Russell S. Finn, 19-FEB-90
  31. Internet: rsfinn@athena.mit.edu, rsfinn@neutron.lcs.mit.edu
  32. CompuServe: 76377,1107
  33. GEnie: RSFINN
  34.  
  35. Flex appears to be covered by a copyright notice from the University of
  36. California, similar to the one covering Berkeley Unix; the Free Software
  37. Foundation is not part of the picture here.  So here is a version
  38. created with THINK C 4.0, along with the source code; as with the
  39. Bison distribution, I am including *all* of the source code I received
  40. with the package.
  41.  
  42. The current version (modification date January 25, 1990) has only the
  43. bare-bones interface provided by the THINK C library routine "ccommand",
  44. which allows the user to type a command line and to redirect the output.
  45. Perhaps someday I may try to implement a "real" user interface; perhaps
  46. not.
  47.  
  48. The only modifications made to the source file are surrounded by "#ifdef
  49. THINK_C"..."#endif"; in theory, then, these sources could be recompiled
  50. on another system if necessary.  These are the actual files modified:
  51. alloca.c, dfa.c, flexdef.h, main.c, misc.c, scan.c, sym.c.  Most of these
  52. changes were minor, and many of them would have been unnecessary if the
  53. original Flex source code had been written for an ANSI-compliant C compiler.
  54. In addition, the file "macutils.c" is completely new; see the discussion
  55. of "MakeRes" below.
  56.  
  57. THINK C users may find it convenient to have the output text files written
  58. by Flex be THINK C documents.  To do this, create a copy of the "ANSI"
  59. project called "ANSI-KAHL", and a copy of the file "fopen.c" called
  60. "fopen-KAHL.c".  In the copy, find the routine "setfiletype", and replace
  61. the lines:
  62.     if (!(oflag & F_BINARY))
  63.         pb.ioFlFndrInfo.fdType = 'TEXT';
  64. with the lines:
  65.     if (!(oflag & F_BINARY)) {
  66.         pb.ioFlFndrInfo.fdType = 'TEXT';
  67.         pb.ioFlFndrInfo.fdCreator = 'KAHL';
  68.         }
  69. Replace "fopen.c" with the new "fopen-KAHL.c", rebuild the new project
  70. "ANSI-KAHL", and use this project in the project file "Flex.π"
  71. instead of the "ANSI" project.
  72.  
  73. ** The "MakeRes" program
  74.  
  75. The output files created by Flex contain large amounts of preinitialized
  76. static data; the file "scan.c" contained in the Flex.π project is one
  77. such file.  However, the Macintosh architecture limits normal applications
  78. to 32K of global data.  In many cases (including Flex), this limit can
  79. be surpassed by the static data generated by Flex.
  80.  
  81. The solution I have implemented for the THINK C version of Flex is to
  82. extract the data tables from the Flex output file, and paste them into
  83. the file "MakeRes.c".  Then, by recompiling and running the program in
  84. the "MakeRes.π" project (it is not necessary to create an application),
  85. a resource file called "Flex.π.rsrc" is created in the current directory.
  86. The Flex output file "scan.c" has been modified to load the static data
  87. from the resource fork of the Flex application.  This is done by calling
  88. the "load_table" function, which is defined in the file "macutils.c".
  89.  
  90. In the application for which I needed Flex, the data tables were small
  91. enough that I didn't need to do this.  However, if your application
  92. requires you to do this, simply follow the model of "scan.c"; the MakeRes
  93. project and source code has been included for your use.
  94.  
  95.