use crate::ast::ParseNode;
pub(crate) fn is_atomic_expression(node: &ParseNode) -> bool {
match node {
ParseNode::Raw { .. }
| ParseNode::ColorToken { .. }
| ParseNode::TextOrd { .. }
| ParseNode::MathOrd { .. }
| ParseNode::Spacing { .. }
| ParseNode::AccentToken { .. }
| ParseNode::OperatorToken { .. }
| ParseNode::Atom { .. }
| ParseNode::Op { .. }
| ParseNode::OperatorName { .. }
| ParseNode::LeftRight { .. }
| ParseNode::Font { .. }
| ParseNode::DelimSizing { .. }
| ParseNode::LeftRightRight { .. }
| ParseNode::Middle { .. } => true,
ParseNode::Sqrt { .. }
| ParseNode::Overline { .. }
| ParseNode::Underline { .. }
| ParseNode::Phantom { .. }
| ParseNode::VPhantom { .. }
| ParseNode::Pmb { .. }
| ParseNode::Kern { .. }
| ParseNode::Enclose { .. }
| ParseNode::Rule { .. }
| ParseNode::IncludeGraphics { .. }
| ParseNode::AccentUnder { .. }
| ParseNode::CdLabel { .. }
| ParseNode::HorizBrace { .. }
| ParseNode::XArrow { .. }
| ParseNode::SupSub { .. } => true,
ParseNode::Styling { body, .. }
| ParseNode::Text { body, .. }
| ParseNode::MClass { body, .. }
| ParseNode::HBox { body, .. }
| ParseNode::Sizing { body, .. }
| ParseNode::Color { body, .. }
| ParseNode::Href { body, .. }
| ParseNode::Html { body, .. }
| ParseNode::OrdGroup { body, .. } => body.len() == 1 && is_atomic_expression(&body[0]),
ParseNode::Accent { base, .. } => is_atomic_expression(base),
ParseNode::Smash { body, .. }
| ParseNode::VCenter { body, .. }
| ParseNode::RaiseBox { body, .. }
| ParseNode::Lap { body, .. } => is_atomic_expression(body),
ParseNode::CdParent { fragment, .. } => is_atomic_expression(fragment),
_ => false,
}
}