Balancing Symbols Algorithm

While !EOF do

Get theSymbol

If theSymbol is OPENING

S.Push(theSymbol)

Else if theSymbol is CLOSING

If S.IsEmpty ->ERROR

Else

Result = S.Pop

If Result != corresponding OPENING symbol -> ERROR

End

If !S.IsEmpty -> ERROR

Else SUCCESS!!