I'm interested in all the cases where shunting-yard algorithm can tell if an expression is not correctly written from a syntax point of view.
So the Shunting-yard algorithm takes an expression written in infix notation and transforms it into prefix or postfix notation. As a simple example, the one taken from wikipedia: an infix notation of an equation would be 3 + 4 × 2 ÷ ( 1 − 5 ) ^ 2 ^ 3 and after being converted to postfix with the algorithm it would become 3 4 2 × 1 5 − 2 3 ^ ^ ÷ +.
The algorithm on wikipedia checks for mismatched parentheses in two cases: First, if it finds a right bracket then pops the operators till a left bracket is found, if it's not found then there are mismatched parentheses. Second, after all tokens are read it pops the operator stack into output queue. If there is a bracket left, there are mismatched parentheses. These 2 things can be done with the algorithm.
Now for my expression in postfix notation 3 4 2 × 1 5 − 2 3 ^ ^ ÷ + how exactly can I say from this that my infix notation was correctly written? I've been thinking that after this expression is evaluated if there is more than one element in the stack then there is an error. What are some other cases I should consider?