private ParsingExpression[] convertToExpressions(Object e1, Object e2, Object[] rest) { ParsingExpression[] result = new ParsingExpression[2 + rest.length]; result[0] = convertToExpression(e1); result[1] = convertToExpression(e2); for (int i = 0; i < rest.length; i++) { result[2 + i] = convertToExpression(rest[i]); } return result; }
/** * Creates parsing expression - "sequence". * See {@link #sequence(Object, Object)} for more details. * * @param e1 first sub-expression * @param e2 second sub-expression * @param rest rest of sub-expressions * @throws IllegalArgumentException if any of given arguments is not a parsing expression */ public final Object sequence(Object e1, Object e2, Object... rest) { return new SequenceExpression(convertToExpressions(e1, e2, rest)); }
final ParsingExpression[] convertToExpressions(Object e1, Object[] rest) { ParsingExpression[] result = new ParsingExpression[1 + rest.length]; result[0] = convertToExpression(e1); for (int i = 0; i < rest.length; i++) { result[1 + i] = convertToExpression(rest[i]); } return result; }
/** * Creates parsing expression - "first of". * See {@link #firstOf(Object, Object)} for more details. * * @param e1 first sub-expression * @param e2 second sub-expression * @param rest rest of sub-expressions * @throws IllegalArgumentException if any of given arguments is not a parsing expression */ public final Object firstOf(Object e1, Object e2, Object... rest) { return new FirstOfExpression(convertToExpressions(e1, e2, rest)); }
private ParsingExpression[] convertToExpressions(Object e1, Object e2, Object[] rest) { ParsingExpression[] result = new ParsingExpression[2 + rest.length]; result[0] = convertToExpression(e1); result[1] = convertToExpression(e2); for (int i = 0; i < rest.length; i++) { result[2 + i] = convertToExpression(rest[i]); } return result; }
/** * Creates parsing expression - "sequence". * See {@link #sequence(Object, Object)} for more details. * * @param e1 first sub-expression * @param e2 second sub-expression * @param rest rest of sub-expressions * @throws IllegalArgumentException if any of given arguments is not a parsing expression */ public final Object sequence(Object e1, Object e2, Object... rest) { return new SequenceExpression(convertToExpressions(e1, e2, rest)); }
final ParsingExpression[] convertToExpressions(Object e1, Object[] rest) { ParsingExpression[] result = new ParsingExpression[1 + rest.length]; result[0] = convertToExpression(e1); for (int i = 0; i < rest.length; i++) { result[1 + i] = convertToExpression(rest[i]); } return result; }
/** * Creates parsing expression - "first of". * See {@link #firstOf(Object, Object)} for more details. * * @param e1 first sub-expression * @param e2 second sub-expression * @param rest rest of sub-expressions * @throws IllegalArgumentException if any of given arguments is not a parsing expression */ public final Object firstOf(Object e1, Object e2, Object... rest) { return new FirstOfExpression(convertToExpressions(e1, e2, rest)); }
/** * Creates parsing expression - "sequence". * During execution of this expression parser will sequentially execute all sub-expressions. * This expression succeeds only if all sub-expressions succeed. * * @param e1 first sub-expression * @param e2 second sub-expression * @throws IllegalArgumentException if any of given arguments is not a parsing expression */ public final Object sequence(Object e1, Object e2) { return new SequenceExpression(convertToExpression(e1), convertToExpression(e2)); }
/** * Creates parsing expression - "first of". * See {@link #firstOf(Object, Object)} for more details. * * @param e1 first sub-expression * @param e2 second sub-expression * @param rest rest of sub-expressions * @throws IllegalArgumentException if any of given arguments is not a parsing expression */ public final Object firstOf(Object e1, Object e2, Object... rest) { return new FirstOfExpression(convertToExpressions(Lists.asList(e1, e2, rest))); }
/** * Creates parsing expression - "sequence". * During execution of this expression parser will sequentially execute all sub-expressions. * This expression succeeds only if all sub-expressions succeed. * * @param e1 first sub-expression * @param e2 second sub-expression * @throws IllegalArgumentException if any of given arguments is not a parsing expression */ public final Object sequence(Object e1, Object e2) { return new SequenceExpression(convertToExpression(e1), convertToExpression(e2)); }
/** * Creates parsing expression - "sequence". * See {@link #sequence(Object, Object)} for more details. * * @param e1 first sub-expression * @param e2 second sub-expression * @param rest rest of sub-expressions * @throws IllegalArgumentException if any of given arguments is not a parsing expression */ public final Object sequence(Object e1, Object e2, Object... rest) { return new SequenceExpression(convertToExpressions(Lists.asList(e1, e2, rest))); }
/** * Creates parsing expression - "sequence". * During execution of this expression parser will sequentially execute all sub-expressions. * This expression succeeds only if all sub-expressions succeed. * * @param e1 first sub-expression * @param e2 second sub-expression * @throws IllegalArgumentException if any of given arguments is not a parsing expression */ public final Object sequence(Object e1, Object e2) { return new SequenceExpression(convertToExpression(e1), convertToExpression(e2)); }
@Override public GrammarRuleBuilder override(Object e, Object... rest) { return override(new SequenceExpression(b.convertToExpressions(e, rest))); }
protected final ParsingExpression[] convertToExpressions(List<Object> expressions) { ParsingExpression[] result = new ParsingExpression[expressions.size()]; for (int i = 0; i < expressions.size(); i++) { result[i] = convertToExpression(expressions.get(i)); } return result; }
@Override public GrammarRuleBuilder is(Object e, Object... rest) { return is(new SequenceExpression(b.convertToExpressions(e, rest))); }
/** * Creates parsing expression - "first of". * During the execution of this expression parser execute sub-expressions in order until one succeeds. * This expressions succeeds if any sub-expression succeeds. * <p> * Be aware that in expression {@code firstOf("foo", sequence("foo", "bar"))} second sub-expression will never be executed. * * @param e1 first sub-expression * @param e2 second sub-expression * @throws IllegalArgumentException if any of given arguments is not a parsing expression */ public final Object firstOf(Object e1, Object e2) { return new FirstOfExpression(convertToExpression(e1), convertToExpression(e2)); }
@Override public GrammarRuleBuilder override(Object e, Object... rest) { return override(new SequenceExpression(b.convertToExpressions(e, rest))); }
/** * Creates parsing expression - "first of". * During the execution of this expression parser execute sub-expressions in order until one succeeds. * This expressions succeeds if any sub-expression succeeds. * <p> * Be aware that in expression {@code firstOf("foo", sequence("foo", "bar"))} second sub-expression will never be executed. * * @param e1 first sub-expression * @param e2 second sub-expression * @throws IllegalArgumentException if any of given arguments is not a parsing expression */ public final Object firstOf(Object e1, Object e2) { return new FirstOfExpression(convertToExpression(e1), convertToExpression(e2)); }
@Override public GrammarRuleBuilder is(Object e, Object... rest) { return is(new SequenceExpression(b.convertToExpressions(e, rest))); }