All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class epp.EppCore

java.lang.Object
   |
   +----epp.EppCore

public class EppCore
extends Object
The EppCore.java file defines methods of the EPP preprocessor that define the framework of the EPP preprocessor.

Note: This class is provided for the sake of creating javadocs. It does not exist in the actual EPP source code.

The EPP preprocessor comprises of four passes, which are the parsing pass, macro expansion pass, type checking pass, and code emitting pass. Each pass passes the abstract syntax tree using a variable (an instance variable of an LD-2 class) named self!tree.

Each pass has the following structure so that a plug-in can add new passes before and after each pass.

    void doTypeCheckingPass() {
      beforeTypeCheckingPass();// hook for adding a pass
      ...;			// pre-processing
      typeCheckingPass();	// main processing
      ...;			// post-processing
      afterTypeCheckingPass();	// hook for adding a pass
    }
The other three passes, parsingPass, macroExpansionPass, and codeEmittingPass also are similar in structure.

A plug-in can add new passes before and after each pass by extending the methods afterXxxPass and beforeXxxPass. The added passes can process global conversion that local conversions of objects such as the macro expansion object cannot handle.

Methods that define the pass's "main portion" (typeCheckingPass method for example), can be used to create an environment for dynamic variables while executing a pass. Example:

SystemMixin bindTypeCheckingEnv {
  class Epp {
    extend void typeCheckingPass(){
      Dynamic.bind(:foo, val);
      try{
	original();
      } finally {
	Dynamic.unbind();
      }
    }
  }
}

See Also:
Epp

Constructor Index

 o EppCore()

Method Index

 o afterCodeEmittingPass()
Called after the execution of the main portion of the code emitting pass.
 o afterMacroExpansionPass()
Called after the execution of the main portion of the macro expansion pass.
 o afterParsingPass()
Called after the execution of the main portion of the parsing pass.
 o backtrack(int)
Returns the position of the pointer within the EppInputStream in argument p, reads one token, and updates the "look ahead token".
 o beforeCodeEmittingPass()
Called before the execution of the main portion of the code emitting pass.
 o beforeMacroExpansionPass()
Called before the execution of the main portion of the macro expansion pass.
 o beforeParsingPass()
Called before the execution of the main portion of the parsing pass.
 o codeEmittingPass()
Executes the main portion of the code emitting pass.
 o defineEmitter(Symbol, Emitter)
 o defineInvokeStyleMacro(Symbol, InvokeStyleMacro)
Registers InvokeStyleMacro to the table.
 o defineMacro(Symbol, Macro)
Registers a macro expansion object to the table.
 o doCodeEmittingPass()
Calls the code emitting pass.
 o doMacroExpansionPass()
Calls the macro expansion pass.
 o doParsingPass()
Calls the parsing pass.
 o doTypeCheckingPass()
Calls the type checking pass.
 o emit1(String, Tree)
Emits tree as a string to outputFileName.
 o emitAdditionalHeader(OutputStream)
Emits strings at the beginning of all files.
 o Epp(String, String)
Invokes a preprocessor.
 o eppSourceVersion()
Returns a string that specifies the version of the source code of the main portion of EPP.
 o eppVersion()
Returns a string that specifies the version of the main portion of EPP and the version of EPP that converted the source code.
 o error(String)
Adds line number information to argument strings, and creates and returns an instance of EppUserError class.
 o extendMacro(Symbol, Macro)
Extends a macro expansion object using a decorator pattern.
 o initEmitterTable()
Initializes the table of Emitter.
 o initializationPass()
Initializes the preprocessor.
 o initInvokeStyleMacroTable()
Initializes the table of InvokeStyleMacro.
 o initMacroTable()
Initializes Macro.macroTable.
 o inputPointer()
Returns the starting position of the look ahead token (the byte number within the EppInputStream).
 o lookahead()
Returns a look ahead token.
 o macroExpansionPass()
Executes the main portion of the macro expansion pass.
 o match(Token)
Ensures that the look ahead token matches the argument and advances the input pointer to the next token.
 o matchAny()
Returns the look ahead token as a value.
 o openEppInputStream(String)
Creates and returns an EppInputStream stream that reads characters from an input file.
 o parsingPass()
Executes the main portion of the parsing pass.
 o readToken(EppInputStream)
Skips space characters, calls the readTokenStar method, and returns one token.
 o redefineEmitter(Symbol, Emitter)
 o redefineInvokeStyleMacro(Symbol, InvokeStyleMacro)
Redefines InvokeStyleMacro registerd with the table.
 o start()
Corresponds to the non-terminal that starts the parsing.

Constructors

 o EppCore
 public EppCore()

Methods

 o Epp
 public void Epp(String inputFileName,
                 String outputFileName)
Invokes a preprocessor. This method is the constructor of the Ld-2 class Epp. This method is called from the EPP main routine (a Java class name Epp).

See Also:
Epp
 o initializationPass
 public void initializationPass()
Initializes the preprocessor. This method is called immediately after the EPP preprocessor is invoked (before parsing begins). Plug-ins may extend this method and add required initialization processing.

 o doParsingPass
 public void doParsingPass()
Calls the parsing pass. Plug-ins normally will not extend this method.

 o doMacroExpansionPass
 public void doMacroExpansionPass()
Calls the macro expansion pass. Plug-ins normally will not extend this method.

 o doTypeCheckingPass
 public void doTypeCheckingPass()
Calls the type checking pass. Plug-ins normally will not extend this method.

 o doCodeEmittingPass
 public void doCodeEmittingPass()
Calls the code emitting pass. Plug-ins normally will not extend this method.

 o error
 public Error error(String str)
Adds line number information to argument strings, and creates and returns an instance of EppUserError class. Call this method when end user level errors such as input program syntax errors occur.

