Software resources for "Compilers and Compiler Generators with C++" =================================================================== P.D. Terry, 5 November 1996 Introduction ------------ The software that accompanies this text was originally developed in Modula-2. It was subsequently converted to Turbo Pascal, and to C++. Although C++ code is used for most of the illustrations in the text, highly self-consistent source code in all three languages is to be found on this diskette. The software is also available in other formats (see below). The C++ source code was mainly developed under MS-DOS using Borland C++ 3.1. It has also been successfully compiled under Linux, using G++, the GNU C compiler. Although many of the case studies have also been tested with Turbo C++ 3.1, there appears to be a bug in that compiler that prevents the template set class from compiling correctly. The Turbo Pascal source code was developed to run on any version of Turbo Pascal from 5.5 onwards (although Delphi users should read the notes on Delphi below). However, it makes little use of OOP extensions. The Modula-2 source code should be immediately usable on MS-DOS based systems using the shareware compiler marketed by Fitted Software Tools (FST), the Stony Brook Modula-2 compiler marketed by Gogesch Micro Systems, Inc., or the TopSpeed Modula-2 compilers developed by Jensen and Partners International (JPI) and now marketed by Clarion Software. It will also compile unchanged under Gardens Point Modula-2 on a wide range of systems. Unpacking the software ---------------------- The software on the diskette is supplied in the form of compressed, self-extracting MS-DOS executable files. There are eight of these files. The sizes shown are the approximate disk space needed after unpacking to a hard drive with 4K sector sizes. CSOURCES.EXE - sources written in C++ (1.9M) PSOURCES.EXE - sources written in Turbo Pascal (1.7M) MSOURCES.EXE - sources written in Modula-2 (1.9M) COMMON.EXE - language independent files (650K) FILEIO.EXE - support library for Modula-2 sources (235K) COCORC.EXE - Coco/R for C/C++ (262K) COCORP.EXE - Coco/R for Turbo Pascal (195K) COCORM.EXE - Coco/R for Modula-2 (210K) To unpack the software, simply follow the steps below. Example MS-DOS commands are shown (these may need alteration, depending on the configuration of your computer). Windows users may follow an equivalent sequence of operations from within the File Manager. - Make a backup copy of the diskette and keep the original in a safe place. - Proceed to unpack (a) the language specific case studies (b) the language independent files (c) the language specific compiler generator and, if you are a Modula-2 user, (d) the FileIO library. Unpacking the case study software --------------------------------- - Create a directory to act as the root directory for storing your sources, for example MKDIR C:\SRCES (C:\SRCES is used as an example only - please yourself in this regard.) - Log onto this as the working directory CD C:\SRCES - Insert the source diskette into the A: drive and unpack the chosen source file to the C:\SRCES directory. For example, for the C++ sources, execute A:\CSOURCES.EXE - You must also unpack the language independent files to the same directory by executing A:\COMMON.EXE These steps will create a small directory hierarchy under the C:\SRCES directory, in which various subdirectories will appear, usually one for each chapter. For example, you will find the source code for the programs in chapter 10 in the directory C:\SRCES\CHAP10\CPP (for the C++ versions) or the directory C:\SRCES\CHAP10\MODULA (for the Modula-2 versions). IMPORTANT - Once you have unpacked the system, read the file C:\SRCES\README.SRC for further details on how the directories are laid out. - You may unpack all three of the language specific sources into the same directory tree if you wish - the C++, Modula-2 and Pascal sources are stored in separate directories under the directory for each chapter. - If you are using Borland C++ you may need to edit the configuration file C:\SRCES\COMMON\TURBOC.CFG to reflect the correct paths and options for your compiler. Unpacking the compiler generator Coco/R --------------------------------------- - Create a directory to act as the root directory for your chosen version of Coco/R, for example MKDIR C:\COCO - Log onto this as the working directory CD C:\COCO - Insert the source diskette into the A: drive and unpack the chosen Coco/R system to the C:\COCO directory. For example, for the C++ version, execute A:\COCORC.EXE This will create a small directory hierarchy under the C:\COCO directory, containing the various components of Coco/R. IMPORTANT - Once you have unpacked the system, read the file C:\COCO\README.1ST for further details on how the directories are laid out, and how to complete the installation of Coco/R so that it can be executed easily. - If you wish to install more than one version of Coco/R, please do so into separate directories, for example C:\COCOC for the C++ version, C:\COCOM for the Modula-2 version, C:\COCOP for the Pascal version. - If you are using Borland C++ you may need to edit the configuration file C:\SRCES\COMMON\TURBOC.CFG to reflect the correct paths and options for your compiler. Setting up the software for a particular case study --------------------------------------------------- Installation of many (but not all) of the case studies requires you simply to - Log onto to the appropriate source drive and subdirectory, for example C: CD C:\SRCES\CHAP15\CPP - Issue the command SETUP with no parameters. This will indicate what parameters might be added to the command to provide a variant appropriate for the case studies of that chapter. - For example, follow this by obeying a SETUP command like SETUP C:\WORK 5 where C:\WORK is a directory that will be created if necessary, and into which the appropriate components for SETUP option 5 will be copied. - Log onto the working directory CD C:\WORK - Issue the MAKE command (C++), or equivalent Coco/R and compiler commands (Pascal or Modula-2) to compile the selected case study. IMPORTANT - The "makefiles" supplied are intended for use with Borland C++ release 3.1; they may need slight alteration. The configuration file TURBOC.CFG may also need alteration. - It is crucial that you are logged onto an appropriate directory before you issue the SETUP command. If this is not the case, you might execute some other SETUP command and become confused! - Some of the simpler case studies - typically those consisting of only one source file - are not managed by a SETUP process. Consult the file C:\SRCES\README.SRC for further details. The FileIO library (Modula-2 users only) ---------------------------------------- Scanners, parsers, and compilers created by Coco/R assume that you will use the I/O module FileIO. You will need to install and compile the version of FileIO that matches your compiler. On the diskette you will find a self-extracting file FILEIO.EXE that contains the sources of FileIO for a variety of MS-DOS compilers. - Make a directory to contain these sources MKDIR C:\FILEIO - Log onto this as the working directory CD C:\FILEIO - Place the source diskette in the A: drive and unpack the FILEIO.EXE file to the C:\FILEIO directory A:\FILEIO.EXE This will create a small directory hierarchy under the C:\FILEIO directory, in which various subdirectories will appear, one for each compiler. In the C:\FILEIO directory you will find a definition module FILEIO.DEF, and in the subdirectories of C:\FILEIO you will find various compiler specific modules, including FILEIO.MOD. You will need to proceed as follows, on the assumption that you have a "working" directory C:\WORK in which you normally develop programs. (You may, of course, find it preferable to install FileIO in the library directory or directories for your Modula-2 compiler.) CD C:\WORK COPY C:\FILEIO\FILEIO.DEF COPY C:\FILEIO\xxx where xxx = JPI (TopSpeed compilers) FST (Fitted Systems Tools compilers) LOG (Logitech compilers) STO (StonyBrook compilers) GPMPC (Gardens Point PC compiler) Follow this by compiling FILEIO.DEF and FILEIO.MOD. The sources supplied will act as models of implementations for compilers not mentioned above. In case of difficulty, please contact the author. Delphi users ------------ The Turbo Pascal case studies, and the output from Coco/R for Pascal will not compile directly under Delphi. They require WinCrt to be added to the list of units "used" (edit the compiler frame files for Coco/R). Furthermore those systems (like the assemblers and compilers) that provide for interactive input/output in their interpreters require use of WinCrt.AssignCrt instead of the current calls to Assign with an empty filename (for example in STKMC.PAS and MC.PAS). LHA213.EXE ---------- The self-extracting files on the diskette were compressed and packed using the freely available program LHA.EXE developed by Haruyasu Yoshizaki. In terms of the distribution agreement for this program, the complete package for LHA.EXE is itself supplied as a self-extracting executable, LHA213.EXE. You are quite welcome to unpack this file, although it is not needed for the operations described above. Obtaining the software with ftp ------------------------------- The latest versions of the source code for the programs in this book, and various related other files of interest are available by anonymous ftp from the author's server site www.scifac.ru.ac.za/compilers Look for the READ.ME files for details of what to get, how to unpack the files, and for differences from the software on this diskette. The latest versions of Coco/R for a variety of languages and operating systems should be available from the following servers Europe: ftp.ssw.uni-linz.ac.at:/pub/Coco USA: ftp.psg.com:/pub/modula-2/coco Central America: uvg.edu.gt:/pub/coco Australia: ftp.fit.qut.edu.au:/pub/coco South Africa: www.scifac.ru.ac.za/coco/ Look for the READ.ME files for details of what to get and how to unpack the kits. Disclaimer ---------- While every attempt has been made to ensure that the software on this diskette (and the versions available by ftp) performs properly, the author and publisher can accept no liability for any damage or loss, including special, incidental, or consequential, caused by the use of the software, directly or indirectly. However, please bring any problems that you may experience to the attention of the author: Pat Terry Computer Science Department Rhodes University GRAHAMSTOWN 6140 South Africa Tel: +27-46-603-8291/2 FAX: +27-46-636-1915 e-mail: p.terry@ru.ac.za Trademarks ---------- Products and services that are referred to in this book may be either trademarks and/or registered trademarks of their respective owners. The Publisher and author make no claim to these trademarks. Borland C++, Turbo C++, Delphi and Turbo Pascal are trademarks of Borland International Corporation. GNU C Compiler is a trademark of the Free Software Foundation. IBM and IBM PC are trademarks of International Business Machines Corporation. Microsoft, MS and MS-DOS are registered trademarks, and Windows is a trademark of Microsoft Corporation. Stony Brook Software and QuickMod are trademarks of Gogesch Micro Systems, Inc. TopSpeed is a registered trademark of Jensen and Partners, International. Any other trademarks inadvertently used here are also duly acknowledged. =END=