Library for constructing parsers and pretty printers based on invertible syntax descriptions
Start by adding zio-parser
as a dependency to your project:
libraryDependencies += "dev.zio" %% "zio-parser" % "0.1.9"
import zio.parser.*
Declare your parsing syntax:
val digitSyntax: Syntax[String, Char, Char, Char] = Syntax.digit
Parse your string:
val result: Either[StringParserError[String], Char] = digitSyntax.parseString("1")
// result: Either[StringParserError[String], Char] = Right(value = '1')
Pretty print the parsing errors:
println(digitSyntax.parseString("Hello").left.map(_.pretty).merge)
// Hello
// ^
// error: Failure at position 0: not a digit
//
Learn more on the ZIO Parser homepage!
For the general guidelines, see ZIO contributor's guide.
See the Code of Conduct