{"id":25933556,"url":"https://github.com/simplygreatwork/pluck","last_synced_at":"2025-06-25T09:07:43.636Z","repository":{"id":193175493,"uuid":"246186243","full_name":"simplygreatwork/pluck","owner":"simplygreatwork","description":"Get started with WebAssembly text format syntax and macros.","archived":false,"fork":false,"pushed_at":"2020-04-24T18:27:18.000Z","size":580,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-04-06T16:38:44.536Z","etag":null,"topics":["compiler","language","macros","parser","programming","transformations","wasm","webassembly"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/simplygreatwork.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}},"created_at":"2020-03-10T02:07:54.000Z","updated_at":"2023-09-21T23:11:47.000Z","dependencies_parsed_at":"2023-09-07T04:46:36.013Z","dependency_job_id":null,"html_url":"https://github.com/simplygreatwork/pluck","commit_stats":null,"previous_names":["simplygreatwork/pluck"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/simplygreatwork/pluck","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplygreatwork%2Fpluck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplygreatwork%2Fpluck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplygreatwork%2Fpluck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplygreatwork%2Fpluck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simplygreatwork","download_url":"https://codeload.github.com/simplygreatwork/pluck/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplygreatwork%2Fpluck/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261841960,"owners_count":23217914,"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":["compiler","language","macros","parser","programming","transformations","wasm","webassembly"],"created_at":"2025-03-04T00:54:19.437Z","updated_at":"2025-06-25T09:07:43.612Z","avatar_url":"https://github.com/simplygreatwork.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# pluck\n\n- **pluck** is a modular and composable programming language construction kit.\n- Get started with WebAssembly text format syntax and macros.\n- Create and use macros to construct your own programming language features.\n- Additional [project documentation](https://www.notion.so/pluck-ad6047f9dd6e4c2dbadd89c69c6914fd) is hosted at Notion.\n\n### Create a macro to recognize and transpile [integer values](/macros/number.js) to WebAssembly\n```javascript\n\nenter : function(node, index, parents, state) {\n  \n  if (! shared.is_inside_function(state)) return\n  if (! query.is_type(node, 'number')) return\n  let parent = query.last(parents)\n  if (query.is_type_value(parent.value[0], 'symbol', 'i32.const')) return\n  if (query.is_type_value(parent.value[0], 'symbol', 'br')) return\n  if (query.is_type_value(parent.value[0], 'symbol', 'br_if')) return\n  parent.value[index] = parse(` (i32.const ${node.value})`)[0]\n}\n```\n\n### Create a macro to configure function [parameters](/macros/accepts.js)\n```javascript\n\nenter : function(node, index, parents, state) {\n  \n  let parent = query.last(parents)\n  if (! query.is_type(parent, 'expression')) return\n  if (! query.is_length_exceeding(parent, 2)) return\n  if (! query.is_type_value(parent.value[0], 'symbol', 'func')) return\n  if (! query.is_type_value(parent.value[2], 'symbol', 'accepts')) return\n  iterate(state.func.value, function(each, index) {\n    if (index \u003c= 2) return true\n    if (query.is_type(each, 'expression')) return false\n    if (query.is_type(each, 'whitespace')) return true\t\t\t// whitespace should be folded already but encountered an issue anyway\n    let value = shared.dollarize(each.value)\n    parent.value[index] = parse(` (param ${value} i32)`)[0]\n    return true\n  })\n  parent.value.splice(2, 1)\n  parent.emit('removed', 2)\n  state.locals = shared.find_locals(state)\n}\n```\n\n### [Install](/compiler/config.js) your macros\n\n```javascript\nmacros: [\n  ...\n  require('./macros/accepts.js')\n  require('./macros/number.js')\n  ...\n]\n```\n\n### Write [example](/examples/demo.wat.watm) code to use your new macros\n\n```wat\nmodule\n  \n  import \"../library/utility.watm\"\n  import \"../library/memory.watm\"\n  import \"../library/string.watm\"\n  import \"../library/number.watm\"\n  import \"../library/boolean.watm\"\n  import \"../library/types.watm\"\n  import \"../library/console.watm\"\n  import \"host\" \"table\" (table 1 anyfunc)\n  memory (import \"host\" \"memory\") 1\n  \n  func main\n    \n    memory_bootstrap\n    callable 42\n    \n  func callable accepts value\n    set input to value\n```\n\n### Overview\n\n- A work in process to get up and running quickly with WebAssembly text format.\n- Parses WebAssembly .wat files, transforms using macros, and launches the project's main function.\n- s-expressions in WebAssembly text format are parsed using a fork of the simple, tiny parser combinator library: uparse\n  - https://github.com/jimf/uparse\n- The parser infers s-expression statements from indentations in the source code.\n- Transformations for string building and automatic module importing and exporting are included.\n- Each module's functions are exported automatically using macros.\n- Each module's functions are imported automatically using macros.\n- Several macros have been partially implemented such as: repeat, if, break, function references, and some logic and arithmetic operators.\n- Contains the beginning of a basic standard library in WebAssembly text format.\n  - strings, numbers, booleans, lists, maps, binary trees, assertions\n- The parser supports documentation first.\n  - Runnable wat source code can be compiled while embedded inside markdown documentation.\n\n### Structure\n\n- /examples\n- /macros\n- /library\n- /compiler\n- /runtime\n- /parser\n- /browser\n- /fixtures\n\n### Requirements\n\n- Requires Node.js\n- Tested with Node.js 13.10.1\n- Node.js 10.16.3 seems to be missing WebAssembly.Global\n\n### Run with GitPod\n\nOpen [pluck](https://gitpod.io/#https://github.com/simplygreatwork/pluck) in GitPod.\n\n```\ngit fetch \u0026\u0026 git fetch --tags\ngit checkout 2020-04-16\nnvm install 13.10.1\nnvm use 13.10.1\nnpm install\nnpm start index\nnpm start macros\nnpm start stress\nnpm start tiny\nnpm start compaction\n```\n\n### Run locally\n```\ngit clone https://github.com/simplygreatwork/pluck.git\ncd pluck\ngit checkout 2020-04-16\nnvm install 13.10.1\nnvm use 13.10.1\nnpm install\nnpm start index\nnpm start macros\n```\n\nYou can run any of the files in the examples folder. Here are some highlights:\n```\nnpm start objects\nnpm start lists\nnpm start maps\nnpm start if\nnpm start if-else\nnpm start repeat\nnpm start repeat-if\nnpm start repeat-nested\nnpm start operators\nnpm start negation\n```\n\nYou can also optionally clean, compile, and run. e.g.\n```\nnpm start index --clean\nnpm start index --no-run\nnpm start index --no-compile\nnpm start index --clean --no-run\n```\n\nIf you encounter any troubles compiling or running, use the option `--clean` or delete the `build` folder.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplygreatwork%2Fpluck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimplygreatwork%2Fpluck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplygreatwork%2Fpluck/lists"}