{"id":13694423,"url":"https://github.com/svstanev/goexp","last_synced_at":"2025-08-21T00:09:06.428Z","repository":{"id":57487475,"uuid":"170700057","full_name":"svstanev/goexp","owner":"svstanev","description":"Recursive descent expression parser in Go","archived":false,"fork":false,"pushed_at":"2019-11-02T13:08:02.000Z","size":26,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-13T22:21:54.019Z","etag":null,"topics":["expression","expression-engine","expression-evaluator","expression-language","golang","parser","recursive-descent-parser"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/svstanev.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}},"created_at":"2019-02-14T14:00:24.000Z","updated_at":"2023-08-10T12:19:40.000Z","dependencies_parsed_at":"2022-09-01T22:51:57.869Z","dependency_job_id":null,"html_url":"https://github.com/svstanev/goexp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/svstanev/goexp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svstanev%2Fgoexp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svstanev%2Fgoexp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svstanev%2Fgoexp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svstanev%2Fgoexp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/svstanev","download_url":"https://codeload.github.com/svstanev/goexp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svstanev%2Fgoexp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271405572,"owners_count":24753799,"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","status":"online","status_checked_at":"2025-08-20T02:00:09.606Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["expression","expression-engine","expression-evaluator","expression-language","golang","parser","recursive-descent-parser"],"created_at":"2024-08-02T17:01:31.630Z","updated_at":"2025-08-21T00:09:06.406Z","avatar_url":"https://github.com/svstanev.png","language":"Go","readme":"# goexp\n\nRecursive descent expression parser in Go\n\n## Installation\n\n```\ngo get -u github.com/svstanev/goexp\n```\n\n## Usage\n\n```golang\npackage main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\n\t\"github.com/svstanev/goexp\"\n\t\"github.com/svstanev/goexp/types\"\n)\n\nfunc main() {\n\tcontext := goexp.NewEvalContext(nil)\n\tcontext.AddName(\"x\", types.Integer(1))\n\tcontext.AddName(\"y\", types.Integer(3))\n\tcontext.AddName(\"z\", types.Integer(5))\n\tcontext.AddMethod(\"max\", func(args ...types.Integer) (interface{}, error) {\n\t\tvar res int64 = math.MinInt64\n\t\tfor _, value := range args {\n\t\t\tn := int64(value)\n\t\t\tif n \u003e res {\n\t\t\t\tres = n\n\t\t\t}\n\t\t}\n\t\treturn types.Integer(res), nil\n\t})\n\n\tres, err := goexp.EvalString(\"max(x, y, z)\", context)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(res)\n}\n```\n\n## Expression language\n\n### Syntax Grammar\n\n```\nexpression      -\u003e logical_or\nlogical_or      -\u003e logical_and ((\"||\") logical_and)*;\nlogical_and     -\u003e logical_not ((\"\u0026\u0026\") logical_not)*;\nlogical_not\t\t\t-\u003e \"!\"? equality;\nequality        -\u003e comparison ((\"==\" | \"!=\") comparison)*;\ncomparison      -\u003e addition ((\"\u003c\" | \"\u003c=\" | \"\u003e\" | \"\u003e=\") addition)*;\naddition        -\u003e multiplication ((\"+\" | \"-\") multiplication)*;\nmultiplication  -\u003e negate ((\"*\" | \"/\" | \"%\") negate)*;\npower \t\t\t\t\t-\u003e negate (\"**\" negate)*;\nnegate          -\u003e \"-\"? call;\ncall            -\u003e primary ((\"(\" arguments? \")\") | (\".\" IDENTIFIER))*;\nprimary         -\u003e \"false\" | \"true\" | \"nil\" | IDENTIFIER | NUMBER | STRING | \"(\" expression \")\";\n\narguments       -\u003e expression (\",\" expression)*;\n```\n\n### Lexical Grammar\n\n```\nIDENTIFIER      -\u003e ALPHA (ALPHA | DIGIT)*;\nNUMBER          -\u003e DIGIT* (\".\" DIGIT*)?;\nSTRING          -\u003e \"'\" \u003cany char except \"'\"\u003e* \"'\"\n                  | '\"' \u003cany char except '\"'\u003e* '\"';\n\nDIGIT           -\u003e '0'...'9'\nALPHA           -\u003e 'a'...'z'|'A'...'Z'|'_'\n```\n\n","funding_links":[],"categories":["开源类库","Open source library"],"sub_categories":["解释器","Interpreter"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsvstanev%2Fgoexp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsvstanev%2Fgoexp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsvstanev%2Fgoexp/lists"}