This is a good programming practice of creating a recursive descent parser besides the calculator itself. The Friends problem calculates the set union(s) or set difference(s) between a given number of sets.
Sample input
{ABC}
{ABC}+{DEFG}+{Z}+{}
{ABE}*{ABCD}
{ABCD}-{CZ}
{ABC}+{CDE}*{CEZ}
({ABC}+{CDE})*{CEZ}
Sample output
{ABC}
{ABCDEFGZ}
{AB}
{ABD}
{ABCE}
{CE}
Source code is available on my GitHub.