/** * Constructs a {@link SettableParser} referring to the supplied {@code parser}. */ public static SettableParser with(Parser parser) { return new SettableParser(parser); }
/** * Returns a parser that succeeds only if the receiver consumes the complete input, otherwise * return a failure with the {@code message}. */ public Parser end(String message) { return new EndOfInputParser(this, message); }
@Override public DelegateParser copy() { return new DelegateParser(delegate); } }
/** * Returns new parser that accepts the receiver, if possible. The returned value can be provided * as {@code otherwise}. */ public Parser optional(Object otherwise) { return new OptionalParser(this, otherwise); }
@Override public String toString() { return super.toString() + "[" + message + "]"; } }
@Override public AndParser copy() { return new AndParser(delegate); } }
/** * Returns a parser that points to the receiver, but can be changed to point to something else at * a later point in time. */ public SettableParser settable() { return SettableParser.with(this); }
/** * Constructs a {@link SettableParser} that currently refers to an {@link FailureParser}. */ public static SettableParser undefined() { return undefined("Undefined parser"); }
/** * Returns a parser (logical not-predicate) that succeeds whenever the receiver fails, but never * consumes input. */ public Parser not(String message) { return new NotParser(this, message); }
@Override public void replace(Parser source, Parser target) { super.replace(source, target); if (left == source) { left = target; } if (right == source) { right = target; } }
@Override public SettableParser copy() { return new SettableParser(delegate); } }
@Override public OptionalParser copy() { return new OptionalParser(delegate, otherwise); } }
@Override public String toString() { return super.toString() + "[" + message + "]"; } }
/** * Returns a parser (logical and-predicate) that succeeds whenever the receiver does, but never * consumes input. */ public Parser and() { return new AndParser(this); }
/** * Returns a parser that points to the receiver, but can be changed to point to something else at * a later point in time. */ public SettableParser settable() { return SettableParser.with(this); }
/** * Constructs a {@link SettableParser} that currently refers to an {@link FailureParser}. */ public static SettableParser undefined() { return undefined("Undefined parser"); }
@Override public SettableParser copy() { return new SettableParser(delegate); } }
/** * Returns new parser that accepts the receiver, if possible. The returned value can be provided * as {@code otherwise}. */ public Parser optional(Object otherwise) { return new OptionalParser(this, otherwise); }
@Override public String toString() { return super.toString() + "[" + message + "]"; } }
/** * Returns a parser (logical and-predicate) that succeeds whenever the receiver does, but never * consumes input. */ public Parser and() { return new AndParser(this); }