public class Until extends Token
Token that specifies a value to parse in the input until
another token is parsed.
An Until consists of an initialSize, a stepSize
and a maxSize (all ValueExpressions) and a
terminator(a Token). First initialSize,
stepSize, and maxSize are evaluated. Using this
token's name, a value of length initialSize is added to the
ParseState and an attempt is made to parse the
terminator. If it succeeds, the resulting parseState is
returned. Otherwise, stepSize is added to the
initialSize and if the resulting value is below
maxSize, a value with the resulting size is added to the
original ParseState and a new attempt to parse the
terminator is made. Parsing fails if no combination of any size
is found where the terminator parses successfully.
If the ValueExpressions evaluate to lists, they are treated
as sets of values to attempt. If stepSize is negative,
maxSize must be smaller than initialSize.
Parsing fails if stepSize is zero.
ValueExpression| Modifier and Type | Field and Description |
|---|---|
static ValueExpression |
DEFAULT_INITIAL |
static ValueExpression |
DEFAULT_MAX |
static ValueExpression |
DEFAULT_STEP |
ValueExpression |
initialSize |
ValueExpression |
maxSize |
ValueExpression |
stepSize |
Token |
terminator |
| Constructor and Description |
|---|
Until(String name,
ValueExpression initialSize,
ValueExpression stepSize,
ValueExpression maxSize,
Token terminator,
Encoding encoding) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
int |
hashCode() |
protected Optional<ParseState> |
parseImpl(Environment environment) |
String |
toString() |
getCanonical, isLocal, makeNameFragment, parsepublic static final ValueExpression DEFAULT_INITIAL
public static final ValueExpression DEFAULT_STEP
public static final ValueExpression DEFAULT_MAX
public final ValueExpression initialSize
public final ValueExpression stepSize
public final ValueExpression maxSize
public final Token terminator
public Until(String name, ValueExpression initialSize, ValueExpression stepSize, ValueExpression maxSize, Token terminator, Encoding encoding)
protected Optional<ParseState> parseImpl(Environment environment)
Copyright © 2017. All rights reserved.