{"id":20124184,"url":"https://github.com/namorniradnug/simpleparser","last_synced_at":"2026-05-09T21:37:39.962Z","repository":{"id":57467538,"uuid":"418264602","full_name":"NamorNiradnug/SimpleParser","owner":"NamorNiradnug","description":"Simple expressions parser.","archived":false,"fork":false,"pushed_at":"2022-05-17T13:38:00.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-13T09:06:33.131Z","etag":null,"topics":["parser"],"latest_commit_sha":null,"homepage":"","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/NamorNiradnug.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":"2021-10-17T21:54:37.000Z","updated_at":"2022-03-17T01:59:13.000Z","dependencies_parsed_at":"2022-09-19T08:51:11.668Z","dependency_job_id":null,"html_url":"https://github.com/NamorNiradnug/SimpleParser","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/NamorNiradnug%2FSimpleParser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NamorNiradnug%2FSimpleParser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NamorNiradnug%2FSimpleParser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NamorNiradnug%2FSimpleParser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NamorNiradnug","download_url":"https://codeload.github.com/NamorNiradnug/SimpleParser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241570819,"owners_count":19984001,"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"],"created_at":"2024-11-13T19:48:09.145Z","updated_at":"2025-11-28T21:04:55.750Z","avatar_url":"https://github.com/NamorNiradnug.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SimpleParser\nSimple expressions parser.\n\n# Installing\nInstalling via pip:\n```bash\n$ pip install simpleparser\n```\n\n# Usage\n## Parser\nTo simply parse something, use `Parser.parse` method. With `Parser` you can describe different parsers.\nThere is ready-made `Defaults.parser`. \n```python\nfrom simpleparser import Defaults\nexpr = \"a + b / 2\"\nparsed = Defaults.parser.parse(expr)\nparsed(a=2, b=4) # returns 4.0\n```\n`Parser.parse` returns callable `ParsedExpression` object.\n### Custom parsers\n`Parser` can be easily configured. It is described by a set of operators and constants types (such as numbers or booleans).\nSee the `Operator` and `ConstantType` documentation below.\n```python\nfrom simpleparser import Parser, Defaults\nmy_parser = Parser(\n    operators=[Defaults.plus, Defaults.minus, Defaults.mul, Defaults.div], # using some operators from `Defaults` here\n    constants=[Defaults.integers_decimal, Defaults.float_point]\n)\n```\nHere `my_parser` parses simple math expressions with 4 basic operators and decimal numbers, for example `1 + 2.0 * a`.\n## Operator\nCreating a custom operator:\n```python\nfrom simpleparser import Operator, Parser\nin_op = Operator(\n    name=\"in\",\n    operator_type=2,\n    func=lambda el, container: el in container,\n    signs=(\"\\u2208\",),\n    priority=3,\n)\n# creating new parser which uses this operator\nnew_parser = Parser([in_op], [])\nel_in_set_checker = new_parser.parse(\"a in A\")\nel_in_set_checker(a=1, A={1, 2, 3}) # True\nel_in_set_checker(a=0, A={1, 2, 3}) # False\n```\n## ConstantType\nDescribes a type of constants which can be used in expression. Here is the definition of `Defaults.boolean`:\n```python\nfrom simpleparser import ConstantType\nboolean = ConstantType(r\"(True|False|true|false)$\", lambda s: True if s in {\"True\", \"true\"} else False)\n```\nParser with this constant type replaces words which are matched by the `boolean`'s regular expression to `True` or `False`.\n```python\nparser = Parser([],[boolean])\nparser.parse(\"True\")() # True\nparser.parse(\"false\")() # False\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnamorniradnug%2Fsimpleparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnamorniradnug%2Fsimpleparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnamorniradnug%2Fsimpleparser/lists"}