Added pattern matching
This release adds support for using Parser
s 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.