Skip to content

Commit

Permalink
doc: simplify debug cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mie6 committed Jan 3, 2025
1 parent 915bd14 commit c51d10c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docs/parsley-debug/recursion-detection.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import parsley.debug.combinator.detectDivergence

@debuggable
object parsers {
lazy val top: Parsley[Unit] = p.void // simplifies the cycle, see #247
lazy val p: Parsley[Unit] = char('a').void | s ~> q
lazy val q: Parsley[Unit] = sepBy1(r, string(",")).void
lazy val r: Parsley[Unit] = many(p).void
Expand All @@ -36,10 +37,10 @@ object parsers {
parsley.debug.util.Collector.registerNames(Map(parsers.p -> "p", parsers.q -> "q", parsers.r -> "r"))
```

While `parsers.p.parse("a")` would work fine, consider what happens if we pass the empty string:
While `parsers.top.parse("a")` would work fine, consider what happens if we pass the empty string:

```scala mdoc:crash
detectDivergence(parsers.p).parse("")
detectDivergence(parsers.top).parse("")
```

Thankfully, the `detectDivergence` combinator can detect that this will cause an issue, and provides
Expand Down

0 comments on commit c51d10c

Please sign in to comment.