{"id":16741559,"url":"https://github.com/duaraghav8/solidityparser","last_synced_at":"2026-05-19T11:05:29.479Z","repository":{"id":98907862,"uuid":"264647961","full_name":"duaraghav8/solidityparser","owner":"duaraghav8","description":"ANTLR4-generated Go library to parse Solidity","archived":false,"fork":false,"pushed_at":"2020-05-22T09:58:00.000Z","size":189,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-22T12:26:56.026Z","etag":null,"topics":["antlr4","golang","parser","solidity"],"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/duaraghav8.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-05-17T11:23:02.000Z","updated_at":"2020-05-22T09:58:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"dd1c2374-e238-4d72-8016-0312c7dbd66b","html_url":"https://github.com/duaraghav8/solidityparser","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/duaraghav8%2Fsolidityparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duaraghav8%2Fsolidityparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duaraghav8%2Fsolidityparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duaraghav8%2Fsolidityparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/duaraghav8","download_url":"https://codeload.github.com/duaraghav8/solidityparser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243806031,"owners_count":20350773,"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":["antlr4","golang","parser","solidity"],"created_at":"2024-10-13T01:03:34.275Z","updated_at":"2026-05-19T11:05:24.438Z","avatar_url":"https://github.com/duaraghav8.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Solidity Parser\nThis is a Go module to parse [Solidity](https://solidity.readthedocs.io/en/latest/), based on [Federico](https://github.com/federicobond) 's [ANTLR grammar](https://github.com/solidityj/solidity-antlr4) for the language.\n\n## Usage\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/antlr/antlr4/runtime/Go/antlr\"\n\t\"github.com/duaraghav8/solidityparser\"\n)\n\nvar code = `\ncontract Foo {\n\tfunction bar(uint x) {}\n}\n\ncontract Bar {\n\tconstructor(){}\n}\n`\n\n// EverythingListener listens for all rules, i.e., it visits\n// all AST nodes.\ntype EverythingListener struct {\n\t*solidityparser.BaseSolidityListener\n}\n\nfunc NewEverythingListener() *EverythingListener {\n\treturn new(EverythingListener)\n}\n\nfunc (l *EverythingListener) EnterEveryRule(ctx antlr.ParserRuleContext) {\n\tfmt.Println(\"Entered a rule\")\n\tfmt.Println(ctx.GetRuleIndex())\n\tfmt.Printf(\"Text: %s\\nStart line: %d\\n\", ctx.GetText(), ctx.GetStart().GetLine())\n\tfmt.Println(\"--------------\")\n}\n\nfunc main() {\n\tcode := antlr.NewInputStream(code)\n\tlexer := solidityparser.NewSolidityLexer(code)\n\tstream := antlr.NewCommonTokenStream(lexer, 0)\n\n\tparser := solidityparser.NewSolidityParser(stream)\n\tparser.AddErrorListener(antlr.NewDiagnosticErrorListener(true))\n\tparser.BuildParseTrees = true\n\n\ttree := parser.SourceUnit()\n\tantlr.ParseTreeWalkerDefault.Walk(NewEverythingListener(), tree)\n}\n```\n\n## Building\nInstall the ANTLR4 tool and the Go runtime as described [here](https://github.com/antlr/antlr4/blob/master/doc/getting-started.md) \u0026 [here](https://github.com/antlr/antlr4/blob/master/doc/go-target.md).\n\nTo generate this Parser:\n1. Update the `solidity-antlr4` [submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules) to the appropriate commit.\n2. Run `scripts/generate-solidity-parser.sh` in the root directory of this repository.\n3. Run `go mod tidy \u0026\u0026 go mod vendor`\n4. Commit and push.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduaraghav8%2Fsolidityparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fduaraghav8%2Fsolidityparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduaraghav8%2Fsolidityparser/lists"}