-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExprParser.cpp
More file actions
30 lines (26 loc) · 945 Bytes
/
ExprParser.cpp
File metadata and controls
30 lines (26 loc) · 945 Bytes
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
#include <unordered_map>
#include "ExprParser.hpp"
int ExprParser::parse()
{
return yyparse(*this);
}
/*
std::string ExprParser::searchIdentValue(const std::string& cname) const
{
// Values taken from https://en.wikipedia.org/wiki/List_of_mathematical_constants
static std::unordered_map<std::string, std::string> cmap = {
{"Pi", "3.14159"}, // Ratio of a circle's circumference to its diameter
{"Tau", "6.28319"}, // Ratio of a circle's circumference to its radius
{"SrTwo", "1.41421"}, // Square root of 2. Pythagoras constant
{"SrThree", "1.73205"}, // Square root of 3. Theodorus' constant
{"Phi", "1.61803"}, // Golden ratio
{"E", "2.71828"}, // Euler's number
};
auto it = cmap.find(cname);
if(it == cmap.end()){
auto it2 = identValues.find(cname);
return (it2 == identValues.end())? "0.0" : it2->second;
} else
return it->second;
}
*/