{"id":16480540,"url":"https://github.com/mgriebling/expressionparser","last_synced_at":"2026-02-04T03:38:07.364Z","repository":{"id":257820243,"uuid":"852885554","full_name":"mgriebling/ExpressionParser","owner":"mgriebling","description":"Swift expression parser and evaluator using a parser generated by Coco. Also produces a LaTeX translation of the text-based input expression.","archived":false,"fork":false,"pushed_at":"2024-10-16T12:01:46.000Z","size":44,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-09T11:56:09.771Z","etag":null,"topics":["ast","coco","compiler-compiler","evaluator","expression","latex","parser","swift","syntax-tree"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/mgriebling.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-09-05T15:41:21.000Z","updated_at":"2025-01-13T03:41:32.000Z","dependencies_parsed_at":"2024-10-17T23:13:06.140Z","dependency_job_id":null,"html_url":"https://github.com/mgriebling/ExpressionParser","commit_stats":{"total_commits":14,"total_committers":1,"mean_commits":14.0,"dds":0.0,"last_synced_commit":"e9984ca215b16c2c508dfc181f9c5320c126ede8"},"previous_names":["mgriebling/expressionparser"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/mgriebling/ExpressionParser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgriebling%2FExpressionParser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgriebling%2FExpressionParser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgriebling%2FExpressionParser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgriebling%2FExpressionParser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mgriebling","download_url":"https://codeload.github.com/mgriebling/ExpressionParser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgriebling%2FExpressionParser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264753014,"owners_count":23658771,"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":["ast","coco","compiler-compiler","evaluator","expression","latex","parser","swift","syntax-tree"],"created_at":"2024-10-11T13:04:20.537Z","updated_at":"2026-02-04T03:38:07.290Z","avatar_url":"https://github.com/mgriebling.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fmgriebling%2FExpressionParser%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/mgriebling/ExpressionParser)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fmgriebling%2FExpressionParser%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/mgriebling/ExpressionParser)\n\n# ExpressionParser\n\nThe **ExpressionParser** package parses and evaluates mathematical expressions\nand produces both a `LaTeX` translation and an evaluated result.\n\nFor example, the following:\n\n```swift\nlet e = ExpressionParser(\"(-b+sqrt(b^2-4a*c))/2a\")\nIdent.addSymbol((\"a\", 1))\nIdent.addSymbol((\"b\", -3))\nIdent.addSymbol((\"c\", -4))\nif let b = e.parse() {\n    print(b)\n}\n```\n\nproduces an output of:\n\n```\n(\"\\\\frac{-{b}+\\\\sqrt{{b}^{2}-4{}{a}\\\\times{c}}}{2{}{a}}\", 4.0)\n```\n\nwhere the `LaTeX` string gives the following typeset equation\n\n$\\frac{-{b}+\\sqrt{{b}^{2}-4{}{a}\\times{c}}}{2{}{a}}$\n\n## Usage\nIn your project's `Package.swift` file add a dependency like\n\n```\ndependencies: [\n    .package(url: \"https://github.com/mgriebling/ExpressionParser.git\", from: \"0.1.0\"),\n]\n```\n\n## Theory\n\n**ExpressionParser** contains two source files, `Parser.swift` and `Scanner.swift`.\nThey were produced by the Coco compiler [https://github.com/mgriebling/Coco]\ntranslating an input ATG (Attributed Grammar) file (exp.atg) that describes the operations to be scanned\nand parsed in a compact text format.  The `Coco` compiler generator also\nrequires some `.frame` files into which sections of code are inserted to\nproduce the final swift parser and scanner files.  An Abstract Syntax Tree\nrepresentation (AST) is built up using the `AST.swift` data type. This\ntree is then evaluated to generate the `LaTeX` translation and evaluates\na result.  For more details about `Coco` refer to the \nhttps://ssw.jku.at/Research/Projects/Coco/ web site.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgriebling%2Fexpressionparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmgriebling%2Fexpressionparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgriebling%2Fexpressionparser/lists"}