hello.t
and GNUmakefile
from one of the
following places into an empty directory, possibly called
hello
:
GNUmakefile.in
to GNUmakefile
and define the prefix
and
exec_prefix
to point to where TOM resides on your
machine, possibly /usr
, /usr/local,
/opt/local, or something similar. If the TOM
compiler, which is called tomc
, resides in
/usr/bin
, the prefix would be /usr,
etc.
This is the source to the `Hello, world!' program when written in TOM.
If you didn't copy the source files, enter it into a file called
hello.t
into a preferrably empty directory (and make
that directory your current directory).
implementation class HelloWorld /* The main method (starts a program). */ int main Array arguments { [[[stdio out] print "Hello, world!"] nl]; = 0; } end; /* We don't need instances of HelloWorld, so this definition (which must be present) can be empty. */ implementation instance HelloWorld end;
When writing your own TOM program, you'll probably always want to use
the TOM makefiles, since they can take care of the details of
compilation. Make sure your hello
directory contains
a file called GNUmakefile
(which is a makefile for
GNU make), with the following contents (the prefix
and exec_prefix
might need to be adjusted if you
started with the GNUmakefile.in
from the TOM WWW
site):
# makefile for TOM hello. # Administrativia on where to find the TOM makefiles. prefix= /usr exec_prefix= /usr tomdir= $(exec_prefix)/tom TOM_MAKEFILES_DIR= $(tomdir)/makefiles # Name of the program that will be built. UNIT= hello # The program consists of one file: hello.t. TOM_SRC= hello include $(TOM_MAKEFILES_DIR)/GNUmakefile.bin
To compile this example program, type make
(or
gnumake
or gmake
or whatever GNU make is
called at your site). If all goes well, this will create an
executable named hello
. Run it:
$ ./hello Hello, world!You are now ready to hack in TOM.
$Id: introduction.html.in,v 1.4 1998/02/14 22:42:53 tiggr Exp $