net.sf.tomp.xtcl
Class CompilerBase

java.lang.Object
  extended by net.sf.tomp.xtcl.CompilerBase
All Implemented Interfaces:
Compiler
Direct Known Subclasses:
XTCompiler

public abstract class CompilerBase
extends java.lang.Object
implements Compiler

Abstract base for a Compiler.

Author:
tomp

Constructor Summary
CompilerBase()
           
 
Method Summary
protected  void assertWholeLineRead(java.lang.String ci, int i, java.lang.String[] cl, Command commandToReturn)
           
 Command compile(CommandLineReader clr)
          Compiles commands from a CommandLineReader into a command Sequence
 Command compile(java.io.File f)
          Compiles commands from a String
 Command compile(java.lang.String s)
          Compiles commands from a String
 Command compile(java.lang.String cl, CommandLineReader clr)
          Compiles commands from a String followed by a CommandLineReader into a command Sequence
protected  Command compileByNextCompiler(java.lang.String ci, java.lang.String[] cl, CommandLineReader clr)
           
 Context getContext()
           
 Compiler getNextCompiler()
           
 void setContext(Context context)
           
protected  int setParameters(java.lang.String[] cl, int i, ParametrizedCommand command)
          Reads and sets all the parameters to the ParametrizedCommand
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.tomp.xtcl.Compiler
compile
 

Constructor Detail

CompilerBase

public CompilerBase()
Method Detail

compile

public Command compile(CommandLineReader clr)
                throws java.lang.Exception
Compiles commands from a CommandLineReader into a command Sequence

Specified by:
compile in interface Compiler
Parameters:
clr - CommandLineReader - the source for compilation
Returns:
compiled Command
Throws:
java.lang.Exception - if compilation fails

compile

public Command compile(java.io.File f)
                throws java.lang.Exception
Compiles commands from a String

Parameters:
f - String - the source from which it compiles
Returns:
compiled Command
Throws:
java.lang.Exception - if compilation fails

compile

public Command compile(java.lang.String s)
                throws java.lang.Exception
Compiles commands from a String

Specified by:
compile in interface Compiler
Parameters:
s - String - the source from which it compiles
Returns:
compiled Command
Throws:
java.lang.Exception - if compilation fails

compile

public Command compile(java.lang.String cl,
                       CommandLineReader clr)
                throws java.lang.Exception
Compiles commands from a String followed by a CommandLineReader into a command Sequence

Specified by:
compile in interface Compiler
Parameters:
cl - String - will be tokenized and passed further to compile(String[], CommandLineReader)
clr - CommandLineReader - the sources for compilation first the String, then the CLR
Returns:
compiled Command
Throws:
java.lang.Exception - if compilation fails

assertWholeLineRead

protected void assertWholeLineRead(java.lang.String ci,
                                   int i,
                                   java.lang.String[] cl,
                                   Command commandToReturn)
Parameters:
ci - Command name - used just for error reporting if it happens
i - current position in the cl fields (parameters) array
cl - fields (parameters) array
commandToReturn -

compileByNextCompiler

protected Command compileByNextCompiler(java.lang.String ci,
                                        java.lang.String[] cl,
                                        CommandLineReader clr)
                                 throws java.lang.Exception
Parameters:
ci -
cl -
clr -
Returns:
Throws:
java.lang.Exception

setParameters

protected int setParameters(java.lang.String[] cl,
                            int i,
                            ParametrizedCommand command)
Reads and sets all the parameters to the ParametrizedCommand

Parameters:
cl - parameter array
i - starting position in the cl array
command - the ParametrizedCommand
Returns:
position in the cl parameter array after parsing

getContext

public Context getContext()
Specified by:
getContext in interface Compiler
Returns:
Returns the context.

getNextCompiler

public Compiler getNextCompiler()
Specified by:
getNextCompiler in interface Compiler
Returns:
Returns the parent.

setContext

public void setContext(Context context)
Specified by:
setContext in interface Compiler
Parameters:
context - The context to set.


Copyright © 2004-2005 Masaryk University in Brno, Faculty of Informatics, Czech Republic. All Rights Reserved.