{"id":22169369,"url":"https://github.com/deltares/mathematical_expression_parser","last_synced_at":"2026-02-18T02:35:29.836Z","repository":{"id":37512753,"uuid":"237914697","full_name":"Deltares/mathematical_expression_parser","owner":"Deltares","description":"The Mathematical Expression Parser is a simple parser to convert Mathematical Expressions  to Symbolic Expression trees which will be used in the D-HYDRO software for D-RTC plugin.","archived":false,"fork":false,"pushed_at":"2024-09-04T13:36:01.000Z","size":96,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-09-05T17:06:08.330Z","etag":null,"topics":["fparsec","fsharp","mathematical-expression-parser"],"latest_commit_sha":null,"homepage":"","language":"F#","has_issues":false,"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/Deltares.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-03T08:07:41.000Z","updated_at":"2024-09-04T13:36:05.000Z","dependencies_parsed_at":"2022-08-19T05:20:28.836Z","dependency_job_id":null,"html_url":"https://github.com/Deltares/mathematical_expression_parser","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/Deltares%2Fmathematical_expression_parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deltares%2Fmathematical_expression_parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deltares%2Fmathematical_expression_parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deltares%2Fmathematical_expression_parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Deltares","download_url":"https://codeload.github.com/Deltares/mathematical_expression_parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227685261,"owners_count":17804131,"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":["fparsec","fsharp","mathematical-expression-parser"],"created_at":"2024-12-02T06:31:19.474Z","updated_at":"2026-02-18T02:35:29.807Z","avatar_url":"https://github.com/Deltares.png","language":"F#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mathematical Expression Parser\r\n\r\nThe Mathematical Expression Parser is a simple parser to convert Mathematical\r\nExpressions written as a string, to Symbolic Expression trees, as shown\r\nin the following picture:\r\n\r\n\u003cp align=\"center\"\u003e\u003cimg src=\"./doc/SymbolicExpression.png\" alt=\"SymbolicExpressionTree\" title=\"Symbolic expression tree parsing\" width=50% /\u003e\u003c/p\u003e\r\n\r\n## How to use:\r\n\r\n### `Parser.parseExpression` function\r\n\r\nThe entry point of the the Mathematical Expression Parser is the `parseExpression`\r\nfunction defined in the `Parser` module. This function takes a string, and will\r\nreturn either `Success of ExpressionTree` or `Failure of String` where the string\r\ncontains the error message.\r\n\r\n### `ExpressionTrees`\r\n\r\nThe expression tree is defined as follows:\r\n\r\nThe base object is the `ExpressionType`. Which describes a complete (sub-)tree.\r\nAn `ExpressionType` is either a `ComposedExpression` of type \r\n`ComposedExpressionType` or an `AtomicExpression` of the type \r\n`AtomicExpressionType`, which cannot be subdivided further. A \r\n`ComposedExpressionType` is a record consisting of an operator, and two other\r\n`ExpressionTypes`. An `AtomicExpressionType` is either a `Parameter` or a \r\n`Constant`.\r\n   \r\n### Defined syntax\r\n\r\nThe supported syntax is defined as follows:\r\n\r\n* Parameter: any term starting with a capitalised letter or an underscore, \r\n   containing letters, numbers, and/or underscores.\r\n* Constant: Any floating point value, e.g. `1`, `1.0`, `1E-3`. This includes\r\n   negative values.\r\n* Infix functions: \r\n   Infix functions are defined as `\u003coperand1\u003e \u003cinfix-function\u003e \u003coperand2\u003e`.\r\n   The following infix functions are currently defined:\r\n   * Multiplication: `*`\r\n   * Division: `/`\r\n   * Addition: `+`\r\n   * Subtraction: `-`\r\n* Binary functions: \r\n   Binary functions are defined as terms starting with a lowercase letter,\r\n   containing letters, numbers, and/or underscores, followed by a set of\r\n   parentheses (without white space). The set of accepted binary functions\r\n   is currently limited to the following:\r\n   * Minimum: `min`\r\n   * Maximum: `max`\r\n\r\nIf no precedence is defined through parentheses, then standard precedence of\r\nmathematical operators assumed, i.e. division and multiplication take \r\nprecedence over subtraction and addition. \r\n\r\nWhitespace inbetween terms, as well as at the beginning and end will be ignored,\r\nthis includes new lines.\r\n\r\n## How to add to an existing solution\r\n\r\nThere are two ways to incorporate the Mathematical Expression Parser into a\r\nproject. The recommended approach is to generate a NuGet package of the \r\nMathematicalExpressionParser.Core as described in the How to build section.\r\nThis package can then be added to your existing project. \r\n\r\nAlternatively, the packages can be added directly to a .net solution. This\r\ndoes require the F# tooling within Visual Studio. The projects can then \r\nbe referenced directly from within the solution.\r\n\r\n## How to build:\r\n\r\nThe repository can be obtained by running \r\n\r\n```bash\r\ngit clone https://github.com/Deltares/mathematical_expression_parser.git\r\n```\r\n\r\nOnce downloaded, the `.sln` file can be opened with Visual Studio. This \r\nshould allow you to build the project, and run the tests. Keep in mind that\r\nthis requires the F# build tools, which can be obtained through the Visual\r\nStudio installer.\r\n\r\nIn order to build the NuGet package, first build the solution in `Release`.\r\nThen navigate to the `MathematicalExpressionParser.Core` folder and run the\r\nfollowing command:\r\n\r\n```bash\r\nnuget pack -properties Configuration=Release\r\n```\r\n\r\nThis will create the MathematicalExpressionParser.core NuGet Package of the\r\ncurrent version.\r\n\r\n## Technologies\r\n\r\nThe Mathematical Expression Parser has been build with the following \r\ntechnologies:\r\n\r\n* [Visual Studio 2019](https://visualstudio.microsoft.com/vs/): Used to build\r\n   the project. This requires the F# build tools.\r\n* [FParsec](https://www.quanttec.com/fparsec/): Parser combinator library used \r\n   to transform the mathematical expression into symbolic expression trees.\r\n* [FParsec-Pipes](https://rspeele.github.io/FParsec-Pipes/): Additional \r\n   extensions for FParsec\r\n* [FsUnit](https://fsprojects.github.io/FsUnit/): Used to write the test suite.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeltares%2Fmathematical_expression_parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeltares%2Fmathematical_expression_parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeltares%2Fmathematical_expression_parser/lists"}