Try to write an algorithm for discriminating whether open and closed parentheses are legally paired in a discriminant expression