Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: Scipi on September 28, 2011, 08:53:24 pm

Title: [Lua]Brainf*ck Interpreter
Post by: Scipi on September 28, 2011, 08:53:24 pm
So I'm starting to learn brainf*ck. So I decided it would be fun to create a quick brainf*ck interpreter in Lua for use on the nspire. :D

I am 99% finished except that the input and output don't work yet. So here's the code if anyone can spot where I'm going wrong. :)

http://pastebin.com/8akS6P9H (http://pastebin.com/8akS6P9H)

Spoiler For Spoiler:
I will also be making a whitespace IDE after this ;D

Thanks![/s]

I have finished the first working version of this program! XD I've attached the source as well as the exe.

Usage is as follows: when you start, you can immediately start writing bf code. You can only use the characters ,.<>[]+- though. Let me know if you want to change that.

Currently there is no word wrap. I need ideas on how to do that. Backspace will delete the last character and arrow keys do nothing.

Press enter to execute and kill the program.

After this will come a whitespace IDE as well.  :w00t:

This project is still incomplete though, and will be for a while.
Title: Re: [Lua]Brainf*ck Interpreter
Post by: chattahippie on September 28, 2011, 08:54:42 pm
Yay! Whitespace is the best!
Title: Re: [Lua]Brainf*ck Interpreter
Post by: boot2490 on September 28, 2011, 09:08:26 pm
May I be stupid:
What is brainf*ck?
Title: Re: [Lua]Brainf*ck Interpreter
Post by: Scipi on September 28, 2011, 09:09:49 pm
Best Language EVER :D (http://www.muppetlabs.com/~breadbox/bf/)
Title: Re: [Lua]Brainf*ck Interpreter
Post by: boot2490 on September 28, 2011, 09:13:13 pm
those examples are literally raping my brain.
199 POSTS!!!
Title: Re: [Lua]Brainf*ck Interpreter
Post by: Scipi on September 28, 2011, 09:14:54 pm
You should check out whitespace then. :P

http://compsoc.dur.ac.uk/whitespace/index.php (http://compsoc.dur.ac.uk/whitespace/index.php)
Title: Re: [Lua]Brainf*ck Interpreter
Post by: Scipi on September 29, 2011, 01:01:56 pm
I updated the pastebin code.

http://pastebin.com/5jM9gySm (http://pastebin.com/5jM9gySm)

I still can't figure out what's going wrong. I think output's working but the input is not. How would I be able to make the program pause and wait for an input?

Also, it displays but it flickers. Why is this? I think it's because I'm refreshing the screen a lot or it's trying to display two strings in the same area.
Title: Re: [Lua]Brainf*ck Interpreter
Post by: boot2490 on September 29, 2011, 03:03:16 pm
Whitespace is just unessecarily hard.
Title: Re: [Lua]Brainf*ck Interpreter
Post by: Scipi on September 29, 2011, 03:26:00 pm
I'm going to have a special mode to actually see the characters with that IDE.

To any who haven't seen the first post,

Quote
I have finished the first working version of this program! XD I've attached the source as well as the exe.

Usage is as follows: when you start, you can immediately start writing bf code. You can only use the characters ,.<>[]+- though. Let me know if you want to change that.

Currently there is no word wrap. I need ideas on how to do that. Backspace will delete the last character and arrow keys do nothing.

Press enter to execute and kill the program.

After this will come a whitespace IDE as well. 

This project is still incomplete though, and will be for a while.

The files are attached to the first post. ;)
Title: Re: [Lua]Brainf*ck Interpreter
Post by: Scipi on October 01, 2011, 12:11:39 pm
Well, I done and goofed. I realized yesterday that the nspire doesn't have the "[" and "]" easily accessible as separate characters. So I made it so "()" = "[]". :)

I also added in linebreaks via the return key (Not the enter key).

I also removed some redundancies and hopefully I managed to fix a HUGE memory leak.  ;D
Title: Re: [Lua]Brainf*ck Interpreter
Post by: Chockosta on October 01, 2011, 12:41:50 pm
Congrats !
I don't know anything about brainf*ck, but I can figure that this was not easy to do...
Title: Re: [Lua]Brainf*ck Interpreter
Post by: Scipi on October 01, 2011, 01:05:12 pm
It actually wasn't too difficult. The worst part was trying to figure out why input wasn't working at first, really. :)

Whitespace might be a little trickier because it's a little more complex than BF. I also have to figure out a way to get tabs. :S