diff options
Diffstat (limited to 'docs/repl.js')
| -rw-r--r-- | docs/repl.js | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/docs/repl.js b/docs/repl.js index 2fc88caa..4fbbda8e 100644 --- a/docs/repl.js +++ b/docs/repl.js @@ -19,27 +19,6 @@ if (doc.count) { } let setExplain = e=>e; -let showErr = (s,e)=>{ - let r=e.src, w=e.message, loc=[]; - while (w&&w.loc||(r!=='!'&&w.sh&&w.sh[0]===2)) { - let is; [is,w]=w; - let n=is.sh?is.sh[0]:0, i=n?is[0]:is; - let pair=n&&is.sh.length>1; if (pair) n*=2; - let to=i=>s.slice(0,i).join('').split('\n').map(l=>Array.from(l)); - let ll=to(i), l=ll.length-1, j=ll[l].length, m=to()[l]; - let k=1,o=i-j,cl=j; while (k<n&&(cl=is[k]-o)<m.length) k++; - let ol=k<n; if (pair) { if (k%2) cl=m.length; else { k--; cl++; } } - let c=Array(cl).fill(0); c[j]=1; - for (let h=1;h<k;h++) c[is[h]-o+(pair?h%2:0)]=1; - if (pair) for (let h=1;h<cl;h++) c[h]^=c[h-1]; - let add = ['',m.join(''),c.map(t=>t?'^':' ').join('')]; - loc = add.concat(ol?['(and other lines)']:[], loc); - } - if (r==='!') w=w?fmt(w).replace(/^/gm,'! '):'! Error'; - else w=w.sh?w.join(''):w; - doc.rslt.classList.add('err'); - doc.rslt.textContent=[w].concat(loc).join('\n'); -} let repl = ()=>{ let s=Array.from(doc.code.value), src=str(s); doc.rslt.classList.remove('err'); @@ -51,7 +30,8 @@ let repl = ()=>{ setExplain(src,c); doc.rslt.textContent=fmt(run.apply(null,c)); } catch(e) { - showErr(src,e); + doc.rslt.classList.add('err'); + doc.rslt.textContent=fmtErr(src,e); } }, 0); } |
