public class Preprocessor
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
defineDirective
--- Directives ---
|
protected java.util.Map<java.lang.String,java.lang.String> |
definedSymbols
Defined symbols.
|
protected java.lang.String |
destFileName
Name of sestination file to receive proprocessed text.
|
protected java.lang.String |
directiveLeadIn
Preprocessor directive lead-in string.
|
protected java.lang.String |
endifDirective |
protected java.lang.String |
ifdefDirective |
protected java.lang.String |
ifndefDirective |
protected java.lang.String |
includeDirective |
protected int |
lineCount
Count of lines processed.
|
protected java.io.BufferedWriter |
outputWriter
Writer to which to output preprocessed text.
|
protected boolean |
skipState
true if skipping lines.
|
protected java.util.Stack<java.lang.Boolean> |
skipStates
Line skip nesting state.
|
protected java.lang.String |
sourceFileName
Name of source file to preprocess.
|
protected java.lang.String |
undefineDirective |
Constructor and Description |
---|
Preprocessor()
Create preprocessor.
|
Preprocessor(java.lang.String leadIn)
Create preprocessor with specified directive lead-in string.
|
Modifier and Type | Method and Description |
---|---|
protected void |
defineSymbol(java.lang.String symbol,
java.lang.String value)
Define a symbol.
|
int |
getLineCount()
Get the number of lines preprocessed.
|
static void |
main(java.lang.String[] args)
Main program.
|
boolean |
preprocess(java.lang.String sourceFileName,
java.lang.String destFileName)
Preprocess one file.
|
boolean |
preprocess(java.lang.String sourceFileName,
java.lang.String destFileName,
boolean quiet)
Preprocess one file.
|
protected void |
processFile(java.lang.String sourceFileName,
java.io.BufferedWriter outputWriter,
boolean quiet)
Process one file.
|
protected java.lang.String |
resolve(java.lang.String s)
Replace defined symbols in string.
|
protected boolean |
symbolDefined(java.lang.String symbol)
Check if symbol defined.
|
protected void |
undefineSymbol(java.lang.String symbol)
Undefine a symbol.
|
protected java.util.Map<java.lang.String,java.lang.String> definedSymbols
protected boolean skipState
protected java.util.Stack<java.lang.Boolean> skipStates
protected int lineCount
protected java.io.BufferedWriter outputWriter
protected java.lang.String sourceFileName
protected java.lang.String destFileName
protected java.lang.String directiveLeadIn
protected java.lang.String defineDirective
protected java.lang.String undefineDirective
protected java.lang.String includeDirective
protected java.lang.String ifdefDirective
protected java.lang.String ifndefDirective
protected java.lang.String endifDirective
public Preprocessor()
public Preprocessor(java.lang.String leadIn)
protected void defineSymbol(java.lang.String symbol, java.lang.String value)
symbol
- The symbol to define.value
- Symbol value.protected void undefineSymbol(java.lang.String symbol)
symbol
- Symbol to undefine.protected boolean symbolDefined(java.lang.String symbol)
symbol
- Symbol name to check if defined.protected java.lang.String resolve(java.lang.String s)
s
- The string containing symbols to replace.protected void processFile(java.lang.String sourceFileName, java.io.BufferedWriter outputWriter, boolean quiet) throws java.lang.Exception
sourceFileName
- File to preprocess.outputWriter
- Output writer. Must be open.quiet
- True to suppress progress messages.java.lang.Exception
- If something goes wrong.public boolean preprocess(java.lang.String sourceFileName, java.lang.String destFileName, boolean quiet)
sourceFileName
- The source file to preprocess.destFileName
- The destination file.quiet
- true to suppress progress messages.public boolean preprocess(java.lang.String sourceFileName, java.lang.String destFileName)
sourceFileName
- The source file to preprocess.destFileName
- The destination file.public int getLineCount()
public static void main(java.lang.String[] args)
args
- Command line arguments.