Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions fastparse/src-2/fastparse/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions fastparse/src-3/fastparse/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ 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.
Expand Down