{"id":13993821,"url":"https://github.com/robotpy/cxxheaderparser","last_synced_at":"2025-04-02T15:06:24.696Z","repository":{"id":45182954,"uuid":"324958910","full_name":"robotpy/cxxheaderparser","owner":"robotpy","description":"Modern pure python C++ header parser","archived":false,"fork":false,"pushed_at":"2024-09-28T23:11:32.000Z","size":383,"stargazers_count":96,"open_issues_count":10,"forks_count":19,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-09-28T23:18:23.975Z","etag":null,"topics":["cplusplus","cpp-parser","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/robotpy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2020-12-28T08:44:44.000Z","updated_at":"2024-09-28T23:10:55.000Z","dependencies_parsed_at":"2023-09-25T05:08:19.270Z","dependency_job_id":"6b9ffd16-61ad-4fff-987a-2e0fe6706f57","html_url":"https://github.com/robotpy/cxxheaderparser","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotpy%2Fcxxheaderparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotpy%2Fcxxheaderparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotpy%2Fcxxheaderparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotpy%2Fcxxheaderparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robotpy","download_url":"https://codeload.github.com/robotpy/cxxheaderparser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246811278,"owners_count":20837748,"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":["cplusplus","cpp-parser","python"],"created_at":"2024-08-09T14:02:34.364Z","updated_at":"2025-04-02T15:06:24.677Z","avatar_url":"https://github.com/robotpy.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"cxxheaderparser\n===============\n\nA pure python C++ header parser that parses C++ headers in a mildly naive\nmanner that allows it to handle many C++ constructs, including many modern\n(C++11 and beyond) features.\n\nThis is a complete rewrite of the `CppHeaderParser` library. `CppHeaderParser`\nis really useful for some tasks, but it's implementation is a truly terrible\nugly hack built on top of other terrible hacks. This rewrite tries to learn\nfrom `CppHeaderParser` and leave its ugly baggage behind.\n\nGoals:\n\n* Parse syntatically valid C++ and provide a useful (and documented!) pure\n  python API to work with the parsed data\n* Process incomplete headers (doesn't need to process includes)\n* Provide enough information for binding generators to wrap C++ code\n* Handle common C++ features, but it may struggle with obscure or overly\n  complex things (feel free to make a PR to fix it!)\n\nNon-goals:\n\n* **Does not produce a full AST**, use Clang if you need that\n* **Not intended to validate C++**, which means this will not reject all\n  invalid C++ headers! Use a compiler if you need that\n* **Parser requires a C++ preprocessor**. If you are parsing\n  headers that contain macros, you should preprocess your code using the\n  excellent pure python preprocessor [pcpp](https://github.com/ned14/pcpp)\n  or your favorite compiler\n  * We have implemented support for PCPP, GCC, and MSVC -- but it is not enabled\n    by default. See the `cxxheaderparser.preprocessor` module for how to enable it.\n* Probably won't be able to parse most IOCCC entries\n\nThere are two APIs available:\n\n* A visitor-style interface to build up your own custom data structures \n* A simple visitor that stores everything in a giant data structure\n\nLive Demo\n---------\n\nA pyodide-powered interactive demo is at https://robotpy.github.io/cxxheaderparser/\n\nDocumentation\n-------------\n\nDocumentation can be found at https://cxxheaderparser.readthedocs.io\n\nInstall\n-------\n\nRequires Python 3.6+, no non-stdlib dependencies if using Python 3.7+.\n\n```\npip install cxxheaderparser\n```\n\nUsage\n-----\n\nTo see a dump of the data parsed from a header:\n\n```\n# pprint format\npython -m cxxheaderparser myheader.h\n\n# JSON format\npython -m cxxheaderparser --mode=json myheader.h\n\n# dataclasses repr format\npython -m cxxheaderparser --mode=repr myheader.h\n\n# dataclasses repr format (formatted with black)\npython -m cxxheaderparser --mode=brepr myheader.h\n```\n\nSee the documentation for anything more complex.\n\nBugs\n----\n\nThis should handle even complex C++ code with few problems, but there are\nalmost certainly weird edge cases that it doesn't handle. Additionally,\nnot all C++17/20 constructs are supported yet (but contributions welcome!).\n\nIf you find an bug, we encourage you to submit a pull request! New\nchanges will only be accepted if there are tests to cover the change you\nmade (and if they don’t break existing tests).\n\nAuthor\n------\n\ncxxheaderparser was created by Dustin Spicuzza\n\nCredit\n------\n\n* Partially derived from and inspired by the `CppHeaderParser` project\n  originally developed by Jashua Cloutier\n* An embedded version of PLY is used for lexing tokens\n* Portions of the lexer grammar and other ideas were derived from pycparser\n* The source code is liberally sprinkled with comments containing C++ parsing\n  grammar mostly derived from the [Hyperlinked C++ BNF Grammar](https://www.nongnu.org/hcb/)\n* cppreference.com has been invaluable for understanding many of the weird\n  quirks of C++, and some of the unit tests use examples from there\n* [Compiler Explorer](godbolt.org) has been invaluable for validating my \n  understanding of C++ by allowing me to quickly type in quirky C++\n  constructs to see if they actually compile\n\nLicense\n-------\n\nBSD License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobotpy%2Fcxxheaderparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobotpy%2Fcxxheaderparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobotpy%2Fcxxheaderparser/lists"}