Skip to content

Commit

Permalink
Parser: Don't skipWhitespace. Then ML works
Browse files Browse the repository at this point in the history
  • Loading branch information
marzipankaiser committed Oct 20, 2023
1 parent d0d5c01 commit 46e89cf
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions examples/casestudies/parser.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ The parsing algorithm is simply implemented as a handler for `Parser`.

```
def parse[R](input: String) { p: => R / Parser }: ParseResult[R] = try {
lexer(input) { skipWhitespace { Success(p()) } }
lexer(input) { Success(p()) }
} with Nondet {
def alt() = resume(true) match {
case Failure(msg) => resume(false)
Expand All @@ -242,12 +242,11 @@ Having implemented a handler for the `Parser` effect, we can run our example "gr
def println(p: ParseResult[Int]): Unit = println(showPR(p){ x => show(x) })
def println(p: ParseResult[Tree]): Unit = println(showPR(p){ x => show(x) })
def main() = {
// println(parse("42") { parseCalls() })
// println(parse("foo(1)") { parseCalls() })
// println(parse("foo(1, 2)") { parseCalls() })
// println(parse("foo(1, 2, 3, 4)") { parseCalls() })
// println(parse("foo(1, 2, bar(4, 5))") { parseCalls() })
// println(parse("foo(1, 2,\nbar(4, 5))") { parseCalls() })
println(parse("42") { parseCalls() })
println(parse("foo(1)") { parseCalls() })
println(parse("foo(1,2)") { parseCalls() })
println(parse("foo(1,2,3,4)") { parseCalls() })
println(parse("foo(1,2,bar(4,5))") { parseCalls() })
println(parse("}42") { parseExpr() })
println(parse("42") { parseExpr() })
Expand Down

0 comments on commit 46e89cf

Please sign in to comment.