Order of parsing + and - This seems like an absurdly simply question, and is possibly below the level of this forum, but it seems the most sensible place.
I'm building an arithmetic equation parser, and currently working on parsing + and - operations. I know that (leaving other operations and brackets aside for the time being) they should be processed from left to right, but it seems very much like processing the minuses first (left to right), then the pluses, has the same effect.
i.e.
$1+2-3+4-5$
(left to right):
$$1+2-3+4-5 \\ =3-3+4-5 \\ =0+4-5 \\ =4-5 \\ =-1$$
(minuses first):
$$1+2-3+4-5 \\ =1+(-1)+4-5 \\ =1+(-1)+(-1) \\ =0+(-1) \\ =-1$$
Is this guaranteed to hold true in all cases? And why is it so?
 A: You are correct that, as long as you do the subtractions first from left to right, you get the same values.
One important thing to note: All of this hinges on the fact that subtraction is just another form of addition, and addition is associative. But associativity of addition is not always true in programming languages, particularly with floating point values. See the note at the end.
In general, $a-b=a+(-b)$. So as long as you recall this, you can see when you can do a "minus" first - namely, when the previous operator is not a $-$. 
$$1+2-3-4 = 1+2+(-3)+(-4)$$
You can't do $(3-4)$ first here because $(-3)+(-4)\neq 3-4$. But you can do $2-3$ first, since $2+(-3)=2-3$. Essentially, you are doing associative addition in this case.
That said, as you say, if you process the subtractions first, from left to right, you get the same result, yes. So:
$$1+2-3-4 = 1+((2-3)-4)$$
Again, this is due to the associative law of addition - subtraction is just addition of a negative:
$$1+2-3-4 = 1+2+(-3)+(-4) = 1+\left(\left(2+(-3)\right)+(-4)\right)$$
Note:
In a lot of computer mathematics, addition is actually not associative. Particularly with floating point.
For example, if floating point number $a$ is very small and $b=c$ are very large, then $(a+b)-c$ returns $0$, while $a+(b-c)$ return $a$.
A: A friend of mine once drunkenly said that every operation in mathematics essentially boils down to addition. In this particular case what you have is:
$$1 + 2 + (-3) + 4 + (-5)$$
Since you already know that addition is commutative, then seen this way, you can jumble these into whatever order you want and still get the same result.
Of course once you start dealing with multiplications, divisions and parentheses, things get more complicated and less amenable to rearrangement.
