Interpret ><> (Fish)

APL (Dyalog) (750)

Because APL does not really have a command line, load this into a workspace (i.e. with )ed F) and then run it from the APL line like so:

      F'quine.fish'
"ar00g!;oooooooooo|

      F'hello.fish'
Hello World!

      F'stack.fish'
12543

It does not handle any errors. The behaviour of wrong code is not specified. It can't do threads either. Where the Esolang page and the question conflict, it follows the question.

Edit: a slightly more readable version with comments can be found here: https://gist.github.com/anonymous/6428866

F f
⎕IO←0
S←⍬
i←''
s←,0
D←4 2⍴D,⌽D←0 1 0 ¯1
p←0 0
v←0
r←⍬
d←0 1
M←d↓↑M⊂⍨10=M←13~⍨10,83 ¯1⎕MAP f
W←{p+←d⋄p|⍨←⍴M⋄p}
R←{⌽{v←⊃⌽S⋄S↓⍨←¯1⋄v}¨⍳⍵}
U←⎕UCS
→v/43
{L←(⍴S)-⊃⌽s
⍵∊G←'><^v':d∘←D[G⍳⍵;]
⍵∊G←'\/':d∘←⌽d×1-2×G⍳⍵
⍵∊G←'|_#':d×←⊃(1 ¯1)(¯1 1)(¯1 ¯1)[G⍳⍵]
⍵∊'x':d∘←D[?4;]
(((~×⊃⌽S)∨L≤0)∧⍵∊'?')∨⍵∊'!':{}W⍬
⍵∊'.':p∘←R 2
⍵∊G←⎕D,'abcdef':S,←G⍳⍵
⍵∊G←'+-=*,)(':S,←⊃(⍎'+-=×,><'[G⍳⍵])/R 2
⍵∊'%':S,←⊃|⍨/R 2
⍵∊'"''':v V∘←1,U⍵
⍵∊':':S,←2/R 1
⍵∊'~':{}R 1
⍵∊'$@':S,←¯1⌽R 2+⍵='@'
⍵∊G←'{}':S,←(1-2×G⍳⍵)⌽R L
⍵∊'r':S,←⌽R L
⍵∊'l':S,←L
⍵∊'[':s,←1-⍨L-R 1
⍵∊']':s↓⍨←¯1
⍵∊G←'no':⍞←(U⍣(G⍳⍵))R 1
⍵∊'&':{⍴r:r∘←⍬⊣S,←r⋄r,←R 1}⍬
⍵∊'i':i↓⍨←1⊣S,←⊃{i∘←10,⍨U⍞}⍣(⊃~×⍴i)⍨i
⍵∊'g':S,←M⌷⍨⌽R 2
⍵∊'p':((⌽1↓G)⌷M)∘←⊃G←R 3
⍵∊';':S∘←0
s≡⍬:s∘←,0⊣S∘←⍬
}U p⌷M
→45
{}{+S,←p⌷M}⍣{V=M⌷⍨W⍬}⍬
v←0
{}W⍬
→14/⍨S≢0

Haskell 1428

Almost all lowercase characters are used as function names.

P.S. Are there any game about these kind (2d pointer) esolangs ? They must be very amusing !

import qualified Data.Map as M
import System.Environment
import Data.Char
import System.Random
type I=Integer
data S=S{p::(I,I),d,e::Int,s::[I],r::S->S,m::M.Map(I,I)Char}
a=zip">v<^\\/_|x+-*,%()=:~!?$@&r{}gponi"[q 0,q 1,q 2,q 3,
 i[1,0,3,2],i[3,2,1,0],i[0,3,2,1],i[2,1,0,3],\s->do x<-randomRIO(0,3);t$s{d=x},
 h(+),h(-),h(*),h div,h mod,h$j(<),h$j(>),h$j(==),
 o(\(x:y)->x:x:y),o tail,t.g.g,\q->t$if s q==[]||head(s q)==0 then g q else q,
 o(\(x:y:z)->(y:x:z)),o(\(x:y:z:w)->(y:z:x:w)),\q->t$(r q)q,
 o reverse,o(\s->last s:init s),o(\s->tail s++[head s]),
 \q->let(i:j:x)=s q in t$q{s=l(b(i,j)q):x},
 \q->let(i:j:k:x)=s q in t$q{s=x,m=M.insert(i,j)(n k)(m q)},
 y$putChar.n,y$putStr.show,\q->do c<-getChar;t(q{s=l c:(s q)})
 ]++[(x,t.c i)|(x,i)<-zip['0'..'9'][0..9]++zip['a'..'f'][10..15]]
