Booleans no longer handled by Parboiled

This commit is contained in:
moandji.ezana 2015-01-23 15:27:48 +02:00
parent e0762bf82a
commit 7380d74592
2 changed files with 5 additions and 10 deletions

View file

@ -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() {}

View file

@ -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());
}