public class IncludeFile
extends java.lang.Object
Strategy overview: The top level MetaMath source file Tokenizer is never closed as include files are processed, but a nested include file statement will close the outer include file, process the inner and then "restart" the outer include file where it left off. This is slightly crude but is a fair compromise since nested include files are unlikely AND there is probably an extra file handle hanging around, so we don't need to close the top level MetaMath source file.
Constructor and Description |
---|
IncludeFile() |
Modifier and Type | Method and Description |
---|---|
static Tokenizer |
initIncludeFile(java.util.Deque<IncludeFile> fileList,
java.io.File f,
java.lang.String fileName,
Statementizer statementizer)
Switches Statementizer processing to an include file after recording
restart information of the previous include file.
|
static Tokenizer |
termIncludeFile(java.util.Deque<IncludeFile> fileList,
Statementizer statementizer)
Terminates processing of the current include file, "pops the stack", and
restores the previous include file for further Statementizer processing.
|
public static Tokenizer initIncludeFile(java.util.Deque<IncludeFile> fileList, java.io.File f, java.lang.String fileName, Statementizer statementizer) throws java.io.FileNotFoundException, java.io.IOException
Switches Statementizer processing to an include file after recording restart information of the previous include file.
Note that the first include file entry in fileList
stores the
Tokenizer
of the top level MetaMath source file read; this is
used to restore Statementizer processing where it left off after end of
file on the include file.
fileList
- List used to store information about IncludeFiles.
Initialize to empty list at start of processing:
fileList = new ArrayList();
. and that's all that is
necessary.f
- File object, previously constructed, that will be used to create
a Reader for the new include file.fileName
- include string file name from Metamath file '$[ xx.mm $]'
statement.statementizer
- the Statementizer presently in use; used here to
switch tokenizers.java.io.FileNotFoundException
- if bogus include file name.java.io.IOException
- if IO errorpublic static Tokenizer termIncludeFile(java.util.Deque<IncludeFile> fileList, Statementizer statementizer) throws java.io.FileNotFoundException, java.io.IOException, MMIOException
fileList
- List used to store information about IncludeFiles.statementizer
- the Statementizer presently in use; used here to
switch tokenizers.java.io.FileNotFoundException
- if bogus include file name.java.io.IOException
- if IO errorMMIOException
- if IO error