{"id":13782516,"url":"https://github.com/johannesfrey/Ceme","last_synced_at":"2025-05-11T15:32:34.130Z","repository":{"id":68259974,"uuid":"56718469","full_name":"johannesfrey/Ceme","owner":"johannesfrey","description":"A scheme interpreter written in C (Work in Progress)","archived":false,"fork":false,"pushed_at":"2016-09-08T17:40:28.000Z","size":131,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-17T03:37:19.200Z","etag":null,"topics":[],"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/johannesfrey.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}},"created_at":"2016-04-20T20:22:25.000Z","updated_at":"2016-06-23T15:17:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"fcaba5b0-0bd9-4d89-bc16-9eec1db2b346","html_url":"https://github.com/johannesfrey/Ceme","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/johannesfrey%2FCeme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johannesfrey%2FCeme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johannesfrey%2FCeme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johannesfrey%2FCeme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johannesfrey","download_url":"https://codeload.github.com/johannesfrey/Ceme/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253588748,"owners_count":21932318,"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-08-03T18:01:38.363Z","updated_at":"2025-05-11T15:32:33.804Z","avatar_url":"https://github.com/johannesfrey.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# Ceme\n\nThis is an experimental scheme interpreter written in C for the lecture \"Design und Implementierung moderner Programmiersprachen\" at Media University Stuttgart.\n\n# Features\n\n* Interactive AST interpreter (REPL)\n* Closures and lexical scopes via inner defines/lambdas\n* Tail-call optimization through Continuation Passing via trampoline function\n* Detection if input expression is complete (REPL indicates pending if not)\n\n# Requirements\n\n* C compiler (`clang`/`gcc`). Specify accordingly by setting the CC env variable.\n* `make`\n\n# Getting started\n\n1. Install the above requirements\n2. Clone this repository\n3. Build\n  - `make` for the regular build\n  - `make debug` for the debug build\n4. Use\n  - run `./scheme` to start the REPL\n\n# Ingredients\n\n## Basic Data Types\n\n* Numbers (no Floats at the moment)\n* Strings\n* Symbols\n* Booleans\n* Lists (cons)\n* Functions\n* Nil and Void\n\n## Builtin Syntax\n\n### Own functions and variables\n\n__define__\n\n__`(define sym expr)`__\n\nDefine a variable:\n\n```\n\u003e  (define foo \"bar\")\n\u003e  foo\n\"bar\"\n```\n\nDefine a function:\n\n```\n\u003e  (define (add a b) (+ a b))\n\u003e  add\n\u003cprocedure: add\u003e\n\u003e  (add 1 2)\n3\n```\n\n__lambda__\n\n__`(lambda [(args) arg] expr ...)`__\n\nBind an anonymous lambda to a variable:\n\n```\n\u003e  (define mylambda (lambda (a) a))\n\u003e  mylambda\n\u003cprocedure: anonymous lambda\u003e\n\u003e  (mylambda \"hello\")\n\"hello\"\n```\n\nBind varargs to a symbol:\n\n```\n\u003e  ((lambda a a) 1 2 3 4)\n(1 2 3 4)\n```\n\n### Control statements\n\n__`(if expr expr expr)`__\n\n```\n\u003e  (if #t \"t\" \"f\")\n#t\n```\n\n### Environment mutation\n\n__`(set! symbol expr)`__\n\nSet a variable to a new value\n\n```\n\u003e  (define foo \"foo\")\n\u003e  foo\n\"foo\"\n\u003e  (set! foo \"bar\")\n\u003e  foo\n\"bar\"\n```\n\n### Quoting input\n\n__`(quote expr)`__ or shorter: __`'expr`__\n\nReturns the unevaluated expr. Good for quickly creating lists.\n\n```\n\u003e  (quote (1 2 3))\n(1 2 3)\n\u003e  'foo\nfoo\n```\n\n## Builtin Functions\n\n### Arithmetic Functions (only for Numbers)\n\n__`(+ expr ...)`__\n\n```\n\u003e  (+ 1 2 3)\n6\n```\n\n__`(- expr ...)`__\n\n```\n\u003e  (- 1 2 3)\n-4\n```\n\n__`(* expr ...)`__\n\n```\n\u003e  (* (+ 1 2 3) (- 1 2 3))\n-24\n```\n\n__`(/ expr ...)`__\n\n```\n\u003e  (/ 8 2)\n4\n```\n\n### Pair Functions\n\n__Pair creation__\n\n__`(cons expr expr)`__\n\nCreate a well-formed list:\n\n```\n\u003e  (cons 1 (cons 2 nil))\n(1 2)\n\n// or via quote\n\u003e  '(1 2)\n(1 2)\n```\n\nCreate a dotted pair:\n\n```\n\u003e  (cons 1 2)\n(1 . 2)\n```\n\n\u003cbr\u003e\n\n__Pair retrieval__\n\n__`(car expr)`__\n\nGet the left part of a pair:\n\n```\n\u003e  (car '(1337 4711))\n1337\n```\n\n__`(cdr expr)`__\n\nGet the right part of a pair:\n\n```\n\u003e  (cdr '(1337 4711))\n(4711)\n```\n\n\u003cbr\u003e\n\n__Pair mutation__\n\n__`(set-car! expr expr)`__\n\nMutably set the left part of a pair:\n\n```\n\u003e  (define mylist '(123 456))\n\u003e  mylist\n(123 456)\n\u003e  (set-car! mylist 321)\n\u003e  mylist\n(321 456)\n```\n\n__`(set-cdr! expr expr)`__\n\nMutably set the right part of a pair:\n\n```\n\u003e  (define mylist '(123 456))\n\u003e  mylist\n(123 456)\n\u003e  (set-cdr! mylist 789)\n\u003e mylist\n(123 . 789)\n```\n\n### Compare Functions\n\n__Equality__\n\n__`(= expr expr)`__ Numbers only\n\n```\n\u003e  (= 123 123)\n#t\n```\n\n__`(eq? expr expr)`__ Reference only; no deep equals at the moment\n\n```\n\u003e  (define foo \"foo\")\n\u003e  (define bar foo)\n\u003e  (eq? foo bar)\n#t\n```\n__Less than__\n\n__`(\u003c expr expr)`__ Numbers only\n\n```\n\u003e  (\u003c 1 123)\n#t\n```\n\n### Boolean type check Functions\n\n`(number? expr)`\n\n`(symbol? expr)`\n\n`(string? expr)`\n\n`(cons? expr)`\n\n`(function? expr)`\n\n`(builtin-function? expr)`\n\n`(syntax? expr)`\n\n`(builtin-syntax? expr)`\n\n`(binding? expr)`\n\n# Todos and Problems\n\n* There is no garbage collection at the moment (naiv mallocing everywhere ;))\n* A wide range of builtin syntax and functions is still missing\n* Still enough edge cases where random errors creep in\n* Code style inconsistencies\n* Refactoring\n* Harness the power of continuations (call/cc etc.)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohannesfrey%2FCeme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohannesfrey%2FCeme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohannesfrey%2FCeme/lists"}