package net.minecraft.util.parsing.packrat; import java.util.Optional; import org.jetbrains.annotations.Nullable; public interface ParseState { Scope scope(); ErrorCollector errorCollector(); default Optional parseTopRule(NamedRule rule) { T object = this.parse(rule); if (object != null) { this.errorCollector().finish(this.mark()); } if (!this.scope().hasOnlySingleFrame()) { throw new IllegalStateException("Malformed scope: " + this.scope()); } else { return Optional.ofNullable(object); } } @Nullable T parse(NamedRule rule); S input(); int mark(); void restore(int cursor); Control acquireControl(); void releaseControl(); ParseState silent(); }