PageSourceSearch

https://none-none1.github.io/Interpret-Esolangs-Online/lstackg.js

js none-none1.github.io collected 2026-10-03 09:42:00 UTC 1,881 bytes, 78 lines download raw bytes

1function lstackg(code,input){
2    var stack=[0],par=[];
3    var match={},cp=0,output='';
4    for(let i=0;i<code.length;i++){
5        if(code[i]=='<'){
6            par.push(i);
7        }
8        if(code[i]=='>'){
9            if(par.length==0){
10                throw new Error('Unmatched >');
11            }
12            var b=par.pop();
13            match[b]=i;
14            match[i]=b;
15        }
16    }
17    if(par.length!=0){
18        throw new Error('Unmatched <');
19    }
20    while(cp<code.length){
21        if('<stack>'.includes(code[cp])==false){
22            cp=cp+1;
23        }
24        if(code[cp]=='<'){
25            if(stack[stack.length-1]==0){
26                cp=match[cp];
27            }else{
28                cp=cp+1;
29            }
30            continue;
31        }
32        if(code[cp]=='>'){
33            if(stack[stack.length-1]!=0){
34                cp=match[cp];
35            }else{
36                cp=cp+1;
37            }
38            continue;
39        }
40        if(code[cp]=='a'){
41            stack[stack.length-1]+=1;
42            stack[stack.length-1]%=256;
43            cp=cp+1;
44            continue;
45        }
46        if(code[cp]=='s'){
47            stack.push(0);
48            cp=cp+1;
49            continue;
50        }
51        if(code[cp]=='t'){
52            if(input.length==0){
53                stack.push(255);
54            }else{
55                var inch=input.charCodeAt(0);
56                input=input.slice(1);
57                stack.push(inch);
58            }
59            cp=cp+1;
60            continue;
61        }
62        if(code[cp]=='c'){
63            if(stack.length>=2){
64                output+=String.fromCharCode(stack.pop());
65            }
66            cp=cp+1;
67            continue;
68        }
69        if(code[cp]=='k'){
70            if(stack.length>=2){
71                stack.pop();
72            }
73            cp=cp+1;
74            continue;
75        }
76    }
77    return output
78}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.