{"id":13749010,"url":"https://github.com/notJoon/lambda","last_synced_at":"2025-05-09T11:31:47.293Z","repository":{"id":152659618,"uuid":"626747923","full_name":"notJoon/lambda","owner":"notJoon","description":"λ-calculus parser made by rust","archived":false,"fork":false,"pushed_at":"2023-04-21T03:47:44.000Z","size":18,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-06T08:52:47.016Z","etag":null,"topics":["json","lambda-calculus","parser","rust"],"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/notJoon.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-12T04:48:14.000Z","updated_at":"2023-04-17T01:07:51.000Z","dependencies_parsed_at":"2023-06-16T15:30:11.293Z","dependency_job_id":null,"html_url":"https://github.com/notJoon/lambda","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/notJoon%2Flambda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notJoon%2Flambda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notJoon%2Flambda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notJoon%2Flambda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/notJoon","download_url":"https://codeload.github.com/notJoon/lambda/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253240350,"owners_count":21876593,"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":["json","lambda-calculus","parser","rust"],"created_at":"2024-08-03T07:00:53.911Z","updated_at":"2025-05-09T11:31:43.358Z","avatar_url":"https://github.com/notJoon.png","language":"Rust","funding_links":[],"categories":["Projects"],"sub_categories":["Libraries"],"readme":"# Lambda Calculus Parser\n\nThis is a parser for **λ-calculus** expressions. It takes a  λ-terms as input, parses it and returns a JSON representation of the term. The parser currently supports  λ-abstractions, variables and function applications. It uses a recursive descent parsing technique.\n\n## Features\n\n- Parses λ-abstractions, variables and function applications\n- Returns a JSON representation of the parsed λ-term\n- Includes a REPL for interactive parsing\n\n## Usage\n\nThe parser is implemented as a **`Parser`** struct with several methods. It uses a `Peekable\u003cChars\u003e` iterator to read the input string single characters at a time. The main parsing function, `parse_term`, loop over the input string and determine the appropriate parsing function to call based on the current character.\n\nThe parsing functions are:\n\n- `parse_lambda` : Parsed a λ-abstraction(e.g., `λx.x`)\n- `parse_application` : Parses a function application (e.g., `(f x)`)\n- `parse_variable` : Parses a variable (e.g., `x`)\n\nThe parser returns an enum **`Term`**, which can be one of the following:\n\n- `Lambda`: Represents a λ-abstraction with a binding variable and a body\n- `Application`: Represents a function application with a function and an argument\n- `Variable`: Represents a variable with a name\n- `Null`: Represents an empty term or failed parsing\n\nThe parsed `Term` is then converted to a JSON format using the `term_to_json` function. which converts the `Term` to a `serde_json::Value` object.\n\n## Example\n\nHere's an example of how to parse a λ-term using the parser:\n\n```rust\nfn main() {\n    let input = \"λf. λx. (f x)\";\n    let term = parse(input);\n    let json = term_to_json(\u0026term);\n    println!(\"{}\", serde_json::to_string_pretty(\u0026json).unwrap());\n}\n```\n\nThis will output:\n\n```json\n{\n  \"bind\": \"f\",\n  \"body\": {\n    \"bind\": \"x\",\n    \"body\": {\n      \"arg\": {\n        \"name\": \"x\",\n        \"tag\": \"var\"\n      },\n      \"func\": {\n        \"name\": \"f\",\n        \"tag\": \"var\"\n      },\n      \"tag\": \"application\"\n    },\n    \"tag\": \"lambda\"\n  },\n  \"tag\": \"lambda\"\n}\n```\n\n\u003e **Note:** There is a problem that the position of the tag goes down when print the current JSON. This will be fixed in the future.\n\nTo use the REPL, run the following command:\n\n```bash\ncargo run\n```\n\nAfter that, you can enter a λ-term and press enter to parse it. The REPL will print the parsed JSON representation of the term.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FnotJoon%2Flambda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FnotJoon%2Flambda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FnotJoon%2Flambda/lists"}