Fix parsing double character binops

This commit is contained in:
Sofia 2026-05-11 16:30:28 +03:00
parent c232fc3d43
commit 8459dea8fb
2 changed files with 7 additions and 1 deletions

View File

@ -475,26 +475,32 @@ namespace parsing {
} }
else if (token.content == "<" && peeked.content == "<") { else if (token.content == "<" && peeked.content == "<") {
inner.next();
stream.m_position = inner.m_position; stream.m_position = inner.m_position;
return types::BinOp{ types::BinOp::BitShiftLeft }; return types::BinOp{ types::BinOp::BitShiftLeft };
} }
else if (token.content == ">" && peeked.content == ">") { else if (token.content == ">" && peeked.content == ">") {
inner.next();
stream.m_position = inner.m_position; stream.m_position = inner.m_position;
return types::BinOp{ types::BinOp::BitShiftRight }; return types::BinOp{ types::BinOp::BitShiftRight };
} }
else if (token.content == "<" && peeked.content == "=") { else if (token.content == "<" && peeked.content == "=") {
inner.next();
stream.m_position = inner.m_position; stream.m_position = inner.m_position;
return types::BinOp{ types::BinOp::LessThanEquals }; return types::BinOp{ types::BinOp::LessThanEquals };
} }
else if (token.content == ">" && peeked.content == "=") { else if (token.content == ">" && peeked.content == "=") {
inner.next();
stream.m_position = inner.m_position; stream.m_position = inner.m_position;
return types::BinOp{ types::BinOp::GreaterThanEquals }; return types::BinOp{ types::BinOp::GreaterThanEquals };
} }
else if (token.content == "=" && peeked.content == "=") { else if (token.content == "=" && peeked.content == "=") {
inner.next();
stream.m_position = inner.m_position; stream.m_position = inner.m_position;
return types::BinOp{ types::BinOp::Equals }; return types::BinOp{ types::BinOp::Equals };
} }
else if (token.content == "!" && peeked.content == "=") { else if (token.content == "!" && peeked.content == "=") {
inner.next();
stream.m_position = inner.m_position; stream.m_position = inner.m_position;
return types::BinOp{ types::BinOp::NotEquals }; return types::BinOp{ types::BinOp::NotEquals };
} }

2
test.c
View File

@ -73,5 +73,5 @@ long long int main() {
short int sh = 123 + 5; short int sh = 123 + 5;
return sh % 10; return (sh % 10) == 8;
} }