public abstract class Model extends Object
Compiler
.
parse(String[], msgr) V parse(String, msgr) // blanks are escaped ! | V / main parsing loop <=========================================\ | \ (recover after error!) \ V \ -------------------------------------- GENERATED CODE | | parseName /parseAbbrev/parsePositionals | | V | | | parse_| | | | | | | | ---------------------------------|--------------------- | | | V | | | V parseEnum | | V parseInt | | parseInit | | | V V | T_ERROR ERROR_UNKNOWN_NAME / \ \ / \_________\_________>THROW exception /
Modifier and Type | Class and Description |
---|---|
protected class |
Model.ExcDuplicate
Thrown if option appears more than once.
|
protected class |
Model.ExcFinish
Thrown if "skip to next option" error recovery reaches end of input.
|
protected class |
Model.ExcNoData
Thrown if argument is needed, but end of line reached.
|
protected class |
Model.ExcNoData_allowed
Thrown if end of line reached when new positional parameter could start.
|
protected class |
Model.ExcUnknownOpt
Thrown if option name / abbrev is unknown.
|
protected class |
Model.ExcWrongType
Thrown if argument is of wrong type.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
boolresult
Result of trying the boolean parser.
|
protected String |
curOption
Human readable identification of the option currently being parsed.
|
protected int |
curParam
Number of the argument (relative to begin of option's types, or to
repeting group!) currently being parsed.
|
protected int |
curParamGroup
Number of the repeting group which is under parsing, or
-1
in case the fixed part is currently being parsed. |
CatalogByString |
descriptions
Filled in by generated code.
|
protected int |
inputlength |
protected String |
inputstring
Input concatentated into one single string, only input data for
the parsing process.
|
protected Matcher |
m_escapedBlanks |
protected Matcher |
matcher
Re-used matcher for the input, once loaded with string data,
then linked to different patterns!
|
protected String |
nextAbbrev
Written to by
updateOptTokens() |
protected String |
nextName
Written to by
updateOptTokens() |
protected String |
nextPToken
Argument token, written be
lookForPToken() and read by type-specific scanners
parseInt() , etc. |
protected boolean |
optTokenValid
Whether an opt token has been consumed and stored
to
nextName or to nextAbbrev . |
protected static Pattern |
p_escapedBlanks |
protected static Pattern |
p_hideblanks
Pattern to recognize blank characters, for escaping them prior to parsing.
|
protected static Pattern |
p_option
Pattern for option keywords (long and short)
|
protected static Pattern |
p_param
Pattern for parameters, ie sections without blanks, or only with
BACKSLASH-ESCAPED blanks.
|
protected SimpleMessage.Generator<Location<String>> |
parseErrorGenerator |
protected boolean |
positionalPhase
Set by runtime code for correct end-of-cmdline handling.
|
protected boolean |
positionalsExplicit
Set by generated code, whenever a positional option has
already been set explitly.
|
protected boolean |
positionalsFound
Set by generated code, whenever a positional option is set implicitly.
|
protected StringBuilder |
protocol
Debugging only !?!?
|
Constructor and Description |
---|
Model() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
_finalCheck()
Callback, overridden by compiled code.
|
protected abstract String |
_getMissingParams() |
protected boolean |
canReenterRepetitionGroup()
Returns only true if there is NO option lead in, AND more character data.
|
static String |
descriptionKeyForCommentField(String name) |
static String |
descriptionKeyForEnum(Class<?> cl) |
static String |
descriptionKeyForEnum(GeneratedClass cl) |
static String |
descriptionKeyForEnumItem(Class<?> cl,
Object item) |
protected void |
ERROR_plus() |
protected void |
ERROR_UNKNOWN_ABBREV()
Called from compiled code.
|
protected void |
ERROR_UNKNOWN_NAME()
Called from compiled code.
|
protected void |
ERROR(String s)
Only source of error messages.
|
String |
getInputString()
Get parsing input, maybe constructred from a String-array.
|
String |
getMissingParams()
Get String of missing parameters, is empty if none are missing.
|
protected void |
getNextPToken()
Decodes next argument token.
|
protected void |
getOptToken()
Decode next option name token, if not already done.
|
String |
getParsingProtocol()
DEBUG only
|
protected void |
lookForPToken()
Decode argument token, advance input, set nextPtoken for further processing.
|
abstract Model |
makeEmptyInstance() |
protected void |
P_ERROR(String msg)
Generate error message related to the current option
and (possibly) repetition group number.
|
void |
parse(String[] args,
MessageReceiver mr)
The main entry for setting all values according to some
command line input, as reaching
public void main(String[])
from some exec system call. |
protected abstract void |
parseAbbrev(String s)
Callback, overridden by compiled code.
|
protected boolean |
parseBool_optional()
Called by compiled code for "switch-type", argument-less options.
|
protected boolean |
parseBool_X()
Aux function, return whether the next token is a representation of
a boolean value, and put the result into
boolresult . |
protected boolean |
parseBool()
Called by compiled code for REQUIRED boolean arguments.
|
protected char |
parseChar()
Called by compiled code.
|
protected <E extends Enum<E>> |
parseEnum(Class<E> enumclass)
Called by compiled code.
|
protected <E extends Enum<E>> |
parseEnumSet(Class<E> enumclass)
Called by compiled code.
FIXME: only the "compilable" enumItem is parsed, not a possibly "uncomilable" @value. |
protected double |
parseFloat()
Called from compiled code.
|
protected void |
parseInit(String opt,
boolean hasIt)
Called from compiled code when starting each option.
|
protected int |
parseInt()
Called from compiled code.
|
protected abstract void |
parseName(String s)
Callback, overridden by compiled code.
|
void |
parseOneString(String s,
MessageReceiver mr)
Central entry point in case the command line data is already
packed into one single String, with escaped blanks.
|
protected String |
parseOneUri()
Called by compiled code.
|
protected abstract void |
parsePositionals()
Callback, overridden by compiled code.
|
protected String |
parseString()
Called by compiled code.
|
protected void |
putprot_option(String s) |
protected void |
putprot(String s) |
protected static String |
serialize(boolean value)
Called by compiled code.
|
protected static String |
serialize(char value)
Called by compiled code.
|
protected static String |
serialize(double value)
Called by compiled code.
|
protected static <E extends Enum<E>> |
serialize(E value)
Called by compiled code.
|
protected static <E extends Enum<E>> |
serialize(EnumSet<E> value)
Called by compiled code.
|
protected static String |
serialize(int value)
Called by compiled code.
|
protected static String |
serialize(String value)
Called by compiled code.
|
protected void |
skipToOption()
Skip input to next option token, if not already done.
|
protected void |
T_ERROR(String msg)
Generate error message on wrong argument type and THROW exception.
|
protected String |
unescapeBlanks(String s) |
protected void |
updateOptTokens()
Decide whether long or short name, and store it to
nextName or nextAbbrev . |
protected void |
WARNING(String s)
Only source of warning messages.
|
protected SimpleMessage.Generator<Location<String>> parseErrorGenerator
protected transient StringBuilder protocol
public CatalogByString descriptions
protected String inputstring
protected transient int inputlength
protected transient String curOption
protected transient int curParam
protected transient int curParamGroup
-1
in case the fixed part is currently being parsed.protected static final Pattern p_option
protected static final Pattern p_param
protected transient Matcher matcher
protected transient String nextPToken
lookForPToken()
and read by type-specific scanners
parseInt()
, etc.protected transient boolean optTokenValid
nextName
or to nextAbbrev
. Invalidated after
its decoding and in parseInit(String, boolean)
.protected transient String nextName
updateOptTokens()
protected transient String nextAbbrev
updateOptTokens()
protected boolean positionalsExplicit
protected boolean positionalsFound
protected boolean positionalPhase
protected static final Pattern p_hideblanks
protected boolean boolresult
protected static final Pattern p_escapedBlanks
protected final Matcher m_escapedBlanks
protected void ERROR(String s)
protected void WARNING(String s)
protected void putprot(String s)
protected void putprot_option(String s)
public static String descriptionKeyForEnum(GeneratedClass cl)
public abstract Model makeEmptyInstance()
protected abstract void _finalCheck()
protected abstract void parseAbbrev(String s)
protected abstract void parseName(String s)
protected abstract void parsePositionals()
protected void P_ERROR(String msg)
protected void ERROR_plus()
protected void T_ERROR(String msg)
protected void updateOptTokens()
nextName
or nextAbbrev
.
Skip input and set optTokenValid flag.
IS ONLY CALLED when match is known to succeed!protected void getOptToken()
parseInit(String, boolean)
.protected void skipToOption()
protected void lookForPToken()
getNextPToken()
,
and as look-ahead for "can re-enter rep group" criterion.
NB result-var is re-set after successul decoding in "parseprotected boolean canReenterRepetitionGroup()
protected void getNextPToken()
public void parseOneString(String s, MessageReceiver mr)
public void parse(String[] args, MessageReceiver mr)
public void main(String[])
from some exec
system call.public String getParsingProtocol()
public String getInputString()
public String getMissingParams()
protected abstract String _getMissingParams()
protected void parseInit(String opt, boolean hasIt)
protected void ERROR_UNKNOWN_NAME()
protected void ERROR_UNKNOWN_ABBREV()
protected int parseInt()
protected double parseFloat()
protected boolean parseBool_X()
boolresult
.protected boolean parseBool_optional()
protected boolean parseBool()
protected String parseString()
protected String parseOneUri()
protected char parseChar()
protected <E extends Enum<E>> EnumSet<E> parseEnumSet(Class<E> enumclass)
protected static String serialize(int value)
protected static String serialize(double value)
protected static String serialize(char value)
protected static String serialize(boolean value)
see also the complete user documentation .