{"id":23640074,"url":"https://github.com/gregorybchris/markers","last_synced_at":"2025-11-09T20:30:17.532Z","repository":{"id":269544400,"uuid":"842625063","full_name":"gregorybchris/markers","owner":"gregorybchris","description":"Boolean formula parsing","archived":false,"fork":false,"pushed_at":"2024-12-24T09:38:09.000Z","size":111,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-24T11:08:28.193Z","etag":null,"topics":["binary","boolean","equation","formula","interpreter","parser","parsing","pratt","sat"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gregorybchris.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-08-14T18:20:27.000Z","updated_at":"2024-12-24T09:38:12.000Z","dependencies_parsed_at":"2024-12-24T11:08:39.183Z","dependency_job_id":"77d20376-c5bf-447c-b810-76764c7e55d6","html_url":"https://github.com/gregorybchris/markers","commit_stats":null,"previous_names":["gregorybchris/markers"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregorybchris%2Fmarkers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregorybchris%2Fmarkers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregorybchris%2Fmarkers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregorybchris%2Fmarkers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gregorybchris","download_url":"https://codeload.github.com/gregorybchris/markers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239576799,"owners_count":19662113,"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":["binary","boolean","equation","formula","interpreter","parser","parsing","pratt","sat"],"created_at":"2024-12-28T08:31:37.861Z","updated_at":"2025-11-09T20:30:17.495Z","avatar_url":"https://github.com/gregorybchris.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003eMarkers\u003c/h1\u003e\n\n  \u003cp\u003e\n    \u003cstrong\u003eSimple parser for boolean formulas\u003c/strong\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n## About\n\nMarkers is a parser for boolean formulas. You can provide it an expression like `a and not (b or c)` as well as variable assignments like `a = true, b = false, c = true` and Markers will evaluate `true and not (false or true)` =\u003e `false`.\n\nSupported tokens are variables, `and`, `or`, `not`, and parentheses.\n\nIf you care about the parse tree and not the evaluation on a set of variable assignments you can also use Markers to just parse an expression and emit a recursive Python structure of boolean operators and variables.\n\n## Installation\n\n[Poetry](https://python-poetry.org/) is a requirement\n\n```bash\npoetry install\n```\n\n## CLI usage\n\n### Parsing a boolean formula\n\n```bash\n$ poetry run markers parse \"not a or b\"\n\u003e BinaryOp(\n\u003e     kind=BinaryOpKind.OR,\n\u003e     left=UnaryOp(\n\u003e         kind=UnaryOpKind.NOT,\n\u003e         arg=Var(name='a')\n\u003e     ),\n\u003e     right=Var(name='b')\n\u003e )\n```\n\n### Evaluating a boolean formula with variable assignments\n\n```bash\n$ poetry run markers eval \"not a or b\" -t b -f a\n\u003e True\n```\n\n## Running tests\n\n```bash\npytest tests\n```\n\n## Motivation\n\nI started working on Markers when I realized that [pytest](https://docs.pytest.org) doesn't expose the internals of its [marks](https://docs.pytest.org/en/stable/reference/reference.html#custom-marks) feature to plugins. You can hook into the results of evaluating the boolean formula, but not the unevaluated parse tree. Markers per function or class can be accessed on `TestItem` objects, for example through the `handle_test_completion` hook.\n\nThe name \"Markers\" is a nod to the fact that pytest is inconsistent with its use of \"mark\" and \"marker\".\n\n## Acknowledgements\n\nThis project borrowed heavily from some online resources and human minds about parsing in general and boolean formula parsing in particular.\n\n- [Eoin Davey's Blog](https://vey.ie/2018/10/04/RecursiveDescent.html)\n- [Scrapscript Interpreter](https://github.com/tekknolagi/scrapscript)\n- [Typped Pratt Parsing](https://abarker.github.io/typped/pratt_parsing_intro.html)\n- [Max Bernstein](https://bernsteinbear.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregorybchris%2Fmarkers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgregorybchris%2Fmarkers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregorybchris%2Fmarkers/lists"}