MADARA  3.2.3
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 
18 // method for checking if a character is a valid operator
19 inline bool
21 {
22  return input == '+'
23  || input == '-'
24  || input == '*'
25  || input == '/' || input == '%';
26 }
27 
28 // method for checking if a character is a number
29 inline bool
31 {
32  return input >= '0' && input <= '9';
33 }
34 
35 // method for checking if a character is a number
36 inline bool
38 {
39  return input == 'e' || input == 'E' || input == '-' ||
40  (input >= '0' && input <= '9');
41 }
42 
43 inline bool
45 {
46  return input == "true" || input == "false" ||
47  input == "nan" || input == "inf";
48 }
49 
50 // method for checking if a character is a number
51 inline bool
53 {
54  return input == '"' || input == '\'';
55 }
56 
57 // method for checking if a character is a candidate
58 // for a part of a variable name
59 inline bool
61 {
62  return (input >= 'a' && input <= 'z')
63  || (input >= 'A' && input <= 'Z')
64  || (input == '_')
65  || (input >= '0' && input <= '9') || input == '.'
66  || input == '{' || input == '}';
67 }
68 
69 // method for checking if input is whitespace
70 inline bool
72 {
73  return input == ' ' || input == '\t' || input == '\r' || input == '\n';
74 }
75 
81 inline bool
83  const std::string & expression)
84 {
85  return cache_.erase (expression) == 1;
86 }
87 
88 
89 #endif // _MADARA_NO_KARL_
90 
91 #endif // _MADARA_KNOWLEDGE_INTERPRETER_INL_
static bool is_reserved_word(const std::string &input)
Checks a given input for a reserved word literal.
Definition: Interpreter.inl:44
static bool is_alphanumeric(char input)
Checks a character to see if it is alphanumeric.
Definition: Interpreter.inl:60
static bool is_number(char input)
Checks a character to see if it is a number.
Definition: Interpreter.inl:30
static struct madara::knowledge::tags::string_t string
static bool is_whitespace(char input)
Checks a character to see if it is whitespace.
Definition: Interpreter.inl:71
ExpressionTreeMap cache_
Cache of expressions that have been previously compiled.
Definition: Interpreter.h:288
static bool is_exponential(char input)
Checks a character to see if it is in scientific format.
Definition: Interpreter.inl:37
static bool is_string_literal(char input)
Checks a character to see if it is a string literal.
Definition: Interpreter.inl:52
bool delete_expression(const std::string &expression)
Attempts to delete an expression from cache.
Definition: Interpreter.inl:82
static bool is_operator(char input)
Checks a character to see if it is a mathematical operator.
Definition: Interpreter.inl:20