Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I want to learn-in-public making an interpreter for my fellow C students.

I've been working on an incremental brainfuck-and-beyond interpreter. Brainfuck is nice because you can deal with single characters rather than lexing or parsing. Right now it's just a brainfuck interpreter with all the bells and whistles you'd want animation, highlighting the loop you're in, skipping the loop you're in, memory tape visualizer, decent error messages when you write a bad loop. Here's a preview (kinda ugg because everything has to live in one file) https://ellie-app.com/nG99JJ3wt6da1

I'd like to make a bit of a writing series on this: start with BF with one instruction and a single cell tape. Expand to cover everything in BF. Then expand out to a language slightly bigger until we have the idea of scopes being a thing.

Here are the ways I was thinking of expanding the language a bit in order to bring in new concepts:

- Bring in numbers where 10> means >>>>>>>>>>. This means we need to parse more than one character at a time and introduce new ways of failing. Like maybe 5[ is a bad instruction because we don't want to have a loop in there 5 times (or maybe we do?)

- Add variables. I know that sounds antithetical, but I think it's interesting. Programs like "++^var>_var" would mean "increments the value in the current cell twice. Store that value into a variable named 'var'. Move one cell to the right. Put the value stored in 'var' into the current cell" so then we have to keep track of what variables are what. Kinda fun.

- subroutines or even better function calls so that the current scope of variables can change. I have no idea what that would be like.

Anyways, is there anything like this out there already?



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: