{"id":29512406,"url":"https://github.com/tuqqu/go-parser","last_synced_at":"2026-01-14T01:25:28.121Z","repository":{"id":37902910,"uuid":"447197351","full_name":"tuqqu/go-parser","owner":"tuqqu","description":"Golang parser written in PHP","archived":false,"fork":false,"pushed_at":"2023-09-09T23:42:56.000Z","size":276,"stargazers_count":42,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-10-19T10:52:22.614Z","etag":null,"topics":["ast","golang","parser","php-parser"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/tuqqu.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":"2022-01-12T11:48:43.000Z","updated_at":"2025-09-17T12:21:18.000Z","dependencies_parsed_at":"2023-01-30T20:01:05.797Z","dependency_job_id":null,"html_url":"https://github.com/tuqqu/go-parser","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/tuqqu/go-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuqqu%2Fgo-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuqqu%2Fgo-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuqqu%2Fgo-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuqqu%2Fgo-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tuqqu","download_url":"https://codeload.github.com/tuqqu/go-parser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuqqu%2Fgo-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28407696,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["ast","golang","parser","php-parser"],"created_at":"2025-07-16T12:01:43.235Z","updated_at":"2026-01-14T01:25:28.110Z","avatar_url":"https://github.com/tuqqu.png","language":"PHP","funding_links":[],"categories":["Golang","Go"],"sub_categories":["Follow me"],"readme":"# GoParser\nGolang parser written in PHP 8.1\n\n## Installation\nTo install this package, run:\n\n```\ncomposer require tuqqu/go-parser\n```\n\n## Example\n```php\nuse GoParser\\Parser;\n\n$program = \u003c\u003c\u003cGO\n    package main\n    \n    import \"fmt\"\n    \n    func main() {\n        res := add(1, 2)\n        fmt.Println(\"1+2 =\", res)\n    }\nGO;\n\n$parser = new Parser($program);\n$ast = $parser-\u003eparse();\n$errs = $parser-\u003egetErrors();\n```\n\nThe parser is capable of recovering itself if a parse error occurs. In such cases, it will continue parsing at the closest node it can recognise.\n\nThe resulting Abstract Syntax Tree (AST) will be as complete as possible. You need to check `getErrors()` to identify any errors.\n\n## Single declaration parsing\n\nThe parser can also handle a single declaration (e.g., a single function) instead of an entire Go program:\n```php\nuse GoParser\\{Parser, ParseMode};\n\n$func = \u003c\u003c\u003cGO\n    func add(x, y int) int { \n        return x + y\n    }\nGO;\n\n$parser = new Parser($func, mode: ParseMode::SingleDecl);\n$decl = $parser-\u003eparseSingleDecl();\n```\n\n## Abstract Syntax Tree\n\nParsing results in an Abstract Syntax Tree. Refer to `src/Ast` for details.\n\nFor the most part, the structure of AST nodes closely follows the official Golang [specification][1].\n\nSome nodes may have slightly different names (e.g., `ExpressionList` instead of `ExprList`), but in most cases, the names are the same or easily recognisable.\n\n## CLI\nPackage comes with a CLI command:\n\n```\n./vendor/bin/go-parser main.go [--flags]\n```\n\nBy default, it uses a simple `NodeDumper` to print AST.\n\nUse `--help` to see other options.\n\n[1]: https://go.dev/ref/spec","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuqqu%2Fgo-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftuqqu%2Fgo-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuqqu%2Fgo-parser/lists"}