{"id":22549232,"url":"https://github.com/seboran/transpilation-ts","last_synced_at":"2025-04-10T01:53:09.610Z","repository":{"id":153336971,"uuid":"624797988","full_name":"Seboran/transpilation-ts","owner":"Seboran","description":"Manipulation d'arbres syntaxiques ","archived":false,"fork":false,"pushed_at":"2024-10-24T08:14:07.000Z","size":616,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-24T22:05:19.898Z","etag":null,"topics":["ast","typescript","visitor-pattern"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/Seboran.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2023-04-07T09:29:04.000Z","updated_at":"2024-10-24T08:14:10.000Z","dependencies_parsed_at":"2024-01-20T09:28:52.021Z","dependency_job_id":"604d6b25-b950-4186-ad97-6147ac74bc07","html_url":"https://github.com/Seboran/transpilation-ts","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/Seboran%2Ftranspilation-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seboran%2Ftranspilation-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seboran%2Ftranspilation-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seboran%2Ftranspilation-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Seboran","download_url":"https://codeload.github.com/Seboran/transpilation-ts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248142938,"owners_count":21054671,"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","typescript","visitor-pattern"],"created_at":"2024-12-07T16:08:20.070Z","updated_at":"2025-04-10T01:53:09.588Z","avatar_url":"https://github.com/Seboran.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Transpilation\n\n## Déplacement\n\nLe projet a été déplacé ici : \u003chttps://github.com/Seboran/monorepo\u003e\n\n## Description\n\nCe projet permet de générer du code dans n'importe quel langage à partir d'un AST\n\n## Comment lancer ce projet ?\n\n```bash\npnpm i\npnpm start\n```\n## Comment créer son propre code\n\nOn veut représenter avec des nodes l'instruction suivante en pseudo code :\n\n```pseudo\nsi X \u003e Y:\n  2 + (5 * 3)\nsinon:\n  2 + (5 - 3)\n```\n\nPour cela on peut identifier que l'instruction est un bloc if, portant une condition, et une expression si vraie et une expression si faux.\n\nCela se représente ainsi :\n\n```typescript\nnew SiNode(\n  new ConditionNode(\n    new SuperieurNode(new LitteralNode('X'), new LitteralNode('Y'))\n  ),\n  new AdditionNode(\n    new NumberNode(2),\n    new MultiplicationNode(new NumberNode(5), new NumberNode(3))\n  ),\n  new AdditionNode(\n    new NumberNode(2),\n    new SoustractionNode(new NumberNode(5), new NumberNode(3))\n  )\n)\n```\n\nPour parcourir cet arbre, chaque node implémente la méthode `accept` qui prend un `VisiteurNode` en argument. Voir par exemple `JavascriptGenerator`.\n\nExemple d'utilisation :\n\n```typescript\nconst javascriptGenerator = new JavascriptGenerator()\nconst code = instructions.accept(javascriptGenerator)\n```\n\nEt notre instance de JavascriptGenerator parcoure toute la node automatiquement.\n\nCe pattern est appelé \"Visitor pattern double dispatch\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseboran%2Ftranspilation-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseboran%2Ftranspilation-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseboran%2Ftranspilation-ts/lists"}