Parse new binops

This commit is contained in:
Sofia 2026-04-10 17:13:14 +03:00
parent 422f95e553
commit 7d4190d9a1
2 changed files with 15 additions and 3 deletions

View File

@ -51,14 +51,26 @@ namespace parsing {
if (token.type != token::Type::Symbol) {
throw std::runtime_error("Expected binop");
}
if (token.content == "=") {
else if (token.content == "=") {
stream.m_position = inner.m_position;
return new types::BinOp{ types::BinOp::Assignment };
}
if (token.content == "+") {
else if (token.content == "+") {
stream.m_position = inner.m_position;
return new types::BinOp{ types::BinOp::Add };
}
else if (token.content == "-") {
stream.m_position = inner.m_position;
return new types::BinOp{ types::BinOp::Sub };
}
else if (token.content == "<") {
stream.m_position = inner.m_position;
return new types::BinOp{ types::BinOp::LessThan };
}
else if (token.content == ">") {
stream.m_position = inner.m_position;
return new types::BinOp{ types::BinOp::GreaterThan };
}
throw std::runtime_error("Expected binop");
}

2
test.c
View File

@ -1,5 +1,5 @@
int main() {
int a = 5;
a = 15 + 20;
return a + 30;
return a - 30;
}