Compiling with C# and Java - Downloading the Resource Kit

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.


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:\resource
It 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:


After downloading and uncompressing the essential components of the Resource Kit, further action has to be taken before it can be used:


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:

The following batch files allow for applications to be built completely from a Cocol attributed grammar:

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.

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.

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.


Disclaimer

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 Terry
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
Date of this release: 5 October 2021