/* * Decompiled with CFR 0.152. * * Could not load the following classes: * org.jspecify.annotations.Nullable */ package net.minecraft.util.parsing.packrat; import net.minecraft.util.parsing.packrat.Control; import net.minecraft.util.parsing.packrat.ParseState; import net.minecraft.util.parsing.packrat.Scope; import net.minecraft.util.parsing.packrat.Term; import org.jspecify.annotations.Nullable; public interface Rule { public @Nullable T parse(ParseState var1); public static Rule fromTerm(Term child, RuleAction action) { return new WrappedTerm(action, child); } public static Rule fromTerm(Term child, SimpleRuleAction action) { return new WrappedTerm(action, child); } public record WrappedTerm(RuleAction action, Term child) implements Rule { /* * WARNING - Removed try catching itself - possible behaviour change. */ @Override public @Nullable T parse(ParseState state) { Scope scope = state.scope(); scope.pushFrame(); try { if (this.child.parse(state, scope, Control.UNBOUND)) { T t = this.action.run(state); return t; } T t = null; return t; } finally { scope.popFrame(); } } } @FunctionalInterface public static interface RuleAction { public @Nullable T run(ParseState var1); } @FunctionalInterface public static interface SimpleRuleAction extends RuleAction { public T run(Scope var1); @Override default public T run(ParseState state) { return this.run(state.scope()); } } }