From 7d4190d9a1993f3d2bcaa72c5464c262dfc7e565 Mon Sep 17 00:00:00 2001 From: Sofia Date: Fri, 10 Apr 2026 17:13:14 +0300 Subject: [PATCH] Parse new binops --- src/parsing.cpp | 16 ++++++++++++++-- test.c | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/parsing.cpp b/src/parsing.cpp index 0fef6aa..7471f07 100644 --- a/src/parsing.cpp +++ b/src/parsing.cpp @@ -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"); } diff --git a/test.c b/test.c index c2af6f2..7eb00a6 100644 --- a/test.c +++ b/test.c @@ -1,5 +1,5 @@ int main() { int a = 5; a = 15 + 20; - return a + 30; + return a - 30; } \ No newline at end of file