mirror of
https://github.com/plexusorg/toml4j.git
synced 2024-12-29 11:42:15 +00:00
Booleans no longer handled by Parboiled
This commit is contained in:
parent
e0762bf82a
commit
7380d74592
2 changed files with 5 additions and 10 deletions
|
@ -1,10 +1,7 @@
|
|||
package com.moandjiezana.toml;
|
||||
|
||||
import static com.moandjiezana.toml.ValueConverterUtils.INVALID;
|
||||
import static com.moandjiezana.toml.ValueConverterUtils.parse;
|
||||
import static com.moandjiezana.toml.ValueConverterUtils.parser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
class BooleanConverter implements ValueConverter {
|
||||
|
||||
|
@ -17,13 +14,15 @@ class BooleanConverter implements ValueConverter {
|
|||
|
||||
@Override
|
||||
public Object convert(String s) {
|
||||
List<String> resultValue = parse(parser().Boolean(), s);
|
||||
Boolean b = s.startsWith("true") ? Boolean.TRUE : Boolean.FALSE;
|
||||
|
||||
if (resultValue == null) {
|
||||
int endIndex = b == Boolean.TRUE ? 4 : 5;
|
||||
|
||||
if (!ValueConverterUtils.isComment(s.substring(endIndex))) {
|
||||
return INVALID;
|
||||
}
|
||||
|
||||
return Boolean.valueOf(resultValue.get(0));
|
||||
return b;
|
||||
}
|
||||
|
||||
private BooleanConverter() {}
|
||||
|
|
|
@ -26,10 +26,6 @@ class ValueParser extends BaseParser<List<Object>> {
|
|||
return FirstOf(EmptyMultilineLiteralString(), Sequence("'''", startList(), Sequence(OneOrMore(TestNot("'''"), ANY), pushToken(match())), "'''", endList(), Comment()));
|
||||
}
|
||||
|
||||
public Rule Boolean() {
|
||||
return Sequence(startList(), FirstOf("true", "false"), pushToken(match()), endList(), Comment());
|
||||
}
|
||||
|
||||
public Rule Integer() {
|
||||
return Sequence(startList(), Sequence(SignedNumber(), pushToken(match())), endList(), Comment());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue