{"id":13782930,"url":"https://github.com/Jim-Fan/lambda","last_synced_at":"2025-05-11T16:33:29.503Z","repository":{"id":214398303,"uuid":"118630543","full_name":"Jim-Fan/lambda","owner":"Jim-Fan","description":"Experimental interpreter for untyped lambda calculus","archived":false,"fork":false,"pushed_at":"2023-12-27T22:05:26.000Z","size":47,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-08-03T18:17:01.558Z","etag":null,"topics":["bison","flex","lambda-calculus","parser"],"latest_commit_sha":null,"homepage":"","language":"C","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/Jim-Fan.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}},"created_at":"2018-01-23T15:37:37.000Z","updated_at":"2023-12-27T22:05:30.000Z","dependencies_parsed_at":"2024-01-07T23:08:34.134Z","dependency_job_id":null,"html_url":"https://github.com/Jim-Fan/lambda","commit_stats":null,"previous_names":["jim-fan/lambda"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jim-Fan%2Flambda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jim-Fan%2Flambda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jim-Fan%2Flambda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jim-Fan%2Flambda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jim-Fan","download_url":"https://codeload.github.com/Jim-Fan/lambda/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253596026,"owners_count":21933496,"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":["bison","flex","lambda-calculus","parser"],"created_at":"2024-08-03T18:01:48.381Z","updated_at":"2025-05-11T16:33:29.268Z","avatar_url":"https://github.com/Jim-Fan.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"lambda: Interpreter for untyped lambda calculus\n===============================================\n\nSummary\n-------\nIntended to acquire better understanding of shift-reduce parsing\nafter reading \u003ci\u003eCompilers - Principles, Techniques, and Tools\u003c/i\u003e\n(authors: Aho, Sethi and Ullman), a parser for lambda calculus is\nimplemented.\n\nDue to simplicity of lambda calculus' syntax, the parser rule\nis indeed simple. Bison's shift-by-default behaviour explains\nright-associativity of expression evaluation.\n\nRudimentary evaluation has been attempted, of which the behaviour\nis incomplete, and may even lead to unexpected non-termination during\npretty-printing. See \u003ci\u003eLimitations\u003c/i\u003e section below.\n\nSignal handling and readline have once been incorporated. Correct\nbehaviour could not be trivially achieved, thus the code has been\nremoved.\n\n\nExample\n-------\n```\n$ ./lambda\n\u003e (/x. /f. f x) (/i.i) 1990;\n\u003csyntax tree\u003e\n| APP(9017)\n  | LAMBDA(9011)\n    | VAR(9010, bound to 9010) x\n    | LAMBDA(9009)\n      | VAR(9008, bound to 9008) f\n      | APP(9007)\n        | VAR(9005, bound to 9008) f\n        | VAR(9006, bound to 9010) x\n  | APP(9016)\n    | LAMBDA(9014)\n      | VAR(9013, bound to 9013) i\n      | VAR(9012, bound to 9013) i\n    | NUMBER(9015) 1990\n\n\u003cafter\u003e\n| LAMBDA(9009)\n  | VAR(9008, bound to 9008) f\n  | APP(9007)\n    | VAR(9005, bound to 9008) f\n        | NUMBER(9015) 1990\n\n\u003cbinding\u003e\nvar id: 9010    bound to: 9015\nvar id: 9013    bound to: 9015\n```\n\nNote:\n* Top-level expression is terminated with \";\"\n* \"/\" acts as keyword \"lambda\" in abstraction\n* Unlike traditional lambda notation, evaluation is right-associative\n* Interpreter responds by showing:\n  1. Syntax tree of top-level expression entered\n  2. Syntax tree of expression after evaluation\n  3. Value binding of lambda variable to its value, if any\n* See /example and /test for more\n\n\nLimitations\n-----------\n* If an expression is lambda abstraction, body of lambda is not\n  reduced. Example: /x.(/i.i) x evaluates to /x.(/i.i) x instead\n  of /x.x\n* Non-termination could arise due to cyclic pprint. For example,\n  applying [S combinator](https://en.wikipedia.org/wiki/SKI_combinator_calculus#Recursive_parameter_passing_and_quoting) to itself, see\n  [this example](https://github.com/Jim-Fan/lambda/tree/master/example/combinator.lam)\n  for detail\n\n\nBuilding and Dependencies\n-------------------------\nDevelopment is done in Cygwin environment with:\n\n* GNU Make 4.2.1\n* gcc 5.4.0\n* GNU bison 3.0.4\n* flex 2.6.4\n* Exuberant Ctags 5.8   (optional)\n\nTo compile, simple run 'make' at shell. Build has been done successfully\non Termux using clang as well. Detailed tool version is not documented\nhere.\n\n\nLearned Topics\n--------------\n* LR(1) parsing\n* Shift/reduce and reduce/reduce conflicts:\n  1. Why do they arise\n  2. How to resolve (if possible)\n* Syntax error handling with \"error\" token of bison\n\n\nAbout Testing\n-------------\nInspired by flex the lexer generator also on github, maintaining\ntest code as well as their output could help tracking parser behaviour\nand is especially useful when there is change in syntax. Output is\nessentially bison trace which needs to be carefully verified before\ncommitting.\n\nSee /test and /example for parser and evaluation tests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJim-Fan%2Flambda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJim-Fan%2Flambda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJim-Fan%2Flambda/lists"}