tcalc 0.2.0
 
Loading...
Searching...
No Matches
priority.hpp File Reference

Operator priority table. More...

#include <unordered_map>
#include <vector>
#include "tcalc/ast/node.hpp"
#include "tcalc/token.hpp"

Go to the source code of this file.

Typedefs

using tcalc::ast::PriorityTable = std::vector< std::unordered_map< token::TokenType, NodeType > >
 Operator priority table type.
 

Variables

const PriorityTable tcalc::ast::BINOP_PRIORITY
 
const PriorityTable tcalc::ast::UNARYOP_PRIORITY
 

Detailed Description

Operator priority table.

Author
Dessera (desse.nosp@m.ra@q.nosp@m.q.com)
Version
0.2.0
Date
2025-06-17

Variable Documentation

◆ BINOP_PRIORITY

const PriorityTable tcalc::ast::BINOP_PRIORITY
inline
Initial value:
= {
{
{ token::TokenType::AND, NodeType::BINARY_AND },
{ token::TokenType::OR, NodeType::BINARY_OR },
},
{
{ token::TokenType::EQUAL, NodeType::BINARY_EQUAL },
{ token::TokenType::NOTEQUAL, NodeType::BINARY_NOT_EQUAL },
{ token::TokenType::GREATER, NodeType::BINARY_GREATER },
{ token::TokenType::GREATEREQUAL, NodeType::BINARY_GREATER_EQUAL },
{ token::TokenType::LESS, NodeType::BINARY_LESS },
{ token::TokenType::LESSEQUAL, NodeType::BINARY_LESS_EQUAL },
},
{
{ token::TokenType::PLUS, NodeType::BINARY_PLUS },
{ token::TokenType::MINUS, NodeType::BINARY_MINUS },
},
{
{ token::TokenType::MULTIPLY, NodeType::BINARY_MULTIPLY },
{ token::TokenType::DIVIDE, NodeType::BINARY_DIVIDE },
}
}

Binary operator priority table.

◆ UNARYOP_PRIORITY

const PriorityTable tcalc::ast::UNARYOP_PRIORITY
inline
Initial value:
= { {
{ token::TokenType::PLUS, NodeType::UNARY_PLUS },
{ token::TokenType::MINUS, NodeType::UNARY_MINUS },
{ token::TokenType::NOT, NodeType::UNARY_NOT },
} }

Unary operator priority table.