public class E4GLPreprocessor extends java.lang.Object implements E4GLConstants
main(java.lang.String[])
or via a programming API (see
preprocess(boolean, java.io.PrintStream)
).Modifier and Type | Field and Description |
---|---|
private Options |
opts
Stores options that control the behavior of the preprocessor.
|
BLUE_DIAMOND, DEFAULT_MODE, MODE_NAMES, OPT_FOUND, OPT_INCLUDE, OPT_KEEP, OPT_WEB_OBJ, UNKNOWN_MODE, WEBSPEED, WEBSPEED_STRICT
Constructor and Description |
---|
E4GLPreprocessor(java.lang.String input)
Create a preprocess instance that can be used to handle the E4GL
preprocessing for a single HTML file and convert that file into a
valid 4GL source file.
|
E4GLPreprocessor(java.lang.String input,
int mode)
Create a preprocess instance that can be used to handle the E4GL
preprocessing for a single HTML file and convert that file into a
valid 4GL source file.
|
E4GLPreprocessor(java.lang.String input,
int mode,
java.lang.String other)
Create a preprocess instance that can be used to handle the E4GL
preprocessing for a single HTML file and convert that file into a
valid 4GL source file.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
calculateOutputDest()
Use the input filename and the known options to calculate the filename
for the output destination.
|
static int |
decodeMode(java.lang.String name)
Decode a compatibility mode name into the corresponding mode constant.
|
java.lang.String |
getInput()
Access the specified input filename.
|
java.lang.String |
getOpsys()
Gets the operating system name which must be used to determine how
escape characters are treated.
|
Options |
getOptions()
Access the specified and/or calculated options for preprocessing the
current input file.
|
java.lang.String |
getOutput()
Access the calculated output filename.
|
java.io.PrintStream |
getOutputDest()
Get a stream that outputs to the file specified by the current output
filename (see
getOutput() ). |
E4GLParser |
getParser()
Create a new instance of the E4GL parser based on previously set
configuration.
|
static void |
main(java.lang.String[] args)
Command line driver for E4GL preprocessing.
|
void |
preprocess(boolean scan,
java.io.PrintStream out)
Read the HTML input file and convert it into 4GL source code.
|
void |
scanForWSOptions()
Scan the input file to parse out any options that are encoded in
<META> or <!--WSMETA--> elements.
|
void |
setInput(java.lang.String input)
Set the specified input filename.
|
void |
setOpsys(java.lang.String opsys)
Sets the operating system name which must be used to determine how
escape characters are treated.
|
void |
setOptions(Options options)
Replace the specified and/or calculated options for preprocessing the
current input file.
|
void |
setOutput(java.lang.String output)
Set the specified output filename.
|
private static void |
syntax(java.lang.String msg,
int rc)
Emit a syntax statement and optional error message to
stderr , then exit the process with the specified return
code. |
private Options opts
public E4GLPreprocessor(java.lang.String input)
input
- Filename of the input HTML file.public E4GLPreprocessor(java.lang.String input, int mode)
input
- Filename of the input HTML file.mode
- Compatibility mode controlling the code generation (see
E4GLConstants
).public E4GLPreprocessor(java.lang.String input, int mode, java.lang.String other)
input
- Filename of the input HTML file.mode
- Compatibility mode controlling the code generation (see
E4GLConstants
).other
- Manually specified options string.public static int decodeMode(java.lang.String name)
The following mappings are implemented:
Name Mode Constant ----------------------- ----------------- ws WEBSPEED webspeed WEBSPEED ws_strict WEBSPEED_STRICT webspeed_strict WEBSPEED_STRICT bd BLUE_DIAMOND blue_diamond BLUE_DIAMOND
name
- The mode name.UNKNOWN_MODE
if there is
any problem.public void preprocess(boolean scan, java.io.PrintStream out)
scan
- true
to scan the input file to resolve all
options before the preprocessing occurs. false
will bypass the scan and use the options that are already
known.out
- An explicit stream to use as the destination for the
preprocessed output. null
means that the
preprocessor should create its own stream using the current
output filename OR if that filename is null
,
then the preprocessor will calculate the output filename
(see calculateOutputDest()
) and then create a
stream to use.public E4GLParser getParser()
E4GLParser.getInput()
and to call
close
on that stream. Neither the parser nor the lexer
(that is being used by the parser) close the input stream when
complete. It is the caller's responsibility to do this!public void scanForWSOptions()
getOptions()
.public java.lang.String calculateOutputDest()
scanForWSOptions()
before calling this method. The resulting filename will be stored in
the current options for downstream usage by the preprocessor.public Options getOptions()
public void setOptions(Options options)
scanForWSOptions()
and/or manually set options strings
in the preprocessor constructor.options
- The options for this preprocessor instance.public java.lang.String getInput()
public void setInput(java.lang.String input)
input
- A filename.public java.lang.String getOutput()
public void setOutput(java.lang.String output)
output
- A filename.public java.lang.String getOpsys()
public void setOpsys(java.lang.String opsys)
opsys
- The new operating system name.public java.io.PrintStream getOutputDest()
getOutput()
). The target file will be removed if
it exists.null
if any failure occurs.private static void syntax(java.lang.String msg, int rc)
stderr
, then exit the process with the specified return
code. This method is called from main(java.lang.String[])
when the user passes
command line parameters which are not viable.msg
- Optional error message; may be null
.rc
- Process return code used with System.exit()
.public static void main(java.lang.String[] args)
Syntax:
java E4GLPreprocessor [-options] <file>Where:
args
- Command line parameters. Use matching double quotes to
pass any argument that requires special characters or
whitespace.