Using the NetRexx compiler


The installation instructions for the NetRexx compiler describe how to use the package you installed to compile and run a simple NetRexx program. This section explains more of the options available to you.

Invoking the compiler as a command

The compiler is a Java program (class) which is called COM.ibm.netrexx.process.NetRexxC (NetRexxC for short). This can be invoked using the Java interpreter, for example, by the command:

  java COM.ibm.netrexx.process.NetRexxC

or by using a system-specific command (such as 'NetRexxC' or 'nrc'). In either case, the compiler invocation is followed by one or more program names (the program files to be compiled). NetRexxC will add the extension '.nrx' to input program names (file specifications) if no extension was given.

So, for example, to compile 'hello.nrx', you can use any of:

  java COM.ibm.netrexx.process.NetRexxC hello
  java COM.ibm.netrexx.process.NetRexxC hello.nrx
  NetRexxC hello.nrx
  nrc hello

(the first two should always work, the last two require that the system-specific command be available). The resulting .class file is placed in the current directory.

On completion, the command will exit with one of three return values: 0 if the compilation was successful, 1 if there were one or more Warnings, but no errors, and 2 if there were one or more Errors.

As well as file names, you can also specify various option words, which are distinguished by the first character of the word being '-'. These may be any of the option words allowed on the NetRexx OPTIONS instruction (see the NetRexx language documentation), prefixed with '-'. These options words can be freely mixed with file specifications.

The compiler also implements some additional option words, which cannot be used on the OPTIONS instruction:

If you are using the provided NetRexxC or nrc scripts, then an additional option is available:

Here are some examples:

  java COM.ibm.netrexx.process.NetRexxC hello -keep -strictargs
  java COM.ibm.netrexx.process.NetRexxC -keep hello wordclock
  java COM.ibm.netrexx.process.NetRexxC hello wordclock -nocompile
  nrc hello
  nrc hello.nrx
  nrc -run hello
  nrc -run Spectrum -keep
  nrc hello -binary -verbose1
  nrc hello -noverbose -format -keep

Option words may be specified in lowercase, mixed case, or uppercase. File specifications are platform-dependent and may be case sensitive, though NetRexxC will always prefer an exact case match over a mismatch.

Note that the -run option is implemented by the script, not the compiler; some scripts (such as NetRexxC.bat) may require that the '-run' be the first word of the command arguments, and/or be in lowercase. They may also require that only the name of the file be given if the -run option is used.

See also the earlier section "The NetRexx home directory" if you need to change the place where the compiler finds its messages (for example, if error messages report 'Sorry, full message unavailable').

Invoking the compiler from Java

The compiler may also be called from a Java program directly, by invoking the method in the COM.ibm.netrexx.process.NetRexxC class described as follows:

  method main(arg=Rexx) constant returns int

The Rexx string passed to the method can be any combination of program names and options (except -run), as described above. A sample program that invokes the NetRexx compiler to compile a program called 'test' is:

  /* compiletest.nrx */
  s='test -keep -verbose4 -utf8'
  say COM.ibm.netrexx.process.NetRexxC.main(s)

The returned int value will be one of the return values described above.

NetRexxC is thread-safe (the only static properties are constants), but it is not known whether javac is thread-safe. Hence the invocation of multiple instances of NetRexxC on different threads should probably specify -nocompile, for safety.


[ previous section | contents | next section ]

From 'nrinst.doc', version 1.00.
Copyright(c) IBM Corporation, 1996, 1997. All rights reserved. ©