diff --git a/fastparse/src-2/fastparse/package.scala b/fastparse/src-2/fastparse/package.scala index 3b3633dd..1e67aab1 100644 --- a/fastparse/src-2/fastparse/package.scala +++ b/fastparse/src-2/fastparse/package.scala @@ -102,6 +102,12 @@ package object fastparse extends fastparse.SharedPackageDefs { def filter(f: T => Boolean) (implicit ctx: P[Any]): P[T] = macro MacroImpls.filterMacro[T] + /** + * Used by for-comprehensions. + */ + def withFilter(f: T => Boolean) + (implicit ctx: P[Any]): P[T] = macro MacroImpls.filterMacro[T] + /** * Transforms the result of this parser using the given partial function, * failing the parse if the partial function is not defined on the result diff --git a/fastparse/src-3/fastparse/package.scala b/fastparse/src-3/fastparse/package.scala index 638ab909..e4b1aec8 100644 --- a/fastparse/src-3/fastparse/package.scala +++ b/fastparse/src-3/fastparse/package.scala @@ -38,6 +38,11 @@ package object fastparse extends fastparse.SharedPackageDefs { inline def filter(f: T => Boolean)(using ctx: P[Any]): P[T] = MacroInlineImpls.filterInline[T](parse0)(f)(ctx) + /** + * Used by for-comprehensions. + */ + inline def withFilter(f: T => Boolean)(using ctx: P[Any]): P[T] = MacroInlineImpls.filterInline[T](parse0)(f)(ctx) + /** Either-or operator: tries to parse the left-hand-side, and if that * fails it backtracks and tries to pass the right-hand-side. Can be * chained more than once to parse larger numbers of alternatives.