-
Notifications
You must be signed in to change notification settings - Fork 0
/
token_helper.h
41 lines (25 loc) · 869 Bytes
/
token_helper.h
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
41
//
// Created by mathe on 05/04/2018.
//
#ifndef METODOS_COMP_CMAKE_TOKEN_HELPER_H
#define METODOS_COMP_CMAKE_TOKEN_HELPER_H
#include <string>
#include <map>
#include <cmath>
using namespace std;
struct TokenInfo {
int precedence;
bool left_associative;
};
extern map<string, TokenInfo> op_info;
bool IsTokenOp(string token);
bool IsTokenFn(string token);
bool IsTokenConst(string token);
int GetOpPrecedence(string token);
int GetOpLeftAssociativity(string token);
double GetConstValue(string token);
bool CompareOpPrecedenceOrLA(string first, string second);
string SearchForNonNumericToken(string expr, int from_position, int *ends_in);
string SearchForNumericToken(string expr, int from_position, int *ends_in);
string SearchForToken(string expr, int from_position, int *ends_in, bool *is_number);
#endif //METODOS_COMP_CMAKE_TOKEN_HELPER_H