fix: recognize unary operators
This commit is contained in:
parent
d54c9636ca
commit
ee18ae3222
1 changed files with 7 additions and 3 deletions
|
|
@ -78,9 +78,13 @@ impl FromStr for Nodes {
|
||||||
} else if c == ')' {
|
} else if c == ')' {
|
||||||
nodes.push(Node::ParenthesisEnd);
|
nodes.push(Node::ParenthesisEnd);
|
||||||
} else {
|
} else {
|
||||||
nodes.push(Node::Operator(
|
if matches!(nodes.last(), Some(Node::Operator(_)) | None) {
|
||||||
c.try_into().map_err(|()| Error::InvalidOperator(c))?,
|
state = ParsingState::ReadingNumber(i);
|
||||||
));
|
} else {
|
||||||
|
nodes.push(Node::Operator(
|
||||||
|
c.try_into().map_err(|()| Error::InvalidOperator(c))?,
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue