Boolean expression evaluation
Your task
Evaluate a boolean expression string built from the literals 'T' and 'F', the binary operators '&' (and) and '|' (or), the unary prefix '!' (not), and parentheses. Precedence from highest to lowest: '!' , then '&', then '|'. '&' and '|' are left-associative; '!' may stack (e.g. '!!T'). There may be spaces between tokens. The expression is always valid. Return a bool. Examples: 'T & F' -> False, '!F | F' -> True, '!(T & F)' -> True.
Examples
eval_bool(expr: str) -> boolExample 1
Input
eval_bool("T & F")Output
False