fix: recognize unary operators

This commit is contained in:
electria 2026-07-15 21:51:12 -07:00
commit ee18ae3222
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs

View file

@ -78,9 +78,13 @@ impl FromStr for Nodes {
} else if c == ')' {
nodes.push(Node::ParenthesisEnd);
} else {
nodes.push(Node::Operator(
c.try_into().map_err(|()| Error::InvalidOperator(c))?,
));
if matches!(nodes.last(), Some(Node::Operator(_)) | None) {
state = ParsingState::ReadingNumber(i);
} else {
nodes.push(Node::Operator(
c.try_into().map_err(|()| Error::InvalidOperator(c))?,
));
}
}
}
}