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