diff --git a/README.md b/README.md index a400a6a5..c26a52e7 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,13 @@ A Java library for parsing binary data formats, using declarative descriptions. ## Using Metal -Metal releases are available in the central Maven repository. To use the latest (9.0.0) release of Metal, include the following section in the pom.xml under dependencies: +Metal releases are available in the central Maven repository. To use the latest (10.0.0) release of Metal, include the following section in the pom.xml under dependencies: ```xml io.parsingdata metal-core - 9.0.0 + 10.0.0 ``` @@ -37,8 +37,8 @@ Please read the [Authenticating to GitHub Packages](https://docs.github.com/en/p ## License -Copyright 2013-2023 Netherlands Forensic Institute -Copyright 2021-2023 Infix Technologies B.V. +Copyright 2013-2024 Netherlands Forensic Institute +Copyright 2021-2024 Infix Technologies B.V. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/core/pom.xml b/core/pom.xml index a7978bd6..a53c4495 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -3,7 +3,7 @@ io.parsingdata metal - 10.0.0-SNAPSHOT + 11.0.0-SNAPSHOT metal-core ${project.groupId}:${project.artifactId} @@ -14,6 +14,7 @@ scm:git:git@github.com:parsingdata/metal.git scm:git:git@github.com:parsingdata/metal.git https://github.com/parsingdata/metal.git + HEAD diff --git a/core/src/main/java/io/parsingdata/metal/Shorthand.java b/core/src/main/java/io/parsingdata/metal/Shorthand.java index 12b76c57..2f67d041 100644 --- a/core/src/main/java/io/parsingdata/metal/Shorthand.java +++ b/core/src/main/java/io/parsingdata/metal/Shorthand.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +54,6 @@ import io.parsingdata.metal.expression.value.FoldRight; import io.parsingdata.metal.expression.value.Join; import io.parsingdata.metal.expression.value.Reverse; -import io.parsingdata.metal.expression.value.Scope; import io.parsingdata.metal.expression.value.SingleValueExpression; import io.parsingdata.metal.expression.value.UnaryValueExpression; import io.parsingdata.metal.expression.value.Value; @@ -348,7 +348,11 @@ private Shorthand() {} public static BinaryValueExpression mapRight(final BiFunction func, final SingleValueExpression leftExpand, final ValueExpression right) { return func.apply(exp(leftExpand, count(right)), right); } /** @see Bytes */ public static ValueExpression bytes(final ValueExpression operand) { return new Bytes(operand); } - /** @see Scope */ public static ValueExpression scope(final ValueExpression scopedValueExpression, final SingleValueExpression scopeSize) { return new Scope(scopedValueExpression, scopeSize); } + + /** @see Ref */ public static NameRef scope(final NameRef operand) { return scope(operand, con(0)); } + /** @see Ref */ public static NameRef scope(final NameRef operand, final SingleValueExpression scopeSize) { return operand.withScope(scopeSize); } + /** @see Ref */ public static DefinitionRef scope(final DefinitionRef operand) { return scope(operand, con(0)); } + /** @see Ref */ public static DefinitionRef scope(final DefinitionRef operand, final SingleValueExpression scopeSize) { return operand.withScope(scopeSize); } /** @see And */ public static BinaryLogicalExpression and(final Expression left, final Expression right) { return new And(left, right); } /** @see Or */ public static BinaryLogicalExpression or(final Expression left, final Expression right) { return new Or(left, right); } diff --git a/core/src/main/java/io/parsingdata/metal/Trampoline.java b/core/src/main/java/io/parsingdata/metal/Trampoline.java index 63b13ae1..e15172c7 100644 --- a/core/src/main/java/io/parsingdata/metal/Trampoline.java +++ b/core/src/main/java/io/parsingdata/metal/Trampoline.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/Util.java b/core/src/main/java/io/parsingdata/metal/Util.java index ae797224..a7c37e27 100644 --- a/core/src/main/java/io/parsingdata/metal/Util.java +++ b/core/src/main/java/io/parsingdata/metal/Util.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/data/ByteStream.java b/core/src/main/java/io/parsingdata/metal/data/ByteStream.java index 42f57236..44ffe35f 100644 --- a/core/src/main/java/io/parsingdata/metal/data/ByteStream.java +++ b/core/src/main/java/io/parsingdata/metal/data/ByteStream.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/data/ByteStreamSource.java b/core/src/main/java/io/parsingdata/metal/data/ByteStreamSource.java index aee9a966..4e791ba9 100644 --- a/core/src/main/java/io/parsingdata/metal/data/ByteStreamSource.java +++ b/core/src/main/java/io/parsingdata/metal/data/ByteStreamSource.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/data/ConcatenatedValueSource.java b/core/src/main/java/io/parsingdata/metal/data/ConcatenatedValueSource.java index 3b866350..19ae581d 100644 --- a/core/src/main/java/io/parsingdata/metal/data/ConcatenatedValueSource.java +++ b/core/src/main/java/io/parsingdata/metal/data/ConcatenatedValueSource.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/data/ConstantSource.java b/core/src/main/java/io/parsingdata/metal/data/ConstantSource.java index 3c74d9d3..51eb4354 100644 --- a/core/src/main/java/io/parsingdata/metal/data/ConstantSource.java +++ b/core/src/main/java/io/parsingdata/metal/data/ConstantSource.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/data/DataExpressionSource.java b/core/src/main/java/io/parsingdata/metal/data/DataExpressionSource.java index 29864f71..232c283f 100644 --- a/core/src/main/java/io/parsingdata/metal/data/DataExpressionSource.java +++ b/core/src/main/java/io/parsingdata/metal/data/DataExpressionSource.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/data/Environment.java b/core/src/main/java/io/parsingdata/metal/data/Environment.java index b3ce7028..c8fa7c17 100644 --- a/core/src/main/java/io/parsingdata/metal/data/Environment.java +++ b/core/src/main/java/io/parsingdata/metal/data/Environment.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/data/ImmutablePair.java b/core/src/main/java/io/parsingdata/metal/data/ImmutablePair.java index 73b1fa3d..a38d3b69 100644 --- a/core/src/main/java/io/parsingdata/metal/data/ImmutablePair.java +++ b/core/src/main/java/io/parsingdata/metal/data/ImmutablePair.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/data/ParseGraph.java b/core/src/main/java/io/parsingdata/metal/data/ParseGraph.java index b1e01df5..1dc52310 100644 --- a/core/src/main/java/io/parsingdata/metal/data/ParseGraph.java +++ b/core/src/main/java/io/parsingdata/metal/data/ParseGraph.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/data/ParseItem.java b/core/src/main/java/io/parsingdata/metal/data/ParseItem.java index c153963f..9727d463 100644 --- a/core/src/main/java/io/parsingdata/metal/data/ParseItem.java +++ b/core/src/main/java/io/parsingdata/metal/data/ParseItem.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/data/ParseReference.java b/core/src/main/java/io/parsingdata/metal/data/ParseReference.java index a9e75cc3..46633189 100644 --- a/core/src/main/java/io/parsingdata/metal/data/ParseReference.java +++ b/core/src/main/java/io/parsingdata/metal/data/ParseReference.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/data/ParseState.java b/core/src/main/java/io/parsingdata/metal/data/ParseState.java index e8b7d9af..0755f224 100644 --- a/core/src/main/java/io/parsingdata/metal/data/ParseState.java +++ b/core/src/main/java/io/parsingdata/metal/data/ParseState.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,18 +42,20 @@ public class ParseState extends ImmutableObject { public final Source source; public final ImmutableList> iterations; public final ImmutableList references; + public final int scopeDepth; - public ParseState(final ParseGraph order, final ParseValueCache cache, final Source source, final BigInteger offset, final ImmutableList> iterations, final ImmutableList references) { + public ParseState(final ParseGraph order, final ParseValueCache cache, final Source source, final BigInteger offset, final ImmutableList> iterations, final ImmutableList references, final int scopeDepth) { this.order = checkNotNull(order, "order"); this.cache = checkNotNull(cache, "cache"); this.source = checkNotNull(source, "source"); this.offset = checkNotNegative(offset, "offset"); this.iterations = checkNotNull(iterations, "iterations"); this.references = checkNotNull(references, "references"); + this.scopeDepth = scopeDepth; } public static ParseState createFromByteStream(final ByteStream input, final BigInteger offset) { - return new ParseState(ParseGraph.EMPTY, new ParseValueCache(), new ByteStreamSource(input), offset, new ImmutableList<>(), new ImmutableList<>()); + return new ParseState(ParseGraph.EMPTY, new ParseValueCache(), new ByteStreamSource(input), offset, new ImmutableList<>(), new ImmutableList<>(), 0); } public static ParseState createFromByteStream(final ByteStream input) { @@ -60,42 +63,42 @@ public static ParseState createFromByteStream(final ByteStream input) { } public ParseState addBranch(final Token token) { - return new ParseState(order.addBranch(token), cache, source, offset, token.isIterable() ? iterations.addHead(new ImmutablePair<>(token, ZERO)) : iterations, references); + return new ParseState(order.addBranch(token), cache, source, offset, token.isIterable() ? iterations.addHead(new ImmutablePair<>(token, ZERO)) : iterations, references, token.isScopeDelimiter() ? scopeDepth + 1 : scopeDepth); } public ParseState closeBranch(final Token token) { if (token.isIterable() && !iterations.head().left.equals(token)) { throw new IllegalStateException(format("Cannot close branch for iterable token %s. Current iteration state is for token %s.", token.name, iterations.head().left.name)); } - return new ParseState(order.closeBranch(), cache, source, offset, token.isIterable() ? iterations.tail() : iterations, references); + return new ParseState(order.closeBranch(), cache, source, offset, token.isIterable() ? iterations.tail() : iterations, references, token.isScopeDelimiter() ? scopeDepth - 1 : scopeDepth); } public ParseState add(final ParseReference parseReference) { - return new ParseState(order, cache, source, offset, iterations, references.addHead(parseReference)); + return new ParseState(order, cache, source, offset, iterations, references.addHead(parseReference), scopeDepth); } public ParseState add(final ParseValue parseValue) { - return new ParseState(order.add(parseValue), cache.add(parseValue), source, offset, iterations, references); + return new ParseState(order.add(parseValue), cache.add(parseValue), source, offset, iterations, references, scopeDepth); } public ParseState createCycle(final ParseReference parseReference) { - return new ParseState(order.add(parseReference), cache, source, offset, iterations, references); + return new ParseState(order.add(parseReference), cache, source, offset, iterations, references, scopeDepth); } public ParseState iterate() { - return new ParseState(order, cache, source, offset, iterations.tail().addHead(new ImmutablePair<>(iterations.head().left, iterations.head().right.add(ONE))), references); + return new ParseState(order, cache, source, offset, iterations.tail().addHead(new ImmutablePair<>(iterations.head().left, iterations.head().right.add(ONE))), references, scopeDepth); } public Optional seek(final BigInteger newOffset) { - return newOffset.compareTo(ZERO) >= 0 ? Optional.of(new ParseState(order, cache, source, newOffset, iterations, references)) : Optional.empty(); + return newOffset.compareTo(ZERO) >= 0 ? Optional.of(new ParseState(order, cache, source, newOffset, iterations, references, scopeDepth)) : Optional.empty(); } public ParseState withOrder(final ParseGraph order) { - return new ParseState(order, NO_CACHE, source, offset, iterations, references); + return new ParseState(order, NO_CACHE, source, offset, iterations, references, scopeDepth); } public ParseState withSource(final Source source) { - return new ParseState(order, cache, source, ZERO, iterations, references); + return new ParseState(order, cache, source, ZERO, iterations, references, scopeDepth); } public Optional slice(final BigInteger length) { @@ -106,7 +109,7 @@ public Optional slice(final BigInteger length) { public String toString() { final String iterationsString = iterations.isEmpty() ? "" : ";iterations:" + iterations; final String referencesString = references.isEmpty() ? "" : ";references:" + references; - return getClass().getSimpleName() + "(source:" + source + ";offset:" + offset + ";order:" + order + iterationsString + referencesString + ";" + cache + ")"; + return getClass().getSimpleName() + "(source:" + source + ";offset:" + offset + ";order:" + order + iterationsString + referencesString + ";scopeDepth:" + scopeDepth + ";" + cache + ")"; } @Override @@ -117,12 +120,13 @@ public boolean equals(final Object obj) { && Objects.equals(offset, ((ParseState)obj).offset) && Objects.equals(source, ((ParseState)obj).source) && Objects.equals(iterations, ((ParseState)obj).iterations) - && Objects.equals(references, ((ParseState)obj).references); + && Objects.equals(references, ((ParseState)obj).references) + && Objects.equals(scopeDepth, ((ParseState)obj).scopeDepth); } @Override public int immutableHashCode() { - return Objects.hash(getClass(), order, cache, offset, source, iterations, references); + return Objects.hash(getClass(), order, cache, offset, source, iterations, references, scopeDepth); } } diff --git a/core/src/main/java/io/parsingdata/metal/data/ParseValue.java b/core/src/main/java/io/parsingdata/metal/data/ParseValue.java index cacbdd43..5830b574 100644 --- a/core/src/main/java/io/parsingdata/metal/data/ParseValue.java +++ b/core/src/main/java/io/parsingdata/metal/data/ParseValue.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/data/Selection.java b/core/src/main/java/io/parsingdata/metal/data/Selection.java index 45b86b4a..ff3fb7dd 100644 --- a/core/src/main/java/io/parsingdata/metal/data/Selection.java +++ b/core/src/main/java/io/parsingdata/metal/data/Selection.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -89,6 +90,20 @@ public static ImmutableList getAllValues(final ParseGraph graph, fin return getAllValues(graph, predicate, NO_LIMIT); } + public static ImmutableList getAllValues(final ParseGraph graph, final Predicate predicate, final int limit, final int requestedScope, final int currentScope) { + return getAllScopedValues(graph, predicate, limit, requestedScope, currentScope).computeResult(); + } + + private static Trampoline> getAllScopedValues(final ParseGraph graph, final Predicate predicate, final int limit, final int requestedScope, final int currentScope) { + if (graph.isEmpty() || limit == 0) { + return complete(ImmutableList::new); + } + if (requestedScope >= currentScope) { + return complete(() -> getAllValues(graph, predicate, limit)); + } + return intermediate(() -> getAllScopedValues(graph.head.asGraph(), predicate, limit, requestedScope, graph.head.getDefinition().isScopeDelimiter() ? currentScope - 1 : currentScope)); + } + private static Trampoline> getAllValues(final ImmutableList graphList, final ImmutableList valueList, final Predicate predicate, final int limit) { if (graphList.isEmpty() || (long) valueList.size() == limit) { return complete(() -> valueList); diff --git a/core/src/main/java/io/parsingdata/metal/data/Slice.java b/core/src/main/java/io/parsingdata/metal/data/Slice.java index 7c08f617..1a068c87 100644 --- a/core/src/main/java/io/parsingdata/metal/data/Slice.java +++ b/core/src/main/java/io/parsingdata/metal/data/Slice.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/data/Source.java b/core/src/main/java/io/parsingdata/metal/data/Source.java index 2aa40bfd..ff05efd7 100644 --- a/core/src/main/java/io/parsingdata/metal/data/Source.java +++ b/core/src/main/java/io/parsingdata/metal/data/Source.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/data/callback/Callback.java b/core/src/main/java/io/parsingdata/metal/data/callback/Callback.java index ddf59c66..57de129b 100644 --- a/core/src/main/java/io/parsingdata/metal/data/callback/Callback.java +++ b/core/src/main/java/io/parsingdata/metal/data/callback/Callback.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/data/callback/Callbacks.java b/core/src/main/java/io/parsingdata/metal/data/callback/Callbacks.java index cdae03f4..345fff19 100644 --- a/core/src/main/java/io/parsingdata/metal/data/callback/Callbacks.java +++ b/core/src/main/java/io/parsingdata/metal/data/callback/Callbacks.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/encoding/ByteOrder.java b/core/src/main/java/io/parsingdata/metal/encoding/ByteOrder.java index 7568d988..388ca3bd 100644 --- a/core/src/main/java/io/parsingdata/metal/encoding/ByteOrder.java +++ b/core/src/main/java/io/parsingdata/metal/encoding/ByteOrder.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/encoding/Encoding.java b/core/src/main/java/io/parsingdata/metal/encoding/Encoding.java index 29a280ac..5dddf211 100644 --- a/core/src/main/java/io/parsingdata/metal/encoding/Encoding.java +++ b/core/src/main/java/io/parsingdata/metal/encoding/Encoding.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/encoding/Sign.java b/core/src/main/java/io/parsingdata/metal/encoding/Sign.java index 866dc796..1eb57b83 100644 --- a/core/src/main/java/io/parsingdata/metal/encoding/Sign.java +++ b/core/src/main/java/io/parsingdata/metal/encoding/Sign.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/Expression.java b/core/src/main/java/io/parsingdata/metal/expression/Expression.java index 59d31d50..1709d79a 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/Expression.java +++ b/core/src/main/java/io/parsingdata/metal/expression/Expression.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/True.java b/core/src/main/java/io/parsingdata/metal/expression/True.java index 8baf17ff..49a30c73 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/True.java +++ b/core/src/main/java/io/parsingdata/metal/expression/True.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/comparison/ComparisonExpression.java b/core/src/main/java/io/parsingdata/metal/expression/comparison/ComparisonExpression.java index 33453fec..bfc92c9c 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/comparison/ComparisonExpression.java +++ b/core/src/main/java/io/parsingdata/metal/expression/comparison/ComparisonExpression.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/comparison/Eq.java b/core/src/main/java/io/parsingdata/metal/expression/comparison/Eq.java index a7e556fb..18be0011 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/comparison/Eq.java +++ b/core/src/main/java/io/parsingdata/metal/expression/comparison/Eq.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/comparison/EqNum.java b/core/src/main/java/io/parsingdata/metal/expression/comparison/EqNum.java index 86c4f310..72fb76fa 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/comparison/EqNum.java +++ b/core/src/main/java/io/parsingdata/metal/expression/comparison/EqNum.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/comparison/EqStr.java b/core/src/main/java/io/parsingdata/metal/expression/comparison/EqStr.java index 4a9dc1e0..49772670 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/comparison/EqStr.java +++ b/core/src/main/java/io/parsingdata/metal/expression/comparison/EqStr.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/comparison/GtEqNum.java b/core/src/main/java/io/parsingdata/metal/expression/comparison/GtEqNum.java index 5fde512f..01b6804c 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/comparison/GtEqNum.java +++ b/core/src/main/java/io/parsingdata/metal/expression/comparison/GtEqNum.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/comparison/GtNum.java b/core/src/main/java/io/parsingdata/metal/expression/comparison/GtNum.java index 0a2c3d54..f70748a6 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/comparison/GtNum.java +++ b/core/src/main/java/io/parsingdata/metal/expression/comparison/GtNum.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/comparison/LtEqNum.java b/core/src/main/java/io/parsingdata/metal/expression/comparison/LtEqNum.java index 42c71444..1144f14c 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/comparison/LtEqNum.java +++ b/core/src/main/java/io/parsingdata/metal/expression/comparison/LtEqNum.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/comparison/LtNum.java b/core/src/main/java/io/parsingdata/metal/expression/comparison/LtNum.java index 56fbab7e..620bc7d8 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/comparison/LtNum.java +++ b/core/src/main/java/io/parsingdata/metal/expression/comparison/LtNum.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/logical/And.java b/core/src/main/java/io/parsingdata/metal/expression/logical/And.java index 98950984..f5dd05c7 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/logical/And.java +++ b/core/src/main/java/io/parsingdata/metal/expression/logical/And.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/logical/BinaryLogicalExpression.java b/core/src/main/java/io/parsingdata/metal/expression/logical/BinaryLogicalExpression.java index a7a84b4f..c9e7ec5f 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/logical/BinaryLogicalExpression.java +++ b/core/src/main/java/io/parsingdata/metal/expression/logical/BinaryLogicalExpression.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/logical/LogicalExpression.java b/core/src/main/java/io/parsingdata/metal/expression/logical/LogicalExpression.java index e76abd28..ad46cddc 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/logical/LogicalExpression.java +++ b/core/src/main/java/io/parsingdata/metal/expression/logical/LogicalExpression.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/logical/Not.java b/core/src/main/java/io/parsingdata/metal/expression/logical/Not.java index 88cfdae9..70255f3d 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/logical/Not.java +++ b/core/src/main/java/io/parsingdata/metal/expression/logical/Not.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/logical/Or.java b/core/src/main/java/io/parsingdata/metal/expression/logical/Or.java index 1f744206..d9150946 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/logical/Or.java +++ b/core/src/main/java/io/parsingdata/metal/expression/logical/Or.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/logical/UnaryLogicalExpression.java b/core/src/main/java/io/parsingdata/metal/expression/logical/UnaryLogicalExpression.java index e2b5ed95..83ab4f2f 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/logical/UnaryLogicalExpression.java +++ b/core/src/main/java/io/parsingdata/metal/expression/logical/UnaryLogicalExpression.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/BinaryValueExpression.java b/core/src/main/java/io/parsingdata/metal/expression/value/BinaryValueExpression.java index 31290224..53d843a2 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/BinaryValueExpression.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/BinaryValueExpression.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/Bytes.java b/core/src/main/java/io/parsingdata/metal/expression/value/Bytes.java index e4d84308..5b253361 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/Bytes.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/Bytes.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/Cat.java b/core/src/main/java/io/parsingdata/metal/expression/value/Cat.java index 9b356115..46d878b8 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/Cat.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/Cat.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/Const.java b/core/src/main/java/io/parsingdata/metal/expression/value/Const.java index b2cdaef2..4186276b 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/Const.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/Const.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/ConstantFactory.java b/core/src/main/java/io/parsingdata/metal/expression/value/ConstantFactory.java index 4f5a040c..85309b27 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/ConstantFactory.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/ConstantFactory.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/CoreValue.java b/core/src/main/java/io/parsingdata/metal/expression/value/CoreValue.java index 86f5bd22..8cdf5670 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/CoreValue.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/CoreValue.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/Elvis.java b/core/src/main/java/io/parsingdata/metal/expression/value/Elvis.java index 7a6b9db5..f1ddc710 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/Elvis.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/Elvis.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/Expand.java b/core/src/main/java/io/parsingdata/metal/expression/value/Expand.java index dc84afb5..dd38a0b8 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/Expand.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/Expand.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/Fold.java b/core/src/main/java/io/parsingdata/metal/expression/value/Fold.java index 86216db7..aace55d1 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/Fold.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/Fold.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/FoldCat.java b/core/src/main/java/io/parsingdata/metal/expression/value/FoldCat.java index 970c3f8e..fc98e8d3 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/FoldCat.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/FoldCat.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/FoldLeft.java b/core/src/main/java/io/parsingdata/metal/expression/value/FoldLeft.java index bd16ed93..6ff5edf0 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/FoldLeft.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/FoldLeft.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/FoldRight.java b/core/src/main/java/io/parsingdata/metal/expression/value/FoldRight.java index fefc0cd6..f34c47eb 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/FoldRight.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/FoldRight.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/Join.java b/core/src/main/java/io/parsingdata/metal/expression/value/Join.java index 5ae7600a..2c627946 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/Join.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/Join.java @@ -1,6 +1,6 @@ /* - * Copyright 2013-2023 Netherlands Forensic Institute - * Copyright 2021-2023 Infix Technologies B.V. + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/NotAValue.java b/core/src/main/java/io/parsingdata/metal/expression/value/NotAValue.java index 801bd95e..6805edca 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/NotAValue.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/NotAValue.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/Reverse.java b/core/src/main/java/io/parsingdata/metal/expression/value/Reverse.java index 94c11ae9..bd7ae533 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/Reverse.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/Reverse.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/Scope.java b/core/src/main/java/io/parsingdata/metal/expression/value/Scope.java deleted file mode 100644 index 19ba5999..00000000 --- a/core/src/main/java/io/parsingdata/metal/expression/value/Scope.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2013-2021 Netherlands Forensic Institute - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.parsingdata.metal.expression.value; - -import static java.math.BigInteger.ZERO; - -import static io.parsingdata.metal.Trampoline.complete; -import static io.parsingdata.metal.Trampoline.intermediate; -import static io.parsingdata.metal.Util.checkNotNull; -import static io.parsingdata.metal.expression.value.NotAValue.NOT_A_VALUE; - -import java.util.Objects; - -import io.parsingdata.metal.ImmutableObject; -import io.parsingdata.metal.Trampoline; -import io.parsingdata.metal.Util; -import io.parsingdata.metal.data.ImmutableList; -import io.parsingdata.metal.data.ParseGraph; -import io.parsingdata.metal.data.ParseState; -import io.parsingdata.metal.encoding.Encoding; -import io.parsingdata.metal.token.Token; - -/** - * A {@link ValueExpression} that prunes the {@link ParseState#order} field to - * let a nested {@link ValueExpression} have only a scoped view. - *