b p q=maybe ' 'id$M.lookup p(m q)
c x q=q{s=x:s q}
f(i,j)0=(i,j+1)
f(i,j)1=(i+1,j)
f(i,j)2=(i,j-1)
f(i,j)3=(i-1,j)
g q=q{p=f(p q)(d q)}
h f=o(\(b:a:k)->f b a:k)
i a s=t$s{d=a!!(d s)}
j f a b|f a b=1|1<2=0
k=zip[0,1..]
l=toInteger.ord
n=chr.fromInteger
o f q=t$q{s=f(s q)}
q x=i[x,x..]
t=return
u s=M.fromList.foldr1(++)$[map(\(j,x)->((i,j),x))l|(i,l)<-k$map k$lines s]
v q=let(x:y)=s q in q{r=w x,s=y}
w x q=q{s=x:(s q),r=v}
y o q=let(i:x)=s q in o i>>t(q{s=x})
z q=[[[y=<<(maybe t id$lookup x a)q,t()]!!j(==)x ';',y$c(l x)q]!!k,w]!!j elem x"'\""
 where k=e q;x=b(p q)q;w=y$q{e=1-k};y=z.g
main=z.S(0,0)0 0[]v.u=<<readFile.head=<<getArgs

An Example Fish Program

mm  v                           
   >              v
   ~>1f+00p       v                     
    ;v?)+afg00    <             #<-- Condition of loop 1
   p>>~ 410p      v             
   0vv?)+cfg01    <  <          #<-- Condition of loop 2
   00>~10g00gg'.'=?v~     v     #<-- Go this route when 
   +0    vp01+1g01~<            #    we find a digit.
   1g    >           ^   
   ^<                      
   v                      <   
                          >       >~      ;
0  >10g0cg"0"$-+00gg:" "=?^~:"."=?^v   
   ^     pc0+1gc0 n-$"0"          ~<

    .......................  
    .......................  
    ......112233...........   This program prints 
    .......................   the number on this field.
    .......................     <------------
    .......................  
    .......................      
    .......................       
    .......................       

><>, 443 bytes

e1r>i::1)$a-*?v{2v
xys^p}+1$}:{:{<
v0{^?)1p}1}+1:{0-<
/rp130p120p210p110p100p00-f{p2
>01g1+11ge+g:0=' '$?$~:21g?v:'"'=$"'"=+?v  :'.'=?v::'p'=$'g'=+?/79p02g1+12g8+.
>03         v20~v?-g12     <1p12        <0p10p11~<
?!  .!p20p21\1p v
g 7a^ v<~<  
 < 69. >001-^.98
1<78v//o!^10^~
3^ 1.!0<
^^ 0-1//~$0$p$  >11g12g+:00g$0(?$~:00g)0$?$~:11pe+0$g:02g:01g+@ @$:0(?!$~$0)@:@(@@*0$?$~01p
0p131<<^$?(@:@@:g$0@:$@:-(1:+1@@:~p00$?)@:g00::+*e-1*2)-10:pbe \

Try it online!

This should (as in, I hope it does) work identically to the reference interpreter with a couple of exceptions; This doesn't strip trailing newlines, and it doesn't throw an error when . receives a negative argument (which wasn't part of the spec anyway). This isn't quite as golfed as I would like, especially regarding the sixth line (with all those chunks of whitespace), but I reached my goal of under 450 bytes, so I thought I'd post it.

This takes the program in through STDIN, and should be separated from the input with a NUL byte if there is any. Otherwise you can input stuff through the -v or -s flags.

This works by storing everything within the codebox itself, letting the simulated stack and register be the same as the actual one. We store the program below our interpreter at coordinates (1,14), with the length of each line at that line's zero. The other seven variables we need (number of lines, current x and y positions, current x and y deltas, whether stringmode is toggled, and whether we are skipping the next instruction) are stored in the top left.

Because of this, we can simulate most instructions by just placing them in the codebox and running them. Some extra care is needed when simulating movement and skipping ones, but this saves a lot of logic. The only special cases are for the jump instruction (.), the stringmode instructions (" and '), and the get and put instructions (g/p). These are mostly taken care of on the sixth line, with the get and put logic on thee last line instead, since that is very involved.

A more detailed explanation is coming...