All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.firemage.autograder.treeg.ast.Alternative Maven / Gradle / Ivy

package de.firemage.autograder.treeg.ast;

import de.firemage.autograder.treeg.TreePrinter;

import java.util.List;
import java.util.stream.Collectors;

public record Alternative(List alternatives) implements RegExNode {
    @Override
    public String toRegEx() {
        return this.alternatives.stream().map(RegExNode::toRegEx).collect(Collectors.joining("|"));
    }

    @Override
    public void toTree(TreePrinter printer) {
        printer.addLine("Alternatives");
        printer.indent();
        this.alternatives.forEach(a -> a.toTree(printer));
        printer.unindent();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy