{"id":13415863,"url":"https://github.com/prataprc/goparsec","last_synced_at":"2025-04-05T19:14:41.953Z","repository":{"id":13165455,"uuid":"15848402","full_name":"prataprc/goparsec","owner":"prataprc","description":"Parser combinator in Go. If there are any cross platform issues or backward compatibility issues, please reach out.","archived":false,"fork":false,"pushed_at":"2021-12-19T14:25:20.000Z","size":1512,"stargazers_count":279,"open_issues_count":12,"forks_count":23,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-07-31T21:54:44.944Z","etag":null,"topics":["golang","parsec","parser","parser-combinators","parsercombinator"],"latest_commit_sha":null,"homepage":"http://prataprc.github.io/astquery.io","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prataprc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-12T18:55:06.000Z","updated_at":"2024-07-30T15:04:45.000Z","dependencies_parsed_at":"2022-08-25T15:01:57.035Z","dependency_job_id":null,"html_url":"https://github.com/prataprc/goparsec","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prataprc%2Fgoparsec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prataprc%2Fgoparsec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prataprc%2Fgoparsec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prataprc%2Fgoparsec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prataprc","download_url":"https://codeload.github.com/prataprc/goparsec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247386266,"owners_count":20930619,"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":["golang","parsec","parser","parser-combinators","parsercombinator"],"created_at":"2024-07-30T21:00:52.615Z","updated_at":"2025-04-05T19:14:41.919Z","avatar_url":"https://github.com/prataprc.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"Parser combinator library in Golang\n===================================\n\n[![Build Status](https://travis-ci.org/prataprc/goparsec.svg?branch=master)](https://travis-ci.org/prataprc/goparsec)\n[![Coverage Status](https://coveralls.io/repos/github/prataprc/goparsec/badge.svg?branch=master)](https://coveralls.io/github/prataprc/goparsec?branch=master)\n[![GoDoc](https://godoc.org/github.com/prataprc/goparsec?status.png)](https://godoc.org/github.com/prataprc/goparsec)\n[![Sourcegraph](https://sourcegraph.com/github.com/prataprc/goparsec/-/badge.svg)](https://sourcegraph.com/github.com/prataprc/goparsec?badge)\n[![Go Report Card](https://goreportcard.com/badge/github.com/prataprc/goparsec)](https://goreportcard.com/report/github.com/prataprc/goparsec)\n\nA library to construct top-down recursive backtracking parsers using\nparser-combinators. Before proceeding you might want to take at peep\nat [theory of parser combinators][theory-link]. As for this package, it\nprovides:\n\n* A standard set of combinators.\n* [Regular expression][regexp-link] based simple-scanner.\n* Standard set of tokenizers based on the simple-scanner.\n\nTo construct syntax-trees based on detailed grammar try with\n[AST struct][ast-link]\n\n* Standard set of combinators are exported as methods to AST.\n* Generate dot-graph EG: [dotfile](testdata/simple.dot)\n  for [html](testdata/simple.html).\n* Pretty print on the console.\n* Make debugging easier.\n\n**NOTE that AST object is a recent development and expect user to adapt to\nnewer versions**\n\nQuick links\n-----------\n\n* [Go documentation][goparsec-godoc-link].\n* [Using the builtin scanner](#using-the-builtin-scanner).\n* [Simple HTML parser][htmlparsec-link].\n* [Querying Abstract Syntax Tree][astquery-link]\n* [Projects using goparsec](#projects-using-goparsec).\n* [Articles](#articles).\n* [How to contribute](#how-to-contribute).\n\nCombinators\n-----------\n\nEvery combinator should confirm to the following signature,\n\n```go\n    // ParsecNode type defines a node in the AST\n    type ParsecNode interface{}\n\n    // Parser function parses input text, higher order parsers are\n    // constructed using combinators.\n    type Parser func(Scanner) (ParsecNode, Scanner)\n\n    // Nodify callback function to construct custom ParsecNode.\n    type Nodify func([]ParsecNode) ParsecNode\n```\n\nCombinators take a variable number of parser functions and\nreturn a new parser function.\n\nUsing the builtin scanner\n-------------------------\n\nBuiltin scanner library manages the input buffer and implements a cursor\ninto the buffer. Create a new scanner instance,\n\n```go\n    s := parsec.NewScanner(text)\n```\n\nThe scanner library supplies method like ``Match(pattern)``,\n``SkipAny(pattern)`` and ``Endof()``, [refer][goparsec-godoc-link] to for\nmore information on each of these methods.\n\nPanics and Recovery\n-------------------\n\nPanics are to be expected when APIs are misused. Programmers might choose\nto ignore errors, but not panics. For example:\n\n* Kleene and Many combinators take one or two parsers as arguments. Less than\n  one or more than two will throw a panic.\n* ManyUntil combinator take two or three parsers as arguments. Less than two\n  or more than three will throw a panic.\n* Combinators accept Parser function or pointer to Parser function. Anything\n  else will panic.\n* When using invalid regular expression to match a token.\n\n\nExamples\n--------\n\n* expr/expr.go, implements a parsec grammar to parse arithmetic expressions.\n* json/json.go, implements a parsec grammar to parse JSON document.\n\nClone the repository run the benchmark suite\n\n```bash\n    $ cd expr/\n    $ go test -test.bench=. -test.benchmem=true\n    $ cd json/\n    $ go test -test.bench=. -test.benchmem=true\n```\n\nTo run the example program,\n\n```bash\n    # to parse expression\n    $ go run tools/parsec/parsec.go -expr \"10 + 29\"\n\n    # to parse JSON string\n    $ go run tools/parsec/parsec.go -json '{ \"key1\" : [10, \"hello\", true, null, false] }'\n```\n\nProjects using goparsec\n-----------------------\n\n* [Monster](https://github.com/prataprc/monster), production system in golang.\n* [GoLedger](https://github.com/tn47/goledger), ledger re-write in golang.\n\nIf your project is using goparsec you can raise an issue to list them under\nthis section.\n\nArticles\n--------\n\n* [Parsing by composing functions][article1-link]\n* [Parser composition for recursive grammar][article2-link]\n* [How to use the ``Maybe`` combinator][article3-link]\n\nHow to contribute\n-----------------\n\n[![Issue Stats](http://issuestats.com/github/prataprc/goparsec/badge/pr)](http://issuestats.com/github/prataprc/goparsec)\n[![Issue Stats](http://issuestats.com/github/prataprc/goparsec/badge/issue)](http://issuestats.com/github/prataprc/goparsec)\n\n* Pick an issue, or create an new issue. Provide adequate documentation for\n  the issue.\n* Assign the issue or get it assigned.\n* Work on the code, once finished, raise a pull request.\n* Goparsec is written in [golang](https://golang.org/), hence expected to\n  follow the global guidelines for writing go programs.\n* If the changeset is more than few lines, please generate a\n  [report card][report-link].\n* As of now, branch ``master`` is the development branch.\n\n[theory-link]: http://en.wikipedia.org/wiki/Parser_combinator\n[regexp-link]: https://golang.org/pkg/regexp\n[ast-link]: http://godoc.org/github.com/prataprc/goparsec#AST\n[goparsec-godoc-link]: http://godoc.org/github.com/prataprc/goparsec\n[htmlparsec-link]: https://github.com/prataprc/goparsec/blob/master/html_test.go\n[astquery-link]: https://prataprc.github.io/astquery.io\n[article1-link]: http://prataprc.github.io/parser-combinator-composition.html\n[article2-link]: http://prataprc.github.io/parser-combinator-recursive.html\n[article3-link]: http://prataprc.github.io/parser-combinator-maybe.html\n[report-link]: https://goreportcard.com/report/github.com/prataprc/goparsec\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprataprc%2Fgoparsec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprataprc%2Fgoparsec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprataprc%2Fgoparsec/lists"}