function args = BR_all_and_args(s)
% BR_all_and_args - get all sub-clauses for and clause
% On input:
%     s (string): logical sentence (fully parenthesize)
% On output:
%     args (struct vector): args of s
%     (k).s (string): k_th clause in s
% Call:
%     args = BR_all_and_args('((1)^(2))');
% Author:
%     T. Henderson
%     UU
%     Fall 2018
%

args = [];
num_args = 0;

if isempty(s)
    return
end

num_clauses = 1;
clauses(1).s = s;
queue = [1];

while ~isempty(queue)
    p = queue(1);
    queue = queue(2:end);
    clause = clauses(p).s;
    if BR_isANDop(clause)
        [OP1,OP2] = BR_getANDargs(clause);
        num_clauses = num_clauses + 1;
        clauses(num_clauses).s = OP1;
        queue = [queue; num_clauses];
        num_clauses = num_clauses + 1;
        clauses(num_clauses).s = OP2;
        queue = [queue; num_clauses];
    else
        num_args = num_args + 1;
        args(num_args).s = clause(2:end-1);
    end
end
