alt<E> function

OrderedChoiceExpression<E> alt<E>(
  1. List<Expression<E>> expressions
)

Implementation

OrderedChoiceExpression<E> alt<E>(List<Expression<E>> expressions) {
  final sequences = <SequenceExpression<E>>[];
  for (final expression in expressions) {
    if (expression is SequenceExpression<E>) {
      sequences.add(expression);
    } else {
      final sequence = SequenceFirstResultExpression(expression, const []);
      sequences.add(sequence);
    }
  }

  final orderedChoice = OrderedChoiceExpression<E>();
  orderedChoice.expressions.addAll(sequences);
  return orderedChoice;
}