- * A Scope expression has two operands: scopedValueExpression (a - * {@link ValueExpression} and scopeSize (a - * {@link SingleValueExpression}). The scopeSize operand is first - * evaluated, if it evaluates to NOT_A_VALUE or a negative value - * an {@link IllegalArgumentException} is thrown. Otherwise the - * order field of the parseState argument is pruned. - * This is done by removing all enclosing scopes above the amount specified by - * scopeSize. An enclosing scope is defined as an unclosed branch - * in the {@link ParseGraph} that has a scope delimiting {@link Token} as its - * definition. Next, the scopedValueExpression is - * evaluated with this pruned {@link ParseGraph} in the {@link ParseState}. - */ -public class Scope extends ImmutableObject implements ValueExpression { - - public final ValueExpression scopedValueExpression; - public final SingleValueExpression scopeSize; - - public Scope(final ValueExpression scopedValueExpression, final SingleValueExpression scopeSize) { - this.scopedValueExpression = checkNotNull(scopedValueExpression, "scopedValueExpression"); - this.scopeSize = checkNotNull(scopeSize, "scopeSize"); - } - - @Override - public ImmutableList eval(final ParseState parseState, final Encoding encoding) { - return scopeSize.evalSingle(parseState, encoding) - .filter(sizeValue -> !sizeValue.equals(NOT_A_VALUE) && sizeValue.asNumeric().compareTo(ZERO) >= 0) - .map(sizeValue -> scopedValueExpression.eval(parseState.withOrder(calculateScope(parseState.order, sizeValue.asNumeric().intValueExact())), encoding)) - .orElseThrow(() -> new IllegalArgumentException("Argument scopeSize must evaluate to a positive, countable value.")); - - } - - private ParseGraph calculateScope(final ParseGraph order, final int size) { - final ImmutableList scopeList = createScopeList(order, new ImmutableList<>()).computeResult(); - if (size >= (long) scopeList.size()) { return order; } - return findScope(scopeList, size).computeResult(); - } - - private Trampoline> createScopeList(final ParseGraph order, final ImmutableList list) { - final ImmutableList newList = order.getDefinition().isScopeDelimiter() ? list.addHead(order) : list; - if (order.isEmpty() || !order.head.isGraph()) { return complete(() -> list); } - return intermediate(() -> createScopeList(order.head.asGraph(), newList)); - } - - private Trampoline findScope(final ImmutableList scopeList, final int size) { - if (size == 0) { return complete(() -> scopeList.head()); } - return intermediate(() -> findScope(scopeList.tail(), size - 1)); - } - - @Override - public String toString() { - return getClass().getSimpleName() + "(" + scopedValueExpression + "," + scopeSize + ")"; - } - - @Override - public boolean equals(final Object obj) { - return Util.notNullAndSameClass(this, obj) - && Objects.equals(scopedValueExpression, ((Scope)obj).scopedValueExpression) - && Objects.equals(scopeSize, ((Scope)obj).scopeSize); - } - - @Override - public int immutableHashCode() { - return Objects.hash(getClass(), scopedValueExpression, scopeSize); - } - -} diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/SingleValueExpression.java b/core/src/main/java/io/parsingdata/metal/expression/value/SingleValueExpression.java index c4586bb4..ef1b3219 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/SingleValueExpression.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/SingleValueExpression.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/UnaryValueExpression.java b/core/src/main/java/io/parsingdata/metal/expression/value/UnaryValueExpression.java index fbe39c3b..f47ed391 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/UnaryValueExpression.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/UnaryValueExpression.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/Value.java b/core/src/main/java/io/parsingdata/metal/expression/value/Value.java index fd93f342..49249163 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/Value.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/Value.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/ValueExpression.java b/core/src/main/java/io/parsingdata/metal/expression/value/ValueExpression.java index 8155883a..439d52d3 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/ValueExpression.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/ValueExpression.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Add.java b/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Add.java index 643a1ff9..9a685c22 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Add.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Add.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Div.java b/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Div.java index 7f412a0e..04e19477 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Div.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Div.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Mod.java b/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Mod.java index 19d077af..4ce095bc 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Mod.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Mod.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Mul.java b/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Mul.java index d47c2b09..d22c7fae 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Mul.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Mul.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Neg.java b/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Neg.java index c4497805..c1277259 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Neg.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Neg.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Sub.java b/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Sub.java index 99a52f1b..b50edd10 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Sub.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/arithmetic/Sub.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/bitwise/And.java b/core/src/main/java/io/parsingdata/metal/expression/value/bitwise/And.java index f0551e3c..63e24e09 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/bitwise/And.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/bitwise/And.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/bitwise/Not.java b/core/src/main/java/io/parsingdata/metal/expression/value/bitwise/Not.java index 4ae7e91b..1fefc65b 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/bitwise/Not.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/bitwise/Not.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/bitwise/Or.java b/core/src/main/java/io/parsingdata/metal/expression/value/bitwise/Or.java index d1a13315..9d6f1ad5 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/bitwise/Or.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/bitwise/Or.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/bitwise/ShiftLeft.java b/core/src/main/java/io/parsingdata/metal/expression/value/bitwise/ShiftLeft.java index cd8096c5..42ae816c 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/bitwise/ShiftLeft.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/bitwise/ShiftLeft.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/bitwise/ShiftRight.java b/core/src/main/java/io/parsingdata/metal/expression/value/bitwise/ShiftRight.java index a6f3c6e5..d23222b9 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/bitwise/ShiftRight.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/bitwise/ShiftRight.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/reference/Count.java b/core/src/main/java/io/parsingdata/metal/expression/value/reference/Count.java index 75299567..21330b47 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/reference/Count.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/reference/Count.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/reference/CurrentIteration.java b/core/src/main/java/io/parsingdata/metal/expression/value/reference/CurrentIteration.java index 0978f0f8..f370df26 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/reference/CurrentIteration.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/reference/CurrentIteration.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/reference/CurrentOffset.java b/core/src/main/java/io/parsingdata/metal/expression/value/reference/CurrentOffset.java index aedd0127..74c7f5f8 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/reference/CurrentOffset.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/reference/CurrentOffset.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/reference/First.java b/core/src/main/java/io/parsingdata/metal/expression/value/reference/First.java index 2eb559d8..6296c90b 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/reference/First.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/reference/First.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/reference/Last.java b/core/src/main/java/io/parsingdata/metal/expression/value/reference/Last.java index 57de3979..25d6edfe 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/reference/Last.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/reference/Last.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/reference/Len.java b/core/src/main/java/io/parsingdata/metal/expression/value/reference/Len.java index 485f0a32..7d965895 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/reference/Len.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/reference/Len.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/reference/Nth.java b/core/src/main/java/io/parsingdata/metal/expression/value/reference/Nth.java index 11c11fd0..c3768361 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/reference/Nth.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/reference/Nth.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/reference/Offset.java b/core/src/main/java/io/parsingdata/metal/expression/value/reference/Offset.java index d06c36e3..a3bdd62c 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/reference/Offset.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/reference/Offset.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/reference/Ref.java b/core/src/main/java/io/parsingdata/metal/expression/value/reference/Ref.java index d6c334a1..ef85d12e 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/reference/Ref.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/reference/Ref.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +17,8 @@ package io.parsingdata.metal.expression.value.reference; +import static java.math.BigInteger.ZERO; + import static io.parsingdata.metal.Trampoline.complete; import static io.parsingdata.metal.Trampoline.intermediate; import static io.parsingdata.metal.Util.checkContainsNoNulls; @@ -57,65 +60,83 @@ public abstract class Ref extends ImmutableObject implements ValueExpression public final ImmutableList references; public final BiPredicate predicate; public final SingleValueExpression limit; + public final SingleValueExpression scope; @SafeVarargs - private Ref(final BiPredicate predicate, final SingleValueExpression limit, final T reference, final T... references) { + private Ref(final BiPredicate predicate, final SingleValueExpression limit, final SingleValueExpression scope, final T reference, final T... references) { this.predicate = checkNotNull(predicate, "predicate"); this.limit = limit; + this.scope = scope; this.references = create(checkContainsNoNulls(references, "references")) .addHead(checkNotNull(reference, "reference")); } - private Ref(final BiPredicate predicate, final SingleValueExpression limit, final ImmutableList references) { + private Ref(final BiPredicate predicate, final SingleValueExpression limit, final SingleValueExpression scope, final ImmutableList references) { this.predicate = checkNotNull(predicate, "predicate"); this.limit = limit; + this.scope = scope; this.references = checkNotNull(references, "references"); } public static class NameRef extends Ref { - public NameRef(final String reference, final String... references) { this(null, reference, references); } - public NameRef(final SingleValueExpression limit, final String reference, final String... references) { super(ParseValue::matches, limit, reference, references); } - private NameRef(final BiPredicate predicate, final SingleValueExpression limit, final ImmutableList references) { super(predicate, limit, references); } + public NameRef(final String reference, final String... references) { this(null, null, reference, references); } + public NameRef(final SingleValueExpression limit, final String reference, final String... references) { this(limit, null, reference, references); } + public NameRef(final SingleValueExpression limit, final SingleValueExpression scope, final String reference, final String... references) { super(ParseValue::matches, limit, scope, reference, references); } + private NameRef(final BiPredicate predicate, final SingleValueExpression limit, final SingleValueExpression scope, final ImmutableList references) { super(predicate, limit, scope, references); } @Override - ImmutableList evalImpl(final ParseState parseState, final int limit) { + protected ImmutableList evalImpl(final ParseState parseState, final int limit, final int requestedScope) { return Optional.of(parseState.cache) - .filter(p -> (long) references.size() == 1) + .filter(p -> references.size() == 1) + .filter(p -> requestedScope >= parseState.scopeDepth) .flatMap(p -> p.find(references.head(), limit)) - .orElseGet(() -> wrap(getAllValues(parseState.order, parseValue -> toList(references).stream().anyMatch(ref -> predicate.test(parseValue, ref)), limit), new ImmutableList()).computeResult()); + .orElseGet(() -> super.evalImpl(parseState, limit, requestedScope)); } @Override public NameRef withLimit(final SingleValueExpression limit) { - return new NameRef(predicate, limit, references); + return new NameRef(predicate, limit, scope, references); + } + @Override + public NameRef withScope(final SingleValueExpression scope) { + return new NameRef(predicate, limit, scope, references); } } public static class DefinitionRef extends Ref { - public DefinitionRef(final Token reference, final Token... references) { this(null, reference, references); } - public DefinitionRef(final SingleValueExpression limit, final Token reference, final Token... references) { super(ParseValue::matches, limit, reference, references); } - private DefinitionRef(final BiPredicate predicate, final SingleValueExpression limit, final ImmutableList references) { super(predicate, limit, references); } + public DefinitionRef(final Token reference, final Token... references) { this(null, null, reference, references); } + public DefinitionRef(final SingleValueExpression limit, final Token reference, final Token... references) { this(limit, null, reference, references); } + public DefinitionRef(final SingleValueExpression limit, final SingleValueExpression scope, final Token reference, final Token... references) { super(ParseValue::matches, limit, scope, reference, references); } + private DefinitionRef(final BiPredicate predicate, final SingleValueExpression limit, final SingleValueExpression scope, final ImmutableList references) { super(predicate, limit, scope, references); } @Override public DefinitionRef withLimit(final SingleValueExpression limit) { - return new DefinitionRef(predicate, limit, references); + return new DefinitionRef(predicate, limit, scope, references); + } + @Override + public DefinitionRef withScope(final SingleValueExpression scope) { + return new DefinitionRef(predicate, limit, scope, references); } } public abstract Ref withLimit(final SingleValueExpression limit); + public abstract Ref withScope(final SingleValueExpression scope); @Override public ImmutableList eval(final ParseState parseState, final Encoding encoding) { + final int requestedScope = scope == null ? parseState.scopeDepth : scope.evalSingle(parseState, encoding) + .filter(sizeValue -> !sizeValue.equals(NOT_A_VALUE) && sizeValue.asNumeric().compareTo(ZERO) >= 0) + .orElseThrow(() -> new IllegalArgumentException("Argument scopeSize must evaluate to a positive, countable value.")).asNumeric().intValueExact(); if (limit == null) { - return evalImpl(parseState, NO_LIMIT); + return evalImpl(parseState, NO_LIMIT, requestedScope); } return limit.evalSingle(parseState, encoding) - .map(limitValue -> limitValue.equals(NOT_A_VALUE) ? ImmutableList.create(NOT_A_VALUE) : evalImpl(parseState, limitValue.asNumeric().intValueExact())) + .map(limitValue -> limitValue.equals(NOT_A_VALUE) ? create(NOT_A_VALUE) : evalImpl(parseState, limitValue.asNumeric().intValueExact(), requestedScope)) .orElseThrow(() -> new IllegalArgumentException("Limit must evaluate to a non-empty value.")); } - ImmutableList evalImpl(final ParseState parseState, final int limit) { - return wrap(getAllValues(parseState.order, parseValue -> toList(references).stream().anyMatch(ref -> predicate.test(parseValue, ref)), limit), new ImmutableList()).computeResult(); + protected ImmutableList evalImpl(final ParseState parseState, final int limit, final int requestedScope) { + return wrap(getAllValues(parseState.order, parseValue -> toList(references).stream().anyMatch(ref -> predicate.test(parseValue, ref)), limit, requestedScope, parseState.scopeDepth), new ImmutableList()).computeResult(); } static List toList(final ImmutableList allValues) { @@ -144,12 +165,13 @@ public String toString() { public boolean equals(final Object obj) { return Util.notNullAndSameClass(this, obj) && Objects.equals(references, ((Ref)obj).references) - && Objects.equals(limit, ((Ref)obj).limit); + && Objects.equals(limit, ((Ref)obj).limit) + && Objects.equals(scope, ((Ref)obj).scope); } @Override public int immutableHashCode() { - return Objects.hash(getClass(), references, limit); + return Objects.hash(getClass(), references, limit, scope); } } diff --git a/core/src/main/java/io/parsingdata/metal/expression/value/reference/Self.java b/core/src/main/java/io/parsingdata/metal/expression/value/reference/Self.java index 620976b8..1607b1bd 100644 --- a/core/src/main/java/io/parsingdata/metal/expression/value/reference/Self.java +++ b/core/src/main/java/io/parsingdata/metal/expression/value/reference/Self.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/token/Cho.java b/core/src/main/java/io/parsingdata/metal/token/Cho.java index 61e54458..3c8ef574 100644 --- a/core/src/main/java/io/parsingdata/metal/token/Cho.java +++ b/core/src/main/java/io/parsingdata/metal/token/Cho.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/token/CycleToken.java b/core/src/main/java/io/parsingdata/metal/token/CycleToken.java index 40d65c69..087fab97 100644 --- a/core/src/main/java/io/parsingdata/metal/token/CycleToken.java +++ b/core/src/main/java/io/parsingdata/metal/token/CycleToken.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/token/Def.java b/core/src/main/java/io/parsingdata/metal/token/Def.java index 3d249050..18a8b4bf 100644 --- a/core/src/main/java/io/parsingdata/metal/token/Def.java +++ b/core/src/main/java/io/parsingdata/metal/token/Def.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/token/DefUntil.java b/core/src/main/java/io/parsingdata/metal/token/DefUntil.java index f7dffbaa..33ce1e5a 100644 --- a/core/src/main/java/io/parsingdata/metal/token/DefUntil.java +++ b/core/src/main/java/io/parsingdata/metal/token/DefUntil.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/token/IterableToken.java b/core/src/main/java/io/parsingdata/metal/token/IterableToken.java index acb3ddd1..3749eacb 100644 --- a/core/src/main/java/io/parsingdata/metal/token/IterableToken.java +++ b/core/src/main/java/io/parsingdata/metal/token/IterableToken.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/token/Post.java b/core/src/main/java/io/parsingdata/metal/token/Post.java index 1dbaa662..2a3cda85 100644 --- a/core/src/main/java/io/parsingdata/metal/token/Post.java +++ b/core/src/main/java/io/parsingdata/metal/token/Post.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/token/Pre.java b/core/src/main/java/io/parsingdata/metal/token/Pre.java index d5b2b69d..b6d63b9b 100644 --- a/core/src/main/java/io/parsingdata/metal/token/Pre.java +++ b/core/src/main/java/io/parsingdata/metal/token/Pre.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/token/Rep.java b/core/src/main/java/io/parsingdata/metal/token/Rep.java index 6dcaf35c..a2d6bd7c 100644 --- a/core/src/main/java/io/parsingdata/metal/token/Rep.java +++ b/core/src/main/java/io/parsingdata/metal/token/Rep.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/token/RepN.java b/core/src/main/java/io/parsingdata/metal/token/RepN.java index 986dcce0..e4de17b8 100644 --- a/core/src/main/java/io/parsingdata/metal/token/RepN.java +++ b/core/src/main/java/io/parsingdata/metal/token/RepN.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/token/Seq.java b/core/src/main/java/io/parsingdata/metal/token/Seq.java index 7534d433..3eda0190 100644 --- a/core/src/main/java/io/parsingdata/metal/token/Seq.java +++ b/core/src/main/java/io/parsingdata/metal/token/Seq.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/token/Sub.java b/core/src/main/java/io/parsingdata/metal/token/Sub.java index 9ace7f49..2232948d 100644 --- a/core/src/main/java/io/parsingdata/metal/token/Sub.java +++ b/core/src/main/java/io/parsingdata/metal/token/Sub.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/token/Tie.java b/core/src/main/java/io/parsingdata/metal/token/Tie.java index 31ea354d..abfdc7bd 100644 --- a/core/src/main/java/io/parsingdata/metal/token/Tie.java +++ b/core/src/main/java/io/parsingdata/metal/token/Tie.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,7 +68,7 @@ protected Optional parseImpl(final Environment environment) { private Trampoline> iterate(final Environment environment, final ImmutableList values, final int index, final ParseState returnParseState) { if (values.isEmpty()) { - return complete(() -> success(new ParseState(environment.parseState.closeBranch(this).order, environment.parseState.cache, returnParseState.source, returnParseState.offset, returnParseState.iterations, returnParseState.references))); + return complete(() -> success(new ParseState(environment.parseState.closeBranch(this).order, environment.parseState.cache, returnParseState.source, returnParseState.offset, returnParseState.iterations, returnParseState.references, returnParseState.scopeDepth))); } if (values.head().equals(NOT_A_VALUE)) { return complete(Util::failure); diff --git a/core/src/main/java/io/parsingdata/metal/token/Token.java b/core/src/main/java/io/parsingdata/metal/token/Token.java index 94aef819..1bfff76d 100644 --- a/core/src/main/java/io/parsingdata/metal/token/Token.java +++ b/core/src/main/java/io/parsingdata/metal/token/Token.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,8 +30,8 @@ import io.parsingdata.metal.data.ParseGraph; import io.parsingdata.metal.data.ParseState; import io.parsingdata.metal.encoding.Encoding; -import io.parsingdata.metal.expression.value.Scope; import io.parsingdata.metal.expression.value.reference.CurrentIteration; +import io.parsingdata.metal.expression.value.reference.Ref; /** * Base class for all Token implementations. @@ -80,7 +81,7 @@ public Optional parse(final Environment environment) { protected abstract Optional parseImpl(final Environment environment); /** - * The {@link Scope} ValueExpression uses this property to determine which + * The {@link Ref} ValueExpression uses this property to determine which * part of the {@link ParseState}'s order (the {@link * ParseGraph}) field is considered to be in scope. The Tokens considered * to be scope delimiters are {@link Seq} and subclasses of {@link diff --git a/core/src/main/java/io/parsingdata/metal/token/TokenRef.java b/core/src/main/java/io/parsingdata/metal/token/TokenRef.java index 17d53e91..112a093a 100644 --- a/core/src/main/java/io/parsingdata/metal/token/TokenRef.java +++ b/core/src/main/java/io/parsingdata/metal/token/TokenRef.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/main/java/io/parsingdata/metal/token/While.java b/core/src/main/java/io/parsingdata/metal/token/While.java index 662c69cc..c0afe61c 100644 --- a/core/src/main/java/io/parsingdata/metal/token/While.java +++ b/core/src/main/java/io/parsingdata/metal/token/While.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/ArgumentsTest.java b/core/src/test/java/io/parsingdata/metal/ArgumentsTest.java index 173a3543..d4fa3f85 100644 --- a/core/src/test/java/io/parsingdata/metal/ArgumentsTest.java +++ b/core/src/test/java/io/parsingdata/metal/ArgumentsTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +49,6 @@ import io.parsingdata.metal.expression.value.Cat; import io.parsingdata.metal.expression.value.FoldLeft; import io.parsingdata.metal.expression.value.FoldRight; -import io.parsingdata.metal.expression.value.Scope; import io.parsingdata.metal.expression.value.ValueExpression; import io.parsingdata.metal.expression.value.arithmetic.Neg; import io.parsingdata.metal.expression.value.reference.Count; @@ -96,8 +96,6 @@ public static Collection arguments() { { Offset.class, new Object[] { null } }, { Count.class, new Object[] { null } }, { Bytes.class, new Object[] { null } }, - { Scope.class, new Object[] { VALID_VE, null } }, - { Scope.class, new Object[] { null, VALID_VE } }, // Derived from BinaryValueExpression { Cat.class, new Object[] { VALID_VE, null } }, { Cat.class, new Object[] { null, VALID_VE } }, diff --git a/core/src/test/java/io/parsingdata/metal/ArithmeticValueExpressionSemanticsTest.java b/core/src/test/java/io/parsingdata/metal/ArithmeticValueExpressionSemanticsTest.java index bd81c01d..4a1210a9 100644 --- a/core/src/test/java/io/parsingdata/metal/ArithmeticValueExpressionSemanticsTest.java +++ b/core/src/test/java/io/parsingdata/metal/ArithmeticValueExpressionSemanticsTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/AutoEqualityTest.java b/core/src/test/java/io/parsingdata/metal/AutoEqualityTest.java index a5e03358..4a86cb15 100644 --- a/core/src/test/java/io/parsingdata/metal/AutoEqualityTest.java +++ b/core/src/test/java/io/parsingdata/metal/AutoEqualityTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,8 +52,9 @@ import java.lang.reflect.Modifier; import java.math.BigInteger; import java.net.URL; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; @@ -110,7 +112,6 @@ import io.parsingdata.metal.expression.value.Join; import io.parsingdata.metal.expression.value.NotAValue; import io.parsingdata.metal.expression.value.Reverse; -import io.parsingdata.metal.expression.value.Scope; import io.parsingdata.metal.expression.value.SingleValueExpression; import io.parsingdata.metal.expression.value.Value; import io.parsingdata.metal.expression.value.ValueExpression; @@ -162,7 +163,7 @@ public class AutoEqualityTest { And.class, Or.class, ShiftLeft.class, ShiftRight.class, Add.class, Div.class, Mod.class, Mul.class, io.parsingdata.metal.expression.value.arithmetic.Sub.class, Cat.class, Nth.class, Elvis.class, FoldLeft.class, FoldRight.class, Const.class, Expand.class, Bytes.class, CurrentOffset.class, - FoldCat.class, CurrentIteration.class, Scope.class, + FoldCat.class, CurrentIteration.class, Join.class, Self.class, Ref.NameRef.class, Ref.DefinitionRef.class, // Expressions Eq.class, EqNum.class, EqStr.class, GtEqNum.class, GtNum.class, LtEqNum.class, LtNum.class, @@ -202,7 +203,7 @@ public class AutoEqualityTest { private static final List> STRINGS = List.of(() -> "a", () -> "b"); private static final List> STRING_ARRAYS = List.of(() -> new String[] {"a"}, () -> new String[] {"b"}, () -> new String[] {"a", "b"}, () -> new String[] {"b", "c"}, () -> new String[] {"a", "b", "c"}); - private static final List> ENCODINGS = List.of(EncodingFactory::enc, EncodingFactory::signed, EncodingFactory::le, () -> new Encoding(Charset.forName("UTF-8"))); + private static final List> ENCODINGS = List.of(EncodingFactory::enc, EncodingFactory::signed, EncodingFactory::le, () -> new Encoding(StandardCharsets.UTF_8)); private static final List> TOKENS = List.of(() -> any("a"), () -> any("b")); private static final List> TOKEN_ARRAYS = List.of(() -> new Token[] { any("a"), any("b")}, () -> new Token[] { any("b"), any("c") }, () -> new Token[] { any("a"), any("b"), any("c") }); private static final List> SINGLE_VALUE_EXPRESSIONS = List.of(() -> con(1), () -> con(2)); @@ -220,12 +221,13 @@ public class AutoEqualityTest { private static final List> PARSE_ITEMS = List.of(() -> CLOSED_BRANCHED_GRAPH, () -> ParseGraph.EMPTY, () -> GRAPH_WITH_REFERENCE, () -> createFromByteStream(DUMMY_STREAM).add(PARSE_VALUE).order, () -> createFromByteStream(DUMMY_STREAM).add(PARSE_VALUE).add(PARSE_VALUE).order, () -> BRANCHED_GRAPH); private static final List> BYTE_STREAMS = List.of(() -> new InMemoryByteStream(new byte[] { 1, 2 }), () -> DUMMY_STREAM); private static final List> BIG_INTEGERS = List.of(() -> ONE, () -> BigInteger.valueOf(3)); - private static final List> PARSE_STATES = List.of(() -> createFromByteStream(DUMMY_STREAM), () -> createFromByteStream(DUMMY_STREAM, ONE), () -> new ParseState(GRAPH_WITH_REFERENCE, NO_CACHE, DUMMY_BYTE_STREAM_SOURCE, TEN, new ImmutableList<>(), new ImmutableList<>())); - private static final List> PARSE_VALUE_CACHES = List.of(() -> NO_CACHE, () -> new ParseValueCache(), () -> new ParseValueCache().add(PARSE_VALUE), () -> new ParseValueCache().add(PARSE_VALUE).add(PARSE_VALUE)); + private static final List> PARSE_STATES = List.of(() -> createFromByteStream(DUMMY_STREAM), () -> createFromByteStream(DUMMY_STREAM, ONE), () -> new ParseState(GRAPH_WITH_REFERENCE, NO_CACHE, DUMMY_BYTE_STREAM_SOURCE, TEN, new ImmutableList<>(), new ImmutableList<>(), 0)); + private static final List> PARSE_VALUE_CACHES = List.of(() -> NO_CACHE, ParseValueCache::new, () -> new ParseValueCache().add(PARSE_VALUE), () -> new ParseValueCache().add(PARSE_VALUE).add(PARSE_VALUE)); private static final List> IMMUTABLE_LISTS = List.of(ImmutableList::new, () -> ImmutableList.create("TEST"), () -> ImmutableList.create(1), () -> ImmutableList.create(1).addHead(2), () -> ImmutableList.create(2).addHead(1).reverse()); private static final List> LISTS = List.of(List::of, () -> List.of("TEST"), () -> List.of(1), () -> List.of(1, 2), () -> new ImmutableList<>(List.of(1, 2)), () -> new ImmutableList<>(List.of(2, 1)).reverse()); private static final List> BOOLEANS = List.of(() -> true, () -> false); private static final List> BIPREDICATES = List.of(() -> (BiPredicate) (o, o2) -> false); + private static final List> MAPS = List.of(Map::of, () -> Map.of("1", 1, "2", 2)); private static final Map, List>> mapping = buildMap(); private static Map, List>> buildMap() { @@ -255,6 +257,7 @@ private static Map, List>> buildMap() { result.put(ImmutableList.class, IMMUTABLE_LISTS); result.put(boolean.class, BOOLEANS); result.put(BiPredicate.class, BIPREDICATES); + result.put(Map.class, MAPS); result.put(List.class, LISTS); return result; } @@ -315,31 +318,38 @@ private static Class getClass(final String className) { private static Collection generateObjectArrays(final Set> classes) throws IllegalAccessException, InstantiationException, InvocationTargetException { Collection results = new ArrayList<>(); for (Class c : classes) { - results.add(generateObjectArrays(c)); + results.addAll(generateObjectArrays(c)); } return results; } - private static Arguments generateObjectArrays(final Class c) throws IllegalAccessException, InvocationTargetException, InstantiationException { - Constructor cons = c.getDeclaredConstructors()[0]; - cons.setAccessible(true); - List>> args = new ArrayList<>(); - for (Class cl : cons.getParameterTypes()) { - if (!mapping.containsKey(cl)) { - throw new AssertionError("Please add a mapping for type " + cl.getSimpleName()); + private static List generateObjectArrays(final Class c) throws IllegalAccessException, InvocationTargetException, InstantiationException { + final List arguments = new ArrayList<>(); + for (Constructor cons : c.getDeclaredConstructors()) { + final boolean containsGenericArgument = Arrays.stream(cons.getParameterTypes()).anyMatch(p -> p == Object.class); + if (containsGenericArgument) { + break; } - args.add(mapping.get(cl)); - } - List>> argLists = generateCombinations(0, args); - List otherInstances = new ArrayList<>(); - for (List> argList : argLists.subList(1, argLists.size())) { - otherInstances.add(cons.newInstance(instantiate(argList).toArray())); + cons.setAccessible(true); + final List>> args = new ArrayList<>(); + for (Class cl : cons.getParameterTypes()) { + if (!mapping.containsKey(cl)) { + throw new AssertionError("Please add a mapping for type " + cl.getSimpleName()); + } + args.add(mapping.get(cl)); + } + final List>> argLists = generateCombinations(0, args); + final List otherInstances = new ArrayList<>(); + for (List> argList : argLists.subList(1, argLists.size())) { + otherInstances.add(cons.newInstance(instantiate(argList).toArray())); + } + arguments.add(Arguments.arguments( + cons.newInstance(instantiate(argLists.get(0)).toArray()), + cons.newInstance(instantiate(argLists.get(0)).toArray()), + otherInstances.toArray() + )); } - return Arguments.arguments( - cons.newInstance(instantiate(argLists.get(0)).toArray()), - cons.newInstance(instantiate(argLists.get(0)).toArray()), - otherInstances.toArray() - ); + return arguments; } private static List>> generateCombinations(final int index, final List>> args) { diff --git a/core/src/test/java/io/parsingdata/metal/BackTrackNameBindTest.java b/core/src/test/java/io/parsingdata/metal/BackTrackNameBindTest.java index 7061552d..8d08c6d1 100644 --- a/core/src/test/java/io/parsingdata/metal/BackTrackNameBindTest.java +++ b/core/src/test/java/io/parsingdata/metal/BackTrackNameBindTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/BackTrackOffsetTest.java b/core/src/test/java/io/parsingdata/metal/BackTrackOffsetTest.java index bd2940e7..8e36b5a9 100644 --- a/core/src/test/java/io/parsingdata/metal/BackTrackOffsetTest.java +++ b/core/src/test/java/io/parsingdata/metal/BackTrackOffsetTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/BitwiseValueExpressionSemanticsTest.java b/core/src/test/java/io/parsingdata/metal/BitwiseValueExpressionSemanticsTest.java index 3190f6cf..ff7c2905 100644 --- a/core/src/test/java/io/parsingdata/metal/BitwiseValueExpressionSemanticsTest.java +++ b/core/src/test/java/io/parsingdata/metal/BitwiseValueExpressionSemanticsTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/ByteLengthTest.java b/core/src/test/java/io/parsingdata/metal/ByteLengthTest.java index 4957d305..e91025df 100644 --- a/core/src/test/java/io/parsingdata/metal/ByteLengthTest.java +++ b/core/src/test/java/io/parsingdata/metal/ByteLengthTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/ComparisonExpressionSemanticsTest.java b/core/src/test/java/io/parsingdata/metal/ComparisonExpressionSemanticsTest.java index 31b8588f..18fcf086 100644 --- a/core/src/test/java/io/parsingdata/metal/ComparisonExpressionSemanticsTest.java +++ b/core/src/test/java/io/parsingdata/metal/ComparisonExpressionSemanticsTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/ConditionalTokenTest.java b/core/src/test/java/io/parsingdata/metal/ConditionalTokenTest.java index 2bc2b578..48709467 100644 --- a/core/src/test/java/io/parsingdata/metal/ConditionalTokenTest.java +++ b/core/src/test/java/io/parsingdata/metal/ConditionalTokenTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/ConstantValueTest.java b/core/src/test/java/io/parsingdata/metal/ConstantValueTest.java index 8fb0facd..1f50d184 100644 --- a/core/src/test/java/io/parsingdata/metal/ConstantValueTest.java +++ b/core/src/test/java/io/parsingdata/metal/ConstantValueTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/CurrentOffsetTest.java b/core/src/test/java/io/parsingdata/metal/CurrentOffsetTest.java index 6c1e6a18..909e3bfb 100644 --- a/core/src/test/java/io/parsingdata/metal/CurrentOffsetTest.java +++ b/core/src/test/java/io/parsingdata/metal/CurrentOffsetTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/DefSizeTest.java b/core/src/test/java/io/parsingdata/metal/DefSizeTest.java index b67f1453..5b2c13c2 100644 --- a/core/src/test/java/io/parsingdata/metal/DefSizeTest.java +++ b/core/src/test/java/io/parsingdata/metal/DefSizeTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/DefinitionTest.java b/core/src/test/java/io/parsingdata/metal/DefinitionTest.java index c5e43c8f..96c6f20e 100644 --- a/core/src/test/java/io/parsingdata/metal/DefinitionTest.java +++ b/core/src/test/java/io/parsingdata/metal/DefinitionTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/EndiannessTest.java b/core/src/test/java/io/parsingdata/metal/EndiannessTest.java index 94a45dc1..86a34549 100644 --- a/core/src/test/java/io/parsingdata/metal/EndiannessTest.java +++ b/core/src/test/java/io/parsingdata/metal/EndiannessTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/EqualityTest.java b/core/src/test/java/io/parsingdata/metal/EqualityTest.java index 6571187a..dbc42b69 100644 --- a/core/src/test/java/io/parsingdata/metal/EqualityTest.java +++ b/core/src/test/java/io/parsingdata/metal/EqualityTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,6 +64,7 @@ import io.parsingdata.metal.data.Slice; import io.parsingdata.metal.encoding.Encoding; import io.parsingdata.metal.expression.True; +import io.parsingdata.metal.expression.value.SingleValueExpression; import io.parsingdata.metal.expression.value.reference.Ref; import io.parsingdata.metal.expression.value.reference.Ref.DefinitionRef; import io.parsingdata.metal.expression.value.reference.Ref.NameRef; @@ -209,6 +211,7 @@ public void stringRef() { assertNotEquals(object, new NameRef("otherName")); assertNotEquals(object, new DefinitionRef(any("name"))); assertNotEquals(object, new NameRef(con(1), "name")); + assertNotEquals(object, new NameRef(con(1), (SingleValueExpression) null, "name")); } @Test @@ -222,6 +225,7 @@ public void definitionRef() { assertNotEquals(object, new DefinitionRef(any("otherName"))); assertNotEquals(object, new NameRef("name")); assertNotEquals(object, new DefinitionRef(con(1), any("name"))); + assertNotEquals(object, new DefinitionRef(con(1), (SingleValueExpression) null, any("name"))); } @Test diff --git a/core/src/test/java/io/parsingdata/metal/ErrorsTest.java b/core/src/test/java/io/parsingdata/metal/ErrorsTest.java index ece6f2f2..49e5d464 100644 --- a/core/src/test/java/io/parsingdata/metal/ErrorsTest.java +++ b/core/src/test/java/io/parsingdata/metal/ErrorsTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/IterateTest.java b/core/src/test/java/io/parsingdata/metal/IterateTest.java index 20f644fe..04d58aac 100644 --- a/core/src/test/java/io/parsingdata/metal/IterateTest.java +++ b/core/src/test/java/io/parsingdata/metal/IterateTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/LogicalExpressionSemanticsTest.java b/core/src/test/java/io/parsingdata/metal/LogicalExpressionSemanticsTest.java index f293f6ef..6c733782 100644 --- a/core/src/test/java/io/parsingdata/metal/LogicalExpressionSemanticsTest.java +++ b/core/src/test/java/io/parsingdata/metal/LogicalExpressionSemanticsTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/PITestCasesTest.java b/core/src/test/java/io/parsingdata/metal/PITestCasesTest.java index 9fcb806a..c62ed249 100644 --- a/core/src/test/java/io/parsingdata/metal/PITestCasesTest.java +++ b/core/src/test/java/io/parsingdata/metal/PITestCasesTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/ReadUntilTest.java b/core/src/test/java/io/parsingdata/metal/ReadUntilTest.java index ff8e565d..eeefaacd 100644 --- a/core/src/test/java/io/parsingdata/metal/ReadUntilTest.java +++ b/core/src/test/java/io/parsingdata/metal/ReadUntilTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/ReducersTest.java b/core/src/test/java/io/parsingdata/metal/ReducersTest.java index af7354e7..f12c33bc 100644 --- a/core/src/test/java/io/parsingdata/metal/ReducersTest.java +++ b/core/src/test/java/io/parsingdata/metal/ReducersTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/ReferenceValueExpressionSemanticsTest.java b/core/src/test/java/io/parsingdata/metal/ReferenceValueExpressionSemanticsTest.java index 7002577d..936cf8fc 100644 --- a/core/src/test/java/io/parsingdata/metal/ReferenceValueExpressionSemanticsTest.java +++ b/core/src/test/java/io/parsingdata/metal/ReferenceValueExpressionSemanticsTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +22,7 @@ import static io.parsingdata.metal.Shorthand.eq; import static io.parsingdata.metal.Shorthand.first; import static io.parsingdata.metal.Shorthand.fold; +import static io.parsingdata.metal.Shorthand.join; import static io.parsingdata.metal.Shorthand.last; import static io.parsingdata.metal.Shorthand.not; import static io.parsingdata.metal.Shorthand.offset; @@ -69,7 +71,7 @@ private static Token limitedSum(final Ref ref) { return seq(rep(def("a", con(1), not(eq(con(0))))), def("zero", con(1), eq(con(0))), - def("sum", con(1), eq(fold(ref, Shorthand::add)))); + def("sum", con(1), eq(fold(join(con(0), ref), Shorthand::add)))); } @Override @@ -106,22 +108,26 @@ public Collection data() { { "[1, 2, 3, 1] a, a, a, first(ref(a.definition))", refMatch(eq(first(ref(refAny)))), stream(1, 2, 3, 1), enc(), true }, { "[1, 2, 3, 6] a, a, a, first(fold(ref(a.definition), add))", refMatch(eq(first(fold(ref(refAny), Shorthand::add)))), stream(1, 2, 3, 6), enc(), true }, { "[1, 2, 3, 2] a, a, a, last(ref(a.definition))", refMatch(eq(last(ref(refAny)))), stream(1, 2, 3, 2), enc(), false }, + { "[1, 2, 3, 0, 0] a, a, a, 0, sum(ref(a, 0))", limitedSum(ref("a", con(0))), stream(1, 2, 3, 0, 0), enc(), true }, { "[1, 2, 3, 0, 3] a, a, a, 0, sum(ref(a, 1))", limitedSum(ref("a", con(1))), stream(1, 2, 3, 0, 3), enc(), true }, { "[1, 2, 3, 0, 5] a, a, a, 0, sum(ref(a, 2))", limitedSum(ref("a", con(2))), stream(1, 2, 3, 0, 5), enc(), true }, { "[1, 2, 3, 0, 6] a, a, a, 0, sum(ref(a, 3))", limitedSum(ref("a", con(3))), stream(1, 2, 3, 0, 6), enc(), true }, - { "[1, 2, 3, 0, 7] a, a, a, 0, sum(ref(a, 4))", limitedSum(ref("a", con(4))), stream(1, 2, 3, 0, 6), enc(), true }, + { "[1, 2, 3, 0, 6] a, a, a, 0, sum(ref(a, 4))", limitedSum(ref("a", con(4))), stream(1, 2, 3, 0, 6), enc(), true }, + { "[1, 2, 3, 0, 0] a, a, a, 0, sum(ref(0, a))", limitedSum(ref(con(0), "a")), stream(1, 2, 3, 0, 0), enc(), true }, { "[1, 2, 3, 0, 3] a, a, a, 0, sum(ref(1, a))", limitedSum(ref(con(1), "a")), stream(1, 2, 3, 0, 3), enc(), true }, { "[1, 2, 3, 0, 5] a, a, a, 0, sum(ref(2, a))", limitedSum(ref(con(2), "a")), stream(1, 2, 3, 0, 5), enc(), true }, { "[1, 2, 3, 0, 6] a, a, a, 0, sum(ref(3, a))", limitedSum(ref(con(3), "a")), stream(1, 2, 3, 0, 6), enc(), true }, - { "[1, 2, 3, 0, 7] a, a, a, 0, sum(ref(4, a))", limitedSum(ref(con(4), "a")), stream(1, 2, 3, 0, 6), enc(), true }, + { "[1, 2, 3, 0, 6] a, a, a, 0, sum(ref(4, a))", limitedSum(ref(con(4), "a")), stream(1, 2, 3, 0, 6), enc(), true }, + { "[1, 2, 3, 0, 0] a, a, a, 0, sum(ref(0, a.definition))", limitedSum(ref(con(0), any("a"))), stream(1, 2, 3, 0, 0), enc(), true }, { "[1, 2, 3, 0, 3] a, a, a, 0, sum(ref(1, a.definition))", limitedSum(ref(con(1), any("a"))), stream(1, 2, 3, 0, 3), enc(), true }, { "[1, 2, 3, 0, 5] a, a, a, 0, sum(ref(2, a.definition))", limitedSum(ref(con(2), any("a"))), stream(1, 2, 3, 0, 5), enc(), true }, { "[1, 2, 3, 0, 6] a, a, a, 0, sum(ref(3, a.definition))", limitedSum(ref(con(3), any("a"))), stream(1, 2, 3, 0, 6), enc(), true }, - { "[1, 2, 3, 0, 7] a, a, a, 0, sum(ref(4, a.definition))", limitedSum(ref(con(4), any("a"))), stream(1, 2, 3, 0, 6), enc(), true }, + { "[1, 2, 3, 0, 6] a, a, a, 0, sum(ref(4, a.definition))", limitedSum(ref(con(4), any("a"))), stream(1, 2, 3, 0, 6), enc(), true }, + { "[1, 2, 3, 0, 0] a, a, a, 0, sum(ref(a.definition, 0))", limitedSum(ref(any("a"), con(0))), stream(1, 2, 3, 0, 0), enc(), true }, { "[1, 2, 3, 0, 3] a, a, a, 0, sum(ref(a.definition, 1))", limitedSum(ref(any("a"), con(1))), stream(1, 2, 3, 0, 3), enc(), true }, { "[1, 2, 3, 0, 5] a, a, a, 0, sum(ref(a.definition, 2))", limitedSum(ref(any("a"), con(2))), stream(1, 2, 3, 0, 5), enc(), true }, { "[1, 2, 3, 0, 6] a, a, a, 0, sum(ref(a.definition, 3))", limitedSum(ref(any("a"), con(3))), stream(1, 2, 3, 0, 6), enc(), true }, - { "[1, 2, 3, 0, 7] a, a, a, 0, sum(ref(a.definition, 4))", limitedSum(ref(any("a"), con(4))), stream(1, 2, 3, 0, 6), enc(), true } + { "[1, 2, 3, 0, 6] a, a, a, 0, sum(ref(a.definition, 4))", limitedSum(ref(any("a"), con(4))), stream(1, 2, 3, 0, 6), enc(), true } }); } diff --git a/core/src/test/java/io/parsingdata/metal/ShorthandOverloadsTest.java b/core/src/test/java/io/parsingdata/metal/ShorthandOverloadsTest.java index 64aab004..5c71df5c 100644 --- a/core/src/test/java/io/parsingdata/metal/ShorthandOverloadsTest.java +++ b/core/src/test/java/io/parsingdata/metal/ShorthandOverloadsTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/ShorthandsTest.java b/core/src/test/java/io/parsingdata/metal/ShorthandsTest.java index 93eb1527..f74596f4 100644 --- a/core/src/test/java/io/parsingdata/metal/ShorthandsTest.java +++ b/core/src/test/java/io/parsingdata/metal/ShorthandsTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/SimpleTest.java b/core/src/test/java/io/parsingdata/metal/SimpleTest.java index 97fc1871..099e1bbb 100644 --- a/core/src/test/java/io/parsingdata/metal/SimpleTest.java +++ b/core/src/test/java/io/parsingdata/metal/SimpleTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/SubStructTableTest.java b/core/src/test/java/io/parsingdata/metal/SubStructTableTest.java index 5ef05316..5ee68ad7 100644 --- a/core/src/test/java/io/parsingdata/metal/SubStructTableTest.java +++ b/core/src/test/java/io/parsingdata/metal/SubStructTableTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/SubStructTest.java b/core/src/test/java/io/parsingdata/metal/SubStructTest.java index a479016f..74392ef4 100644 --- a/core/src/test/java/io/parsingdata/metal/SubStructTest.java +++ b/core/src/test/java/io/parsingdata/metal/SubStructTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/ToStringTest.java b/core/src/test/java/io/parsingdata/metal/ToStringTest.java index 8d6a20c6..88dfac14 100644 --- a/core/src/test/java/io/parsingdata/metal/ToStringTest.java +++ b/core/src/test/java/io/parsingdata/metal/ToStringTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -129,7 +130,7 @@ private Token t() { } private ValueExpression v() { - return fold(foldLeft(foldRight(rev(bytes(neg(add(div(mod(mul(sub(cat(scope(last(ref(n())), con(0))), first(nth(exp(ref(n()), con(NOT_A_VALUE)), con(1)))), sub(CURRENT_ITERATION, con(1))), cat(ref(n()), ref(t()))), add(SELF, add(offset(ref(n())), add(CURRENT_OFFSET, count(ref(n())))))), elvis(ref(n()), ref(n())))))), Shorthand::add, last(ref(n()))), Shorthand::add), Shorthand::add, last(ref(n()))); + return fold(foldLeft(foldRight(rev(bytes(neg(add(div(mod(mul(sub(cat(last(scope(ref(n()), con(0)))), first(nth(exp(ref(n()), con(NOT_A_VALUE)), con(1)))), sub(CURRENT_ITERATION, con(1))), cat(ref(n()), ref(t()))), add(SELF, add(offset(ref(n())), add(CURRENT_OFFSET, count(ref(n())))))), elvis(ref(n()), ref(n())))))), Shorthand::add, last(ref(n()))), Shorthand::add), Shorthand::add, last(ref(n()))); } @Test @@ -173,15 +174,15 @@ public void encoding() { @Test public void data() { final ParseState parseState = stream(1, 2); - final String parseStateString = "ParseState(source:ByteStreamSource(InMemoryByteStream(2));offset:0;order:pg(EMPTY);cache:size=0)"; + final String parseStateString = "ParseState(source:ByteStreamSource(InMemoryByteStream(2));offset:0;order:pg(EMPTY);scopeDepth:0;cache:size=0)"; assertEquals(parseStateString, parseState.toString()); final ParseState parseStateWithIterations = parseState.addBranch(rep(def("a",1))).iterate(); - final String parseStateWithIterationsString = "ParseState(source:ByteStreamSource(InMemoryByteStream(2));offset:0;order:pg(pg(terminator:Rep),pg(EMPTY),true);iterations:>Rep(Def(a,Const(0x01)))->1;cache:size=0)"; + final String parseStateWithIterationsString = "ParseState(source:ByteStreamSource(InMemoryByteStream(2));offset:0;order:pg(pg(terminator:Rep),pg(EMPTY),true);iterations:>Rep(Def(a,Const(0x01)))->1;scopeDepth:1;cache:size=0)"; assertEquals(parseStateWithIterationsString, parseStateWithIterations.toString()); final ParseState parseStateWithoutCache = parseStateWithIterations.withOrder(parseStateWithIterations.order); - final String parseStateWithoutCacheString = "ParseState(source:ByteStreamSource(InMemoryByteStream(2));offset:0;order:pg(pg(terminator:Rep),pg(EMPTY),true);iterations:>Rep(Def(a,Const(0x01)))->1;no-cache)"; + final String parseStateWithoutCacheString = "ParseState(source:ByteStreamSource(InMemoryByteStream(2));offset:0;order:pg(pg(terminator:Rep),pg(EMPTY),true);iterations:>Rep(Def(a,Const(0x01)))->1;scopeDepth:1;no-cache)"; assertEquals(parseStateWithoutCacheString, parseStateWithoutCache.toString()); final Optional result = Optional.of(parseState); @@ -221,10 +222,10 @@ public void toStringOnParseStateCollections() { assertFalse(parseState.toString().contains(";iterations:")); assertFalse(parseState.toString().contains(";references:")); final ImmutableList> iterationsList = ImmutableList.create(new ImmutablePair<>(t(), BigInteger.ZERO)); - final ParseState parseStateWithIteration = new ParseState(parseState.order, parseState.cache, parseState.source, parseState.offset, iterationsList, new ImmutableList<>()); + final ParseState parseStateWithIteration = new ParseState(parseState.order, parseState.cache, parseState.source, parseState.offset, iterationsList, new ImmutableList<>(), 0); assertTrue(parseStateWithIteration.toString().contains(";iterations:" + iterationsList.toString())); final ImmutableList referencesList = ImmutableList.create(new ParseReference(BigInteger.ZERO, parseState.source, t())); - final ParseState parseStateWithReference = new ParseState(parseState.order, parseState.cache, parseState.source, parseState.offset, new ImmutableList<>(), referencesList); + final ParseState parseStateWithReference = new ParseState(parseState.order, parseState.cache, parseState.source, parseState.offset, new ImmutableList<>(), referencesList, 0); assertTrue(parseStateWithReference.toString().contains(";references:" + referencesList.toString())); } diff --git a/core/src/test/java/io/parsingdata/metal/TrampolineTest.java b/core/src/test/java/io/parsingdata/metal/TrampolineTest.java index f5e0bedf..a9b7555d 100644 --- a/core/src/test/java/io/parsingdata/metal/TrampolineTest.java +++ b/core/src/test/java/io/parsingdata/metal/TrampolineTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/TreeTest.java b/core/src/test/java/io/parsingdata/metal/TreeTest.java index b0684320..b3247d55 100644 --- a/core/src/test/java/io/parsingdata/metal/TreeTest.java +++ b/core/src/test/java/io/parsingdata/metal/TreeTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/UtilHexTest.java b/core/src/test/java/io/parsingdata/metal/UtilHexTest.java index 88fa51ae..adefdd7f 100644 --- a/core/src/test/java/io/parsingdata/metal/UtilHexTest.java +++ b/core/src/test/java/io/parsingdata/metal/UtilHexTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/UtilInflateTest.java b/core/src/test/java/io/parsingdata/metal/UtilInflateTest.java index ba2d9af3..c2c8bf42 100644 --- a/core/src/test/java/io/parsingdata/metal/UtilInflateTest.java +++ b/core/src/test/java/io/parsingdata/metal/UtilInflateTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/UtilityClassTest.java b/core/src/test/java/io/parsingdata/metal/UtilityClassTest.java index c4ac6e8f..1d1c5475 100644 --- a/core/src/test/java/io/parsingdata/metal/UtilityClassTest.java +++ b/core/src/test/java/io/parsingdata/metal/UtilityClassTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/ValueExpressionSemanticsTest.java b/core/src/test/java/io/parsingdata/metal/ValueExpressionSemanticsTest.java index 65308405..a6b7b99f 100644 --- a/core/src/test/java/io/parsingdata/metal/ValueExpressionSemanticsTest.java +++ b/core/src/test/java/io/parsingdata/metal/ValueExpressionSemanticsTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/ByNameTest.java b/core/src/test/java/io/parsingdata/metal/data/ByNameTest.java index 7e79ea3b..82d1c21d 100644 --- a/core/src/test/java/io/parsingdata/metal/data/ByNameTest.java +++ b/core/src/test/java/io/parsingdata/metal/data/ByNameTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/ByteStreamSourceTest.java b/core/src/test/java/io/parsingdata/metal/data/ByteStreamSourceTest.java index ac9a53c8..88ad22a7 100644 --- a/core/src/test/java/io/parsingdata/metal/data/ByteStreamSourceTest.java +++ b/core/src/test/java/io/parsingdata/metal/data/ByteStreamSourceTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/ConcatenatedValueSourceErrorTest.java b/core/src/test/java/io/parsingdata/metal/data/ConcatenatedValueSourceErrorTest.java index e2206d6e..24a30557 100644 --- a/core/src/test/java/io/parsingdata/metal/data/ConcatenatedValueSourceErrorTest.java +++ b/core/src/test/java/io/parsingdata/metal/data/ConcatenatedValueSourceErrorTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/ConcatenatedValueSourceTest.java b/core/src/test/java/io/parsingdata/metal/data/ConcatenatedValueSourceTest.java index 176fcc23..1be19356 100644 --- a/core/src/test/java/io/parsingdata/metal/data/ConcatenatedValueSourceTest.java +++ b/core/src/test/java/io/parsingdata/metal/data/ConcatenatedValueSourceTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/ConstantSliceTest.java b/core/src/test/java/io/parsingdata/metal/data/ConstantSliceTest.java index d278fa8c..7d6cb02f 100644 --- a/core/src/test/java/io/parsingdata/metal/data/ConstantSliceTest.java +++ b/core/src/test/java/io/parsingdata/metal/data/ConstantSliceTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/ConstantSourceTest.java b/core/src/test/java/io/parsingdata/metal/data/ConstantSourceTest.java index 2c22d6a9..4b511934 100644 --- a/core/src/test/java/io/parsingdata/metal/data/ConstantSourceTest.java +++ b/core/src/test/java/io/parsingdata/metal/data/ConstantSourceTest.java @@ -1,6 +1,6 @@ /* - * Copyright 2013-2023 Netherlands Forensic Institute - * Copyright 2021-2023 Infix Technologies B.V. + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/DataExpressionSourceTest.java b/core/src/test/java/io/parsingdata/metal/data/DataExpressionSourceTest.java index ff269fe7..b69df9ad 100644 --- a/core/src/test/java/io/parsingdata/metal/data/DataExpressionSourceTest.java +++ b/core/src/test/java/io/parsingdata/metal/data/DataExpressionSourceTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/ImmutableListHeadTailTest.java b/core/src/test/java/io/parsingdata/metal/data/ImmutableListHeadTailTest.java index 89081b37..77f9c6e0 100644 --- a/core/src/test/java/io/parsingdata/metal/data/ImmutableListHeadTailTest.java +++ b/core/src/test/java/io/parsingdata/metal/data/ImmutableListHeadTailTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/ParseGraphTest.java b/core/src/test/java/io/parsingdata/metal/data/ParseGraphTest.java index d8ec1c4c..e0c2fe8b 100644 --- a/core/src/test/java/io/parsingdata/metal/data/ParseGraphTest.java +++ b/core/src/test/java/io/parsingdata/metal/data/ParseGraphTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/ParseReferenceTest.java b/core/src/test/java/io/parsingdata/metal/data/ParseReferenceTest.java index 0c6f2b63..2cad1e70 100644 --- a/core/src/test/java/io/parsingdata/metal/data/ParseReferenceTest.java +++ b/core/src/test/java/io/parsingdata/metal/data/ParseReferenceTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/ParseStateTest.java b/core/src/test/java/io/parsingdata/metal/data/ParseStateTest.java index 4745a666..41a14897 100644 --- a/core/src/test/java/io/parsingdata/metal/data/ParseStateTest.java +++ b/core/src/test/java/io/parsingdata/metal/data/ParseStateTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/ParseValueCacheTest.java b/core/src/test/java/io/parsingdata/metal/data/ParseValueCacheTest.java index 09bddbff..3cdd7bc6 100644 --- a/core/src/test/java/io/parsingdata/metal/data/ParseValueCacheTest.java +++ b/core/src/test/java/io/parsingdata/metal/data/ParseValueCacheTest.java @@ -150,6 +150,7 @@ public static Stream cacheUsageTest() { arguments("multi definitionRef", ref(pv2Definition, pv3Definition), false), arguments("multi definitionRef with limit", ref(con(1), pv2Definition, pv3Definition), false), + // Requested scope is smaller than the scopeDepth of the ParseState. arguments("scoped nameRef", scope(ref("second.name"), con(1)), false), arguments("scoped nameRef with limit", scope(ref(con(1), "second.name"), con(1)), false), arguments("scoped multi nameRef", scope(ref("second.name", "first.name"), con(1)), false), @@ -157,14 +158,24 @@ public static Stream cacheUsageTest() { arguments("scoped definitionRef", scope(ref(pv2Definition), con(1)), false), arguments("scoped definitionRef with limit", scope(ref(con(1), pv2Definition), con(1)), false), arguments("scoped multi definitionRef", scope(ref(pv2Definition, pv3Definition), con(1)), false), - arguments("scoped multi definitionRef with limit", scope(ref(con(1), pv2Definition, pv3Definition), con(1)), false) + arguments("scoped multi definitionRef with limit", scope(ref(con(1), pv2Definition, pv3Definition), con(1)), false), + + // Requested scope matches or exceeds the scopeDepth of the ParseState. + arguments("matching scoped nameRef", scope(ref("second.name"), con(2)), true), + arguments("matching scoped nameRef with limit", scope(ref(con(1), "second.name"), con(2)), true), + arguments("matching scoped multi nameRef", scope(ref("second.name", "first.name"), con(2)), false), + arguments("matching scoped multi nameRef with limit", scope(ref(con(1), "second.name", "first.name"), con(2)), false), + arguments("matching scoped definitionRef", scope(ref(pv2Definition), con(2)), false), + arguments("matching scoped definitionRef with limit", scope(ref(con(1), pv2Definition), con(2)), false), + arguments("matching scoped multi definitionRef", scope(ref(pv2Definition, pv3Definition), con(2)), false), + arguments("matching scoped multi definitionRef with limit", scope(ref(con(1), pv2Definition, pv3Definition), con(2)), false) ); } @ParameterizedTest(name="{2} - {0}") @MethodSource public void cacheUsageTest(final String testName, final ValueExpression expression, final boolean shouldUseCache) { - final ParseState parseState = new ParseState(ParseGraph.EMPTY, parseValueCache, createFromBytes(new byte[0]).source, ZERO, new ImmutableList<>(), new ImmutableList<>()); + final ParseState parseState = new ParseState(ParseGraph.EMPTY, parseValueCache, createFromBytes(new byte[0]).source, ZERO, new ImmutableList<>(), new ImmutableList<>(), 2); final ImmutableList eval = expression.eval(parseState, enc()); // The parseState is empty, while the cache if filled. // That means, if result is not empty, the cache was used. diff --git a/core/src/test/java/io/parsingdata/metal/data/ParseValueTest.java b/core/src/test/java/io/parsingdata/metal/data/ParseValueTest.java index f6cff362..38e6b44d 100644 --- a/core/src/test/java/io/parsingdata/metal/data/ParseValueTest.java +++ b/core/src/test/java/io/parsingdata/metal/data/ParseValueTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/SelectionTest.java b/core/src/test/java/io/parsingdata/metal/data/SelectionTest.java index 1c68b883..3a321aa2 100644 --- a/core/src/test/java/io/parsingdata/metal/data/SelectionTest.java +++ b/core/src/test/java/io/parsingdata/metal/data/SelectionTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/SliceTest.java b/core/src/test/java/io/parsingdata/metal/data/SliceTest.java index 54baccd2..63c4f46d 100644 --- a/core/src/test/java/io/parsingdata/metal/data/SliceTest.java +++ b/core/src/test/java/io/parsingdata/metal/data/SliceTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/SourceAndSliceTest.java b/core/src/test/java/io/parsingdata/metal/data/SourceAndSliceTest.java index fbaa96bf..6ee1d21d 100644 --- a/core/src/test/java/io/parsingdata/metal/data/SourceAndSliceTest.java +++ b/core/src/test/java/io/parsingdata/metal/data/SourceAndSliceTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/callback/CallbackTest.java b/core/src/test/java/io/parsingdata/metal/data/callback/CallbackTest.java index f10e7458..3969f553 100644 --- a/core/src/test/java/io/parsingdata/metal/data/callback/CallbackTest.java +++ b/core/src/test/java/io/parsingdata/metal/data/callback/CallbackTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/selection/ByName.java b/core/src/test/java/io/parsingdata/metal/data/selection/ByName.java index bda12058..0075ac60 100644 --- a/core/src/test/java/io/parsingdata/metal/data/selection/ByName.java +++ b/core/src/test/java/io/parsingdata/metal/data/selection/ByName.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/selection/ByToken.java b/core/src/test/java/io/parsingdata/metal/data/selection/ByToken.java index 64b1fde1..51620658 100644 --- a/core/src/test/java/io/parsingdata/metal/data/selection/ByToken.java +++ b/core/src/test/java/io/parsingdata/metal/data/selection/ByToken.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/selection/ByTokenTest.java b/core/src/test/java/io/parsingdata/metal/data/selection/ByTokenTest.java index bdc31139..a52da017 100644 --- a/core/src/test/java/io/parsingdata/metal/data/selection/ByTokenTest.java +++ b/core/src/test/java/io/parsingdata/metal/data/selection/ByTokenTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/selection/ByType.java b/core/src/test/java/io/parsingdata/metal/data/selection/ByType.java index 240bef01..072aba3c 100644 --- a/core/src/test/java/io/parsingdata/metal/data/selection/ByType.java +++ b/core/src/test/java/io/parsingdata/metal/data/selection/ByType.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/data/selection/ByTypeTest.java b/core/src/test/java/io/parsingdata/metal/data/selection/ByTypeTest.java index 30ee59ec..4ef80976 100644 --- a/core/src/test/java/io/parsingdata/metal/data/selection/ByTypeTest.java +++ b/core/src/test/java/io/parsingdata/metal/data/selection/ByTypeTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/BytesTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/BytesTest.java index 5c2cf47a..dfaf9a68 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/BytesTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/BytesTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/ConstantFactoryBigIntegerTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/ConstantFactoryBigIntegerTest.java index 54baa612..cb060085 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/ConstantFactoryBigIntegerTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/ConstantFactoryBigIntegerTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/ConstantFactoryLongTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/ConstantFactoryLongTest.java index ed3e51ca..57698fe0 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/ConstantFactoryLongTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/ConstantFactoryLongTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/CountTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/CountTest.java index 0830d9f7..4420e7f4 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/CountTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/CountTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/CurrentOffsetTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/CurrentOffsetTest.java index 73b79827..2c8225c8 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/CurrentOffsetTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/CurrentOffsetTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/ElvisExpressionTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/ElvisExpressionTest.java index ecb6206e..c16e5c57 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/ElvisExpressionTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/ElvisExpressionTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/ExpandTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/ExpandTest.java index c4f0a2cb..fdf96e13 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/ExpandTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/ExpandTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/FoldCatTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/FoldCatTest.java index 1bb2a9e6..7561c243 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/FoldCatTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/FoldCatTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/FoldEdgeCaseTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/FoldEdgeCaseTest.java index 805adeba..8c0c3937 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/FoldEdgeCaseTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/FoldEdgeCaseTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/JoinTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/JoinTest.java index 480bbb45..48e7ba0c 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/JoinTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/JoinTest.java @@ -1,6 +1,6 @@ /* - * Copyright 2013-2023 Netherlands Forensic Institute - * Copyright 2021-2023 Infix Technologies B.V. + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/NotAValueTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/NotAValueTest.java index 42931389..1b425469 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/NotAValueTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/NotAValueTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/NthExpressionTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/NthExpressionTest.java index 2a522349..b8914629 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/NthExpressionTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/NthExpressionTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/RefEdgeCaseTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/RefEdgeCaseTest.java index 4d7f7432..ce78e4c5 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/RefEdgeCaseTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/RefEdgeCaseTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/ScopeTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/ScopeTest.java index 4df0b4a0..9eb7bb41 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/ScopeTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/ScopeTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +24,12 @@ import static io.parsingdata.metal.Shorthand.EMPTY; import static io.parsingdata.metal.Shorthand.con; +import static io.parsingdata.metal.Shorthand.count; import static io.parsingdata.metal.Shorthand.def; import static io.parsingdata.metal.Shorthand.eq; +import static io.parsingdata.metal.Shorthand.eqNum; import static io.parsingdata.metal.Shorthand.first; +import static io.parsingdata.metal.Shorthand.post; import static io.parsingdata.metal.Shorthand.ref; import static io.parsingdata.metal.Shorthand.repn; import static io.parsingdata.metal.Shorthand.scope; @@ -52,22 +56,24 @@ public class ScopeTest { @Test public void notAValueScopeSize() { - final Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> new Scope(con(0), EMPTY_SVE).eval(EMPTY_PARSE_STATE, enc())); + final Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> scope(ref("a"), EMPTY_SVE).eval(EMPTY_PARSE_STATE, enc())); assertEquals("Argument scopeSize must evaluate to a positive, countable value.", e.getMessage()); } @Test public void negativeScopeSize() { - final Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> new Scope(con(0), con(-1, signed())).eval(EMPTY_PARSE_STATE, enc())); + final Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> scope(ref("a"), con(-1, signed())).eval(EMPTY_PARSE_STATE, enc())); assertEquals("Argument scopeSize must evaluate to a positive, countable value.", e.getMessage()); } @Test - public void scopeSizes() { + public void scopeSizesByName() { final Token scopesToken = seq(any("value"), // 0 repn(seq(any("value"), // 1 seq(any("value"), // 2 + // deepestValue=2, default scope=0, so refers to the deepest scope, which includes only the "value" in this seq + def("deepestValue", con(1), eq(first(scope(ref("value"))))), // deepestValue=2, scope=0, so refers to the deepest scope, which includes only the "value" in this seq def("deepestValue", con(1), eq(first(scope(ref("value"), con(0))))), // middleValue=1, scope=1, so includes the current seq and the one above it. @@ -82,7 +88,35 @@ public void scopeSizes() { ), con(1) ) ); - final Optional result = scopesToken.parse(env(stream(0, 1, 2, 2, 1, 1, 0, 0), enc())); + final Optional result = scopesToken.parse(env(stream(0, 1, 2, 2, 2, 1, 1, 0, 0), enc())); + assertTrue(result.isPresent()); + } + + + @Test + public void scopeSizesByDefinition() { + final Token value = any("value"); + final Token scopesToken = + seq(value, // 0 + repn(seq(value, // 1 + seq(value, // 2 + // deepestValue=2, default scope=0, so refers to the deepest scope, which includes only the "value" in this seq + def("deepestValue", con(1), eq(first(scope(ref(value))))), + // deepestValue=2, scope=0, so refers to the deepest scope, which includes only the "value" in this seq + def("deepestValue", con(1), eq(first(scope(ref(value), con(0))))), + // middleValue=1, scope=1, so includes the current seq and the one above it. + def("middleValue", con(1), eq(first(scope(ref(value), con(1))))), + // stillMiddleValue=1, scope=2, but since repn is also a scope delimiter, it does not include the top-level seq + def("stillMiddleValue", con(1), eq(first(scope(ref(value), con(2))))), + // topValue=0, scope=3, includes all scope delimiting tokens, to effectively global + def("topValue", con(1), eq(first(scope(ref(value), con(3))))), + // hugeScope=0, scope=100, everything from 3 up is global scope since there are 4 scope delimiting tokens (0-3) + def("hugeScope", con(1), eq(first(scope(ref(value), con(100))))) + ) + ), con(1) + ) + ); + final Optional result = scopesToken.parse(env(stream(0, 1, 2, 2, 2, 1, 1, 0, 0), enc())); assertTrue(result.isPresent()); } @@ -105,8 +139,56 @@ public void parseGraphWithEmptyBranch() { @Test public void parseGraphWithEmptyBranchSimplified() { - final Optional result = def("a", first(scope(con(1), con(0)))).parse(env(stream(0))); - assertEquals(ZERO, ref("a").eval(result.get(), enc()).head().asNumeric()); + final Optional result = post(def("a", con(1)), eqNum(con(0), scope(ref("a"), con(0)))).parse(env(stream(0))); + assertTrue(result.isPresent()); + } + + @Test + public void trivialScope() { + final Token trivialScope = + seq( + any("value"), + seq( + any("value"), + post( + post( + any("value"), + eqNum(count(scope(ref("value"), con(0))), con(2))), + eqNum(count(scope(ref("value"), con(1))), con(3)) + ) + ) + ); + + final Optional result = trivialScope.parse(env(stream(0, 0, 0), enc())); + assertTrue(result.isPresent()); + assertEquals(3, result.get().offset.intValueExact()); + } + + @Test + public void orderedScope() { + final Token orderedScope = + seq( + any("s"), + any("s"), + repn(any("s"), con(1)), + seq(any("s"), + any("s"), + seq(any("s"), + post( + post( + post(any("s"), + eqNum(count(ref("s")), con(7)) + ), + eqNum(count(ref("s")), con(7)) + ), + eqNum(count(ref("s")), con(7)) + ) + ) + ) + ); + final Optional result = orderedScope.parse(env(stream(7, 6, 5, 4, 3, 2, 1), enc())); + assertTrue(result.isPresent()); + assertEquals(7, result.get().offset.intValueExact()); } } diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/ValueExpressionEvalEmptyTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/ValueExpressionEvalEmptyTest.java index f5fcec71..6cdcfdba 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/ValueExpressionEvalEmptyTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/ValueExpressionEvalEmptyTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/ValueExpressionListSemanticsTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/ValueExpressionListSemanticsTest.java index d78bcedd..63c7a69d 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/ValueExpressionListSemanticsTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/ValueExpressionListSemanticsTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/reference/CurrentIterationEdgeCaseTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/reference/CurrentIterationEdgeCaseTest.java index 029c5a5c..5864a71d 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/reference/CurrentIterationEdgeCaseTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/reference/CurrentIterationEdgeCaseTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/reference/CurrentIterationTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/reference/CurrentIterationTest.java index 1713cd87..869bd7b8 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/reference/CurrentIterationTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/reference/CurrentIterationTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/reference/LocalReferenceFollowingScopeTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/reference/LocalReferenceFollowingScopeTest.java index 8b834780..efb87a6d 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/reference/LocalReferenceFollowingScopeTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/reference/LocalReferenceFollowingScopeTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/reference/LocalReferenceNestedScopeTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/reference/LocalReferenceNestedScopeTest.java index 1696af80..b97e03e5 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/reference/LocalReferenceNestedScopeTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/reference/LocalReferenceNestedScopeTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/expression/value/reference/OffsetTest.java b/core/src/test/java/io/parsingdata/metal/expression/value/reference/OffsetTest.java index df303df6..12a7e95b 100644 --- a/core/src/test/java/io/parsingdata/metal/expression/value/reference/OffsetTest.java +++ b/core/src/test/java/io/parsingdata/metal/expression/value/reference/OffsetTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/token/DefTest.java b/core/src/test/java/io/parsingdata/metal/token/DefTest.java index 4a534054..899767c6 100644 --- a/core/src/test/java/io/parsingdata/metal/token/DefTest.java +++ b/core/src/test/java/io/parsingdata/metal/token/DefTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/token/DefUntilTest.java b/core/src/test/java/io/parsingdata/metal/token/DefUntilTest.java index 2616bc0c..f3b4a4fa 100644 --- a/core/src/test/java/io/parsingdata/metal/token/DefUntilTest.java +++ b/core/src/test/java/io/parsingdata/metal/token/DefUntilTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +18,12 @@ package io.parsingdata.metal.token; import static java.nio.charset.StandardCharsets.US_ASCII; +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertIterableEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import static io.parsingdata.metal.Shorthand.CURRENT_OFFSET; @@ -27,6 +31,7 @@ import static io.parsingdata.metal.Shorthand.con; import static io.parsingdata.metal.Shorthand.def; import static io.parsingdata.metal.Shorthand.eq; +import static io.parsingdata.metal.Shorthand.join; import static io.parsingdata.metal.Shorthand.last; import static io.parsingdata.metal.Shorthand.mod; import static io.parsingdata.metal.Shorthand.post; @@ -36,10 +41,12 @@ import static io.parsingdata.metal.Shorthand.sub; import static io.parsingdata.metal.Shorthand.until; import static io.parsingdata.metal.data.selection.ByName.getAllValues; +import static io.parsingdata.metal.util.EncodingFactory.enc; import static io.parsingdata.metal.util.EncodingFactory.signed; import static io.parsingdata.metal.util.EnvironmentFactory.env; import static io.parsingdata.metal.util.ParseStateFactory.stream; +import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Optional; @@ -49,11 +56,15 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; +import io.parsingdata.metal.data.Environment; import io.parsingdata.metal.data.ImmutableList; import io.parsingdata.metal.data.ParseState; import io.parsingdata.metal.data.ParseValue; +import io.parsingdata.metal.data.callback.Callback; +import io.parsingdata.metal.data.callback.Callbacks; import io.parsingdata.metal.encoding.Encoding; import io.parsingdata.metal.expression.Expression; +import io.parsingdata.metal.expression.value.ValueExpression; class DefUntilTest { @@ -187,4 +198,51 @@ private static void assertNameScope(final Function tokenProvider, assertEquals("data", getAllValues(parse.get().order, "struct.value").head().asString()); } + @Test + void listsSemanticsTest() { + // It is ok for the lists to have different lengths. They are used simultaneously as triples, and the number of triples considered is equal to the length of the smallest list. + final ValueExpression initialSize = join(con(12), con(7), con(5), con(0)); // 12 is ignored + final ValueExpression stepSize = join(con(1), con(5), con(6)); + final ValueExpression maxSize = join(con(105), con(21), con(18), con(15), con(13)); // 21 and 105 are ignored + final Token def = def("test", initialSize, stepSize, maxSize, def("terminator", 1, eq(con("X")))); + + // The above DefUntil token should check the following offsets: + // combination 0-6-13: 0+0=0, 0+6=6, 0+12=12 + // combination 5-5-15: 5+0=5, 5+5=10, 5+10=15 + // combination 7-1-18: 7+0=7, 7+1=8, 7+2=9, 7+3=10, 7+4=11 + // Total checks expected = 11. + + final List offsets = new ArrayList<>(); + final Callbacks callbacks = Callbacks.create().add(genericCallback(offsets, "terminator")); + + final Optional parse = def.parse(new Environment(stream("01234567890X--------", UTF_8), callbacks, enc())); + assertTrue(parse.isPresent()); + assertAll( + () -> assertEquals(11, parse.get().offset.intValue()), + () -> assertEquals(11, offsets.size()), + () -> assertIterableEquals(List.of(0, 6, 12, 5, 10, 15, 7, 8, 9, 10, 11), offsets), + () -> assertEquals("01234567890", getAllValues(parse.get().order, "test").head.asString()) + ); + } + + private static Callback genericCallback(final List checkCount, final String tokenName) { + return new Callback() { + @Override + public void handleSuccess(Token token, ParseState before, ParseState after) { + countTerminator(token, before); + } + + @Override + public void handleFailure(Token token, ParseState before) { + countTerminator(token, before); + } + + private void countTerminator(Token token, ParseState before) { + if (token.name.equals(tokenName)) { + checkCount.add(before.offset.intValue()); + } + } + }; + } + } diff --git a/core/src/test/java/io/parsingdata/metal/token/ParameterizedUntilTest.java b/core/src/test/java/io/parsingdata/metal/token/ParameterizedUntilTest.java index fe06c234..94f18ba7 100644 --- a/core/src/test/java/io/parsingdata/metal/token/ParameterizedUntilTest.java +++ b/core/src/test/java/io/parsingdata/metal/token/ParameterizedUntilTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/token/PostTest.java b/core/src/test/java/io/parsingdata/metal/token/PostTest.java index face8fa8..afc8eebb 100644 --- a/core/src/test/java/io/parsingdata/metal/token/PostTest.java +++ b/core/src/test/java/io/parsingdata/metal/token/PostTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/token/PreTest.java b/core/src/test/java/io/parsingdata/metal/token/PreTest.java index bc5b97a6..18c397df 100644 --- a/core/src/test/java/io/parsingdata/metal/token/PreTest.java +++ b/core/src/test/java/io/parsingdata/metal/token/PreTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/token/TieTest.java b/core/src/test/java/io/parsingdata/metal/token/TieTest.java index 85229181..edf23c45 100644 --- a/core/src/test/java/io/parsingdata/metal/token/TieTest.java +++ b/core/src/test/java/io/parsingdata/metal/token/TieTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/token/TokenRefTest.java b/core/src/test/java/io/parsingdata/metal/token/TokenRefTest.java index 7c287474..5db234f3 100644 --- a/core/src/test/java/io/parsingdata/metal/token/TokenRefTest.java +++ b/core/src/test/java/io/parsingdata/metal/token/TokenRefTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/token/TokenTest.java b/core/src/test/java/io/parsingdata/metal/token/TokenTest.java index 5c5e7e1b..2d2678cd 100644 --- a/core/src/test/java/io/parsingdata/metal/token/TokenTest.java +++ b/core/src/test/java/io/parsingdata/metal/token/TokenTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/token/WhileTest.java b/core/src/test/java/io/parsingdata/metal/token/WhileTest.java index 08b124db..dc6abb03 100644 --- a/core/src/test/java/io/parsingdata/metal/token/WhileTest.java +++ b/core/src/test/java/io/parsingdata/metal/token/WhileTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/util/ClassDefinition.java b/core/src/test/java/io/parsingdata/metal/util/ClassDefinition.java index 6cbc0fda..f9356e9c 100644 --- a/core/src/test/java/io/parsingdata/metal/util/ClassDefinition.java +++ b/core/src/test/java/io/parsingdata/metal/util/ClassDefinition.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/util/EncodingFactory.java b/core/src/test/java/io/parsingdata/metal/util/EncodingFactory.java index 10033105..11d1f721 100644 --- a/core/src/test/java/io/parsingdata/metal/util/EncodingFactory.java +++ b/core/src/test/java/io/parsingdata/metal/util/EncodingFactory.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/util/EnvironmentFactory.java b/core/src/test/java/io/parsingdata/metal/util/EnvironmentFactory.java index 14d05ef3..e43226eb 100644 --- a/core/src/test/java/io/parsingdata/metal/util/EnvironmentFactory.java +++ b/core/src/test/java/io/parsingdata/metal/util/EnvironmentFactory.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/util/InMemoryByteStream.java b/core/src/test/java/io/parsingdata/metal/util/InMemoryByteStream.java index 9709362b..f7d08519 100644 --- a/core/src/test/java/io/parsingdata/metal/util/InMemoryByteStream.java +++ b/core/src/test/java/io/parsingdata/metal/util/InMemoryByteStream.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/util/ParameterizedParse.java b/core/src/test/java/io/parsingdata/metal/util/ParameterizedParse.java index 2336fb04..015b4830 100644 --- a/core/src/test/java/io/parsingdata/metal/util/ParameterizedParse.java +++ b/core/src/test/java/io/parsingdata/metal/util/ParameterizedParse.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/util/ParseStateFactory.java b/core/src/test/java/io/parsingdata/metal/util/ParseStateFactory.java index bb33e195..88361c14 100644 --- a/core/src/test/java/io/parsingdata/metal/util/ParseStateFactory.java +++ b/core/src/test/java/io/parsingdata/metal/util/ParseStateFactory.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/util/ReadTrackingByteStream.java b/core/src/test/java/io/parsingdata/metal/util/ReadTrackingByteStream.java index a7514563..7e41e783 100644 --- a/core/src/test/java/io/parsingdata/metal/util/ReadTrackingByteStream.java +++ b/core/src/test/java/io/parsingdata/metal/util/ReadTrackingByteStream.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/src/test/java/io/parsingdata/metal/util/TokenDefinitions.java b/core/src/test/java/io/parsingdata/metal/util/TokenDefinitions.java index 1f10019a..1c0e5cf2 100644 --- a/core/src/test/java/io/parsingdata/metal/util/TokenDefinitions.java +++ b/core/src/test/java/io/parsingdata/metal/util/TokenDefinitions.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/formats/pom.xml b/formats/pom.xml index 796e1b64..b8b0d37b 100644 --- a/formats/pom.xml +++ b/formats/pom.xml @@ -3,7 +3,7 @@ io.parsingdata metal - 10.0.0-SNAPSHOT + 11.0.0-SNAPSHOT metal-formats ${project.groupId}:${project.artifactId} @@ -14,6 +14,7 @@ scm:git:git@github.com:parsingdata/metal.git scm:git:git@github.com:parsingdata/metal.git https://github.com/parsingdata/metal.git + HEAD diff --git a/formats/src/main/java/io/parsingdata/metal/expression/value/GUID.java b/formats/src/main/java/io/parsingdata/metal/expression/value/GUID.java index e7f2d326..082cf1b1 100644 --- a/formats/src/main/java/io/parsingdata/metal/expression/value/GUID.java +++ b/formats/src/main/java/io/parsingdata/metal/expression/value/GUID.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/formats/src/main/java/io/parsingdata/metal/expression/value/UUID.java b/formats/src/main/java/io/parsingdata/metal/expression/value/UUID.java index 10739fd5..3242c354 100644 --- a/formats/src/main/java/io/parsingdata/metal/expression/value/UUID.java +++ b/formats/src/main/java/io/parsingdata/metal/expression/value/UUID.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/formats/src/main/java/io/parsingdata/metal/format/Callback.java b/formats/src/main/java/io/parsingdata/metal/format/Callback.java index 7567b0d1..36ec16aa 100644 --- a/formats/src/main/java/io/parsingdata/metal/format/Callback.java +++ b/formats/src/main/java/io/parsingdata/metal/format/Callback.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/formats/src/main/java/io/parsingdata/metal/format/JPEG.java b/formats/src/main/java/io/parsingdata/metal/format/JPEG.java index 4cebeb1f..2fade229 100644 --- a/formats/src/main/java/io/parsingdata/metal/format/JPEG.java +++ b/formats/src/main/java/io/parsingdata/metal/format/JPEG.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/formats/src/main/java/io/parsingdata/metal/format/PNG.java b/formats/src/main/java/io/parsingdata/metal/format/PNG.java index c760beb4..80e712da 100644 --- a/formats/src/main/java/io/parsingdata/metal/format/PNG.java +++ b/formats/src/main/java/io/parsingdata/metal/format/PNG.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/formats/src/main/java/io/parsingdata/metal/format/VarInt.java b/formats/src/main/java/io/parsingdata/metal/format/VarInt.java index 7d37d6f3..80f03dd2 100644 --- a/formats/src/main/java/io/parsingdata/metal/format/VarInt.java +++ b/formats/src/main/java/io/parsingdata/metal/format/VarInt.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/formats/src/main/java/io/parsingdata/metal/format/ZIP.java b/formats/src/main/java/io/parsingdata/metal/format/ZIP.java index e7d01206..e6ec77da 100644 --- a/formats/src/main/java/io/parsingdata/metal/format/ZIP.java +++ b/formats/src/main/java/io/parsingdata/metal/format/ZIP.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/formats/src/test/java/io/parsingdata/metal/DescriptionClassTest.java b/formats/src/test/java/io/parsingdata/metal/DescriptionClassTest.java index acef752b..fb06ebb2 100644 --- a/formats/src/test/java/io/parsingdata/metal/DescriptionClassTest.java +++ b/formats/src/test/java/io/parsingdata/metal/DescriptionClassTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/formats/src/test/java/io/parsingdata/metal/expression/value/GUIDTest.java b/formats/src/test/java/io/parsingdata/metal/expression/value/GUIDTest.java index 4c946ab7..1cb157d9 100644 --- a/formats/src/test/java/io/parsingdata/metal/expression/value/GUIDTest.java +++ b/formats/src/test/java/io/parsingdata/metal/expression/value/GUIDTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/formats/src/test/java/io/parsingdata/metal/expression/value/UUIDTest.java b/formats/src/test/java/io/parsingdata/metal/expression/value/UUIDTest.java index c6c27497..d9f73368 100644 --- a/formats/src/test/java/io/parsingdata/metal/expression/value/UUIDTest.java +++ b/formats/src/test/java/io/parsingdata/metal/expression/value/UUIDTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/formats/src/test/java/io/parsingdata/metal/format/CallbackTest.java b/formats/src/test/java/io/parsingdata/metal/format/CallbackTest.java index 0491cbe3..83edc39c 100644 --- a/formats/src/test/java/io/parsingdata/metal/format/CallbackTest.java +++ b/formats/src/test/java/io/parsingdata/metal/format/CallbackTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/formats/src/test/java/io/parsingdata/metal/format/FormatTest.java b/formats/src/test/java/io/parsingdata/metal/format/FormatTest.java index be154c89..cd90116b 100644 --- a/formats/src/test/java/io/parsingdata/metal/format/FormatTest.java +++ b/formats/src/test/java/io/parsingdata/metal/format/FormatTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/formats/src/test/java/io/parsingdata/metal/format/VarIntTest.java b/formats/src/test/java/io/parsingdata/metal/format/VarIntTest.java index 50a619d2..746566c5 100644 --- a/formats/src/test/java/io/parsingdata/metal/format/VarIntTest.java +++ b/formats/src/test/java/io/parsingdata/metal/format/VarIntTest.java @@ -1,5 +1,6 @@ /* - * Copyright 2013-2021 Netherlands Forensic Institute + * Copyright 2013-2024 Netherlands Forensic Institute + * Copyright 2021-2024 Infix Technologies B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/pom.xml b/pom.xml index af0ea360..8b6fe74c 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ io.parsingdata metal ${project.groupId}:${project.artifactId} - 10.0.0-SNAPSHOT + 11.0.0-SNAPSHOT pom https://github.com/parsingdata/metal A Java library for parsing binary data formats, using declarative descriptions. @@ -46,6 +46,7 @@ scm:git:git@github.com:parsingdata/metal.git scm:git:git@github.com:parsingdata/metal.git https://github.com/parsingdata/metal.git + HEAD