{"id":23163931,"url":"https://github.com/yhtiyar/expressionparser","last_synced_at":"2025-05-12T15:45:17.194Z","repository":{"id":89963843,"uuid":"243968798","full_name":"Yhtiyar/ExpressionParser","owner":"Yhtiyar","description":"Java math expression builder and parser","archived":false,"fork":false,"pushed_at":"2021-02-18T09:17:00.000Z","size":88,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T23:51:11.167Z","etag":null,"topics":["algebra","expression","expression-builder","expression-evaluator","expression-parser","java","math","math-expressions"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Yhtiyar.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":"2020-02-29T12:55:07.000Z","updated_at":"2023-08-25T16:52:55.000Z","dependencies_parsed_at":"2023-05-30T17:01:30.611Z","dependency_job_id":null,"html_url":"https://github.com/Yhtiyar/ExpressionParser","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/Yhtiyar%2FExpressionParser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yhtiyar%2FExpressionParser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yhtiyar%2FExpressionParser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yhtiyar%2FExpressionParser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yhtiyar","download_url":"https://codeload.github.com/Yhtiyar/ExpressionParser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253767572,"owners_count":21961137,"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":["algebra","expression","expression-builder","expression-evaluator","expression-parser","java","math","math-expressions"],"created_at":"2024-12-18T00:31:55.883Z","updated_at":"2025-05-12T15:45:17.163Z","avatar_url":"https://github.com/Yhtiyar.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ExpressionParser\n\nJava math expression parser\n\nReadme is outdated(it is still relevant, but I've made some updates that simlifies usage), will be updated soon.\n\n## Usage\n\n```Java\n                \nExpressionParser ep = new DoubleExpressionParser(); //All evaluation will be for Double type\n\n/*For parsing and evaluating as BigInteger type*/\nExpressionParser bigIntegerParser = new BigIntegerExpressionParser();\n\ntry {\n    System.out.println(ep.parse(\"x*y + log2 (5*x) + z - 2*x\").evaluate(5d, 1.5d, 2.9d));\n    System.out.println(ep.parse(pow2(x) min (1 + z^10 / y));\n    System.out.println(new CheckedAdd\u003c\u003e(new Const\u003c\u003e(3), new Const\u003c\u003e(5), new IntegerOperation()).evaluate(0, 0, 0);\n    \n}\ncatch (ParserException e){\n    System.out.println(e);\n}\n```\n\n`evalute(x, y, z)` takes 3 arguments - values of x, y and z.\n\u003e I will update it later to take not fixed amount of variables but, map of variables-values\n\n### Exceptions\n  **All operations are checked while evaluations**, so you will get `EvaluateException` if there will be problem while evaluation, e.g. **overflow**, **division by zero**\n  \n  **Parser exeptions** You will get `ParserException` if you will try to parse invalid exception\n  \n  **Note:** to see all exceptions open `expression/exception` folder\n\n## Operations\n1. `+`\n2. `-`\n3. `*`\n4. `/`\n5. `pow2` 2^expr **Usage**: `pow2(expr)`, could be used without brackets if there is only one argument: `pow2 x`\n6. `log2` log2(expr)\n7. `count` count of active bits in binary form of number `count 8 = 1; count(4 + 3) = 3`\n8. `min` **usage** `1 min 2` -\u003e `1`, **NOTE:** it has lowest priority while evaluating, so `1+2*3 min 3*1+1` -\u003e `4`\n9. `max` usage same as min\n10 `^` power, **usage** `2^10` -\u003e `1024`\n\nEach operation has its own class. \n\n## Generics \nEach expression will be parsed and evaluated on the type you will provide in constructor of expressionParser.\nFor the Const, you need to provide Type : `c = new Const\u003cInteger\u003e(3); c = new Const\u003cDouble\u003e(3.d)`\nFor the operations, it is required to provide Operation type in constructors `new CheckedAdd\u003c\u003e(new Const\u003c\u003e(3), new Const\u003c\u003e(5), new IntegerOperation())`\n\n### Types\n1. `Integer` **usage** `new Const\u003cInteger\u003e(3);`\n2.  Double\n3.  BigInteger\n  \n### Operation types\n1. `IntegerOperation`\n2.  `DoubleOperation`\n3.  `BigIntegerOperation`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyhtiyar%2Fexpressionparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyhtiyar%2Fexpressionparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyhtiyar%2Fexpressionparser/lists"}