org.jawk
Class Awk

java.lang.Object
  extended by org.jawk.Awk

public class Awk
extends java.lang.Object

Entry point into the parsing, analysis, and execution/compilation of a Jawk script.

The overall process to execute a Jawk script is as follows:

Two additional semantic checks on the syntax tree are employed (both to resolve function calls for defined functions). As a result, the syntax tree is traversed three times. And the number of times tuples are traversed is depends on whether interpretation or compilation takes place. As of this writing, Jawk traverses the tuples once for interpretation, and two times for compilation (once for global variable arrangement, and the second time for translation to bytecode).

By default a minimal set of extensions are automatically included. Please refer to the EXTENSION_PREFIX static field contents for an up-to-date list. As of the initial release of the extension system, the prefix defines the following extensions:

Note: Compilation requires the installation of The Apache Byte Code Engineering Library (BCEL). Please see the AwkCompilerImpl Javadocs or the project webpage for more details.

See Also:
AVM, AwkCompilerImpl

Constructor Summary
Awk(java.lang.String[] args, java.io.InputStream is, java.io.PrintStream os, java.io.PrintStream es)
          Class constructor to support the JSR 223 scripting interface already provided by Java SE 6.
 
Method Summary
static int invoke(java.lang.String[] args)
          An entry point to Jawk that provides the exit code of the script if interpreted or an compiler error status if compiled.
static void main(java.lang.String[] args)
          The entry point to Jawk for the VM.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Awk

public Awk(java.lang.String[] args,
           java.io.InputStream is,
           java.io.PrintStream os,
           java.io.PrintStream es)
    throws java.lang.Exception
Class constructor to support the JSR 223 scripting interface already provided by Java SE 6.

Parameters:
args - String arguments from the command-line.
is - The input stream to use as stdin.
os - The output stream to use as stdout.
es - The output stream to use as stderr.
Throws:
java.lang.Exception - enables exceptions to propogate to the callee.
Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
The entry point to Jawk for the VM.

The main method is a simple call to the invoke method. The current implementation is as follows:

 System.exit(invoke(args));
 

Parameters:
args - Command line arguments to the VM.
Throws:
java.io.IOException - upon an IO error.
java.lang.ClassNotFoundException - if compilation is requested, but no compilation implementation class is found.

invoke

public static int invoke(java.lang.String[] args)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
An entry point to Jawk that provides the exit code of the script if interpreted or an compiler error status if compiled. If compiled, a non-zero exit status indicates that there was a compilation problem.

Parameters:
args - Command line arguments to the VM.
Returns:
The exit code to the script if interpreted, or exit code of the compiler.
Throws:
java.io.IOException - upon an IO error.
java.lang.ClassNotFoundException - if compilation is requested, but no compilation implementation class is found.