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

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

There is a newer version: 0.6.1
Show newest version
package de.firemage.autograder.treeg.ast;

import de.firemage.autograder.treeg.TreePrinter;

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

public record CharacterClass(boolean negated, List ranges) implements RegExNode {
    @Override
    public String toRegEx() {
        return "[" + (this.negated ? "^" : "") + this.ranges.stream().map(CharacterClassEntry::toRegEx).collect(Collectors.joining()) + "]";
    }

    @Override
    public void toTree(TreePrinter printer) {
        printer.addLine("Character Class" + (this.negated ? " (negated)" : ""));
        printer.indent();
        this.ranges.forEach(r -> r.toTree(printer));
        printer.unindent();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy