MNNBFSL

From Esolang
Jump to navigation Jump to search

MNNBFSL (an acronym of Mada Namae no Nai ("still unnamed") BrainFuck Fuu ("Style") Stack Language, in original Japanese まだ名前のないBrainfuck風スタック言語) - is an esoteric programming language somewhat inspired by Brainfuck and Forth. Despite the similarities to BF, MNNBFSL is stack based, while BF is cell based.

It was invented by the Japanese blogger yshl in July 2014, and the specifications were publicized in August.

The two stacks initialized at the start of a MNNBFSL program are the data stack and the return stack. The program counter is initialized to 0.

Commands

There are 10 commands, including "s" which is used for debugging.

Character Meaning
" Duplicate the top value of the data stack.
+ Increment the top value of the data stack.
- Decrement the top value of the data stack.
> Pop a value from the data stack and push it onto the return stack.
< Pop a value from the return stack and push it onto the data stack.
[ Push the value of the program counter onto the return stack.
] Pop a value from the data stack, if it equals 0 then pop a value from the return stack; else pop a value from the return stack and set the program counter to that value.
. Pop a value from the data stack and write it as an ascii byte to stdout.
, Read 1 byte from stdin, push the byte to the data stack, and push 1 to the data stack. If at the end of stdin, push 0 to the data stack.
s Print the data stack and the return stack to stderr (for debugging).
other No operation (but the program counter still increments).

Note: Trying to access a value from an empty stack should return a (data or return) stack underflow error.

Examples

Cat

[<+++++"[->+++++<"][]">"++>]  [.,]

Hello world

[<"++++++++[>++++<-"]>"++++"[>+<-"]>>"<">[>+<-"]">]<".>"---.++++".".+++".>".<"++++++++."."+++.---".--------.

Collatz sequence

[<+++++++++++++++++++++++++++(n=27)[
">[<[-"]-<[>[<[-"]"<[->>+"----------
[<"[-"]+++++++++[>+++++<-"][]>]----------<+> <<"][]"][]
+[[<[-"]++++++[>++++++++<-"][]-.+"][]    ;
___________
[<"[-"]++++++++++++[>++++++++++++<-"][]>"-][<[-"]+++++"-">>>[<[-"]<<-[>"<-"][]<-[>>>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<<-"][][->+<"][]>"]__________________
[<[-"]++++++++++.
[<[-"]>_
">[<[-"]<[->+"--[<"[-"]++++[>++++++++<-"][]>]--  <"][]_
[<"[-"]++++++[>+++++++++++<-"][]>]_
<+>"[-->-<"][]<]__
___________
<+++>>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<+"[-->-<"][][<[-"]+]

Bitwise Cyclic Tag interpreter

To input a BCT program and data, standard input should follow the format:

   /Program.Initial data-string// (Example: /00111.101//)
[,>[<[-"]+++++++[->-------<"][]++++<][+"][]>_

  ">[ "[-"]++[->-<"][]<-->]<<<_
>">[-"]<<"[->>>+<<<"][][ "[-"]+[->-<"][]<---------------------->]>">[-"]<<[->>+<<"][]>_

"[<"[-"]+++++++++++++++[->+++++++++<"][]>---]<<[-"][]> "[-"]+++++++++++++++++++++++++++"[->++++++++++++++++++++++++++++++++++<"][]">]_____________;_
  
">[ "[-"]++[->-<"][]<- -->]<<<_
>">[-"]<<"[->>>+<<<"][][ "[-"]+[->-<"][]<---------------------->]>">[-"]<<[->>+<<"][]>_ 

<<">[<"[-"]+++++++++++++++[->+++++++++<"][]>--- ]"[-"]+++++++++++++++++++++++++++"[->++++++++++++++++++++++++++++++++++<"][]">]___________________________; 

 > ">">[-"]<<"[->>>+<<<"][][ "[-"]++[->-<"][]<---------------------->]>">[-"]<<[->>+<<"][]>_ 
"[-"]+++++++++++++++++++++++++++"[->++++++++++++++++++++++++++++++++++<"][]">]
______________________________________________________________________________________________________________________________________________________
______________________________________________________________________________________________________________________________________________________
">["[-"]++[->-<"][]<-->]<"[ "[-"]+[->-<"][]<-->]
"<">[->+<"]++++++++++"[->+++++++<"][][<[->+<"][]>--- ][<[-"]---">]
______________________________________________________________________;
<"[ "[-"]++[->-<"][]<- -->"+++++++++++++++++++++++++++++++++++++++++++++++.]>[<[-"]++++++++++"."[->++++<"][]--">]

The data-string is printed to standard output after each 11, 10 or 0 instruction is executed.

Implementation

Burlesque

"### the duplicate command is represented by ' (singlequote mark) instead of double"vv
{0 {} {""} {""} "" "" {} "End Program"}jXX{J{'[ '] '- '+ '< '> ', '. '' 's}jFi+.0=={vv'_}if}m[1saPp{pPJ1!!j0!!!!
{
{'[ ==}{pPJ3!!j0!!+]pPj3saPp}
{'< ==}{pP3!!0!!""=={PP"rStack Underflow"7saJPp{0}2saPp}if pPJ2!!j3!!0!!0iaPPj2saJ3!!0RA3saPp}
{'> ==}{pP2!!0!!""=={PP"dStack Underflow"7saJPp{0}3saPp}if pPJ3!!j2!!0!!0iaPPj3saJ2!!0RA2saPp}
{'+ ==}{pP2!!0!!""=={PP"dStack Underflow"7saJPp{0}2saPp}if pP2!!J0!!+.0 saPPj2saPp}
{'- ==}{pP2!!0!!""=={PP"dStack Underflow"7saJPp{0}2saPp}if pP2!!J0!!-.0 saPPj2saPp}
{'' ==}{pP2!!0!!""=={PP"dStack Underflow"7saJPp{0}2saPp}if pP2!!J0!!0ia   PPj2saPp}
{'] ==}{pP2!!0!!""=={PP"dStack Underflow"7saJPp{0}2saPp}if pP3!!0!!""=={PP"rStack Underflow"7saJPp{0}3saPp}if pP2!!0!!{{0 !=}{pP3!!0!!PPj0saJ0!!-.0saPp} {0 ==}{"test"vv}}cne!PPJ2!!0RA2saJ3!!0RA3saPp} 
{', ==}{pP5!!nu{{0 ==}{pP5!!0!!**pP2!!j0iaPPj2saJ5!!0RA5saPp} {1 ==}{pP2!!0 0iaPPj2saPp}}cne!}
{'. ==}{pP2!!0!!""=={PP"dStack Underflow"7saJPp{0}2saPp}if pP4!!pP2!!0!!L[.+PPj4saJ2!!0RA2saPp}
{'s ==}{pP2!!<-1.-Sh"""\[|\]|,"R~" \\ ".+pP3!!<-1.-<-Sh"""\[|\]|,"R~.+"    ".+ShpP6!!j_+PPj6saPp}
{'_ ==}{PPPp}
}cne!pP0!!PPj+.0saPp
}{pPJ0!!j1!!L[.< pP7!!"End Program"==&&}w!
pP6!!"\n\nstderr:\r  "0ia"output:\n\r  "pP4!!Sh.+0ia{"  "jSh.+}m[)Qp^

Try our "Hello World!" online (dead link)

External resources

  • Various MNNBFSL resources, including an interpreter implemented in C++ and more example programs, can be found on the creator's github.
  • InMNNBFSL, a MNNBFSL interpreter implemented in Lua.
  • webMNNBFSL, MNNBFSL interpreter in Javascript with code tracing.