tcalc 0.2.0
 
Loading...
Searching...
No Matches
priority.hpp
Go to the documentation of this file.
1
12#pragma once
13
14#include <unordered_map>
15#include <vector>
16
17#include "tcalc/ast/node.hpp"
18#include "tcalc/token.hpp"
19
20namespace tcalc::ast {
21
27 std::vector<std::unordered_map<token::TokenType, NodeType>>;
28
30 {
31 { token::TokenType::AND, NodeType::BINARY_AND },
32 { token::TokenType::OR, NodeType::BINARY_OR },
33 },
34 {
35 { token::TokenType::EQUAL, NodeType::BINARY_EQUAL },
36 { token::TokenType::NOTEQUAL, NodeType::BINARY_NOT_EQUAL },
37 { token::TokenType::GREATER, NodeType::BINARY_GREATER },
38 { token::TokenType::GREATEREQUAL, NodeType::BINARY_GREATER_EQUAL },
39 { token::TokenType::LESS, NodeType::BINARY_LESS },
40 { token::TokenType::LESSEQUAL, NodeType::BINARY_LESS_EQUAL },
41 },
42 {
43 { token::TokenType::PLUS, NodeType::BINARY_PLUS },
44 { token::TokenType::MINUS, NodeType::BINARY_MINUS },
45 },
46 {
47 { token::TokenType::MULTIPLY, NodeType::BINARY_MULTIPLY },
48 { token::TokenType::DIVIDE, NodeType::BINARY_DIVIDE },
49 }
50};
53 { token::TokenType::PLUS, NodeType::UNARY_PLUS },
54 { token::TokenType::MINUS, NodeType::UNARY_MINUS },
55 { token::TokenType::NOT, NodeType::UNARY_NOT },
56} };
58}
Base class for AST nodes.
std::vector< std::unordered_map< token::TokenType, NodeType > > PriorityTable
Operator priority table type.
Definition priority.hpp:27
const PriorityTable UNARYOP_PRIORITY
Definition priority.hpp:52
const PriorityTable BINOP_PRIORITY
Definition priority.hpp:29
Input token definition.