MADARA  3.1.8
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 // method for checking if a character is a number
44 inline bool
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
52 inline bool
54 {
55  return (input >= 'a' && input <= 'z')
56  || (input >= 'A' && input <= 'Z')
57  || (input == '_')
58  || (input >= '0' && input <= '9') || input == '.'
59  || input == '{' || input == '}';
60 }
61 
62 // method for checking if input is whitespace
63 inline bool
65 {
66  return input == ' ' || input == '\t' || input == '\r' || input == '\n';
67 }
68 
74 inline bool
76  const std::string & expression)
77 {
78  return cache_.erase (expression) == 1;
79 }
80 
81 
82 #endif // _MADARA_NO_KARL_
83 
84 #endif // _MADARA_KNOWLEDGE_INTERPRETER_INL_
static bool is_alphanumeric(char input)
Checks a character to see if it is alphanumeric.
Definition: Interpreter.inl:53
static bool is_number(char input)
Checks a character to see if it is a number.
Definition: Interpreter.inl:30
static bool is_whitespace(char input)
Checks a character to see if it is whitespace.
Definition: Interpreter.inl:64
ExpressionTreeMap cache_
Cache of expressions that have been previously compiled.
Definition: Interpreter.h:280
static bool is_exponential(char input)
Checks a character to see if it is in scientific format.
Definition: Interpreter.inl:37
static constexpr struct madara::knowledge::tags::string_t string
static bool is_string_literal(char input)
Checks a character to see if it is a string literal.
Definition: Interpreter.inl:45
bool delete_expression(const std::string &expression)
Attempts to delete an expression from cache.
Definition: Interpreter.inl:75
static bool is_operator(char input)
Checks a character to see if it is a mathematical operator.
Definition: Interpreter.inl:20