Implementing a stack I can't believe we don't have this already.. It's one of the most important data-structures in programming, yet still simple enough to implement it in a code-golf:

Challenge

Your task is to implement a stack that allows pushing and popping numbers, to test your implementation and keep I/O simple we'll use the following setup:


Input will be a list of non-negative integers


Every positive integer \$n\$ indicates a \$\texttt{push(}n\texttt{)}\$ and every \$0\$ indicates a \$\texttt{pop()}\$ - discarding the top element.


Output will be the resulting stack


Example

For example if we're given \$[12,3,0,101,11,1,0,0,14,0,28]\$:

$$
 \begin{aligned}
  &amp; 12  &amp; [12]          \\
  &amp; 3   &amp; [3,12]        \\
  &amp; 0   &amp; [12]          \\
  &amp; 101 &amp; [101,12]      \\
  &amp; 11  &amp; [11,101,12]   \\
  &amp; 1   &amp; [1,11,101,12] \\
  &amp; 0   &amp; [11,101,12]   \\
  &amp; 0   &amp; [101,12]      \\
  &amp; 14  &amp; [14,101,12]   \\
  &amp; 0   &amp; [101,12]      \\
  &amp; 28  &amp; [28,101,12]
 \end{aligned}
$$

Output will be: \$[28,101,12]\$

Rules


Input will be a list of non-negative integers in any default I/O format


you may use a negative integer to signify the end of a stream of integers

Output will be a list/matrix/.. of the resulting stack


your choice where the top element will be (at the beginning or end), the output just has to be consistent
output is flexible (eg. integers separated by new-lines would be fine), the only thing that matters is the order
you may use a negative integer to signify the bottom of the stack

You're guaranteed that there will never be a \$0\$ when the stack is empty


Examples

[] -&gt; []
[1] -&gt; [1]
[1,0,2] -&gt; [2]
[4,0,1,12] -&gt; [12,1]
[8,3,1,2,3] -&gt; [3,2,1,3,8]
[1,3,7,0,0,0] -&gt; []
[13,0,13,10,1,0,1005,5,0,0,0] -&gt; [13]
[12,3,0,101,11,1,0,0,14,0,28] -&gt; [28,101,12]
MATL, 6 bytes
&quot;@?@}x

Input is a row vector of numbers.
The final stack is shown upside down, with the most recent element below.
Try it online! Or verify all test cases.
Explanation
&quot;         % For each element in the input (implicit)
  @       %   Push current element
  ?       %   If non-zero (this consumes the current element)
    @     %     Push current element again
  }       %   Else
    x     %     Delete most recent element
          %   End (implicit)
          % End (implicit)
          % Display (implicit)