{"id":13415973,"url":"https://github.com/vlasovskikh/funcparserlib","last_synced_at":"2025-10-21T20:53:04.402Z","repository":{"id":30919586,"uuid":"34477477","full_name":"vlasovskikh/funcparserlib","owner":"vlasovskikh","description":"Recursive descent parsing library for Python based on functional combinators","archived":false,"fork":false,"pushed_at":"2024-05-04T09:31:43.000Z","size":2180,"stargazers_count":355,"open_issues_count":11,"forks_count":38,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-10-17T10:44:44.565Z","etag":null,"topics":["functional-programming","parser-combinators","parsing","python"],"latest_commit_sha":null,"homepage":"https://funcparserlib.pirx.ru","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vlasovskikh.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-04-23T19:38:11.000Z","updated_at":"2025-08-21T14:50:53.000Z","dependencies_parsed_at":"2023-11-19T00:26:10.129Z","dependency_job_id":"33aac836-5217-4b91-9d74-c16289a0c53c","html_url":"https://github.com/vlasovskikh/funcparserlib","commit_stats":{"total_commits":266,"total_committers":10,"mean_commits":26.6,"dds":"0.33458646616541354","last_synced_commit":"18c0a99dcdb427e35226c74b7cc2617223c8e1fa"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/vlasovskikh/funcparserlib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vlasovskikh%2Ffuncparserlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vlasovskikh%2Ffuncparserlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vlasovskikh%2Ffuncparserlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vlasovskikh%2Ffuncparserlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vlasovskikh","download_url":"https://codeload.github.com/vlasovskikh/funcparserlib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vlasovskikh%2Ffuncparserlib/sbom","scorecard":{"id":925503,"data":{"date":"2025-08-04","repo":{"name":"github.com/vlasovskikh/funcparserlib","commit":"18c0a99dcdb427e35226c74b7cc2617223c8e1fa"},"scorecard":{"version":"v5.2.1-28-gc1d103a9","commit":"c1d103a9bb9f635ec7260bf9aa0699466fa4be0e"},"score":2.5,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/10 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/gh-pages.yml:1","Warn: no topLevel permission defined: .github/workflows/publish-to-pypi.yml:1","Warn: no topLevel permission defined: .github/workflows/python-checks.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/gh-pages.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/vlasovskikh/funcparserlib/gh-pages.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/gh-pages.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/vlasovskikh/funcparserlib/gh-pages.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/gh-pages.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/vlasovskikh/funcparserlib/gh-pages.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish-to-pypi.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/vlasovskikh/funcparserlib/publish-to-pypi.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish-to-pypi.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/vlasovskikh/funcparserlib/publish-to-pypi.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/publish-to-pypi.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/vlasovskikh/funcparserlib/publish-to-pypi.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-checks.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/vlasovskikh/funcparserlib/python-checks.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-checks.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/vlasovskikh/funcparserlib/python-checks.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/python-checks.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/vlasovskikh/funcparserlib/python-checks.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/gh-pages.yml:19","Warn: pipCommand not pinned by hash: .github/workflows/gh-pages.yml:20","Warn: pipCommand not pinned by hash: .github/workflows/publish-to-pypi.yml:19","Warn: pipCommand not pinned by hash: .github/workflows/publish-to-pypi.yml:20","Warn: pipCommand not pinned by hash: .github/workflows/python-checks.yml:30","Warn: pipCommand not pinned by hash: .github/workflows/python-checks.yml:31","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   3 third-party GitHubAction dependencies pinned","Info:   0 out of   6 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#license"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#packaging"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 21 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"15 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2024-230 / GHSA-248v-346w-9cwc","Warn: Project is vulnerable to: PYSEC-2024-60 / GHSA-jjg7-2v4v-x38h","Warn: Project is vulnerable to: GHSA-cpwx-vrp4-4pq7","Warn: Project is vulnerable to: GHSA-gmj6-6f8f-6699","Warn: Project is vulnerable to: GHSA-h5c8-rqwp-cp95","Warn: Project is vulnerable to: GHSA-h75v-3vvj-5mfj","Warn: Project is vulnerable to: GHSA-q2x7-8rv6-6q7h","Warn: Project is vulnerable to: GHSA-9hjg-9r4m-mvj7","Warn: Project is vulnerable to: GHSA-9wx4-h78v-vm56","Warn: Project is vulnerable to: PYSEC-2025-49 / GHSA-5rjg-fvgr-3xxf","Warn: Project is vulnerable to: GHSA-cx63-2mw6-8hw5","Warn: Project is vulnerable to: GHSA-34jh-p97f-mpxf","Warn: Project is vulnerable to: GHSA-pq67-6m6q-mj2v","Warn: Project is vulnerable to: PYSEC-2024-187 / GHSA-rqc4-2hc7-8c8v","Warn: Project is vulnerable to: GHSA-jfmj-5v4g-7637"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-25T11:38:36.316Z","repository_id":30919586,"created_at":"2025-08-25T11:38:36.316Z","updated_at":"2025-08-25T11:38:36.316Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280333492,"owners_count":26312845,"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","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["functional-programming","parser-combinators","parsing","python"],"created_at":"2024-07-30T21:00:53.396Z","updated_at":"2025-10-21T20:53:04.372Z","avatar_url":"https://github.com/vlasovskikh.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"Funcparserlib\n=============\n\nRecursive descent parsing library for Python based on functional combinators.\n\n[![PyPI](https://img.shields.io/pypi/v/funcparserlib)](https://pypi.org/project/funcparserlib/)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/funcparserlib)](https://pypi.org/project/funcparserlib/)\n\n\nDescription\n-----------\n\nThe primary focus of `funcparserlib` is **parsing little languages** or **external DSLs** (domain specific languages).\n\nParsers made with `funcparserlib` are pure-Python LL(\\*) parsers. It means that it's **very easy to write parsers** without thinking about lookaheads and other hardcore parsing stuff. However, recursive descent parsing is a rather slow method compared to LL(k) or LR(k) algorithms. Still, parsing with `funcparserlib` is **at least twice faster than PyParsing**, a very popular library for Python.\n\nThe source code of `funcparserlib` is only 1.2K lines of code, with lots of comments. Its API is fully type hinted. It features the longest parsed prefix error reporting, as well as a tiny lexer generator for token position tracking.\n\nThe idea of parser combinators used in `funcparserlib` comes from the [Introduction to Functional Programming](https://www.cl.cam.ac.uk/teaching/Lectures/funprog-jrh-1996/) course. We have converted it from ML into Python.\n\n\nInstallation\n------------\n\nYou can install `funcparserlib` from [PyPI](https://pypi.org/project/funcparserlib/):\n\n```shell\n$ pip install funcparserlib\n```\n\nThere are no dependencies on other libraries.\n\n\nDocumentation\n-------------\n\n* [Getting Started](https://funcparserlib.pirx.ru/getting-started/)\n    * Your **starting point** with `funcparserlib`\n* [API Reference](https://funcparserlib.pirx.ru/api/)\n    * Learn the details of the API\n\nThere are several examples available in the `tests/` directory:\n\n* [GraphViz DOT parser](https://github.com/vlasovskikh/funcparserlib/blob/master/tests/dot.py)\n* [JSON parser](https://github.com/vlasovskikh/funcparserlib/blob/master/tests/json.py)\n\nSee also [the changelog](https://funcparserlib.pirx.ru/changes/).\n\n\nExample\n-------\n\nLet's consider a little language of **numeric expressions** with a syntax similar to Python expressions. Here are some expression strings in this language:\n\n```\n0\n1 + 2 + 3\n-1 + 2 ** 32\n3.1415926 * (2 + 7.18281828e-1) * 42\n```\n\n\nHere is **the complete source code** of the tokenizer and the parser for this language written using `funcparserlib`:\n\n```python\nfrom typing import List, Tuple, Union\nfrom dataclasses import dataclass\n\nfrom funcparserlib.lexer import make_tokenizer, TokenSpec, Token\nfrom funcparserlib.parser import tok, Parser, many, forward_decl, finished\n\n\n@dataclass\nclass BinaryExpr:\n    op: str\n    left: \"Expr\"\n    right: \"Expr\"\n\n\nExpr = Union[BinaryExpr, int, float]\n\n\ndef tokenize(s: str) -\u003e List[Token]:\n    specs = [\n        TokenSpec(\"whitespace\", r\"\\s+\"),\n        TokenSpec(\"float\", r\"[+\\-]?\\d+\\.\\d*([Ee][+\\-]?\\d+)*\"),\n        TokenSpec(\"int\", r\"[+\\-]?\\d+\"),\n        TokenSpec(\"op\", r\"(\\*\\*)|[+\\-*/()]\"),\n    ]\n    tokenizer = make_tokenizer(specs)\n    return [t for t in tokenizer(s) if t.type != \"whitespace\"]\n\n\ndef parse(tokens: List[Token]) -\u003e Expr:\n    int_num = tok(\"int\") \u003e\u003e int\n    float_num = tok(\"float\") \u003e\u003e float\n    number = int_num | float_num\n\n    expr: Parser[Token, Expr] = forward_decl()\n    parenthesized = -op(\"(\") + expr + -op(\")\")\n    primary = number | parenthesized\n    power = primary + many(op(\"**\") + primary) \u003e\u003e to_expr\n    term = power + many((op(\"*\") | op(\"/\")) + power) \u003e\u003e to_expr\n    sum = term + many((op(\"+\") | op(\"-\")) + term) \u003e\u003e to_expr\n    expr.define(sum)\n\n    document = expr + -finished\n\n    return document.parse(tokens)\n\n\ndef op(name: str) -\u003e Parser[Token, str]:\n    return tok(\"op\", name)\n\n\ndef to_expr(args: Tuple[Expr, List[Tuple[str, Expr]]]) -\u003e Expr:\n    first, rest = args\n    result = first\n    for op, expr in rest:\n        result = BinaryExpr(op, result, expr)\n    return result\n```\n\nNow, consider this numeric expression: `3.1415926 * (2 + 7.18281828e-1) * 42`.\n\nLet's `tokenize()` it using the tokenizer we've created with `funcparserlib.lexer`:\n\n```\n[\n    Token('float', '3.1415926'),\n    Token('op', '*'),\n    Token('op', '('),\n    Token('int', '2'),\n    Token('op', '+'),\n    Token('float', '7.18281828e-1'),\n    Token('op', ')'),\n    Token('op', '*'),\n    Token('int', '42'),\n]\n```\n\nLet's `parse()` these tokens into an expression tree using our parser created with `funcparserlib.parser`:\n\n```\nBinaryExpr(\n    op='*',\n    left=BinaryExpr(\n        op='*',\n        left=3.1415926,\n        right=BinaryExpr(op='+', left=2, right=0.718281828),\n    ),\n    right=42,\n)\n```\n\nLearn how to write this parser using `funcparserlib` in the [Getting Started](https://funcparserlib.pirx.ru/getting-started/) guide!\n\n\nUsed By\n-------\n\nSome open-source projects that use `funcparserlib` as an explicit dependency:\n\n* [Hy](https://github.com/hylang/hy), a Lisp dialect that's embedded in Python\n    * 4.7K stars, version `~=1.0`, Python 3.8+\n* [Splash](https://github.com/scrapinghub/splash), a JavaScript rendering service with HTTP API, by Scrapinghub\n    * 3.9K stars, version `*`. Python 3 in Docker\n* [graphite-beacon](https://github.com/klen/graphite-beacon), a simple alerting system for Graphite metrics\n    * 453 stars, version `==0.3.6`, Python 2 and 3\n* [blockdiag](https://github.com/blockdiag/blockdiag), generates block-diagram image file from spec-text file\n    * 194 stars, version `\u003e= 1.0.0a0`, Python 3.7+\n* [kll](https://github.com/kiibohd/kll), Keyboard Layout Language (KLL) compiler\n    * 113 stars, copied source code, Python 3.5+\n\n\nNext\n----\n\nRead the [Getting Started](https://funcparserlib.pirx.ru/getting-started/) guide to start learning `funcparserlib`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvlasovskikh%2Ffuncparserlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvlasovskikh%2Ffuncparserlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvlasovskikh%2Ffuncparserlib/lists"}