From ed29ad687928db7a7b5236ebf0f33b81b9807a07 Mon Sep 17 00:00:00 2001 From: Jamie Willis Date: Mon, 20 Jan 2025 15:29:07 +0000 Subject: [PATCH] fix: moved ManyUntil.Stop into instructions package --- parsley/shared/src/main/scala/parsley/combinator.scala | 8 ++------ .../internal/machine/instructions/IterativeInstrs.scala | 7 +++++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/parsley/shared/src/main/scala/parsley/combinator.scala b/parsley/shared/src/main/scala/parsley/combinator.scala index 25b452bad..897e74188 100644 --- a/parsley/shared/src/main/scala/parsley/combinator.scala +++ b/parsley/shared/src/main/scala/parsley/combinator.scala @@ -561,16 +561,12 @@ private [parsley] trait combinator { */ final def manyTill[A](p: Parsley[A], end: Parsley[_]): Parsley[List[A]] = manyTill(p, end, List) private [parsley] final def manyTill[A, C](p: Parsley[A], end: Parsley[_], factory: Factory[A, C]): Parsley[C] = { - new Parsley(new frontend.ManyTill((end.as(ManyUntil.Stop).ut() |: p: Parsley[Any]).internal, factory)) + new Parsley(new frontend.ManyTill((end.as(parsley.internal.machine.instructions.ManyUntil.Stop).ut() |: p: Parsley[Any]).internal, factory)) } // TODO: find a way to make this redundant private [parsley] final def skipManyUntil(p: Parsley[_], end: Parsley[_]): Parsley[Unit] = { - new Parsley(new frontend.SkipManyUntil((end.as(ManyUntil.Stop).ut() |: p.void.ut(): Parsley[Any]).internal)) - } - - private [parsley] object ManyUntil { - object Stop + new Parsley(new frontend.SkipManyUntil((end.as(parsley.internal.machine.instructions.ManyUntil.Stop).ut() |: p.void.ut(): Parsley[Any]).internal)) } /** This combinator repeatedly parses a given parser '''one''' or more times, until the `end` parser succeeds, collecting the results into a list. diff --git a/parsley/shared/src/main/scala/parsley/internal/machine/instructions/IterativeInstrs.scala b/parsley/shared/src/main/scala/parsley/internal/machine/instructions/IterativeInstrs.scala index 412ef10c2..537bc3c99 100644 --- a/parsley/shared/src/main/scala/parsley/internal/machine/instructions/IterativeInstrs.scala +++ b/parsley/shared/src/main/scala/parsley/internal/machine/instructions/IterativeInstrs.scala @@ -217,7 +217,7 @@ private [internal] final class ManyUntil(var label: Int) extends InstrWithLabel override def apply(ctx: Context): Unit = { ensureRegularInstruction(ctx) ctx.stack.upop() match { - case parsley.combinator.ManyUntil.Stop => ctx.exchangeAndContinue(ctx.stack.peek[mutable.Builder[Any, Any]].result()) + case ManyUntil.Stop => ctx.exchangeAndContinue(ctx.stack.peek[mutable.Builder[Any, Any]].result()) case x => ctx.stack.peek[mutable.Builder[Any, Any]] += x ctx.pc = label @@ -227,12 +227,15 @@ private [internal] final class ManyUntil(var label: Int) extends InstrWithLabel override def toString: String = s"ManyUntil($label)" // $COVERAGE-ON$ } +private [parsley] object ManyUntil { + object Stop +} private [internal] final class SkipManyUntil(var label: Int) extends InstrWithLabel { override def apply(ctx: Context): Unit = { ensureRegularInstruction(ctx) ctx.stack.upop() match { - case parsley.combinator.ManyUntil.Stop => ctx.inc() + case ManyUntil.Stop => ctx.inc() case _ => ctx.pc = label } }