implemented infix operator parsing

This commit is contained in:
Karma Riuk
2025-07-11 10:30:37 +02:00
parent 6e471a91d5
commit a7f5950a55
7 changed files with 155 additions and 6 deletions

22
src/parser/precedence.cpp Normal file
View File

@@ -0,0 +1,22 @@
#include "precedence.hpp"
namespace parser {
precedence precedence_for(token::type type) {
switch (type) {
case token::type::EQ:
case token::type::NEQ:
return precedence::EQUALS;
case token::type::LT:
case token::type::GT:
return precedence::LESS_GREATER;
case token::type::PLUS:
case token::type::MINUS:
return precedence::SUM;
case token::type::ASTERISK:
case token::type::SLASH:
return precedence::PRODUCT;
default:
return precedence::LOWEST;
}
}
} // namespace parser