| Bytes | Lang | Time | Link |
|---|---|---|---|
| 396 | C | 150806T054754Z | Jerry Je |
| 560 | JavaScript ES6 | 200610T235621Z | nununois |
C 396
Thanks to @ceilingcat for some very nice pieces of golfing - now even shorter
#define A*I==42?I++,P[atol(I++)]:atol(I++)
#define F(a)-91-a|i;i-=*I-93+a?*I==91+a:-1);}
i,c;char*I;X[999],*P=X;Y(){for(;*I++F(2)B(){for(i=!--I;*--I F(0)main(j,a)int**a;{for(I=a[1];j=*I++;printf(j-4?j+9?j==19?*P=A:j==1?*P+=A:j==3?*P-=A:!j?*P*=A:j==5?*P/=A:j==20?P+=A:j-17?j-51?j-49?I=j+2?I:index(I,41)+1:*P||Y(i=1):B():({for(c=A;c;c+=c<0?:-1)if(i=c<1)B();else for(;*I++F(2)),"":P:"%d",*P))j-=42;}
and the slightly less golfed version of my original answer:
#include <stdio.h>
#include <stdlib.h>
#define L strtol(I++,&I,10)
#define A *I=='*'?I++,P[L]:L
int X[999],*P=X;
int main(int i, char *a[])
{
char* I=a[1];
while(*I)
{
switch(*I++)
{
case '(': while(*I++!=')'); break;
case '.': printf("%d",*P); break;
case '!': printf("%c",(char*)*P); break;
case '[': if(!*P)
for(i=1;*I++!=']'||i;)
{
if(*I=='[')
i+=1;
if(*I==']')
i-=1;
}
break;
case ']': for(--I,i=0;*--I !='['||i;)
{
if(*I==']')
i+=1;
if(*I=='[')
i-=1;
}
break;
case '=': *P=A; break;
case '+': *P+=A; break;
case '-': *P-=A; break;
case '*': *P*=A; break;
case '/': *P/=A; break;
case '>': P+=A; break;
case ';': for(int c=A; c; c+=c<0?1:-1)
{
if(c>0)
for(i=0;*I++!=']'||i;)
{
if(*I=='[')
i+=1;
if(*I==']')
i-=1;
}
else
for(--I,i=0;*--I !='['||i;)
{
if(*I==']')
i+=1;
if(*I=='[')
i-=1;
}
}
}
}
return 0;
}
JavaScript (ES6) - 560 bytes
Uses prompt() for input and alert() for output. It could be shortened if alert() was called for every character instead but I decided it would be better to buffer the characters so they could all be displayed at once.
b=[],d=0,e=[],f=0,g="",h="",k=prompt().replace(/(\s+|\(.*\))/g,""),l=0;n=()=>{m=g;if(m&&(a=m.substr(1),c=m.charAt(),a="*"==a.charAt()?b[d+parseInt(a.substr(1))]:parseInt(a),"["==c&&(b[d]?e.push(f-1):l++),"]"==c&&l&&(0<l&&(f=e.pop()),0>l&&(l=-l),l--),!l&&("="==c&&(b[d]=a),"+-*/".includes(c)&&eval("b[d]"+c+"=a"),">"==c&&(d+=a),"."==c&&(h+=b[d]),"!"==c&&(h+=String.fromCharCode(b[d])),";"==c&&(0<a&&(l=-l-a),0>a))))for(i=0;i<-a;i++)f=e.pop()}
for(f=0;f<k.length;f++)0<f&&"=+-*/>.![];".includes(k[f])&&k[f-1].match(/[0-9.!\[\]]/)&&(n(),g=""),g+=k[f];h&&alert(h);