{"id":15029215,"url":"https://github.com/xp-framework/ast","last_synced_at":"2026-02-14T12:09:00.691Z","repository":{"id":26710806,"uuid":"109585391","full_name":"xp-framework/ast","owner":"xp-framework","description":"AST for the XP Framework","archived":false,"fork":false,"pushed_at":"2025-12-21T15:33:17.000Z","size":567,"stargazers_count":3,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-23T05:38:34.457Z","etag":null,"topics":["ast","code-generation","compiler","metaprogramming","php","php-parser","php7","php8","php8-features","xp-framework"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xp-framework.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-11-05T14:13:46.000Z","updated_at":"2025-12-21T15:32:48.000Z","dependencies_parsed_at":"2024-03-23T17:47:26.081Z","dependency_job_id":"71960439-af8d-405b-a9a1-28b73105c96c","html_url":"https://github.com/xp-framework/ast","commit_stats":null,"previous_names":[],"tags_count":72,"template":false,"template_full_name":null,"purl":"pkg:github/xp-framework/ast","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-framework%2Fast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-framework%2Fast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-framework%2Fast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-framework%2Fast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xp-framework","download_url":"https://codeload.github.com/xp-framework/ast/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-framework%2Fast/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29443468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T10:51:12.367Z","status":"ssl_error","status_checked_at":"2026-02-14T10:50:52.088Z","response_time":53,"last_error":"SSL_read: 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","code-generation","compiler","metaprogramming","php","php-parser","php7","php8","php8-features","xp-framework"],"created_at":"2024-09-24T20:09:58.486Z","updated_at":"2026-02-14T12:09:00.676Z","avatar_url":"https://github.com/xp-framework.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"XP AST\n======\n\n[![Build status on GitHub](https://github.com/xp-framework/ast/workflows/Tests/badge.svg)](https://github.com/xp-framework/ast/actions)\n[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)\n[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)\n[![Requires PHP 7.4+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_4plus.svg)](http://php.net/)\n[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)\n[![Latest Stable Version](https://poser.pugx.org/xp-framework/ast/version.svg)](https://packagist.org/packages/xp-framework/ast)\n\nAbstract syntax tree library used for [XP Compiler](https://github.com/xp-framework/compiler).\n\nExample\n-------\n```php\nuse lang\\ast\\{Language, Tokens};\n\n$tree= Language::named('PHP')-\u003eparse(new Tokens('echo PHP_VERSION;'))-\u003etree();\n\n// lang.ast.ParseTree(source: (string))@{\n//   scope =\u003e lang.ast.Scope {\n//     parent =\u003e null\n//     package =\u003e null\n//     imports =\u003e []\n//     types =\u003e []\n//   }\n//   children =\u003e [lang.ast.nodes.EchoStatement {\n//     kind =\u003e \"echo\"\n//     expressions =\u003e [lang.ast.nodes.Literal {\n//       kind =\u003e \"literal\"\n//       expression =\u003e \"PHP_VERSION\"\n//       line =\u003e 1\n//     }]\n//     line =\u003e 1\n//   }]\n// }\n```\n\nCompile-time metaprogramming\n----------------------------\nRegister transformations by creating classes inside the `lang.ast.syntax.php` package - see https://github.com/xp-framework/rfc/issues/327\n\n\n```php\nnamespace lang\\ast\\syntax\\php;\n\nuse lang\\ast\\Code;\nuse lang\\ast\\nodes\\{Method, Signature};\nuse lang\\ast\\syntax\\Extension;\nuse codegen\\Getters;\n\nclass CreateGetters implements Extension {\n\n  public function setup($language, $emitter) {\n    $emitter-\u003etransform('class', function($codegen, $class) {\n      if ($class-\u003eannotation(Getters::class)) {\n        foreach ($class-\u003eproperties() as $property) {\n          $class-\u003edeclare(new Method(\n            ['public'],\n            $property-\u003ename,\n            new Signature([], $property-\u003etype),\n            [new Code('return $this-\u003e'.$property-\u003ename)]\n          ));\n        }\n      }\n      return $class;\n    });\n  }\n}\n```\n\nWhen compiling the following sourcecode, getters for the `id` and `name` members will automatically be added.\n\n```php\nuse codegen\\Getters;\n\n#[Getters]\nclass Person {\n  private int $id;\n  private string $name;\n\n  public function __construct(int $id, string $name) {\n    $this-\u003eid= $id;\n    $this-\u003ename= $name;\n  }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-framework%2Fast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxp-framework%2Fast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-framework%2Fast/lists"}