https://github.com/bf-enterprise-solutions/ed.bf Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Resources + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} bf-enterprise-solutions / ed.bf Public * Notifications * Fork 0 * Star 32 Infinitely configurable integrated IDE and text editor 32 stars 0 forks Activity Star Notifications * Code * Issues 0 * Pull requests 0 * Actions * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Security * Insights bf-enterprise-solutions/ed.bf This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. master Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 2 branches 7 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/b] Use Git or checkout with SVN using the web URL. [gh repo clone bf-ent] Work fast with our official CLI. Learn more about the CLI. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @aartaka aartaka README: Mention number commands. ... 8b917f5 Oct 8, 2023 README: Mention number commands. 8b917f5 Git stats * 65 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time licenses licenses/TERMS-OF-SERVICE: Add. August 20, 2023 18:16 CONTRIBUTING CONTRIBUTING: Update. March 13, 2023 23:17 Makefile Rename to ed.bf. December 29, 2022 14:25 README.bf README: Mention number commands. October 8, 2023 13:18 ed.bf ed.bf: Add copyright notice. August 21, 2023 17:29 View code README.bf [ED.BF---AN OPINIONATED ED RE-IMPLEMENTATION IN BRAINFUCK The original grep [as part of ed text editor] was written [overnight] in PDP-11 assembly language [by Ken Thompson]. -- Brian Kernigan, in the YouTube Computerphile video about grep (https://www.youtube.com/watch?v=NTfOnGZUZDk). Not being Ken Thompson is a struggle every working software engineer has to contend with. -- David Gillies, a YouTube comment under the same video. UNIX ed is notorious for being the most user-hostile text editor. It was initially implemented in assembly. Brainfuck is notorious for being one of the most programmer-hostile programming languages. It is extremely close to assembly. Feels like a perfect match for one get the feel of the legendary programmer existence, doesn't it? ed.bf is an incomplete, buggy and (potentially) Turing-complete re-implementation of UNIX ed in Brainfuck. It is ALREADY non-standard in where we feel it necessary. The memory layout (see below) it has allows for terrible hacks and more efficient text editing if you understand it. It will NEVER be fixed and will always stay overrestrictive/hackable. Enjoy. [1 GETTING STARTED Clone the code: [shell: git clone https://github.com/bf-enterprise-solutions/ed.bf.git] Find the proper implementation. ed.bf work only on implementations where: - All cells are initially zeroed. - Tape size is at least 122 * cell size (see layout for why). - Cell wraparound works in both directions. Run ed.bf and enjoy the most user-and-programmer-hostile text editor!] [2 ED.BF COMMANDS - 'c' to change the current line. - 'd' to remove the current line (flush it clean, basically). Moves all the filled lines after the deleted one to cover it. - 'p' to print the current line. - '=' to print the current line number. Even if the line is empty. - newline to go to next line. - '-' to go to previous line. - Any number to go to the respective numbered line. - '!' to evaluate Brainfuck code on the current line contents. Given that Brainfuck implies no underlying OS, there's no shell. Thus, the meta-evaluation of Brainfuck code is as close to ed's '!' meaning as we can get. Uses meta.bf (https://github.com/bf-enterprise-solutions/meta.bf) internally. - 'q' to exit ed.bf.] [3 EXAMPLE SESSION This is simply a free-style copy of the example ed session from Wikipedia (https://en.wikipedia.org/wiki/Ed_(text_editor)#Example). Lines starting with '>' are user input. Note that ed.bf doen't do any indication of when to input commands, much like original ed. Thus, these '>' were added for clarity and shouldn't be there in the actual session. Also note that ed.bf doesn't yet support comments, neither on the line by themselves nor inline. Those were added for clarity too. Using those can break ed.bf. Or it won't do anything, who knows... ========================================================================= # bff is used as bf interpreter there, but any other # interpreter/compiler should be fine too $ bff ed.bf # run ed.bf > c # input one line > ed.bf is an opinionated UNIX ed re-implementation in Brainfuck. > ed.bf is an opinionated UNIX ed re-implementation in Brainfuck. > c # input another line > This is line number two. > This is line number two. > c # input empty line > > = # print a line number 3 > - # line back This is line number two. > - # line back ed.bf is an opinionated UNIX ed re-implementation in Brainfuck. > - # line back, but there's nowhere to go ? > p # print current line ed.bf is an opinionated UNIX ed re-implementation in Brainfuck. > ! [.>]+++++ +++++.[-] # run a script ed.bf is an opinionated UNIX ed re-implementation in Brainfuck. > q # quit =========================================================================] [3 MEMORY LAYOUT Layout is approximately this: [0][80 command cells][0][80 text cells (a line)][0][80 command cells][0] etc. 80 text cells mean a restriction of 80 characters per line. Enforcing this otherwise optional thing helps to ensure the layout stability. 80 command cells need a further explanation. After the command parsing, their layout is: [line number/exit flag][start line number][end line number][command flag][command][75 argument cells] This layout hints at some more restrictions that ed.bf has: - Line number is one cell, and thus there can only be as many lines, as cell capacity allows. For 8 bit implementations, 255 is the maximum line number. Pick a 16/32/64 bit implementation if you want more lines. - Same restriction holds for start and end line numbers. - Line number serves as the exit flag. If it's zero, ed.bf exits. Thus, the range of values for line numbers is 1 to 255. - Commands can only be one char wide, as in classic ed. - There are only 75 cells for arguments. Anything wider will break ed.bf in horrible ways. Unless you know what you're doing, restrict your command arguments to 75 characters. - Command flag is the flag used for the command switch. It should be zero unless the current command is not yet processed. - Start and end line numbers are not yet used, but will be... one day. You can hack the layout, if you want. It is trivial to rewrite command/line areas by supplying overly long input.] [4 TO DO - [ ] More commands -- [ ] Simple commands ('a', 'd', '=' etc.) --- [X] '=' -- half-standard: indexes lines from 1. Prints current line, instead of the last line. --- [X] 'q' -- non-standard: does not prompt for confirmation. Brainfuck has no file handling anyway. --- [X] 'c' -- non-standard: inserts exactly one line terminated by newline. Creates the line if necessary. --- [X] 'p'. --- [X] newline -- non-standard: moves forward and prints next line unless it's an empty line. Stays on this empty line. --- [X] 'd'. --- [X] Standalone '-'. -- [ ] Commands with args ('s' etc.) -- [ ] OS-specific placeholders ('w', 'r'). -- [ ] Commands with optional args. -- [X] Meta-evaluation with '!'. - [ ] Addresses. -- [X] Address without a command -- half-standard: moves to lines that don't even exist yet. Enjoy. -- [X] Simple addresses ('1', '222'). -- [ ] Ranges ('10,20'). -- [ ] Address aliases (',' and '.', '$', ';', '%'). -- [ ] Relative addresses ('-10'). -- [ ] Mark addresses ('k', '''). -- [ ] Forward regexp addresses. -- [ ] Backward regexp addresses. -- [ ] Addresses with commands. - [ ] Make ed.bf embeddable. -- [ ] Terminate on the same memory cell that ed.bf started on. -- [ ] Clean up the memory before terminating. - [ ] Use GNU m4 macros to reduce code repetition. -- Is that worthy of Brainfuck programmer? No, it's not. --- Do I care? Depends on how much bloat I'll end up with.] [5 CHANGE LOG Version 1.5.7-revision-12 - Integrate meta.bf nested loops support. Version 1.4: - Rename to ed.bf and polish the code a bit. Version 1.3: - Add meta-evaluation in with the help of meta.bf (https://github.com/bf-enterprise-solutions/meta.bf). Version 1.2 - A new and minimal bfed-min.bf Version 1.1 - Command sectors are 80 cells long now. Version 1.0 - Finally, a full range of editing primitives: =, -, newline, c, d, p.]] About Infinitely configurable integrated IDE and text editor Topics interactive text ide brainfuck text-editor brainfuck-programs ed brainfuck-ide Resources Readme Activity Stars 32 stars Watchers 1 watching Forks 0 forks Report repository Releases 7 tags Languages * Brainfuck 99.8% * Makefile 0.2% Footer (c) 2023 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time.