P.D. Terry, Rhodes University
(Last updated 5 October 2021)
This directory contains instructions for downloading and installing the Resource Kit for the full 2005 edition of Compiling with C# and Java by P.D. Terry (Pearson Education, 2005 ).
*** This "instance" version of the Resource Kit is designed for case studies that would match an "instantiable" extended release of Coco/R released by the author in late 2005. In the releases of 2005 and 2017, the generated classes export static methods only, as is the case for all the case studies discussed in the text book. The components of the 2005 and 2017 releases are closely compatible, but incompatible with the "instance" release.
Software developed by Pat Terry, Rhodes University, Grahamstown, South Africa. (p.terry@ru.ac.za)
The instructions are given from the perspective of a user running a 32-bit version of the Microsoft (tm) Windows operating system, and it is assumed that the user has installed either or both of a .NET SDK (Software Development Kit) or a Java SDK.
http://msdn.microsoft.com/netframework/downloads/
This includes the .NET framework with the CLR, the .NET class library, the C# compiler and other tools, and the entire API documentation. (Note that Visual Studio .NET is not included, as the Visual Studio software is not free of charge.)
http://java.sun.com
For efficiency, the components of the Resource Kit are supplied in the form of a set of compressed (.zip) files; the files were compressed with the 32-bit version of Info-ZIP's compression utility, but can be decompressed using Info-ZIP's software or some other decompressor such as WinZip.
Before downloading any of the components of the Resource Kit, create a top level directory (folder) into which the compressed files can be saved. In the descriptions that follow it will be assumed that this directory is called
c:\resource
From a "Dos Window" this directory can be created with a command like
mkdir c:\resourceIt can, of course, also be created from within Windows Explorer.
Once the top level directory has been created, save in it those of the following files for the components of the Resource Kit that you wish to install:
This is an essential download if you plan to experiment with the C# version of Coco/R, and is supplied in terms of the GNU GPL licence. If this file is uncompressed from the top level directory it will add the following components to the Resource Kit hierarchy:
c:\resource Top level c:\resource\cococ Coco/R for C# (GNU software) c:\resource\cococ\frames Frame files for Coco/R for C# c:\resource\cococ\sources Source code of Coco/R for C#
This is an essential download if you plan to experiment with the Java version of Coco/R, and is supplied in terms of the GNU GPL licence. If this file is uncompressed from the top level directory it will add the following components to the Resource Kit hierarchy:
c:\resource Top level c:\resource\cocoj Coco/R for Java (GNU software) c:\resource\cococ\frames Frame files for Coco/R for Java c:\resource\cococ\sources Source code of Coco/R for Java
If these files are uncompressed from the top level directory they will add the following components to the Resource Kit hierarchy:
c:\resource\command Instructions and specimen batch files for running the programs c:\resource\libsource Library source c:\resource\classes Library classes
If this file is uncompressed from the top level directory it will add the following components to the Resource Kit hierarchy:
c:\resource\instanceindex.html HTML index page c:\resource\gnu.htm GNU licence
A local copy of the Resource website can then be browsed by pointing your browser at
file:///C:/resource/instanceindex.html
These are recommended downloads. If these files are saved and then uncompressed from the top level directory c:\resource they will add the following components to the Resource Kit hierarchy:
c:\resource Top level c:\resource\instancetext\Chap*.pdf PDF versions of each chapter (2005 and "instance" versions are identical at present) c:\resource\instancetext\Chap*.htm HTML (web) versions of each chapter c:\resource\instancesrce\chap01 Source code and other files for Chapter 1 (instantiable versions) c:\resource\instancesrce\chap02 Source code and other files for Chapter 2 (instantiable versions) .... c:\resource\instancesrce\chap16 Source code and other files for Chapter 16 (instantiable versions)
This is an non-essential download, useful if you wish to experiment further with Oolong and Gnoloo, and is supplied in terms of the GNU GPL licence. If this file is uncompressed from the top level directory it will add the following components to the Resource Kit hierarchy:
c:\resource Top level c:\resource\engel Engel's Oolong assembler (GNU software) c:\resource\engel\COM Class files (in a further hierarchy) c:\resource\engel\doc Documentation c:\resource\engel\tests Engel's test files
This is an non-essential download, useful if you wish to experiment further with Oolong and Gnoloo, and is supplied in terms of the GNU GPL licence. If this file is uncompressed from the top level directory it will add the following components to the Resource Kit hierarchy:
c:\resource Top level c:\resource\fixengel Modifications for Oolong
The modifications can be made after reading the documentation. Precompiled versions of Oolong and Gnoloo are supplied in the
c:\resource\command
directory, with these modifications already effected.
This is an optional download. If this file is uncompressed from the top level directory it will add the following components to the Resource Kit hierarchy:
c:\resource Top level c:\resource\CSMinor c:\resource\CSMinor\sample1 directory containing complete sample programs c:\resource\CSMinor\sample2 directory containing programs that merely illustrate aspects of code generation
This is an optional download, and is supplied in terms of the GNU GPL licence. If this file is uncompressed from the top level directory it will add the following components to the Resource Kit hierarchy:
c:\resource Top level c:\resource\Linz Linz releases of Coco/R
The c:\resource\Linz directory contains the 2021 "instantiable" distributions from Linz in compressed form, from an earlier version of which were derived the 2008 extended versions provided in this distribution in the files CocoC.zip and CocoJ.zip.
The most recent versions of the Linz release of Coco/R may be obtained from https://ssw.jku.at/Research/Projects/Coco/
After downloading and uncompressing the essential components of the Resource Kit, further action has to be taken before it can be used:
The RESOURCE environment variable may be defined in several ways - a simple one being to issue a command like
set RESOURCE=C:\resource
from a command prompt. However, it may be preferable to modify the default list of environment variables for your setup so that this variable is defined automatically each time the system is started.
The PATH environment variable may be modified in several ways - a simple one being to issue a command like
PATH=%PATH%;%RESOURCE%\command
from a command prompt. However, it may be preferable to modify the default setting for the PATH so that this change comes into effect automatically each time the system is started.
The setting of the CLASSPATH variable will depend on other software that you already have installed, such as the version of the Java runtime system. A command like
set CLASSPATH=.;%RESOURCE%\classes;
might suffice (assuming that you have already defined the RESOURCE environment variable).
Developing your own applications, or experimenting with the case studies in the kit, is conveniently carried out as follows:
Arrange your source and support files into part of a working directory hierarchy. For illustration the top level of this system is assumed to be C:\work. We assume the attributed Cocol grammar to be stored in a file Grammar.atg, that a driver frame file has been stored in a file Grammar.frame and that there are some support routines in a file Support.cs or Support.java (again, these names are used merely for illustration).
For the C# version the files should be set up as:
C:\work Grammar.atg Grammar.frame C:\work\Grammar\ Support.cs
and for the Java version the files should be set up differently:
C:\work C:\work\Grammar\ Grammar.atg Grammar.frame Grammar.manifest Support.java
Grammar.manifest (which applies only to the Java version) is optional; if present it would typically read
Manifest-Version: 1.0 Main-Class: Grammar/Grammar
and can be used by the system to build a jar file for the application, named Grammar.jar.
It is possible for both sets of files to coexist. For example, in the "chap13" directory of the source, once installed, you would find
C:\resource\instancesrce\chap13 work directory Parva.atg C# version of attributed grammar Parva.frame C# version of driver frame file C:\resource\instancesrce\chap13\parva subdirectory Parva.atg Java version of attributed grammar Parva.frame Java version of driver frame file Parva.manifest Manifest file to build Parva.jar Table.cs C# version of symbol table class Table.java Java version of symbol table class . . .
Clearly there are other ways of arranging the system, and experienced users may wish to experiment in this regard.
The C:\resource\command directory contains various batch files/scripts to expedite the use of Coco/R. They can only be immediately useful if the PATH environment variable has been modified to include this "command" directory, if the environment variable RESOURCE is defined to point to the top level of the Source Kit directory hierarchy, and the CLASSPATH environment variable defined so as to gain access to specialised library classes. Instructions for this were given earlier.
The following batch files execute Coco/R, but do not compile and link the application:
Run Coco/R for C# to generate scanner, parser and driver from a Cocol grammar
Run Coco/R for Java to generate scanner, parser and driver from a Cocol grammar
The following batch files allow for applications to be built completely from a Cocol attributed grammar:
Run Coco/R for C# to generate scanner, parser and driver from a Cocol grammar and then compile and link the resulting system using a C# compiler.
Example: C:\resource\chap06\> ccMake Parva
Note that the grammar file (Parva.atg) is specified without extension; this is added automatically.
Run Coco/R for Java to generate scanner, parser and driver from a Cocol grammar and then compile and link the resulting system using the "javac" compiler.
Example: C:\resource\chap06\> cjMake Parva -options NC
Execute a Java application built with Coco/R for Java
Example: C:\resource\chap06\> cjRun Parva hello.pav
The following batch files allow for compilation of C#Minor programs (Chapters 15/16):
Note that the source file (Hello.cs) is specified with no extension; this is added automatically.
Compile a C#Minor program to CLR assembler (using the C# version of the C#Minor compiler)
Example: C:\resource\CSMinor\sample1\> C#MCLR Hello
Compile a C#Minor program to CLR assembler (using the Java version of the C#Minor compiler)
Example: C:\resource\CSMinor\sample1\> C#MCLRJ Hello
Compile a C#Minor program to JVM assembler (using the C# version of the C#Minor compiler)
Example: C:\resource\CSMinor\sample1\> C#MJVM Hello
Compile a C#Minor program to JVM assembler (using the Java version of the C#Minor compiler)
Example: C:\resource\CSMinor\sample1\> C#MJVMJ Hello
These compilation commands assume the existence of the corresponding version of the C#Minor compiler:
- CSMCLR.exe - Compiled version of the C#Minor compiler for the CLR
- CSMCLR.jar - Compiled classes for the C#Minor compiler for the CLR
- CSMJVM.exe - Compiled version of the C#Minor compiler for the JVM
- CSMJVM.jar - Compiled classes for the C#Minor compiler for the JVM
Once a C#Minor compiler has been compiled into assembler code it can be assembled and linked and then executed using the appropriate sequence below. Note that the source file (Hello.il) is specified with no extension; this is added automatically.
Assemble and link CIL code for the CLR to produce an .exe file
Example: C:\resource\CSMinor\sample1\> linkclr Hello C:\resource\CSMinor\sample1\> Hello
Assemble and link Oolong code for the JVM to produce a .class file
Example: C:\resource\CSMinor\sample1\> C#MJVMJ Hello C:\resource\CSMinor\sample1\> java Hello
The Java system assumes the existence of the Oolong assembler:
The following files provide for the simple execution of Joshua Engels Oolong assembler and Gnoloo disassembler:
Execute the Oolong assembler Oolong.jar - Classes for the OOlong assembler
Example: C:\resource\CSMinor\sample1\> Oolong Hello.il
Execute the Gnoloo disassembler Gnoloo.jar - Classes for the Gnoloo disassembler
Example: C:\resource\CSMinor\sample1\> Gnoloo Hello.class
The following batch commands may need editing. They provide ways of dealing with some of the environment variables needed by the rest of the system.
Sample batch file for setting CLASSPATH environment variable (needs modification to suit your setup).
Sample batch file for setting RESOURCE environment variable (needs modification to suit your setup).
Batch file to unset RESOURCE environment variable
While every attempt has been made to ensure that the material in this distribution performs properly, the author 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 TerryDate of this release: 5 October 2021
Computer Science Department
Rhodes University
GRAHAMSTOWN 6140
South Africa
Tel: +27-46-603-8292 (Office)
Tel: +27-73-728-6329 (Mobile)
e-mail: p.terry@ru.ac.za