{"id":19517290,"url":"https://github.com/scala/scala-parser-combinators","last_synced_at":"2025-05-13T17:09:50.527Z","repository":{"id":10083260,"uuid":"12140830","full_name":"scala/scala-parser-combinators","owner":"scala","description":"simple combinator-based parsing for Scala. formerly part of the Scala standard library, now a separate community-maintained module","archived":false,"fork":false,"pushed_at":"2025-05-09T14:36:21.000Z","size":1175,"stargazers_count":663,"open_issues_count":24,"forks_count":131,"subscribers_count":32,"default_branch":"main","last_synced_at":"2025-05-09T15:44:23.567Z","etag":null,"topics":["parser-combinators","parsing","scala"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scala.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2013-08-15T18:35:18.000Z","updated_at":"2025-05-09T14:36:25.000Z","dependencies_parsed_at":"2023-02-16T23:31:35.178Z","dependency_job_id":"a3cb0500-6c26-4a82-9bcd-6dbd28eac08f","html_url":"https://github.com/scala/scala-parser-combinators","commit_stats":null,"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scala%2Fscala-parser-combinators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scala%2Fscala-parser-combinators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scala%2Fscala-parser-combinators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scala%2Fscala-parser-combinators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scala","download_url":"https://codeload.github.com/scala/scala-parser-combinators/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253306312,"owners_count":21887560,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["parser-combinators","parsing","scala"],"created_at":"2024-11-11T00:01:29.046Z","updated_at":"2025-05-13T17:09:45.452Z","avatar_url":"https://github.com/scala.png","language":"Scala","readme":"# scala-parser-combinators\n\n[![build](https://github.com/scala/scala-parser-combinators/workflows/test/badge.svg)](https://github.com/scala/scala-parser-combinators/actions/workflows/ci.yml?query=branch%3Amain)\n[\u003cimg src=\"https://img.shields.io/maven-central/v/org.scala-lang.modules/scala-parser-combinators_2.12.svg?label=latest%20release%20for%202.12\"/\u003e](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.scala-lang.modules%20a%3Ascala-parser-combinators_2.12)\n[\u003cimg src=\"https://img.shields.io/maven-central/v/org.scala-lang.modules/scala-parser-combinators_2.13.svg?label=latest%20release%20for%202.13\"/\u003e](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.scala-lang.modules%20a%3Ascala-parser-combinators_2.13)\n[\u003cimg src=\"https://img.shields.io/maven-central/v/org.scala-lang.modules/scala-parser-combinators_3.svg?label=latest%20release%20for%203\"/\u003e](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.scala-lang.modules%20a%3Ascala-parser-combinators_3)\n\nThis was originally part of the Scala standard library, but is now community-maintained, under the guidance of the Scala team at Akka (formerly Lightbend). If you are interested in joining the maintainers team, please contact [@Philippus](https://github.com/philippus) or [@SethTisue](https://github.com/SethTisue).\n\n## Choosing a parsing library\n\nThis library's main strengths are:\n\n* Stability. It's been around and in wide use for more than a decade.\n* The codebase is modest in size and its internals are fairly simple.\n* It's plain vanilla Scala. No macros, code generation, or other magic is involved.\n* Multiple versions of Scala (2.12, 2.13, 3) are supported on all back ends (JVM, JS, Native).\n\nIts main weaknesses are:\n\n* Performance. If you are ingesting large amounts of data, you may want something faster.\n* Minimal feature set.\n* Inflexible, unstructured error reporting.\n\nA number of other parsing libraries for Scala are available -- [see list on Scaladex](https://index.scala-lang.org/awesome/parsing?sort=stars).\n\n## Documentation\n\n * [Current API](https://javadoc.io/page/org.scala-lang.modules/scala-parser-combinators_2.13/latest/scala/util/parsing/combinator/index.html)\n * The [Getting Started](docs/Getting_Started.md) guide\n * A more complicated example, [Building a lexer and parser with Scala's Parser Combinators](https://enear.github.io/2016/03/31/parser-combinators/)\n * \"Combinator Parsing\", chapter 33 of [_Programming in Scala, Third Edition_](http://www.artima.com/shop/programming_in_scala), shows how to apply this library to e.g. parsing of arithmetic expressions. The second half of the chapter examines how the library is implemented.\n\n## Adding an sbt dependency\n\nTo depend on scala-parser-combinators in sbt, add something like this to your build.sbt:\n\n```\nlibraryDependencies += \"org.scala-lang.modules\" %% \"scala-parser-combinators\" % \u003cversion\u003e\n```\n\nTo support multiple Scala versions, see the example in [scala/scala-module-dependency-sample](https://github.com/scala/scala-module-dependency-sample).\n\n### Scala.js and Scala Native\n\nScala-parser-combinators is also available for Scala.js and Scala Native:\n\n```\nlibraryDependencies += \"org.scala-lang.modules\" %%% \"scala-parser-combinators\" % \u003cversion\u003e\n```\n\n## Example\n\n```scala\nimport scala.util.parsing.combinator._\n\ncase class WordFreq(word: String, count: Int) {\n  override def toString = s\"Word \u003c$word\u003e occurs with frequency $count\"\n}\n\nclass SimpleParser extends RegexParsers {\n  def word: Parser[String]   = \"\"\"[a-z]+\"\"\".r       ^^ { _.toString }\n  def number: Parser[Int]    = \"\"\"(0|[1-9]\\d*)\"\"\".r ^^ { _.toInt }\n  def freq: Parser[WordFreq] = word ~ number        ^^ { case wd ~ fr =\u003e WordFreq(wd,fr) }\n}\n\nobject TestSimpleParser extends SimpleParser {\n  def main(args: Array[String]) = {\n    parse(freq, \"johnny 121\") match {\n      case Success(matched,_) =\u003e println(matched)\n      case Failure(msg,_) =\u003e println(s\"FAILURE: $msg\")\n      case Error(msg,_) =\u003e println(s\"ERROR: $msg\")\n    }\n  }\n}\n```\n\nFor a detailed unpacking of this example see\n[Getting Started](docs/Getting_Started.md).\n\n## Contributing\n\n * See the [Scala Developer Guidelines](https://github.com/scala/scala/blob/2.13.x/CONTRIBUTING.md) for general contributing guidelines\n * Have a look at [existing issues](https://github.com/scala/scala-parser-combinators/issues)\n * Ask questions and discuss [in GitHub Discussions](https://github.com/scala/scala-parser-combinators/discussions)\n * Feel free to open draft pull requests with partially completed changes, to get feedback.\n","funding_links":[],"categories":["Table of Contents","Parsing"],"sub_categories":["Parsing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscala%2Fscala-parser-combinators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscala%2Fscala-parser-combinators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscala%2Fscala-parser-combinators/lists"}