aboutsummaryrefslogtreecommitdiff
path: root/src/utils.h
blob: 5c6e80e64d32e9594261baa53a10dd9b12b1cd86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef PARSER_SRC_UTILS_H_
#define PARSER_SRC_UTILS_H_

#include <string>
#include <vector>

#include "nodes.h"

namespace SimpleParser {

enum class PrecedenceLevel : uint8_t {
	FIRST  = 1,
	SECOND = 2,
	THIRD  = 3,
	FOURTH = 4,
	FIFTH  = 5,
};

enum class TokenType {
	OPERATOR_PLUS,
	OPERATOR_MINUS,
	OPERATOR_DIVIDE,
	OPERATOR_MULTIPLY,
	OPERATOR_POWER,
	PARENTHESES_OPEN,
	PARENTHESES_CLOSE,
	VALUE_NUMBER,
	VALUE_IDENTIFIER,
};

TokenType determineToken(const char);
TokenType determineToken(const std::string&);
PrecedenceLevel precedence(TokenType);
std::vector<std::string> lexer(const std::string&);

double stringToDouble(const std::string&);

}

#endif  // PARSER_SRC_UTILS_H_