EmuBug

From Esolang
Jump to: navigation, search

Well, I was fascinated by Thue and wanted to write something in it ... well, why not an Interpreter. However I did not understand languages like brainfuck or underload quite well to implement them, or I was not sure how to do so and so I came up with my own.

Originally I wanted just the program to be called EmuBug (emulated bug) but then I had to name the new language so too.

By executing the program Step by Step in Debug Mode one can see a '()' moving , changing shape while executing commands coded in dot and comma ( . , ) .

The original EmuBug had a ,,, SHT command which leaved something behind, but it was replaced by a CHX command.

I hope the code is simple enough to be easily understood and be modified by whomever wants to do so.

There are two kinds of data in EmuBug. Unmarked data in which also the instructions are coded in the form of dots and commas and marked data which for some reason is called flowers and basically is changed unmarked data in the form of i and o.

Currently EmuBug does not support more than two loops in one another , thus for(i=0;i<x;++i){for(j=0;j<x;++j{}} is tested and should work while for(k=0;k<x;++k){for(i=0;i<x;++i){for(j=0;j<x;++j{}}} will not.

Programms start with a and end with w analogous to the Greek alphabets alpha and omega which look similar.

EmuBug allows to change the code by INC and DEC by the help of SET and UST.

Here's a list of commands:

Commands 
NOP ... does nothing and the bug passes seen through 
CHX ,,, bug splits and checks flower value if zero the bug moves two commands further 
SET .., bug transforms the next six bits to flowers(o or i) ; goes in this -> direction
UST ,.. bug transforms the next encounting six flowers ( o i ) to normal (. ,) ; goes back <-
        (wouldn't make much sense without that feature)
         ((in worst case runs on the 'a' on the beginning and this was it))  
GBK ,., bug goes back to the next HER command
       by running on another GBK command one HER command on the way will be ignored
       (thus just one loop in another one is supported)
      ((in worst case runs on the 'a' on the beginning and this was it))  
HER .,. bug who goes back halts HERe
INC ,,. "bug" increments marked flowers by splitting and going back to them 
        ((in worst case runs on the 'a' on the beginning and this was it))  
DEC .,, "bug" decrements marked flowers by splitting and going back to them 
        ((in worst case runs on the 'a' on the beginning and this was it))    

Well, here are some sample programs to see some action.


programm set flowers and go back to HER 
a'()'.......,.........,...,,,......,.,......,,,w
NOP NOP HER NOP NOP SET oooiii NOP NOP GBK NOP NOP ...  
programm increment in loop 
a'()'.......,.........,...,,,......,,....,.,......,,,w
NOP NOP HER NOP NOP SET oooiii NOP NOP INC NOP GBK NOP NOP ... 
programm decrement in loop 
a'()'.......,.........,...,,,.......,,...,.,......,,,w 
NOP NOP HER NOP NOP SET oooiii NOP NOP DEC NOP GBK NOP NOP ...
programm grow flowers and harvest them (SET and UST) 
a'()'.......,.........,...,,,......,.....,.,......,,,w
NOP NOP HER NOP NOP SET oooiii NOP NOP UST NOP GBK NOP NOP ...


programm chaos outbreak ... modifies the code with SET, INC and UST 
a'()'.......,......,.,...,......,,....,.....,.,w
NOP NOP HER NOP SET oioooi NOP NOP INC NOP UST NOP GBK 
programm "KodIng" 4 FuN (only worked in an earlier version where the SHT command existed) 
a'()'.,....,,,,,,,,,...,.,w
HER NOP SHT SHT SHT NOP GBK 
delete the CHX lines in the source code and add '()',,,::=,,,...'()'

programm checked loop ( C-equivalent for(i=0;i<2;++i){} )
a'()'.......,...,....,.....,,,,,,.,...,........w
NOP NOP HER SET 000 002 NOP DEC CHX GBK NOP UST NOP NOP 

Finally , you wanna try it out and thus you need the interpreter and there it is.

#::=..'()'.and.whats.in.between.is.the.state.of.the.emulated.cpu
#::=..which.looks.like.a.moving.bug.and executes.the.commands.o.
#::=...in.the.beginnig.it.should.be.the.first.in.the.data.section.
#::=...---..thus.after.::=...
#::=
#::=the.bug.goes.through.the.commands/data.encode.with.'.'(dot).and
#::=','.(comma).
#::=...IT.IS.GOOD.THE.FIRST.CHARACTER.BE.'a'.AND.THE.LAST.'w'..in.the.data.area.after.::=
#::=implementation.of.the.NOP.command
'()'...::=...'()'
#::=implementation.of.the.CHX.command
'()',,,::=<[Z)',,,
,<[Z::=<[Z,
.<[Z::=<[Z.
o<[Z::=<[Co
.<[C::=.>T>
,<[C::=,>T>
o<[C::=<[Co
i<[C::=i>f>
i<[Z::=i>f>
a<[Z::=a'(
>f>o::=o>f>
>f>i::=i>f>
>f>.::=.>f>
>f>,::=,>f>
>f>)',,,::=,,,'()'
>T>o::=o>T>
>T>i::=i>T>
>T>.::=.>T>
>T>,::=,>T>
>T>)',,,::=,,,X>
X>...::=...'()'
X>..,::=..,'()'
X>.,.::=.,.'()'
X>,..::=,..'()'
X>,.,::=,.,'()'
X>.,,::=.,,'()'
X>,,.::=,,.'()'
X>,,,::=,,,'()'
#::=implementation.of.the.SET(..,).command.;.transforming.data.to.flowers(o,i)
'()'..,::=..,'(s)'
'(s)'.::=o'(1s)'
'(1s)'.::=o'(2s)'
'(2s)'.::=o'(3s)'
'(3s)'.::=o'(4s)'
'(4s)'.::=o'(5s)'
'(5s)'.::=o'()'
'(s)',::=i'(1s)'
'(1s)',::=i'(2s)'
'(2s)',::=i'(3s)'
'(3s)',::=i'(4s)'
'(4s)',::=i'(5s)'
'(5s)',::=i'()'
'(s)'o::=o'()'
'(s)'i::=i'()'
'()'o::=o'()'
'()'i::=i'()'
#::=implementation.of.the.UST(,..).command.;.transforming.flower(oi).to.data(.,)
'()',..::=,..'(u)'
o'(u::='(1u.
o'(1u::='(2u.
o'(2u::='(3u.
o'(3u::='(4u.
o'(4u::='(5u.
o'(5u::='(.
i'(u::='(1u,
i'(1u::='(2u,
i'(2u::='(3u,
i'(3u::='(4u,
i'(4u::='(5u,
i'(5u::='(,
.'(u::='(u.
,'(u::='(u,
a'(u::=a'(
#::=implementation.of.GBK(,.,).ah,yeah,and..HER
'()',.,::='(<-!)~,.,
...'(<-!)~::='(<-!)~...
..,'(<-!)~::='(<-!)~..,
,..'(<-!)~::='(<-!)~,..
,,.'(<-!)~::='(<-!)~,,.
.,,'(<-!)~::='(<-!)~.,,
,,,'(<-!)~::='(<-!)~,,,
.,.'(<-!)~::=.,.'()'
o'(<-!)~::='(<-!)~o
i'(<-!)~::='(<-!)~i
,.,'(<-!)~::='(<-H)~,.,
.,.'(<-H)~::='(<-!)~.,.
,.,'(<-H)~::='(<-H)~,.,
...'(<-H)~::='(<-H)~...
..,'(<-H)~::='(<-H)~..,
,..'(<-H)~::='(<-H)~,..
,,.'(<-H)~::='(<-H)~,,.
.,,'(<-H)~::='(<-H)~.,,
,,,'(<-H)~::='(<-H)~,,,
o'(<-H)~::='(<-H)~o
i'(<-H)~::='(<-H)~i
'()'.,.::=.,.'()'
a'(<-!)~::=a'()'
#::=implementation.of.INC(,,.)
'()',,.::=,,.<+)'
.<+::=<+.
,<+::=<+,
o<+::=i'(
i<+::=<+o
.i<+::=.o'(
,i<+::=.o'(
'(.::=.'(
'(,::=,'(
'(o::=o'(
'(i::=i'(
a<+::=a'(
#::=implementation.of.DEC(.,,)
'()'.,,::=.,,<-)'
.<-::=<-.
,<-::=<-,
i<-::=o'(
o<-::=<-i
.o<-::=.i'(
,o<-::=.i'(
a<-::=a'(
::=
a'()'.......,...,....,.....,,,,,,.,...,........w