%% pvs_to_cvc_subtypes
% converts types of the pvs syntax to cvc3 syntax. the syntax for doing
% typing in the two languages is slightly different so we need to write
% this function to translate between them.
%
% inputs:
%   pvs_type:string - a string of a pvs type
% outputs;
%   cvc_type:string - a string of the cvc type.
% Author: Colin Eles elesc@mcmaster.ca
% Organization: McMaster Centre for Software Certification

function [ cvc_type ] = pvs_to_cvc_subtypes( pvs_type )
%PVS_TO_CVC_SUBTYPES Summary of this function goes here
%   Detailed explanation goes here




%pvs_type is parsed
string = char(pvs_type);

% change cases
string = regexprep(string,'real','REAL');
string = regexprep(string,'Real','REAL');
string = regexprep(string,'int','INT');
string = regexprep(string,'Int','INT');
string = regexprep(string,'bool','BOOLEAN');
string = regexprep(string,'Bool','BOOLEAN');
string = regexprep(string,'BOOL[^EAN]','BOOLEAN');

% remove brackets
string_no_brack = regexp(string,'(?<=\{)[^\n]*(?=\})','match');
if isempty(string_no_brack)
    
    cvc_type = {string};
    return
end

split_at_pipe = regexp(char(string_no_brack),'\|','split');
if (size(split_at_pipe,2) ~= 2)
    %something strange happened
    cvc_type = {string};
    return;
end

new_type = ['SUBTYPE( LAMBDA (' char(split_at_pipe{1}) '): ' char(split_at_pipe{2}) ')'];
cvc_type = {new_type};

    


end

