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.parsingdatametal-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.parsingdatametal
- 10.0.0-SNAPSHOT
+ 11.0.0-SNAPSHOTmetal-core${project.groupId}:${project.artifactId}
@@ -14,6 +14,7 @@
scm:git:git@github.com:parsingdata/metal.gitscm:git:git@github.com:parsingdata/metal.githttps://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