function literals = BR_get_literals(s)
% BR_get_literals - returns vector of literals in s
% On input:
%     s (string): fully parenthesized logical sentence
% On output:
%     literals (vector): literal values (signed) in s
% Call:
%     b = BR_get_literals('((1)v(2))');
% Author:
%     T. Henderson
%     UU
%     Fall 2018
%

LEFT_PAREN = '(';
MINUS = '-';

literals = [];

if isempty(s)
    return
end

len_s = length(s);
index = 0;
while index<len_s
    index = index + 1;
    if (s(index)==LEFT_PAREN&BR_isdigit(s(index+1)))
        index = index + 1;
        v = str2num(s(index));
        index = index + 1;
        while BR_isdigit(s(index))
            v = 10*v + str2num(s(index));
        end
        literals = [literals,v];
    elseif (s(index)==LEFT_PAREN&s(index+1)==MINUS)
        index = index + 2;
        v = str2num(s(index));
        index = index + 1;
        while BR_isdigit(s(index))
            v = 10*v + str2num(s(index));
        end
        literals = [literals,-v];
    end
end
