{"id":19027928,"url":"https://github.com/rexim/ebf","last_synced_at":"2026-02-27T18:41:50.340Z","repository":{"id":54303664,"uuid":"45293552","full_name":"rexim/ebf","owner":"rexim","description":"Brainfuck language transpiler to Emacs Lisp","archived":false,"fork":false,"pushed_at":"2021-02-25T12:11:24.000Z","size":31,"stargazers_count":20,"open_issues_count":11,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-02T03:18:01.849Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Emacs Lisp","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/rexim.png","metadata":{"files":{"readme":"README.org","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}},"created_at":"2015-10-31T07:52:39.000Z","updated_at":"2024-11-17T18:50:19.000Z","dependencies_parsed_at":"2022-08-13T11:30:43.782Z","dependency_job_id":null,"html_url":"https://github.com/rexim/ebf","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rexim%2Febf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rexim%2Febf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rexim%2Febf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rexim%2Febf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rexim","download_url":"https://codeload.github.com/rexim/ebf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240079610,"owners_count":19744720,"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-11-08T21:09:28.008Z","updated_at":"2026-02-27T18:41:45.292Z","avatar_url":"https://github.com/rexim.png","language":"Emacs Lisp","funding_links":[],"categories":[],"sub_categories":[],"readme":"* ebf\n\nBrainfuck language transpiler to Emacs Lisp\n\n** Usage\n\nThe brainfuck language transpiler to Emacs Lisp consists of ~ebf~\nmacro which expands to the actual Emacs Lisp code. Here is the\nsignature of this macro:\n\n#+BEGIN_SRC emacs-lisp\n\n(ebf INPUT-CALLBACK OUTPUT-CALLBACK \u0026rest INSTRUCTIONS)\n\n#+END_SRC\n\n~INPUT-CALLBACK~ is called on comma instruction and should have zero\narguments and return a number.\n\n~OUTPUT-CALLBACK~ is called on dot instruction and should have one\nargument of an integer type.\n\n~INSTRUCTIONS~ is a list of symbols and vectors of symbols. Vectors\nare accepted so we don't need to escape square brackets of our\nbrainfuck program. Symbols' names should be sequences of valid\nbrainfuck instructions excluding square brackets.\n\nEvaluation of the macro expansion causes the brainfuck program\nexecution.\n\nSo the code\n\n#+BEGIN_SRC emacs-lisp\n  (ebf input output \\,+++[-\u003e+\u003c].)\n#+END_SRC\n\nwill be expanded to\n\n#+BEGIN_SRC emacs-lisp\n  (let ((MEMORY68087 (make-vector 100 0))\n        (POINTER68088 0)\n        (INPUT68085 input)\n        (OUTPUT68086 output))\n    (aset MEMORY68087 POINTER68088 (funcall INPUT68085))\n    (cl-incf (aref MEMORY68087 POINTER68088) 3)\n    (while (not (zerop (aref MEMORY68087 POINTER68088)))\n      (cl-decf (aref MEMORY68087 POINTER68088) 1)\n      (cl-incf POINTER68088 1)\n      (while (\u003c= (length MEMORY68087) POINTER68088)\n        (let ((memory-length (length MEMORY68087)))\n          (setq MEMORY68087\n                (vconcat MEMORY68087\n                         (make-vector\n                          (max 1 (/ memory-length 2))\n                          0)))))\n      (cl-incf (aref MEMORY68087 POINTER68088) 1)\n      (cl-decf POINTER68088 1))\n    (funcall OUTPUT68086 (aref MEMORY68087 POINTER68088)))\n#+END_SRC\n\nWe collapse several instructions in a row and automatically expand the\nmemory to the right. We plan to add more optimization in the future.\n\nHere is the classical Hello World example with some output:\n\n#+BEGIN_SRC emacs-lisp\n(require 'ebf)\n\n(let ((result nil))\n  (ebf nil #'(lambda (x) (push x result))\n       ++++++++++[\u003e+++++++\u003e++++++++++\u003e+++\u003e+\u003c\u003c\u003c\u003c-]\u003e++\n       .\u003e+.+++++++..+++.\u003e++.\u003c\u003c+++++++++++++++.\u003e.+++.\n       ------.--------.\u003e+.\u003e.)\n  (apply #'string (reverse result)));\u003c- put cursor here and press C-x C-e\n#+END_SRC\n\n** Compiling ebf\n\n~ebf~ macro produces the code that doesn't depend on ~ebf~ module\nitself. That means we can byte-compile our brainfuck programs so they\nwill not require ~ebf~ at runtime.\n\nCheck [[http://www.gnu.org/software/emacs/manual/html_node/elisp/Compiling-Macros.html][Macros and Byte Compilation]] section of the official Emacs Lisp\nmanual on how to do that.\n\nBasically we will need to wrap our ~(require 'ebf)~ with\n~eval-when-compile~ like\n\n#+BEGIN_SRC emacs-lisp\n(eval-when-compile\n (require 'ebf))\n#+END_SRC\n\n** License\n\nCopyright (C) 2015 Alexey Kutepov a.k.a rexim\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frexim%2Febf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frexim%2Febf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frexim%2Febf/lists"}