{"id":21269786,"url":"https://github.com/prashantrahul141/expr-solver","last_synced_at":"2025-03-15T11:44:27.011Z","repository":{"id":221228395,"uuid":"753794353","full_name":"prashantrahul141/expr-solver","owner":"prashantrahul141","description":"Simple expression solver, using Pratt Parser technique, and a Tree Walker Interpreter, written in rust. ","archived":false,"fork":false,"pushed_at":"2024-02-10T17:13:19.000Z","size":63,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T04:48:24.568Z","etag":null,"topics":["crate","expression-evaluator","expression-parser","rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/expr-solver","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/prashantrahul141.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}},"created_at":"2024-02-06T20:02:08.000Z","updated_at":"2024-02-15T16:33:45.000Z","dependencies_parsed_at":"2024-02-09T12:59:03.488Z","dependency_job_id":null,"html_url":"https://github.com/prashantrahul141/expr-solver","commit_stats":null,"previous_names":["prashantrahul141/expr-resolver","prashantrahul141/expr-solver"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prashantrahul141%2Fexpr-solver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prashantrahul141%2Fexpr-solver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prashantrahul141%2Fexpr-solver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prashantrahul141%2Fexpr-solver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prashantrahul141","download_url":"https://codeload.github.com/prashantrahul141/expr-solver/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243725542,"owners_count":20337667,"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":["crate","expression-evaluator","expression-parser","rust"],"created_at":"2024-11-21T08:11:53.411Z","updated_at":"2025-03-15T11:44:26.987Z","avatar_url":"https://github.com/prashantrahul141.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Expression Solver\n\nSolves a mathematical expression while following precedence and associativity.\n\nThe crate provides one public api function.\n\n```rs\nfn resolve(input_string: String) -\u003e Result\u003cf64, String\u003e\n```\n\nThis takes mathematical expressions as String, and returns a Result enum with solved value or incase of an error, error string.\n\n### Examples\n\n```rs\nuse expr_solver::resolve;\n\n// simple binary expression.\nresolve(\"2+2\".to_string()); // Ok(2.0)\n\n// follows precendence, 2 + (2 _ 2) and NOT (2 + 2) _ 2\nresolve(\"2+2*2\".to_string()); // Ok(6.0);\n\n// unary expression.\nresolve(\"-2\".to_string()); // Ok(-2.0)\n\n// even chain them. -(-2)\nresolve(\"--2\".to_string()); // Ok(2.0)\n\n// binary and unary in one expression.\nresolve(\"2+-2\".to_string()); // Ok(0.0)\n\n// gives syntax error.\nresolve(\"2)2\".to_string()); // Err(String);\n```\n\n### Inner workings\n\nThere are three steps involved\n\n#### 1. Lexical Analysis.\n\nBreaks the input string into indiviual tokens.\n\n#### 2. Parser\n\nThis uses a Pratt Parsing technique to parse the stream of tokens into Abstract Syntax Tree (AST).\n\n#### 3. Interpreting\n\nUses a 'Tree-Walk' interpreter to evalute the AST.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprashantrahul141%2Fexpr-solver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprashantrahul141%2Fexpr-solver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprashantrahul141%2Fexpr-solver/lists"}