{"id":16899918,"url":"https://github.com/gyulyvgc/postfix-predicate-interpreter","last_synced_at":"2025-03-20T12:24:54.982Z","repository":{"id":250148340,"uuid":"833580328","full_name":"GyulyVGC/postfix-predicate-interpreter","owner":"GyulyVGC","description":"A postfix expression converter and interpreter for generic boolean predicates","archived":false,"fork":false,"pushed_at":"2025-03-17T08:53:48.000Z","size":53,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T09:42:15.824Z","etag":null,"topics":["postfix","postfix-calculator","postfix-expression","rpn","rpn-calculator","rpn-expression","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/GyulyVGC.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":"2024-07-25T10:33:46.000Z","updated_at":"2025-03-07T21:09:10.000Z","dependencies_parsed_at":"2024-08-20T16:57:32.990Z","dependency_job_id":"b902ab1a-cc2b-44b8-8b85-354e15222560","html_url":"https://github.com/GyulyVGC/postfix-predicate-interpreter","commit_stats":null,"previous_names":["gyulyvgc/generic-rpn-interpreter","gyulyvgc/rpn-predicate-interpreter","gyulyvgc/postfix-predicate-interpreter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GyulyVGC%2Fpostfix-predicate-interpreter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GyulyVGC%2Fpostfix-predicate-interpreter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GyulyVGC%2Fpostfix-predicate-interpreter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GyulyVGC%2Fpostfix-predicate-interpreter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GyulyVGC","download_url":"https://codeload.github.com/GyulyVGC/postfix-predicate-interpreter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244610285,"owners_count":20480951,"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":["postfix","postfix-calculator","postfix-expression","rpn","rpn-calculator","rpn-expression","rust"],"created_at":"2024-10-13T17:50:54.706Z","updated_at":"2025-03-20T12:24:54.946Z","avatar_url":"https://github.com/GyulyVGC.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# postfix-predicate-interpreter\nA postfix expression converter and interpreter for generic boolean predicates.\n\n\u003e [!NOTE]\n\u003e \n\u003e \u003ci\u003e\n\u003e Postfix representation, also known as Reverse Polish Notation (RPN),\n\u003e is an alternative way to describe mathematical expressions.\u003cbr/\u003e\n\u003e While the standard representation (infix) uses operators between operands,\n\u003e the postfix representation uses operators after operands.\u003cbr/\u003e\n\u003e Expressions in postfix form are easier and less expensive to evaluate than standard infix expressions:\n\u003e they can be evaluated linearly left-to-right, since this notation removes the concept of operator precedence and the need for parenthesis. \n\u003e \u003c/i\u003e\n\n## Features\n- Instantiate an infix expression made of generic boolean predicates\n- Instantiate a postfix expression made of generic boolean predicates\n- Convert an infix expression to a postfix expression\n- Convert a postfix expression to an infix expression\n- Evaluate a postfix expression\n\n## Usage\nLet's say you want to evaluate the infix expression `A AND (B OR C)`.\n\nWe can instantiate the infix expression as follows:\n``` rust\nlet infix = InfixExpression::from_tokens(vec![\n    InfixToken::Predicate(\"A\"),\n    InfixToken::Operator(Operator::And),\n    InfixToken::Parenthesis(Parenthesis::Open),\n    InfixToken::Predicate(\"B\"),\n    InfixToken::Operator(Operator::Or),\n    InfixToken::Predicate(\"C\"),\n    InfixToken::Parenthesis(Parenthesis::Close),\n])\n.unwrap();\n```\n\nWe can then convert the infix expression to the equivalent postfix expression `A B C OR AND`:\n``` rust\nlet postfix = infix.to_postfix();\nassert_eq!(\n    postfix,\n    PostfixExpression::from_tokens(vec![\n        PostfixToken::Predicate(\"A\"),\n        PostfixToken::Predicate(\"B\"),\n        PostfixToken::Predicate(\"C\"),\n        PostfixToken::Operator(Operator::Or),\n        PostfixToken::Operator(Operator::And),\n    ])\n    .unwrap()\n);\n```\n\nFinally, we can evaluate the postfix expression:\n``` rust\nlet result = postfix.evaluate(\u0026predicate_evaluator);\n```\n\nNote that predicates are represented as letters in this example (`A`, `B`, `C`),\nbut they can be any type that resolves to either true or false given a predicate evaluator.\u003cbr/\u003e\nThe predicate evaluator is an object of a type implementing the `PredicateEvaluator` trait;\nsuch an object is passed as argument to the `evaluate` method, making it possible to solve the expression.\n\n\u003e [!NOTE]\n\u003e \n\u003e The aim of the library is to evaluate expressions whose results depend on an external context,\n\u003e represented by the value of the predicate evaluator.\n    ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgyulyvgc%2Fpostfix-predicate-interpreter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgyulyvgc%2Fpostfix-predicate-interpreter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgyulyvgc%2Fpostfix-predicate-interpreter/lists"}