A typical usage of this method is shown below.

   throw error("message");
If a fatal error occured, use Epp.fatal instead of this method. @see epp.EppUserError

See Also:
fatal
 o lookahead
 public Token lookahead()
Returns a look ahead token. The input pointer will not be advanced.

 o match
 public Token match(Token token)
Ensures that the look ahead token matches the argument and advances the input pointer to the next token. If the token and argument match, the token is returned. Otherwise, the error method is called with a comprehensible message.

 o matchAny
 public Token matchAny()
Returns the look ahead token as a value. And, advances the input pointer.

 o start
 public Tree start()
Corresponds to the non-terminal that starts the parsing.

 o readToken
 public Token readToken(EppInputStream in)
Skips space characters, calls the readTokenStar method, and returns one token. This method is called from the matchAny() method. Do not call this method directly from from the parsing routine.

See Also:
Lex, readTokenStart
 o openEppInputStream
 public EppInputStream openEppInputStream(String inputFileName)
Creates and returns an EppInputStream stream that reads characters from an input file. Plug-ins may extend the behaviour of an iput stream by redefining this method and making it return a subclass of EppInputStream. (A Factory method of Design pattern.)

 o beforeParsingPass
 public void beforeParsingPass()
Called before the execution of the main portion of the parsing pass.

 o parsingPass
 public void parsingPass()
Executes the main portion of the parsing pass. Plug-ins may extend this method, for example, to create an environment for dynamic variables when excuting the pass.

 o afterParsingPass
 public void afterParsingPass()
Called after the execution of the main portion of the parsing pass.

 o inputPointer
 public int inputPointer()
Returns the starting position of the look ahead token (the byte number within the EppInputStream). The return value is used as an argument to the backtrack method.

See Also:
backtrack
 o backtrack
 public void backtrack(int p)
Returns the position of the pointer within the EppInputStream in argument p, reads one token, and updates the "look ahead token". The next time lookahead() is called, the token beginning immediately after p will be returned. The int value specified as the argument must be retrieved using the inputPointer method before calling this method.

See Also:
inputPointer
 o initMacroTable
 public void initMacroTable()
Initializes Macro.macroTable. Plug-ins may extend this method to add/extend macro expansion objects registered in the table, by calling defineMacro or extendMacro.

See Also:
defineMacro, extendMacro, Macro
 o defineMacro
 public void defineMacro(Symbol tag,
                         Macro func)
Registers a macro expansion object to the table. If a macro expansion object that corresponds to the specified tag is already registered, a fatal error occurs.

See Also:
initMacroTable, Macro
 o extendMacro
 public void extendMacro(Symbol tag,
                         Macro func)
Extends a macro expansion object using a decorator pattern. The original macro expansion object can be referenced from within argument func through variable orig.

See Also:
initMacroTable, Macro
 o beforeMacroExpansionPass
 public void beforeMacroExpansionPass()
Called before the execution of the main portion of the macro expansion pass.

 o macroExpansionPass
 public void macroExpansionPass()
Executes the main portion of the macro expansion pass. Plug-ins may extend this method, for example, to create an environment for dynamic variables when excuting the pass.

 o afterMacroExpansionPass
 public void afterMacroExpansionPass()
Called after the execution of the main portion of the macro expansion pass.

 o defineInvokeStyleMacro
 public void defineInvokeStyleMacro(Symbol tag,
                                    InvokeStyleMacro func)
Registers InvokeStyleMacro to the table.

See Also:
initInvokeStyleMacroTable, InvokeStyleMacro
 o redefineInvokeStyleMacro
 public void redefineInvokeStyleMacro(Symbol tag,
                                      InvokeStyleMacro func)
Redefines InvokeStyleMacro registerd with the table.

See Also:
initInvokeStyleMacroTable, InvokeStyleMacro
 o initInvokeStyleMacroTable
 public void initInvokeStyleMacroTable()
Initializes the table of InvokeStyleMacro. Plug-ins may extend this method to add/extend InvokeStyleMacro objects registered in the table, by calling defineInvokeStyleMacro or redefineInvokeStyleMacro.

See Also:
InvokeStyleMacro
 o initEmitterTable
 public void initEmitterTable()
Initializes the table of Emitter. Plug-in prorammers normally should not extend this method.

See Also:
Emitter
 o defineEmitter
 public void defineEmitter(Symbol tag,
                           Emitter func)
 o redefineEmitter
 public void redefineEmitter(Symbol tag,
                             Emitter func)
 o beforeCodeEmittingPass
 public void beforeCodeEmittingPass()
Called before the execution of the main portion of the code emitting pass.

 o codeEmittingPass
 public void codeEmittingPass()
Executes the main portion of the code emitting pass. Plug-ins may extend this method, for example, to create an environment for dynamic variables when excuting the pass.

 o afterCodeEmittingPass
 public void afterCodeEmittingPass()
Called after the execution of the main portion of the code emitting pass.

 o emit1
 public void emit1(String outputFileName,
                   Tree tree)
Emits tree as a string to outputFileName. However, if outputFileName already exists and is not a "file generated by EPP", an EppUserError is thrown.

See Also:
isGeneratedFile
 o emitAdditionalHeader
 public void emitAdditionalHeader(OutputStream out)
Emits strings at the beginning of all files. This method is called from emit1.

See Also:
emit1
 o eppVersion
 public String eppVersion()
Returns a string that specifies the version of the main portion of EPP and the version of EPP that converted the source code.

 o eppSourceVersion
 public String eppSourceVersion()
Returns a string that specifies the version of the source code of the main portion of EPP.


All Packages  Class Hierarchy  This Package  Previous  Next  Index