Write a Deadfish Interpreter Sandbox, Codidact
A rewrite of this question with a simpler input format and guidelines.
Challenge
Deadfish uses a single accumulator, on which all commands are to be performed.
It has the following commands:




Command
Description




i
increment the accumulator


d
decrement the accumulator


s
square the value of the accumulator


o
output the value of the accumulator as a number




If, after executing a command, the accumulator is equal to -1 or equal to 256, the accumulator must be reset to zero.
I/O
Input can be taken as a single string, list of codepoints, or any other reasonable format. It is guaranteed that the input will only consist of deadfish commands.
Output can be given as an array of numbers, or just the numbers printed with separators between them.
Testcases
(some are borrowed from the Esolangs wiki)
iissso -&gt; 0
diissisdo -&gt; 288
iissisdddddddddddddddddddddddddddddddddo -&gt; 0
isssoisoisoisoiso -&gt; 1,4,25,676,458329
ooooosioiiisooo -&gt; 0,0,0,0,0,1,16,16,16
iiii -&gt; nothing
iiiiiiiissdiiiiiiiiiiiiiiiiio -&gt; 4112
o -&gt; 0

Without Outputs
flex, 86 \$\cdots\$ 83 82 bytes
Saved 2 bytes and got moved into TIO thanks to Mukundan314!!!

%{
a;m(){a*=a!=256;}
%}
%%
i m(++a);
d m(a&amp;&amp;--a);
s m(a*=a);
o printf(&quot;%d &quot;,a);
%%

Try it online!
flex stands for fast lexical analyser generator. It takes input as above and generates a lexer in C.
The input comprises of a C declaration section:
%{
a;m(){a*=a!=256;}
%}

where here we simply declare the accumulator a (implicitly as an int) and a function to set the accumulator to \$0\$ if it's \$256\$ after a computation.
This is followed by the rules section comprised of all the regexes that need to be parsed along with their actions (in C):
%%
i m(++a);
d m(a&amp;&amp;--a);
s m(a*=a);
o printf(&quot;%d &quot;,a);
%%   

here we have our 4 characters along with the code to run when each is encountered. Decrement will only happen if the accumulator is non-zero.
There's a program section that follows this but it will simply default to a main that runs the parser if left out (as in this case).
You can generate the C-source code lexer from the above (in file deadfish.l) and compile it with the following:
flex deadfish.l
gcc lex.yy.c -o deadfish -lfl  

After compiling, running the following:
echo iissso | ./deadfish
echo diissisdo | ./deadfish
echo iissisdddddddddddddddddddddddddddddddddo | ./deadfish
echo isssoisoisoisoiso | ./deadfish
echo ooooosioiiisooo | ./deadfish
echo iiiiiiiissdiiiiiiiiiiiiiiiiio | ./deadfish  

outputs:
0
288
0
1 4 25 676 458329
0 0 0 0 0 1 16 16 16
4112   

You can also just run it as ./deadfish and have an interactive deadfish environment to play with to your heart's content!