Improve string parser supplier argument checking
This commit is contained in:
parent
897eafba79
commit
a0c80582d3
1 changed files with 9 additions and 4 deletions
|
|
@ -152,16 +152,21 @@ public final class StandardParserRegistry<C> implements ParserRegistry<C> {
|
||||||
final boolean greedy = options.get(StandardParameters.GREEDY, false);
|
final boolean greedy = options.get(StandardParameters.GREEDY, false);
|
||||||
final boolean greedyFlagAware = options.get(StandardParameters.FLAG_YIELDING, false);
|
final boolean greedyFlagAware = options.get(StandardParameters.FLAG_YIELDING, false);
|
||||||
final boolean quoted = options.get(StandardParameters.QUOTED, false);
|
final boolean quoted = options.get(StandardParameters.QUOTED, false);
|
||||||
if (greedy && quoted) {
|
if (greedyFlagAware && quoted) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"Don't know whether to create GREEDY_FLAG_YIELDING or QUOTED StringArgument.StringParser, both specified."
|
||||||
|
);
|
||||||
|
} else if (greedy && quoted) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Don't know whether to create GREEDY or QUOTED StringArgument.StringParser, both specified."
|
"Don't know whether to create GREEDY or QUOTED StringArgument.StringParser, both specified."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final StringArgument.StringMode stringMode;
|
final StringArgument.StringMode stringMode;
|
||||||
if (greedy) {
|
// allow @Greedy and @FlagYielding to both be true, give flag yielding priority
|
||||||
stringMode = StringArgument.StringMode.GREEDY;
|
if (greedyFlagAware) {
|
||||||
} else if (greedyFlagAware) {
|
|
||||||
stringMode = StringArgument.StringMode.GREEDY_FLAG_YIELDING;
|
stringMode = StringArgument.StringMode.GREEDY_FLAG_YIELDING;
|
||||||
|
} else if (greedy) {
|
||||||
|
stringMode = StringArgument.StringMode.GREEDY;
|
||||||
} else if (quoted) {
|
} else if (quoted) {
|
||||||
stringMode = StringArgument.StringMode.QUOTED;
|
stringMode = StringArgument.StringMode.QUOTED;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue