{"id":15657810,"url":"https://github.com/willothy/woq","last_synced_at":"2025-03-30T02:21:51.427Z","repository":{"id":108851456,"uuid":"593479323","full_name":"willothy/woq","owner":"willothy","description":"My own version of Tsoding's Noq expression transformer, with added features such as lists, constant expression evaluation and variable match type constraints.","archived":false,"fork":false,"pushed_at":"2023-02-03T07:13:53.000Z","size":17314,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-05T04:46:14.214Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","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/willothy.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-01-26T04:56:22.000Z","updated_at":"2023-02-03T07:22:29.000Z","dependencies_parsed_at":"2023-03-24T08:17:12.487Z","dependency_job_id":null,"html_url":"https://github.com/willothy/woq","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/willothy%2Fwoq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willothy%2Fwoq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willothy%2Fwoq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willothy%2Fwoq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willothy","download_url":"https://codeload.github.com/willothy/woq/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246266582,"owners_count":20749817,"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":[],"created_at":"2024-10-03T13:09:50.559Z","updated_at":"2025-03-30T02:21:51.409Z","avatar_url":"https://github.com/willothy.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Woq\n### My version of Tsoding's Noq expression transformer, with some of my own added features.\n\u003cbr\u003e\n\n## Features and Plans\n\n- [X] Pattern matching to replace expressions based on rules\n- [X] List expressions\n    - [X] Basic list usage\n    - [X] Repeating expressions in lists\n    - [X] List conversion to binary op with separators\n    - [ ] Retrieving iteration index with `@`\n- [X] Unary expression\n    - [X] `+` and `-` unary operators\n    - [X] `+` and `-` unary operators with list conversion\n- [X] Variable type constraints\n    - [X] `#` for number, `%` for string, `$` for symbol, `!` for function, `[]` for list\n    - [X] Use in rules to constrain the variable type they match\n- [X] Constant expression folding / evaluation\n    - [X] `eval` intrinsic\n    - [ ] Evaluate list exprs (dot product, vec add, etc)\n- [ ] LaTeX or other rendered math expr output (maybe)\n- [ ] Neovim integration (WIP)\n\n\n## Examples:\n\n### `Basic Expressions`:\n    Number: Positive and negative values allowed\n    String: Text enclosed in double quotes - escapes not yet supported\n    Symbol: identifier starting with a lowercase letter or underscore, matched literally\n    Variable: identifier starting with an uppercase letter, bound to a value when matching\n\n    X + 5 =\u003e Variable + Number\n    \"Hello, world!\" =\u003e String\n    foo =\u003e Symbol\n\n### `List Expressions`:\n    (1, 2, 3, 4)\n\n    Repeating patterns:\n    (N, ..) =\u003e matches (N, N, N, etc.)\n\n    Repeating pattern with conversion to binop:\n    (N, +..) =\u003e N + N + N + N ...\n\n    Vector Add:\n    (1, 2, 3) + (4, 5, 6) =\u003e List + List\n\n### `Function Expressions`:\n    f(X, Y) =\u003e Function(Var, Var)\n    f(X, Y)(G, (H, I)) =\u003e Function(Var, Var)(Var, List)\n\n### `Rules`:\n#### Definition:\n\u003ccode\u003ename \u0026#58;\u0026#58; pattern \u0026#61; replacement\u003c/code\u003e\u003cbr\u003e\nAdd single number to vector:\n\u003ccode\u003evec_add_one \u0026#58;\u0026#58; (A, ..) + N = (A + 1, ..)\u003c/code\u003e\n\u003ccode\u003e(1, 2, 3) + 5 =\u003e (1 + 5, 2 + 5, 3 + 5)\u003c/code\u003e\u003cbr\u003e\nVector add:\n\u003ccode\u003evec_add \u0026#58;\u0026#58; \u0026#40;A, ..) + (B, ..) = (A + B, ..)\u003c/code\u003e\u003cbr\u003e\nVector dot product:\n    \u003ccode\u003edot \u0026#58;\u0026#58; (A, ..) * (B, ..) = (A * B, +..)\u003c/code\u003e\n    \u003ccode style=\"margin-left: 22px;\"\u003e=\u003e (A0 * B0) + (A1 * B1) + (A2 * B2) + ...\u003c/code\u003e\n\u003c/code\u003e\n\n#### Application:\n\u003ccode\u003erule | strategy\u003c/code\u003e\u003cbr\u003e\n\u003ccode\u003edot | 0\u003c/code\u003e applies the vector dot product rule to its first match in current shape\n\u003ccode\u003evec_add | all\u003c/code\u003e applies the vec_add rule to all matches in current shape\n\n#### Checking:\nUsing the intrinsic `check` strategy, you can print all matches for a given rule. You use check the same way as a rule application strategy:\n\u003ccode\u003edot | check\u003c/code\u003e checks for matches of the dot rule in the current shape\n\u003ccode\u003evec_add | check \u003c/code\u003e checks for matches of the vec_add rule in the current shape\n\n### `Variable Constraints`:\n    X# =\u003e Number\n    X% =\u003e String\n    X$ =\u003e Symbol\n    X! =\u003e Function\n    X[] =\u003e List\n\n    Add single number to vector (with type constraints):\n    vec_add_one :: (A#, ..) + N# = (A + 1, ..)\n\n### `Constant Folding`:\n    eval | \u003cstrategy\u003e\n\n    eval is an intrinsic which matches and evaluates constant expressions.\n\n    // example uses:\n    eval | 0\n    eval | check\n\n[//]: # (Colon: \u0026#58; Open, close paren: \u0026#40;, \u0026#41;)\n[//]: # (equals: \u0026#61;)\n[//]: # (sub: \u0026#115;)\n[//]: # (sup: \u0026#115;)\n[//]: # (plus: \u0026#43;)\n[//]: # (star: \u0026#42;)\n[//]: # (tilde: \u0026#126;)\n[//]: # (underscore: \u0026#95;)\n[//]: # (comma: \u0026#44;)\n[//]: # (period: \u0026#46;)\n[//]: # (pipe: \u0026#124;)\n[//]: # (caret: \u0026#94;)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillothy%2Fwoq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillothy%2Fwoq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillothy%2Fwoq/lists"}