Skip to content

Commit

Permalink
Merge pull request #369 from parsingdata/until-revised
Browse files Browse the repository at this point in the history
-#360: Rename Until class to DefUntil
  • Loading branch information
jvdb committed Mar 2, 2023
2 parents ddb1541 + 8fa5ad9 commit ad747cf
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 32 deletions.
40 changes: 20 additions & 20 deletions core/src/main/java/io/parsingdata/metal/Shorthand.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
import io.parsingdata.metal.token.Tie;
import io.parsingdata.metal.token.Token;
import io.parsingdata.metal.token.TokenRef;
import io.parsingdata.metal.token.Until;
import io.parsingdata.metal.token.DefUntil;
import io.parsingdata.metal.token.While;

public final class Shorthand {
Expand Down Expand Up @@ -125,34 +125,34 @@ private Shorthand() {}
public static Token def(final String name, final long size, final Expression predicate) { return def(name, size, predicate, null); }


/** "DEFinition": Instantiates a {@link Until} where the size of the def is dynamically determined. */
public static Token def(final String name, final ValueExpression initialSize, final ValueExpression stepSize, final ValueExpression maxSize, final Token terminator, final Encoding encoding) { return new Until(name, initialSize, stepSize, maxSize, terminator, encoding); }
/** "DEFinition": Instantiates a {@link DefUntil} where the size of the def is dynamically determined. */
public static Token def(final String name, final ValueExpression initialSize, final ValueExpression stepSize, final ValueExpression maxSize, final Token terminator, final Encoding encoding) { return new DefUntil(name, initialSize, stepSize, maxSize, terminator, encoding); }

/** "DEFinition": Instantiates a {@link Until} where the size of the def is dynamically determined with {@code encoding = null}. */
/** "DEFinition": Instantiates a {@link DefUntil} where the size of the def is dynamically determined with {@code encoding = null}. */
public static Token def(final String name, final ValueExpression initialSize, final ValueExpression stepSize, final ValueExpression maxSize, final Token terminator) { return def(name, initialSize, stepSize, maxSize, terminator, null); }

/** "DEFinition": Instantiates a {@link Until} where the size of the def is dynamically determined with {@code maxSize = null}. */
/** "DEFinition": Instantiates a {@link DefUntil} where the size of the def is dynamically determined with {@code maxSize = null}. */
public static Token def(final String name, final ValueExpression initialSize, final ValueExpression stepSize, final Token terminator, final Encoding encoding) { return def(name, initialSize, stepSize, null, terminator, encoding); }

/** "DEFinition": Instantiates a {@link Until} where the size of the def is dynamically determined with {@code maxSize = null} and {@code encoding = null}. */
/** "DEFinition": Instantiates a {@link DefUntil} where the size of the def is dynamically determined with {@code maxSize = null} and {@code encoding = null}. */
public static Token def(final String name, final ValueExpression initialSize, final ValueExpression stepSize, final Token terminator) { return def(name, initialSize, stepSize, null, terminator, null); }

/** "DEFinition": Instantiates a {@link Until} where the size of the def is dynamically determined with {@code stepSize = null} and {@code maxSize = null}. */
/** "DEFinition": Instantiates a {@link DefUntil} where the size of the def is dynamically determined with {@code stepSize = null} and {@code maxSize = null}. */
public static Token def(final String name, final ValueExpression initialSize, final Token terminator, final Encoding encoding) { return def(name, initialSize, null, terminator, encoding); }

/** "DEFinition": Instantiates a {@link Until} where the size of the def is dynamically determined with {@code stepSize = null}, {@code maxSize = null} and {@code encoding = null}. */
/** "DEFinition": Instantiates a {@link DefUntil} where the size of the def is dynamically determined with {@code stepSize = null}, {@code maxSize = null} and {@code encoding = null}. */
public static Token def(final String name, final ValueExpression initialSize, final Token terminator) { return def(name, initialSize, null, terminator, null); }

/** "DEFinition": Instantiates a {@link Until} where the size of the def is dynamically determined with {@code initialSize = null}, {@code stepSize = null} and {@code maxSize = null}. */
/** "DEFinition": Instantiates a {@link DefUntil} where the size of the def is dynamically determined with {@code initialSize = null}, {@code stepSize = null} and {@code maxSize = null}. */
public static Token def(final String name, final Token terminator, final Encoding encoding) { return def(name, null, terminator, encoding); }

/** "DEFinition": Instantiates a {@link Until} where the size of the def is dynamically determined with {@code initialSize = null}, {@code stepSize = null}, {@code maxSize = null} and {@code encoding = null}. */
/** "DEFinition": Instantiates a {@link DefUntil} where the size of the def is dynamically determined with {@code initialSize = null}, {@code stepSize = null}, {@code maxSize = null} and {@code encoding = null}. */
public static Token def(final String name, final Token terminator) { return def(name, terminator, null); }

/** "DEFinition": Instantiates a {@link Until} with the expression nested in a {@link Post} and {@code initialSize = con(1)}. */
/** "DEFinition": Instantiates a {@link DefUntil} with the expression nested in a {@link Post} and {@code initialSize = con(1)}. */
public static Token def(final String name, final Expression predicate, final Encoding encoding) { return def(name, con(1), post(EMPTY, predicate), encoding); }

/** "DEFinition": Instantiates a {@link Until} where the terminator is the expression nested in a {@link Post}, {@code initialSize = con(1)} and {@code encoding = null}. */
/** "DEFinition": Instantiates a {@link DefUntil} where the terminator is the expression nested in a {@link Post}, {@code initialSize = con(1)} and {@code encoding = null}. */
public static Token def(final String name, final Expression predicate) { return def(name, predicate, null); }


Expand Down Expand Up @@ -214,28 +214,28 @@ private Shorthand() {}
/** @see Tie */ public static Token tie(final Token token, final ValueExpression dataExpression) { return tie(token, dataExpression, null); }


/** "DEFinition": Instantiates a {@link Until} and its terminator nested in a {@link Seq}. */
/** "DEFinition": Instantiates a {@link DefUntil} and its terminator nested in a {@link Seq}. */
public static Token until(final String name, final ValueExpression initialSize, final ValueExpression stepSize, final ValueExpression maxSize, final Token terminator, final Encoding encoding) { return seq(def(name, initialSize, stepSize, maxSize, terminator, encoding), terminator); }

/** "DEFinition": Instantiates a {@link Until} and its terminator nested in a {@link Seq} with {@code encoding = null}. */
/** "DEFinition": Instantiates a {@link DefUntil} and its terminator nested in a {@link Seq} with {@code encoding = null}. */
public static Token until(final String name, final ValueExpression initialSize, final ValueExpression stepSize, final ValueExpression maxSize, final Token terminator) { return until(name, initialSize, stepSize, maxSize, terminator, null); }

/** "DEFinition": Instantiates a {@link Until} and its terminator nested in a {@link Seq} with {@code maxSize = null}. */
/** "DEFinition": Instantiates a {@link DefUntil} and its terminator nested in a {@link Seq} with {@code maxSize = null}. */
public static Token until(final String name, final ValueExpression initialSize, final ValueExpression stepSize, final Token terminator, final Encoding encoding) { return until(name, initialSize, stepSize, null, terminator, encoding); }

/** "DEFinition": Instantiates a {@link Until} and its terminator nested in a {@link Seq} with {@code maxSize = null} and {@code encoding = null}. */
/** "DEFinition": Instantiates a {@link DefUntil} and its terminator nested in a {@link Seq} with {@code maxSize = null} and {@code encoding = null}. */
public static Token until(final String name, final ValueExpression initialSize, final ValueExpression stepSize, final Token terminator) { return until(name, initialSize, stepSize, null, terminator, null); }

/** "DEFinition": Instantiates a {@link Until} and its terminator nested in a {@link Seq} with {@code stepSize = null} and {@code maxSize = null}. */
/** "DEFinition": Instantiates a {@link DefUntil} and its terminator nested in a {@link Seq} with {@code stepSize = null} and {@code maxSize = null}. */
public static Token until(final String name, final ValueExpression initialSize, final Token terminator, final Encoding encoding) { return until(name, initialSize, null, terminator, encoding); }

/** "DEFinition": Instantiates a {@link Until} and its terminator nested in a {@link Seq} with {@code stepSize = null}, {@code maxSize = null} and {@code encoding = null}. */
/** "DEFinition": Instantiates a {@link DefUntil} and its terminator nested in a {@link Seq} with {@code stepSize = null}, {@code maxSize = null} and {@code encoding = null}. */
public static Token until(final String name, final ValueExpression initialSize, final Token terminator) { return until(name, initialSize, null, terminator, null); }

/** "DEFinition": Instantiates a {@link Until} and its terminator nested in a {@link Seq} with {@code initialSize = null}, {@code stepSize = null} and {@code maxSize = null}. */
/** "DEFinition": Instantiates a {@link DefUntil} and its terminator nested in a {@link Seq} with {@code initialSize = null}, {@code stepSize = null} and {@code maxSize = null}. */
public static Token until(final String name, final Token terminator, final Encoding encoding) { return until(name, null, terminator, encoding); }

/** "DEFinition": Instantiates a {@link Until} and its terminator nested in a {@link Seq} with {@code initialSize = null}, {@code stepSize = null}, {@code maxSize = null} and {@code encoding = null}. */
/** "DEFinition": Instantiates a {@link DefUntil} and its terminator nested in a {@link Seq} with {@code initialSize = null}, {@code stepSize = null}, {@code maxSize = null} and {@code encoding = null}. */
public static Token until(final String name, final Token terminator) { return until(name, terminator, null); }


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
*
* @see ValueExpression
*/
public class Until extends Token {
public class DefUntil extends Token {

public static final ValueExpression DEFAULT_INITIAL = con(0);
public static final ValueExpression DEFAULT_STEP = con(1);
Expand All @@ -81,7 +81,7 @@ public class Until extends Token {
public final ValueExpression maxSize;
public final Token terminator;

public Until(final String name, final ValueExpression initialSize, final ValueExpression stepSize, final ValueExpression maxSize, final Token terminator, final Encoding encoding) {
public DefUntil(final String name, final ValueExpression initialSize, final ValueExpression stepSize, final ValueExpression maxSize, final Token terminator, final Encoding encoding) {
super(checkNotEmpty(name, "name"), encoding);
this.initialSize = initialSize == null ? DEFAULT_INITIAL : initialSize;
this.stepSize = stepSize == null ? DEFAULT_STEP : stepSize;
Expand Down Expand Up @@ -140,10 +140,10 @@ public String toString() {
@Override
public boolean equals(final Object obj) {
return super.equals(obj)
&& Objects.equals(initialSize, ((Until)obj).initialSize)
&& Objects.equals(stepSize, ((Until)obj).stepSize)
&& Objects.equals(maxSize, ((Until)obj).maxSize)
&& Objects.equals(terminator, ((Until)obj).terminator);
&& Objects.equals(initialSize, ((DefUntil)obj).initialSize)
&& Objects.equals(stepSize, ((DefUntil)obj).stepSize)
&& Objects.equals(maxSize, ((DefUntil)obj).maxSize)
&& Objects.equals(terminator, ((DefUntil)obj).terminator);
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions core/src/test/java/io/parsingdata/metal/ArgumentsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
import io.parsingdata.metal.token.Sub;
import io.parsingdata.metal.token.Token;
import io.parsingdata.metal.token.TokenRef;
import io.parsingdata.metal.token.Until;
import io.parsingdata.metal.token.DefUntil;
import io.parsingdata.metal.token.While;

@RunWith(Parameterized.class)
Expand Down Expand Up @@ -153,8 +153,8 @@ public static Collection<Object[]> arguments() {
{ TokenRef.class, new Object[] { null, VALID_NAME, null } },
{ TokenRef.class, new Object[] { null, null, null } },
{ TokenRef.class, new Object[] { VALID_NAME, EMPTY_NAME, null } },
{ Until.class, new Object[] { null, VALID_VE, VALID_VE, VALID_VE, VALID_T, null }},
{ Until.class, new Object[] { VALID_NAME, VALID_VE, VALID_VE, VALID_VE, null, null }}
{ DefUntil.class, new Object[] { null, VALID_VE, VALID_VE, VALID_VE, VALID_T, null }},
{ DefUntil.class, new Object[] { VALID_NAME, VALID_VE, VALID_VE, VALID_VE, null, null }}
});
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/test/java/io/parsingdata/metal/AutoEqualityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
import io.parsingdata.metal.token.Tie;
import io.parsingdata.metal.token.Token;
import io.parsingdata.metal.token.TokenRef;
import io.parsingdata.metal.token.Until;
import io.parsingdata.metal.token.DefUntil;
import io.parsingdata.metal.token.While;
import io.parsingdata.metal.util.EncodingFactory;
import io.parsingdata.metal.util.InMemoryByteStream;
Expand Down Expand Up @@ -200,7 +200,7 @@ public static Collection<Object[]> data() throws IllegalAccessException, Invocat
return generateObjectArrays(
// Tokens
Cho.class, Def.class, Pre.class, Rep.class, RepN.class, Seq.class, Sub.class, Tie.class,
TokenRef.class, While.class, Post.class, Until.class,
TokenRef.class, While.class, Post.class, DefUntil.class,
// ValueExpressions
Len.class, Offset.class, Neg.class, Not.class, Count.class, First.class, Last.class, Reverse.class,
And.class, Or.class, ShiftLeft.class, ShiftRight.class, Add.class, Div.class, Mod.class, Mul.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

class UntilTest {
class DefUntilTest {

private static final String INPUT_1 = "Hello, World!";
private static final String INPUT_2 = "Another line...";
Expand Down

0 comments on commit ad747cf

Please sign in to comment.