A Quick Guide to Running Modula 2 at UMBC

Document Sample
scope of work template
							            A Quick Guide to Running Modula 2 at UMBC
                        September 30, 1999
                             CMSC 331

The MOCKA Modula 2 compiler has been installed in my account on the gl systems.
The directory is ~nicholas/../pub/331/modula/mocka

At the beginning of a terminal session, add the command m2c to your path with the
command

source ~nicholas/../pub/331/modula/modulasetup

You only have to do this once each session, not every time you run the compiler. Now,
suppose that you have a Modula program in a file called Hello.mi Choose file names
with care – Modula requires that the root file name (e.g.Hello) match the name of the
MODULE. To compile, link, and execute this program, issue the commands

m2c –c Hello
m2c –p Hello
Hello

The actual terminal session would resemble:

jabba.gl.umbc.edu> pwd
/afs/umbc.edu/users/n/i/nicholas/home/modula
jabba.gl.umbc.edu> ls
Hello.mi MoreProg.mi OverProg.mi
jabba.gl.umbc.edu> cat Hello.mi
MODULE Hello;

FROM InOut IMPORT WriteLn, WriteString;

BEGIN
          WriteString("Hello, world");
          WriteLn;

END Hello.
jabba.gl.umbc.edu> source ~nicholas/../pub/331/modula/modulasetup
jabba.gl.umbc.edu> which m2c
/afs/umbc.edu/users/n/i/nicholas/pub/331/modula/mocka/bin/m2c
jabba.gl.umbc.edu> m2c -c Hello
jabba.gl.umbc.edu> m2c -p Hello
jabba.gl.umbc.edu> Hello
Hello, world
jabba.gl.umbc.edu> ls
Hello Hello.mi Hello.o Hello.r MoreProg.mi OverProg.mi
jabba.gl.umbc.edu>
Here’s another Modula program:
jabba.gl.umbc.edu> cat -n OverProg.mi
     1                      (* Chapter 7 - Program 1 *)
     2 MODULE OverProg;     (* Overall program construction
example *)
     3
     4 FROM InOut IMPORT WriteString, WriteLn;
     5
     6       PROCEDURE Proc1;
     7       BEGIN
     8         WriteString("Procedure 1");
     9         WriteLn;
    10       END Proc1;
    11
    12       PROCEDURE Proc2;
    13            PROCEDURE Proc3;
    14            BEGIN
    15              WriteString("Procedure 3");
    16              WriteLn;
    17            END Proc3;
    18
    19            PROCEDURE Proc4;
    20                 PROCEDURE Proc5;
    21                 BEGIN
    22                   WriteString("Procedure 5");
    23                   WriteLn;
    24                 END Proc5;
    25            BEGIN
    26              WriteString("Procedure 4");
    27              WriteLn;
    28              Proc5;
    29              Proc3;
    30            END Proc4;
    31       BEGIN
    32         WriteString("Procedure 2");
    33         WriteLn;
    34         Proc3;
    35         Proc4;
    36       END Proc2;
    37
    38 BEGIN
    39    WriteString("Main Program");
    40    WriteLn;
    41    Proc2;
    42    Proc1;
    43 END OverProg.
jabba.gl.umbc.edu>

						
Related docs