{"id":16892391,"url":"https://github.com/lunakoly/cash","last_synced_at":"2026-05-20T04:45:31.186Z","repository":{"id":67240993,"uuid":"342365685","full_name":"lunakoly/Cash","owner":"lunakoly","description":"Zi best command-line interpreter. Legacy: github.com/lunakoly/CashLegacy","archived":false,"fork":false,"pushed_at":"2021-07-07T20:59:25.000Z","size":1171,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-25T09:43:39.904Z","etag":null,"topics":["command-line","shell"],"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/lunakoly.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-02-25T20:07:13.000Z","updated_at":"2022-01-07T10:28:20.000Z","dependencies_parsed_at":"2023-02-21T11:15:21.989Z","dependency_job_id":null,"html_url":"https://github.com/lunakoly/Cash","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/lunakoly%2FCash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lunakoly%2FCash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lunakoly%2FCash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lunakoly%2FCash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lunakoly","download_url":"https://codeload.github.com/lunakoly/Cash/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244583190,"owners_count":20476233,"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":["command-line","shell"],"created_at":"2024-10-13T17:11:14.927Z","updated_at":"2026-05-20T04:45:31.120Z","avatar_url":"https://github.com/lunakoly.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cash\n\nYeah, one more shell... I was wondering if I could make a flexible shell with minimalistic syntax, and what problems I would face if I try. So, that's it.\n\nBefore Rust, I'd been using C++ for Cash, and the old source code can be found here: [Legacy Cash](https://github.com/lunakoly/CashLegacy)\n\n## Project Structure\n\nThere're several crates:\n\n* `helpers` - Common pieces of Rust code I use all the time. For instance, due to the lack of Kotlin-like Elvis operator `?:`, I made my own `elvis!` macro and shortcuts for `Option` and `Result`.\n* `degen` - Helps generating source code. Contains some handy `render*()` functions for rendering various Rust (and possibly non-Rust) code structures (these are simple template-processing functions with some sort of indent management). Code generation is necessary for the Visitor pattern and some other things.\n* `building` - This contains code that parses some input JSON's of my internal format and generates resulting Rust code. This module uses `degen` for source code generation.\n* `parsing` - This defines the `Stream` abstraction - a simple API for working with data that flows sequentially, and contains a bunch of typical implementations. Also contains a TDLtR parser implementation that can handle left-recursion.\n* `frontend` - Contains everything related lexical analysis and parsing. It's `build.rs` uses `building`. Parser input data structures (`Rule`'s) are generated from `grammar.json`, and AST nodes are defined via `ast.json`.\n* `processing` - Functions for running processes in a platform-independent way.\n* `backend` - Contains code relevant to the actual command execution, defines `Value`'s and such things.\n* `terminals` - Module that implements a custom user input management (because I wanted to see how I could implement such a thing manually, in a platform-dependent way).\n\n## Cash Parser\n\nInitially I was going to use a parser without a tokenizer (hello, `cherry`), but later decided that parsing `{ a, b -\u003e command }` without a tokenizer would be a bit hard, so I implemented a top-down left-to-right parser that can handle left recursion.\n\nFor example, here's a piece of grammar:\n\n```json\n\"plus\": {\n    \"@plus + @times\": \"handle_binary\",\n    \"@plus - @times\": \"handle_binary\",\n    \"@times\": \"handle_pass\"\n},\n```\n\nInstead of _just_ trying to apply a single rule from `plus` to the token stream, we are _trying to apply the rule as many times as we can_. For simple rules (non-left-recurrent) it makes no difference - after applying the first time, we \"have a value of type `@plus` on top of our hypothetical token stack\", and being a non-left-recurrent means, it's first item is not `@plus`. But we can then in a loop attempt to apply left-recurrent rules as much times as we'd like :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flunakoly%2Fcash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flunakoly%2Fcash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flunakoly%2Fcash/lists"}