Skip to content

Added pattern matching

Compare
Choose a tag to compare
@BenchR267 BenchR267 released this 21 Sep 20:33
· 55 commits to master since this release
e2d56ac

This release adds support for using Parsers with Swifts internal pattern matching (switch - case). That means you can write something like

switch "a" {
    case L.char: print("it's a char :)")
    case L.digit: print("it's a digit!")
    default: print("it's something unexpected :/")
}

It will try to parse the value ("a" in the example) with each parser and checks as well if the rest is empty. So only if the complete input matches, the case matches.