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