An open API service indexing awesome lists of open source software.

https://github.com/zio/zio-parser


https://github.com/zio/zio-parser

Last synced: 6 months ago
JSON representation

Awesome Lists containing this project

README

          

[//]: # (This file was autogenerated using `zio-sbt-website` plugin via `sbt generateReadme` command.)
[//]: # (So please do not edit it manually. Instead, change "docs/index.md" file or sbt setting keys)
[//]: # (e.g. "readmeDocumentation" and "readmeSupport".)

# ZIO Parser

Library for constructing parsers and pretty printers based on invertible syntax descriptions

[![Development](https://img.shields.io/badge/Project%20Stage-Development-green.svg)](https://github.com/zio/zio/wiki/Project-Stages) ![CI Badge](https://github.com/zio/zio-parser/workflows/CI/badge.svg) [![Sonatype Releases](https://img.shields.io/nexus/r/https/oss.sonatype.org/dev.zio/zio-parser_3.svg?label=Sonatype%20Release)](https://oss.sonatype.org/content/repositories/releases/dev/zio/zio-parser_3/) [![Sonatype Snapshots](https://img.shields.io/nexus/s/https/oss.sonatype.org/dev.zio/zio-parser_3.svg?label=Sonatype%20Snapshot)](https://oss.sonatype.org/content/repositories/snapshots/dev/zio/zio-parser_3/) [![javadoc](https://javadoc.io/badge2/dev.zio/zio-parser-docs_3/javadoc.svg)](https://javadoc.io/doc/dev.zio/zio-parser-docs_3) [![ZIO Parser](https://img.shields.io/github/stars/zio/zio-parser?style=social)](https://github.com/zio/zio-parser)

## Introduction

[![Zymposium - ZIO Parser](https://i.ytimg.com/vi/DEPpL9LBiyA/maxresdefault.jpg)](https://www.youtube.com/watch?v=DEPpL9LBiyA)

## Installation

Start by adding `zio-parser` as a dependency to your project:

```scala
libraryDependencies += "dev.zio" %% "zio-parser" % "0.1.9"
```

## Getting Started

```scala
import zio.parser.*
```

Declare your parsing syntax:

```scala
val digitSyntax: Syntax[String, Char, Char, Char] = Syntax.digit
```

Parse your string:

```scala
val result: Either[StringParserError[String], Char] = digitSyntax.parseString("1")
// result: Either[StringParserError[String], Char] = Right(value = '1')
```

Pretty print the parsing errors:

```scala
println(digitSyntax.parseString("Hello").left.map(_.pretty).merge)
// Hello
// ^
// error: Failure at position 0: not a digit
//
```

[//]: # (TODO: Add example section)
[//]: # (## Example)

## Documentation

Learn more on the [ZIO Parser homepage](https://zio.dev/zio-parser/)!

## Contributing

For the general guidelines, see ZIO [contributor's guide](https://zio.dev/about/contributing).

## Code of Conduct

See the [Code of Conduct](https://zio.dev/about/code-of-conduct)

## Support

Come chat with us on [![Badge-Discord]][Link-Discord].

[Badge-Discord]: https://img.shields.io/discord/629491597070827530?logo=discord "chat on discord"
[Link-Discord]: https://discord.gg/2ccFBr4 "Discord"

## License

[License](LICENSE)