Here the first program I made with TIC:
a BrainF**k interpreter in moonscript
--[moonscript] --brainfuck interpreter by oSchyns --v0.2.0 BF="++++ ++++".. "[>+++++ +++++<-]".. ">++++.----- ----- -.--- ---."--.. --uncomment to test error output --"<< force a tape outbound" IN="" --tape to perform computation class Tape new:(l,m)=> @l=l --cell limit @m=m --loop the finite tape @t={} --tape @h=0 --read head --correct values @l-=1 if @l~=nil @m-=1 if @m~=nil --rhead out of the bounds of the tape unbound:=> if @m~=nil then return @h>@m @h<0 --init nil cell to zero init:=> @t[@h]=0 if @t[@h]==nil --move read head to the left mvL:=> @h-=1 if @m~=nil then if @h<0 @h=@m --move read head to the right mvR:=> @h+=1 if @m~=nil then if @h>@m @h=0 --decreament cell decr:=> @init! @t[@h]-=1 if @l~=nil then if @t[@h]<0 @t[@h]=@l --increament cell incr:=> @init! @t[@h]+=1 if @l~=nil then if @t[@h]>@l @t[@h]=0 --ins: insert value in cell --out: get value from cell ins:(i)=> @t[@h]=i if i~=nil out: => @t[@h] or 0 --stack to hold indexes of brackets class Stack new: => @s={} top: => @s[#@s] pop: => @s[#@s]=nil push:(i)=> @s[#@s+1]=i --automaton to execute the program class Automaton new:(p,i,l,m)=> @t=Tape l,m --tape @s=Stack! --stack @r=1 --read head @p="" --program @i=i --input @o="" --output @e=nil --error --strip useless chars of program for c in p\gmatch "[<>%+%-%[%]%.%,]+" @p..=c b=@check! if b~=nil @e="brackets mismatch at "..b --check for brackets mismatch check:=> s=Stack! for i=1,#@p if @program(i)=='[' then s\push i elseif @program(i)==']' return i if #s.s<=0 s\pop! return s\top! if #s.s> 0 return nil --get char from input input:=> if @i==nil or @i=="" then return nil c1=@i\byte! --1st char of i @i=@i\sub 2 --remove 1st char return c1 --output: add char to output --program: get instruction at 'n' --continue: continue execution output: (n)=> @o..=string.char(n) program:(n)=> @p\sub n,n continue: => @r<=#@p and @e==nil --find matching bracket match:(b)=> m=1 while m>0 and b<=#@p b+=1 if @program(b)=='[' then m+=1 elseif @program(b)==']' then m-=1 return b --opening bracket open:=> --jump to matching bracket if (@t\out!)==0 then @r=@match @r else @s\push @r --closing bracket clos:=> if (@t\out!)==0 then @s\pop! elseif @s\top! ~=nil then @r=@s\top! --automaton's' execution step step:=> switch @program @r when '<' then @t\mvL! when '>' then @t\mvR! when '-' then @t\decr! when '+' then @t\incr! when ',' then @t\ins @input! when '.' then @output @t\out! when '[' then @open! when ']' then @clos! @r+=1 if @t\unbound! @e="tape outbound !" --create automaton 'TM' using --program 'BF' --input 'IN' TM=Automaton BF,IN,128,nil --execute 'TM' while TM\continue! TM\step! --print result of execution cls! i=0 TM.o..="\n" --print each line for o in TM.o\gmatch "[%S \t]*\n" print o,0,i*6 i+=1 --print error unless TM.e==nil print TM.e,0,130,6 export TIC=-> --http://moonscript.org/reference/ --http://moonscript.org/compiler/ --https://esolangs.org/wiki/Brainfuck --http://zacstewart.com/2013/09/15/learning-cpp-a-br...
I also put some pages I used to code it.
Should I post it it the github wiki ?