© P.D. Terry, Rhodes University, 5 November 1996 (Revised February 2021)
October 1999: It is likely that you wish to obtain the files that accompany this book and install the system from this web site rather than from a diskette! In this case, any references here or in the book to files of the form
A:SOMEFILEshould be changed to
X:SOMEFILEwhere X: is the path to the directory/folder in which the source files reside.
The page you are reading now describes the layout of the directory structure set up after you have installed the sources for the book onto your system
C:\SRCESthat you have installed a version of Coco/R onto a directory
C:\COCOand that you will be using a working directory for a case study of interest
C:\WORKThese names are suggestions only; you are free to use different volumes (C:, D:, E: ...) and different directories if you prefer.
In the directory C:\SRCES you should find
README.SRC - this file CHECK.PAS - Source of CHECK CHECK.EXE - Executable to assist with the SETUP process (This is invoked automatically by the SETUP process) CONVERT.PAS - Source of CONVERT CONVERT.EXE - Program to convert text files between operating systems (translating line marks appropriate to the O/S in use)Typing the command CONVERT with no parameters gives details of use.
Example: CONVERT DOS.CPP APPLE.CPP 2
* CHAP04 - Machine emulation CHAP05 - Language specification * CHAP06 - Simple assemblers * CHAP07 - Advanced assembler features CHAP08 - Grammars and their classification * CHAP10 - Parser and scanner construction * CHAP11 - Syntax directed translation * CHAP12 - Using Coco/R - overview * CHAP13 - Using Coco/R - case studies * CHAP14 - A simple compiler - the front end (Clang level 1) * CHAP15 - A simple compiler - the back end (Clang level 1) * CHAP15.ASM - A simple compiler - generating assembler code * CHAP16D - Simple block structure (using a display) (Clang level 2) * CHAP16S - Simple block structure (using a static link) * CHAP17 - Parameters and functions (Clang level 3) * CHAP18 - Concurrent programming (Clang level 4) * COMMON - Files that are common to many Clang case studies ASMBLER - A macro assembler with full-screen interpreter HASH - Investigation of minimal perfect hash functions (Chapter 14) * TOPSY - Suggestions for the Topsy project (Chapters 14, 15)Those subdirectories marked with an * contain further subdirectories depending on the implementation language. For example, once you have unpacked the sources, you will find that they appear in directories like
C:\SRCES\CHAP18\CPP for the C++ versionsor, correspondingly
C:\SRCES\CHAP18\PASCAL for the Pascal versions C:\SRCES\CHAP18\MODULA for the Modula-2 versions
C: CD C:\SRCES\CHAP15\CPP
SETUPwith 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 5where C:\WORK is a directory that will be created if necessary, and into which the appropriate components for SETUP option 5 will be copied.
CD C:\WORKand issuing the MAKE command (C++) or equivalent compiler commands (Pascal or Modula-2) to compile the selected case study.
IMPORTANT
C: CD C:\SRCES\CHAP15\CPP DEL C:\WORK\*.* or RD C:\WORK\ /S SETUP C:\WORK 5
Some of the simpler case studies - typically those consisting of only one source file - are not managed by a SETUP process.
In cases of difficulty, please contact the author
Pat Terry
Computer Science Department
Rhodes University
MAKHANDA / GRAHAMSTOWN 6140
South Africa
email: p.terry@ru.ac.za>
CHAP04\x\SETUP.BAT - Execute CHAP04\x\SETUP.BAT to piece together a complete case studyThe following files pertain to the single-accumulator machine (section 4.3)
CHAP04\BITS.ASM - Count the bits in a number (simple code) CHAP04\BITS.MC - Count the bits in a number (core image) CHAP04\SIEVE.MC - Sieve of Eratosthenes (core image) CHAP04\x\AS.* - Assembler (using mnemonics) CHAP04\x\AS0.* - Loader (from core image) CHAP04\x\ASM.MK - Makefile for Borland C++ CHAP04\x\ASSEMBLE.* - Main routine CHAP04\x\MC.* - Single-accumulator machine interpreter CHAP04\x\MISC.H - Miscellaneous routinesThe following files pertain to the stack based machine (section 4.4)
CHAP04\LSMALL.STK - Find largest and smallest in a sequence CHAP04\x\STACKASM.* - Main routine CHAP04\x\STACKASM.MK - Makefile for Borland C++ CHAP04\x\STKASM.* - Rudimentary assembler CHAP04\x\STKMC.* - Stack machine interpreter
CHAP05\*.ATG - Various sample Coco/R grammars CHAP05\COCOL.ATG - Cocol/R expressed in Cocol/R (section 5.9.5)
CHAP06\x\SETUP.BAT - Execute CHAP06\x\SETUP.BAT to piece together a complete case study CHAP06\ASM*.ATG - Grammars for the ASSEMBLER language CHAP06\*.ASM - Simple source examples CHAP06\x\AS1.* - One-pass assembler CHAP06\x\AS2.* - Two-pass assembler CHAP06\x\ASM.MK - Makefile for Borland C++ CHAP06\x\ASSEMBLE.* - Main routine CHAP06\x\LA.* - Lexical analyzer CHAP06\x\MISC.H - Miscellaneous routines CHAP06\x\SA.* - Syntax analyzer CHAP06\x\SH.* - Source handler CHAP06\x\ST1.* - Symbol table handler - One-pass assembler CHAP06\x\ST2.* - Symbol table handler - Two-pass assembler CHAP06\x\TP.* - Definitions of special types
CHAP07\x\SETUP.BAT - Execute CHAP07\x\SETUP.BAT to piece together a complete case study CHAP07\*.ASM - Simple source examples CHAP07\x\AS.* - One-pass assembler CHAP07\x\ASMBASE.H - One-pass assembler base class CHAP07\x\ASSEMBLE.* - Main routine CHAP07\x\LA.* - Lexical analyzer CHAP07\x\MAKEFILE - Make file for Borland C++ CHAP07\x\MH.* - Macro handler CHAP07\x\MISC.H - Miscellaneous routines CHAP07\x\SA.* - Syntax analyzer CHAP07\x\SET.H - Template set class (C++) CHAP07\x\SH.* - Source handler CHAP07\x\ST.* - Symbol table handler (hashed) CHAP07\x\ST2.* - Symbol table handler (simple linked list) CHAP07\x\TP.* - Definitions of special types
CHAP08\CLANG1.ATG - Clang grammar in BNF (section 8.7.1) CHAP08\CLANG2.ATG - Clang grammar in EBNF (section 8.7.2) CHAP08\QUERY.CLN - Sample Clang program with unclear semantics CHAP08\VOTE.CLN - Sample Clang program CHAP08\VOTE.TOP - Sample Topsy program
CHAP10\x\LRDATA - Data for LR Parser demonstration CHAP10\x\LRPARSER.* - Toy LR parser program CHAP10\x\PARSER1.* - Parser from section 10.2 (no nested routines) CHAP10\x\PARSER2.* - Parser from section 10.2 (equivalent grammar) CHAP10\x\PARSER3.* - Parser from section 10.2 (Pascal/Modula with nested routines)
CHAP11\x\CLASS.DTA - Data for Coco/R case study CHAP11\x\CLASSL.FRM - Coco/R compiler frame file CHAP11\x\CLASSLIS.ATG - Cocol grammar for case study of section 11.5 CHAP11\x\DBASEMAN.* - Dummy data base handler module CHAP11\x\MAKE.BAT - Batch file to make the C++ case study of 11.5 CHAP11\x\PARSER4.* - Parse infix expressions (section 11.1) CHAP11\x\PARSER5.* - Convert infix to reverse Polish (section 11.1) CHAP11\x\PARSER6.* - Evaluate infix expressions (section 11.3) CHAP11\x\TURBOC.CFG - Sample Borland C++ configuration file
CHAP12\x\CALC.ATG - Attributed grammar for simple adding machine CHAP12\x\CALC.FRM - Coco/R compiler frame file CHAP12\x\CALC0.ATG - Unattributed grammar for addin machine (12.2) CHAP12\x\DATA - Specimen data for adding machine CHAP12\x\MAKE.BAT - Batch file to make the system with Borland C++ CHAP12\x\TURBOC.CFG - Sample Borland C++ configuration file
CHAP13\x\SETUP.BAT - Execute CHAP13\x\SETUP.BAT to piece together a complete case study CHAP13\x\MISC.H - Miscellaneous routinesThe following files refer to various exercises
CHAP13\x\EXPR1.ATG - Grammar for parsing expressions CHAP13\x\EXPR2.ATG - Grammar for converting infix expressions to Polish CHAP13\x\EXPR3.ATG - Grammar for evaluating expressionsThe following files refer to case study 13.1 - C declarations
CHAP13\DECL.DTA - Specimen declarations CHAP13\x\CDECL.MK - Makefile for Borland C++ CHAP13\x\CDECL.ATG - Attributed grammar for parsing declarationsThe following files refer to case study 13.2 - one address code generation
CHAP13\EXPR.DTA - Specimen data CHAP13\x\EXPR.FRM - Coco/R compiler frame file CHAP13\x\EXPR.MK - Makefile for Borland C++ CHAP13\x\EXPR4.ATG - Attributed grammar for parsing expressions and generating one-address code on the flyThe following files refer to case study 13.3 - code generation via an AST
CHAP13\EXPR.DTA - Specimen data CHAP13\x\EXPR.FRM - Coco/R compiler frame file CHAP13\x\EXPR2.MK - Makefile for Borland C++ CHAP13\x\EXPR5.ATG - Attributed grammar for parsing expressions and generate code from an ASTThe following are the AST tree handlers using variant records/unions
CHAP13\x\ASTREES0.* - Simple AST CHAP13\x\ASTREES1.* - AST with constant folding CHAP13\x\ASTREES2.* - AST for fairly optimal one-address code CHAP13\x\ASTREES3.* - AST for fairly optimal single-accumulator codeThe following are the AST tree handlers using FST Modula-2 OOP
CHAP13\x\FSTTREE0.* - Simple AST CHAP13\x\FSTTREE1.* - AST with constant folding CHAP13\x\FSTTREE2.* - AST for fairly optimal one-address code CHAP13\x\FSTTREE3.* - AST for fairly optimal single-accumulator codeThe following are the AST tree handlers using C++ or Turbo Pascal OOP
CHAP13\x\TREES0.* - Simple AST CHAP13\x\TREES1.* - AST with constant folding CHAP13\x\TREES2.* - AST for fairly optimal one-address code CHAP13\x\TREES3.* - AST for fairly optimal single-accumulator codeThe following are the AST tree handlers using TopSpeed Modula-2 OOP
CHAP13\x\JPITREE0.* - Simple AST CHAP13\x\JPITREE1.* - AST with constant folding CHAP13\x\JPITREE2.* - AST for fairly optimal one-address code CHAP13\x\JPITREE3.* - AST for fairly optimal single-accumulator codeThe following files refer to case study 13.4 - parser generators
CHAP13\EBNF.ATG - Unattributed grammar CHAP13\GRAM*.* - Specimen simple grammars CHAP13\PROG1*.* - Specimen simple programs CHAP13\x\EBNF.ATG - Attributed grammar CHAP13\x\EBNF.FRM - Coco/R compiler frame file CHAP13\x\EBNF.MK - Makefile for Borland C++ CHAP13\x\GP.* - Graph parser support CHAP13\x\GS.* - Graph scanner support CHAP13\x\SRC.* - Program source handler
CHAP14\x\SETUP.BAT - Execute CHAP14\x\SETUP.BAT to piece together a complete case study CHAP14\CLANG.ATG - Unattributed grammar CHAP14\*.CLN - Simple programs to parse CHAP14\x\CLANG.ATG - Attributed grammar CHAP14\x\CLANG.FRM - Coco/R compiler frame file CHAP14\x\CLANG.MK - Coco/R makefile for Borland C++ CHAP14\x\CLN.* - Main routine (Modula/Pascal versions) CHAP14\x\CLN0.CPP - Main routine - no error recovery CHAP14\x\CLN0.MK - Hand-crafted makefile for Borland C++ CHAP14\x\CLN1.CPP - Main routine - with error recovery CHAP14\x\CLN1.MK - Hand-crafted makefile for Borland C++ CHAP14\x\PARSER0.* - Hand-crafted parser, no error recovery CHAP14\x\PARSER1.* - Hand crafted parser, follower set error recovery CHAP14\x\PARSER2.* - Hand crafted parser, ordered token error recovery CHAP14\x\TABLE.* - Symbol table handler
CHAP16D - Simple block structure (using a display) (Clang level 2)
CHAP16S - Simple block structure (using a static link)
CHAP17 - Parameters and functions (Clang level 3)
CHAP18 - Concurrent programming (Clang level 4) The case studies in these chapters are supported in very similar directory structures. They contain the sources for a variety of implementation strategies for Clang compilers at a variety of levels, using both hand-crafted and Coco/R generated compilers.
CHAPnn\x\SETUP.BAT - Execute CHAPnn\x\SETUP.BAT to piece together a complete case study CHAPnn\*.CLN - Simple programs to compile. Note that the programs for one "level" of Clang can also be compiled by higher levels. For example, the examples in CHAP15 can be compiled by the Clang compilers in chapters 15, 16, 17 and 18. CHAPnn\CLANG.ATG - Unattributed grammar for Clang CHAP18\CLANG.RPT - Language definition for Clang level 4. Others could be derived from this by the removal of features. CHAPnn\x\CGEN1.* - On-the-fly code generators CHAPnn\x\CGEN2.* - AST code generators (Variant record/Union) CHAPnn\x\CGEN3.* - AST code generators (OOP) CHAPnn\x\CLANG.ATG - Attributed grammar for on-the-fly generation CHAPnn\x\CLANGAST.ATG - Attributed grammar for AST generation CHAPnn\x\PARSER1.* - Hand crafted parser, follower set error recovery, on the fly code generator CHAPnn\x\PARSER2.* - Hand crafted parser, ordered token error recovery, on the fly code generator CHAPnn\x\PARSER3.* - Hand crafted parser, follower set error recovery, AST code generator CHAPnn\x\PARSER4.* - Hand crafted parser, ordered token error recovery, AST code generator CHAPnn\x\PSEUDORA.* - Random number generators (Modula-2, Clang 4) CHAPnn\x\STKMC.* - Interpreter CHAPnn\x\TABLE.* - Symbol table handler CHAPnn\x\TESTRAND.MOD - Test random number generation (Modula)
COMMON\x\SETUP.BAT - Called from CHAPnn\x\SETUP.BAT to piece together complete case studies. (Do NOT run this batch file on its own.) COMMON\READ.ME - Notes on some of these programs COMMON\x\CLANG.FRM - Coco/R compiler frame file COMMON\x\CLANG.MK - Coco/R makefile for Borland C++ COMMON\x\CLN.* - Hand-crafted main routine COMMON\x\CLN.MK - Hand-crafted makefile for Borland C++ COMMON\x\MISC.H - Various types and declarations (C++) COMMON\x\PARSER.DEF - Parser definition (Modula) COMMON\x\REPORT.* - Error reporting module/class/unit COMMON\x\SCAN.* - Hand-crafted scanner COMMON\x\SET.H - Template set class (C++) COMMON\x\SRCE.* - Hand-crafted source handler COMMON\x\TURBOC.CFG - Sample Borland C++ configuration file
CHAP15.ASM\x\SETUP.BAT - Execute CHAP15.ASM\x\SETUP.BAT to piece together a complete case study CHAP15.ASM\x\CGEN*.* - Code generators CHAP15.ASM\x\CLANG.FRM - Coco/R compiler frame file CHAP15.ASM\x\CLANG.MK - Coco/R makefile for Borland C++ CHAP15.ASM\x\CLANGAST.ATG - Coco/R attributed grammar CHAP15.ASM\x\CLN.* - Hand-crafted main routine CHAP15.ASM\x\CLN.MK - Hand-crafted makefile for Borland C++ CHAP15.ASM\x\COMPILE.BAT - Compile/assemble from hand-crafted version CHAP15.ASM\x\COMPILE1.BAT - Compile/assemble from Coco/R version CHAP15.ASM\x\PARSER*.* - Hand-crafted parser
ASMBLER\ASM.EXE - Executable of the assembler/interpreter ASMBLER\*.ASM - Simple source examples ASMBLER\READ.ME - Instructions for executing ASM
HASH\*.KEY - Lists of keywords for some languages HASH\FINDHASH.* - Cichelli's algorithm for finding minimal perfect hash functions. HASH\READ.ME - Instructions for running FINDHASH
TOPSY\x\SETUP.BAT - Execute TOPSY\x\SETUP.BAT to piece together the complete case study TOPSY\*.TOP - Sample Topsy source files TOPSY\TOPSY.RPT - Topsy language definition TOPSY\TOPSY0.ATG - Basic Topsy level 1 grammar TOPSY\x\CGEN.* - Code generator TOPSY\x\STKMC.* - Interpreter TOPSY\x\TABLE.* - Symbol table manager TOPSY\x\TOPSY.ATG - Attributed grammar TOPSY\x\TOPSY.FRM - Coco/R compiler frame file TOPSY\x\MAKEFILE - Makefile for Borland C++
Any other trademarks inadvertently used here are also duly acknowledged.