{"id":21725871,"url":"https://github.com/hpb0412/odin-mpc","last_synced_at":"2025-07-18T18:31:22.018Z","repository":{"id":264733642,"uuid":"832503803","full_name":"hpb0412/odin-mpc","owner":"hpb0412","description":"A binding to the mpc library for the Odin programming language.","archived":false,"fork":false,"pushed_at":"2025-03-03T15:10:39.000Z","size":5,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-03T16:24:50.967Z","etag":null,"topics":["combinators","odin","odin-lang","parser","parser-combinators"],"latest_commit_sha":null,"homepage":"","language":"Odin","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/hpb0412.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-07-23T06:50:33.000Z","updated_at":"2025-03-03T15:10:44.000Z","dependencies_parsed_at":"2024-11-26T03:21:33.324Z","dependency_job_id":"7b0831ec-e0b3-42f3-a50d-29159984681c","html_url":"https://github.com/hpb0412/odin-mpc","commit_stats":null,"previous_names":["hpb0412/odin-mpc"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hpb0412/odin-mpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hpb0412%2Fodin-mpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hpb0412%2Fodin-mpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hpb0412%2Fodin-mpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hpb0412%2Fodin-mpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hpb0412","download_url":"https://codeload.github.com/hpb0412/odin-mpc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hpb0412%2Fodin-mpc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265809885,"owners_count":23831943,"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":["combinators","odin","odin-lang","parser","parser-combinators"],"created_at":"2024-11-26T03:20:01.784Z","updated_at":"2025-07-18T18:31:22.003Z","avatar_url":"https://github.com/hpb0412.png","language":"Odin","funding_links":[],"categories":["Bindings"],"sub_categories":["Vendor"],"readme":"# odin-mpc\n\nThis is a binding to the [mpc](https://github.com/orangeduck/mpc) for Odin programming language.\n\n`mpc` stands for `Micro Parser Combinators`\n\nThis wrapper is targeting\n- revision `d4c99b753bb110cb66c671f6f7c1d8813d24863d`\n- commited on Aug 22, 2023\n\n## Mapping\n\n\u003e I intent to keep 1-1 mapping, unless there is a requirement from Odin that force us to do differently.\n\nBasically, for function we have\n| C  | Odin |\n| - | - |\n| `mpc_`func_name | func_name |\n| `mpcf_`func_name  | `f`_func_name |\n| `mpca_`func_name  | `a`_func_name |\n\nWith struct and named enum (with its items)\n(*) name of struct's member is preserved\n\n| C  | Odin |\n| - | - |\n| mpc_`structname`_t | Structname |\n| mpc_`enumname`_t | Enumname |\n| mpc_`enumname`_item_name | ITEM_NAME |\n\nFor unnamed enum, I converted to Odin's `bit_set`\n```c\nenum {\n  MPCA_LANG_DEFAULT              = 0,\n  MPCA_LANG_PREDICTIVE           = 1,\n  MPCA_LANG_WHITESPACE_SENSITIVE = 2\n};\n```\n```odin\nA_LANG :: enum {\n\tDEFAULT              = 0,\n\tPREDICTIVE           = 1,\n\tWHITESPACE_SENSITIVE = 2,\n}\nA_LANG_SET :: bit_set[A_LANG;c.int]\n```\n\n## Example\n\nThis example is based on the one from origin's [quickstart](https://github.com/orangeduck/mpc?tab=readme-ov-file#quickstart)\n\nLet take a quick look on the original code\n```c\nmpc_parser_t *Expr  = mpc_new(\"expression\");\nmpc_parser_t *Prod  = mpc_new(\"product\");\nmpc_parser_t *Value = mpc_new(\"value\");\nmpc_parser_t *Maths = mpc_new(\"maths\");\n\nmpca_lang(MPCA_LANG_DEFAULT,\n  \" expression : \u003cproduct\u003e (('+' | '-') \u003cproduct\u003e)*; \"\n  \" product    : \u003cvalue\u003e   (('*' | '/')   \u003cvalue\u003e)*; \"\n  \" value      : /[0-9]+/ | '(' \u003cexpression\u003e ')';    \"\n  \" maths      : /^/ \u003cexpression\u003e /$/;               \",\n  Expr, Prod, Value, Maths, NULL);\n\nmpc_result_t r;\n\nif (mpc_parse(\"input\", input, Maths, \u0026r)) {\n  mpc_ast_print(r.output);\n  mpc_ast_delete(r.output);\n} else {\n  mpc_err_print(r.error);\n  mpc_err_delete(r.error);\n}\n\nmpc_cleanup(4, Expr, Prod, Value, Maths);\n```\n\nAssume you name your collection as `dependencies`, below is Odin's equivalent\n```odin\nimport \"dependencies:mpc\"\n\n//...\n\nExpr  : ^mpc.Parser = mpc.new(\"expression\")\nProd  : ^mpc.Parser = mpc.new(\"product\")\nValue : ^mpc.Parser = mpc.new(\"value\")\nMaths : ^mpc.Parser = mpc.new(\"maths\")\ndefer mpc.cleanup(4, Expr, Prod, Value, Maths)\n\nmpc.a_lang(\n\t{.DEFAULT},\n\t\" expression : \u003cproduct\u003e (('+' | '-') \u003cproduct\u003e)*; \\n\" +\n\t\" product    : \u003cvalue\u003e   (('*' | '/')   \u003cvalue\u003e)*; \\n\" +\n\t\" value      : /[0-9]+/ | '(' \u003cexpression\u003e ')';    \\n\" +\n\t\" maths      : /^/ \u003cexpression\u003e /$/;               \\n\",\n\tExpr,\n\tProd,\n\tValue,\n\tMaths,\n\tnil,\n)\n\nr :  mpc.Result\n\nif mpc.parse(\"input\", input, Maths, \u0026r) {\n    mpc.ast_print(transmute(^mpc.Ast)r.output)\n    mpc.ast_delete(transmute(^mpc.Ast)r.outpout)\n} else {\n    mpc.err_print(r.error)\n    mpc.err_delete(r.error)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhpb0412%2Fodin-mpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhpb0412%2Fodin-mpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhpb0412%2Fodin-mpc/lists"}