Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 44718

Tasks involving writing interpreters for various languages or formalisms.

3 votes

µUnitDC: A unit-aware RPN calculator

JavaScript (Node.js), 209 bytes p=>p.map(n=>a.push(y=+n?[+n,...Buffer(36)]:n<0+a.pop()?a.pop().map((o,i)=>(m=y[i],i)?n<'+'?o+m:n<'/'?o-m?E:o:o-m:eval(o+n+m)):(y[parseInt(n,36)]=1,y)),a=[])&&a.map(x=>x …
tsh's user avatar
  • 35.6k
10 votes

Implement a simple stack language

JavaScript (Node.js), 103 bytes -2bytes by l4m2 p=>p.split` `.reduce(([a=[],b=[],...S],i)=>[{A:a+b,S:b-a,X:[b,a],P:b}[i]??[1/i?+i:a,a,b],S].flat(2),[]) Attempt This Online! Operators: A: Add S: Sub …
tsh's user avatar
  • 35.6k
5 votes

Inject arbitrary code into a compiler (robbers)

Cracks Javastack 0);
<!-- place your code here 
console.log(`42`)
//
tsh's user avatar
  • 35.6k
4 votes

AoCG2021 Day 16: Interpret Duet

JavaScript, 249 bytes P=>{for(Q=[...P],P.M=[],Q.M=[],I=J=Q.p=1;E=I+J&&P[P.$??=0];[P,Q]=[Q,P])with(P)I=J,J=1,([[,O],X,Y]=E.split` `).map(C=>P[C]??=0),eval({g:X+`>0&&($+=${Y}-1)`,n:`Q.M.push(${X})`,c:`M …
tsh's user avatar
  • 35.6k
4 votes

Interpret underload

JavaScript (V8), 189 bytes f=([C,...P],X=T=L='',Y,...S)=>C?eval(`f(P,${L*(L-=C=='('?-1:C==')')?'X+C,Y':` ^P.unshift(...X)&&Y ~Y,X :X,X,Y !Y *Y+X a'('+X+')',Y S(T+=X,Y) ('',X,Y )X,Y`.match(` [${C}](.* …
tsh's user avatar
  • 35.6k
4 votes

Execute a Befunge Chess Board

JavaScript (V8), 125 bytes a=>eval("for(d=5,w=a[x=y=0].length,h=a.length;(c=a[y%=h][x%=w])<9;d%2?x+=w+m:y+=h+m)a[y][x]='T',d=c>2?c:d,m=(d%3-1)*-~!+c;c") Try it online! '<': '3', '^': '6', …
tsh's user avatar
  • 35.6k
5 votes

Make a !!!Batch compiler/translator

JavaScript, 118 bytes s=>s.replace(/.+?\?/g,x=>x[i=x.length-2]>','?'& ?!%/.:0123456789=+-<>@*'[i-2]:String.fromCharCode(x[i]<'+'?96+i:63+i)) Try it online! JavaScript, 118 bytes s=>s.replace(/.!+( …
tsh's user avatar
  • 35.6k
7 votes

Evaluate left-or-right

Retina 0.8.2, 22 bytes {`\((.>)?(.)(<.)?\) $2 Try it online! Basically the port of my JavaScript answer in Retina. I just learnt how to write loop in past 10 minutes and got this. {` loops the replac …
tsh's user avatar
  • 35.6k
11 votes

Evaluate left-or-right

JavaScript (Node.js), 50 bytes f=a=>a[1]?f(a.replace(/\((.>)?(.)(<.)?\)/,'$2')):a Try it online! Repeat apply regex replace until only 1 char left. The regex /\((.>)?(.)(<.)?\)/ get the calculate re …
tsh's user avatar
  • 35.6k
1 vote

Write an interpreter for simplified 33

JavaScript (Node.js), 264 bytes S=>I=>[...S].map(s=>K?K=0:1/s?C=+(C+s):eval("A*=C;[A,C]=[C,A];K=!A;;K=A;K=A>0;A%=C;K=A<=0;A=A/C|0;I=I.replace(/-?\\d+/,n=>(A=+n,''));K=A>=0;O+=A;K=A<0;A+=C;C=0;;[A]= …
tsh's user avatar
  • 35.6k
1 vote

Do a BackFlip for ais523!

JavaScript, 172 bytes f=(a,d=3,x=0,y=0,n=1)=>(p=a[y]||[],q=p[x])?(p[x]=~(t='^<V>'.indexOf(q))?'^<V>'[d^2]:q=='/'?(t=3-d,'\\'):q=='\\'?(t=d^1,'/'):(t=d,q),f(a,t,x+(t&1&&t-2),y+(~t&1&&t-1),n+1)):n Bu …
tsh's user avatar
  • 35.6k