MADARA  3.4.1
Interpreter.inl
Go to the documentation of this file.
1 
2 
3 #ifndef _MADARA_KNOWLEDGE_INTERPRETER_INL_
4 #define _MADARA_KNOWLEDGE_INTERPRETER_INL_
5 
6 #ifndef _MADARA_NO_KARL_
7 
8 #include "Interpreter.h"
9 
17 // method for checking if a character is a valid operator
19 {
20  return input == '+' || input == '-' || input == '*' || input == '/' ||
21  input == '%';
22 }
23 
24 // method for checking if a character is a number
26 {
27  return input >= '0' && input <= '9';
28 }
29 
30 // method for checking if a character is a number
32 {
33  return input == 'e' || input == 'E' || input == '-' ||
34  (input >= '0' && input <= '9');
35 }
36 
38  const std::string& input)
39 {
40  return input == "true" || input == "false" || input == "nan" ||
41  input == "inf";
42 }
43 
44 // method for checking if a character is a number
46 {
47  return input == '"' || input == '\'';
48 }
49 
50 // method for checking if a character is a candidate
51 // for a part of a variable name
53 {
54  return (input >= 'a' && input <= 'z') || (input >= 'A' && input <= 'Z') ||
55  (input == '_') || (input >= '0' && input <= '9') || input == '.' ||
56  input == '{' || input == '}';
57 }
58 
59 // method for checking if input is whitespace
61 {
62  return input == ' ' || input == '\t' || input == '\r' || input == '\n';
63 }
64 
71  const std::string& expression)
72 {
73  return cache_.erase(expression) == 1;
74 }
75 
76 #endif // _MADARA_NO_KARL_
77 
78 #endif // _MADARA_KNOWLEDGE_INTERPRETER_INL_
static bool is_operator(char input)
Checks a character to see if it is a mathematical operator.
Definition: Interpreter.inl:18
static bool is_string_literal(char input)
Checks a character to see if it is a string literal.
Definition: Interpreter.inl:45
static bool is_reserved_word(const std::string &input)
Checks a given input for a reserved word literal.
Definition: Interpreter.inl:37
static bool is_whitespace(char input)
Checks a character to see if it is whitespace.
Definition: Interpreter.inl:60
static bool is_exponential(char input)
Checks a character to see if it is in scientific format.
Definition: Interpreter.inl:31
static bool is_alphanumeric(char input)
Checks a character to see if it is alphanumeric.
Definition: Interpreter.inl:52
static bool is_number(char input)
Checks a character to see if it is a number.
Definition: Interpreter.inl:25
bool delete_expression(const std::string &expression)
Attempts to delete an expression from cache.
Definition: Interpreter.inl:70
constexpr string_t string