3 #ifndef _MADARA_KNOWLEDGE_INTERPRETER_H_
4 #define _MADARA_KNOWLEDGE_INTERPRETER_H_
6 #ifndef _MADARA_NO_KARL_
135 std::string::size_type& i,
int& accumulated_precedence,
136 ::std::list<Symbol*>& list,
Symbol*& returnableInput);
148 const std::string& input, std::string::size_type& i,
149 int& accumulated_precedence, ::std::list<Symbol*>& list,
163 const std::string& input, std::string::size_type& i,
164 int& accumulated_precedence, ::std::list<Symbol*>& list,
177 const std::string& input, std::string::size_type& i,
178 int& accumulated_precedence, ::std::list<Symbol*>& list,
191 const std::string& input, std::string::size_type& i,
192 int& accumulated_precedence, ::std::list<Symbol*>& list,
202 Symbol* op, ::std::list<Symbol*>& list);
217 const std::string& input, std::string::size_type& i,
218 Symbol*& lastValidInput,
bool& handled,
int& accumulated_precedence,
219 ::std::list<Symbol*>& list,
bool build_argument_list =
false);
232 const std::string& input, std::string::size_type& i,
233 Symbol*& lastValidInput,
bool& handled,
int& accumulated_precedence,
234 ::std::list<Symbol*>& list);
249 const std::string& input, std::string::size_type& i,
250 Symbol*& lastValidInput,
bool& handled,
int& accumulated_precedence,
251 ::std::list<Symbol*>& list,
bool build_argument_list =
false);
Encapsulates a MADARA KaRL expression into an evaluatable tree.
Parses incoming expression strings into a parse tree and generates an expression tree from the parse ...
static bool is_operator(char input)
Checks a character to see if it is a mathematical operator.
static bool is_string_literal(char input)
Checks a character to see if it is a string literal.
static bool is_reserved_word(const std::string &input)
Checks a given input for a reserved word literal.
static bool is_whitespace(char input)
Checks a character to see if it is whitespace.
static bool is_exponential(char input)
Checks a character to see if it is in scientific format.
void variable_insert(madara::knowledge::ThreadSafeContext &context, const std::string &input, std::string::size_type &i, int &accumulated_precedence, ::std::list< Symbol * > &list, Symbol *&lastValidInput)
Inserts a variable into the tree.
static bool is_alphanumeric(char input)
Checks a character to see if it is alphanumeric.
void number_insert(madara::knowledge::ThreadSafeContext &context, const std::string &input, std::string::size_type &i, int &accumulated_precedence, ::std::list< Symbol * > &list, Symbol *&lastValidInput)
Inserts a number into the tree.
void handle_parenthesis(madara::knowledge::ThreadSafeContext &context, const std::string &input, std::string::size_type &i, Symbol *&lastValidInput, bool &handled, int &accumulated_precedence, ::std::list< Symbol * > &list, bool build_argument_list=false)
Handles a parenthesis.
void handle_array(madara::knowledge::ThreadSafeContext &context, const std::string &input, std::string::size_type &i, Symbol *&lastValidInput, bool &handled, int &accumulated_precedence, ::std::list< Symbol * > &list)
Handles a parenthesis.
static bool is_number(char input)
Checks a character to see if it is a number.
void system_call_insert(madara::knowledge::ThreadSafeContext &context, const std::string &input, std::string::size_type &i, int &accumulated_precedence, ::std::list< Symbol * > &list, Symbol *&lastValidInput)
Inserts a system call into the tree.
void precedence_insert(madara::knowledge::ThreadSafeContext &context, Symbol *op, ::std::list< Symbol * > &list)
Inserts a mathematical operator into the tree.
ExpressionTree interpret(madara::knowledge::ThreadSafeContext &context, const std::string &input)
Compiles an expression into an expression tree.
void handle_for_loop(madara::knowledge::ThreadSafeContext &context, std::string &variable, const std::string &input, std::string::size_type &i, int &accumulated_precedence, ::std::list< Symbol * > &list, Symbol *&returnableInput)
extracts precondition, condition, postcondition, and body from input
void string_insert(char opener, madara::knowledge::ThreadSafeContext &context, const std::string &input, std::string::size_type &i, int &accumulated_precedence, ::std::list< Symbol * > &list, Symbol *&lastValidInput)
Inserts a variable into the tree.
ExpressionTreeMap cache_
Cache of expressions that have been previously compiled.
bool delete_expression(const std::string &expression)
Attempts to delete an expression from cache.
virtual ~Interpreter()
Destructor.
void main_loop(madara::knowledge::ThreadSafeContext &context, const std::string &input, std::string::size_type &i, Symbol *&lastValidInput, bool &handled, int &accumulated_precedence, ::std::list< Symbol * > &list, bool build_argument_list=false)
Inserts a variable into the tree.
Interpreter()
Constructor.
Abstract base class of all parse tree nodes.
This class stores variables and their values for use by any entity needing state information in a thr...
std::map< std::string, ExpressionTree > ExpressionTreeMap
Copyright(c) 2020 Galois.