Skip to content

Commit

Permalink
#162: Minor refactorings.
Browse files Browse the repository at this point in the history
  • Loading branch information
jvdb committed Jun 9, 2017
1 parent 32e5bd4 commit b5e0d7f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/io/parsingdata/metal/token/Nod.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Nod(final String name, final ValueExpression size, final Encoding encodin
}

@Override
protected Optional<Environment> parseImpl(final String scope, final Environment environment, final Encoding encoding) throws IOException {
protected Optional<Environment> parseImpl(final String scope, final Environment environment, final Encoding encoding) {
final ImmutableList<Optional<Value>> sizes = size.eval(environment.order, encoding);
if (sizes.size != 1 || !sizes.head.isPresent()) {
return failure();
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/io/parsingdata/metal/token/Pre.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.Objects;
import java.util.Optional;

import io.parsingdata.metal.Util;
import io.parsingdata.metal.data.Environment;
import io.parsingdata.metal.encoding.Encoding;
import io.parsingdata.metal.expression.Expression;
Expand Down Expand Up @@ -57,7 +58,7 @@ protected Optional<Environment> parseImpl(final String scope, final Environment
return failure();
}
final Optional<Environment> result = token.parse(scope, environment.addBranch(this), encoding);
return result.isPresent() ? success(result.get().closeBranch()) : failure();
return result.map(resultEnvironment -> success(resultEnvironment.closeBranch())).orElseGet(Util::failure);
}

@Override
Expand Down

0 comments on commit b5e0d7f

Please sign in to comment.