import java.util.*;

public class MathsParser
{
    public MathsParser (boolean debug)
    {
        _debug = debug;
    }

    /**
     * All numbers within expressions are single digit so we can continue to use them as
     * characters.
     * 
     * Handle different precedence  to part 1.
     */

    public long parse (Vector<String> data)
    {
        long finalResult = 0L;

        /*
         * Since + has precedence, we need to unwind the entire
         * equation and compute those values first before doing *
         */

        for (int i = 0; i < data.size(); i++)
        {
            String currentLine = data.elementAt(i);
            char[] lineArray = currentLine.trim().replaceAll("\\s", "").toCharArray(); // remove all spaces
            Vector<Character> unrolled = new Vector<Character>();
            Stack<Character> nested = new Stack<Character>();
            Stack<Long> values = new Stack<Long>();

            for (int j = 0; j < lineArray.length; j++)
            {
                switch (lineArray[j])
                {
                    case Tokens.OPEN_BRACE:
                    {
                        nested.push(lineArray[j]);
                    }
                    break;
                    case Tokens.CLOSE_BRACE:
                    {
                        boolean done = false;

                        while (!done && !nested.isEmpty())
                        {
                            Character c = nested.pop();

                            if (c != Tokens.OPEN_BRACE)
                                unrolled.add(c);
                            else
                                done = true;
                        }
                    }
                    break;
                    case Tokens.PLUS:
                    {
                        boolean done = false;

                        while (!done && !nested.isEmpty())
                        {
                            Character c = nested.pop();

                            if (c == Tokens.OPEN_BRACE)
                                done = true;
                            else
                            {
                                if (c == Tokens.PLUS)
                                    unrolled.add(c);
                            }
                        }

                        nested.push(lineArray[j]);
                    }
                    break;
                    case Tokens.MULTIPLY:
                    {
                        boolean done = false;

                        while (!done && !nested.isEmpty())
                        {

                        }
                    }
                    break;
                    default:
                    {
                        unrolled.add(lineArray[j]);
                    }
                    break;
                }
            }
        }

        return finalResult;
    }

    private boolean _debug;
}
@@ -880,60 +880,8 @@
 %3E();
-%0A            Stack%3CLong%3E values = new Stack%3CLong%3E();
 %0A%0A  
@@ -2560,267 +2560,1648 @@
   %7B%0A
-%0A                        %7D%0A                    %7D%0A                    break;%0A                    default:%0A                    %7B%0A                        unrolled.add(lineArray%5Bj%5D);%0A                    %7D%0A                    break;%0A                %7D%0A            %7D
+                            Character c = nested.pop();%0A%0A                            if (c == Tokens.OPEN_BRACE)%0A                                done = true;%0A                            else%0A                            %7B%0A                                if ((c == Tokens.PLUS) %7C%7C (c == Tokens.MULTIPLY))%0A                                    unrolled.add(c);%0A                            %7D%0A                        %7D%0A%0A                        nested.push(lineArray%5Bj%5D);%0A                    %7D%0A                    break;%0A                    default:%0A                    %7B%0A                        unrolled.add(lineArray%5Bj%5D);%0A                    %7D%0A                    break;%0A                %7D%0A            %7D%0A%0A            while (!nested.empty())%0A            %7B%0A                unrolled.add(nested.pop());%0A            %7D%0A%0A            Stack%3CLong%3E values = new Stack%3CLong%3E();%0A      %0A            for (int k = 0; k %3C unrolled.size(); k++)%0A            %7B%0A                Character c = unrolled.elementAt(k);%0A%0A                switch (c)%0A                %7B%0A                    case Tokens.PLUS:%0A                    %7B%0A                        values.push(values.pop() + values.pop());%0A                    %7D%0A                    break;%0A                    case Tokens.MULTIPLY:%0A                    %7B%0A                        values.push(values.pop() * values.pop());%0A                    %7D%0A                    break;%0A                    default:%0A                    %7B%0A                        values.push((long) Character.getNumericValue(c));%0A                    %7D%0A                    break;%0A                %7D%0A            %7D%0A      %0A            finalResult += values.pop();
 %0A   

Update MathsParser.java