Quantcast
Channel: Vimタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 5608

Orelang(俺言語)をVim scriptで実装してみた

$
0
0

http://qiita.com/shuetsu@github/items/ac21e597265d6bb906dc#comment-9e44bdb74529dc3df9fe

http://blog.64p.org/entry/2016/09/30/014358

http://mattn.kaoriya.net/software/lang/go/20160930110535.htm

http://qiita.com/alpha_kai_NET/items/aa4c71a09f853fda7011

function!s:eval(e,v)if type(a:v)== type([])returns:doRun(a:e,a:v)endifreturna:vendfunctionfunction!s:doRun(e,v)letr=0letm=a:v[0]
  ifm=="step"for vv ina:v[1:]
      letr=s:doRun(a:e, vv)endforelseifm=="until"while!s:eval(a:e,a:v[1])letr=s:doRun(a:e,a:v[2])endwhileelseifm=="while"whiles:eval(a:e,a:v[1])letr=s:doRun(a:e,a:v[2])endwhileelseifm=="set"letr=s:eval(a:e,a:v[2])leta:e[s:eval(a:e,a:v[1])] =relseifm=="get"letr=a:e[s:eval(a:e,a:v[1])]
  elseifm=="<="letr=s:eval(a:e,a:v[1])<=s:eval(a:e,a:v[2])elseifm=="="letr=s:eval(a:e,a:v[1])==s:eval(a:e,a:v[2])elseifm=="+"letr=s:eval(a:e,a:v[1])+s:eval(a:e,a:v[2])elseifm=="print"letr=s:eval(a:e,a:v[1])
    echo relsethrow"unknown operator: "+ string(a:v)endifreturnrendfunctionlets:source = '
\["step",
\  ["set","sum",0 ],
\  ["set","i",1 ],
\  ["while", ["<=", ["get","i"],10],
\    ["step",
\      ["set","sum", ["+", ["get","sum"], ["get","i"]]],
\      ["set","i", ["+", ["get","i"],1]]]],
\  ["print", ["get","sum"]]]
\'

letv= json_decode(s:source)calls:doRun({},v)

Viewing all articles
Browse latest Browse all 5608

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>