at.dms.compiler.tools.common
Class Compiler

java.lang.Object
  extended by at.dms.compiler.tools.common.Compiler

public abstract class Compiler
extends Object

This class defines the common behaviour of all KOPI compilers.


Constructor Summary
protected Compiler()
          Creates a new compiler instance.
 
Method Summary
protected  String checkDestination(String destination)
          Checks if destination is absolute or relative to working directory.
 long getTimestamp()
          Returns the timestamp of the compilation session, identifying it uniquely.
 void inform(Message message)
          Write a message to the diagnostic output.
 void inform(MessageDescription description)
          Write a message to the diagnostic output.
 void inform(MessageDescription description, Object parameter)
          Write a message to the diagnostic output.
 void inform(MessageDescription description, Object[] parameters)
          Write a message to the diagnostic output.
 void inform(MessageDescription description, Object parameter1, Object parameter2)
          Write a message to the diagnostic output.
 void inform(PositionedError error)
          Write a message to the diagnostic output.
 void inform(UnpositionedError error)
          Write a message to the diagnostic output.
abstract  boolean parseComments()
          Returns true iff comments should be parsed (false if to be skipped).
abstract  void reportTrouble(PositionedError trouble)
          Reports a trouble (error or warning).
abstract  boolean run(String[] args)
          Runs a compilation session
 boolean run(String dir, PrintWriter err, String[] args)
          Runs a compilation session
protected  void setWorkingDirectory(String dir)
          Sets the directory where to search for source files.
abstract  boolean verboseMode()
          Returns true iff compilation runs in verbose mode.
 File[] verifyFiles(String[] names)
          Creates an array of files from the specified array of file names.
 Vector<Object> verifyFiles(Vector names)
          Takes a vector of file names an checks that each exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Compiler

protected Compiler()
Creates a new compiler instance.

Method Detail

setWorkingDirectory

protected void setWorkingDirectory(String dir)
Sets the directory where to search for source files.

Parameters:
dir - the name of the directory

getTimestamp

public final long getTimestamp()
Returns the timestamp of the compilation session, identifying it uniquely.


verifyFiles

public File[] verifyFiles(String[] names)
                   throws UnpositionedError
Creates an array of files from the specified array of file names.

Parameters:
names - an array of file names
Returns:
an array of files
Throws:
UnpositionedError - at least one file does not exist

verifyFiles

public Vector<Object> verifyFiles(Vector names)
                           throws UnpositionedError
Takes a vector of file names an checks that each exists.

Parameters:
names - a vector of file names
Returns:
a vector of files known to exist
Throws:
UnpositionedError - at least one file does not exist

checkDestination

protected String checkDestination(String destination)
Checks if destination is absolute or relative to working directory.


run

public boolean run(String dir,
                   PrintWriter err,
                   String[] args)
Runs a compilation session

Parameters:
dir - the working directory
err - the diagnostic output stream
args - the arguments to the compiler
Returns:
true iff the compilation succeeded

run

public abstract boolean run(String[] args)
Runs a compilation session

Parameters:
args - the arguments to the compiler
Returns:
true iff the compilation succeeded

reportTrouble

public abstract void reportTrouble(PositionedError trouble)
Reports a trouble (error or warning).

Parameters:
trouble - a description of the trouble to report.

parseComments

public abstract boolean parseComments()
Returns true iff comments should be parsed (false if to be skipped).


verboseMode

public abstract boolean verboseMode()
Returns true iff compilation runs in verbose mode.


inform

public void inform(UnpositionedError error)
Write a message to the diagnostic output.

Parameters:
error - the formatted message

inform

public void inform(PositionedError error)
Write a message to the diagnostic output.

Parameters:
error - the formatted message

inform

public void inform(Message message)
Write a message to the diagnostic output.

Parameters:
message - the formatted message

inform

public void inform(MessageDescription description,
                   Object[] parameters)
Write a message to the diagnostic output.

Parameters:
description - the message description
parameters - the array of parameters

inform

public void inform(MessageDescription description,
                   Object parameter1,
                   Object parameter2)
Write a message to the diagnostic output.

Parameters:
description - the message description
parameter1 - the first parameter
parameter2 - the second parameter

inform

public void inform(MessageDescription description,
                   Object parameter)
Write a message to the diagnostic output.

Parameters:
description - the message description
parameter - the parameter

inform

public void inform(MessageDescription description)
Write a message to the diagnostic output.

Parameters:
description - the message description