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