{"id":29520999,"url":"https://github.com/n0bra1n3r/mast","last_synced_at":"2025-07-16T16:32:03.009Z","repository":{"id":46102733,"uuid":"427648833","full_name":"n0bra1n3r/mast","owner":"n0bra1n3r","description":"A simple DSL for defining abstract syntax trees in Nim","archived":false,"fork":false,"pushed_at":"2024-09-07T03:37:28.000Z","size":27,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"staging","last_synced_at":"2025-07-13T15:42:42.745Z","etag":null,"topics":["abstract-syntax-tree","ast","domain-specific-language","dsl","macros","nim","nim-lang"],"latest_commit_sha":null,"homepage":"","language":"Nim","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/n0bra1n3r.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":"2021-11-13T11:40:09.000Z","updated_at":"2024-09-07T19:42:21.000Z","dependencies_parsed_at":"2024-09-07T05:14:07.264Z","dependency_job_id":null,"html_url":"https://github.com/n0bra1n3r/mast","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/n0bra1n3r/mast","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n0bra1n3r%2Fmast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n0bra1n3r%2Fmast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n0bra1n3r%2Fmast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n0bra1n3r%2Fmast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/n0bra1n3r","download_url":"https://codeload.github.com/n0bra1n3r/mast/tar.gz/refs/heads/staging","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n0bra1n3r%2Fmast/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265524603,"owners_count":23782009,"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":["abstract-syntax-tree","ast","domain-specific-language","dsl","macros","nim","nim-lang"],"created_at":"2025-07-16T16:30:44.546Z","updated_at":"2025-07-16T16:32:03.001Z","avatar_url":"https://github.com/n0bra1n3r.png","language":"Nim","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mast\n\n![Testing](https://github.com/n0bra1n3r/mast/actions/workflows/test.yml/badge.svg)\n\nA simple DSL for defining abstract syntax trees in [Nim](https://nim-lang.org/).\n\nThis project was directly inspired by the [breeze](https://github.com/alehander92/breeze)\nlibrary.\n\n## Overview\n\nThis library provides another way to write Nim [macros](https://nim-lang.org/docs/macros.html)\nmore closely following the output of [`treeRepr`](https://nim-lang.org/docs/macros.html#treeRepr%2CNimNode).\n\n## Showcase\n\nPlease **see [tests](tests/)** for examples of most features. This section\nprovides an incomplete summary of the core functionality.\n\n### Basic example\n\nThe following is an example usage:\n\n```nim\nimport mast\n\nmacro makeMain(say: static string) =\n  ast:\n    ProcDef:\n      `main`\n      Empty\n      Empty\n      FormalParams:\n        Empty\n      Empty\n      Empty\n      StmtList:\n        Command:\n          `echo`\n          \"Hello macro!\"\n        Command:\n          `echo`\n          (lit say)\n\nmakeMain \"Hello world!\"\n```\n\n```nim\n# `makeMain` expands to:\nproc main() =\n  echo \"Hello macro!\"\n  echo \"Hello world!\"\n```\n\nNotice that most elements in the AST definition correspond to their `nnk*`\n[NimNode](https://nim-lang.org/docs/macros.html#NimNodeKind) counterparts.\nExceptions to this pattern are the following:\n\n* Identifiers which are enclosed in backticks (\"`\")\n* Literals which are simply specified in the AST definition as-is\n* External expressions which are embedded in the AST by enclosing them in\nparentheses\n\n### Identifiers\n\nUnder the hood mast uses the [`fmt`](https://nim-lang.org/docs/strformat.html#fmt.m%2Cstaticstring%2Cstaticchar%2Cstaticchar)\nmacro to parse identifier names. This means that identifier names can be\ncomposed using the following syntax:\n\n```nim\nlet i = 1\nlet newIdent = ast`ident{i}` # generates `Ident \"ident1\"`\n```\n\nBound symbols can be specified by using the `sym` macro:\n\n```nim\nlet boundSym = ast (sym someDeclaredSymbol)\n```\n\nLastly, new symbols can be generated using the following syntax:\n\n```nim\nlet genSymed = ast (sym Proc`someProcSymbol`)\n```\n\nThe `Proc` symbol here corresponds to [`nskProc`](https://nim-lang.org/docs/macros.html#NimSymKind),\nand the symbol inside the backticks can be interpolated in the same way as\nidentifiers.\n\n## Installing\n\nThe package can be installed by following the nimble instructions\n[here](https://github.com/nim-lang/nimble#nimble-install).\n\n## Usage\n\nSimply import mast into your module to start using it.\n\n## Contributing\n\nThis project is maintained during my free time, and serves as a tool for a game\nengine I am writing after work hours. Contributions are welcome, and I will\nmerge them immediately if they serve to keep the project robust, simple, and\nmaintainable.\n\n**Cheers and happy coding!** 🍺\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn0bra1n3r%2Fmast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fn0bra1n3r%2Fmast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn0bra1n3r%2Fmast/lists"}