aboutsummaryrefslogtreecommitdiff
path: root/script.h
diff options
context:
space:
mode:
Diffstat (limited to 'script.h')
-rw-r--r--script.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/script.h b/script.h
new file mode 100644
index 0000000..05427ca
--- /dev/null
+++ b/script.h
@@ -0,0 +1,60 @@
+#pragma once
+
+#include "enginedata.h"
+#include "query.h"
+#include <vector>
+#include <unordered_map>
+#include <map>
+
+struct Script;
+struct Query;
+
+
+enum ExprNodeType {
+ EFN_ADD=0, EFN_SUBTRACT, EFN_MULTIPLY, EFN_DIVIDE, EFN_MODULO,
+ EFN_EQUAL, EFN_UNEQUAL,
+ EFN_LESS, EFN_GREATER, EFN_LESSEQUAL, EFN_GREATEREQUAL,
+ EFN_AND, EFN_OR,
+ EFN_NOT, //1 arg
+ EFN_MAX, EFN_MIN,
+
+ EFN_NUMBER, EFN_VARIABLE, //0 arg
+ EFN_INVALID //invalid
+};
+
+bool validateExprNodeType(ExprNodeType);
+
+struct Expression {
+ ExprNodeType type;
+ vector<Expression> args;
+ int evaluate(unordered_map<string,QueryResult>&);
+};
+
+
+enum ScriptLineType {
+ SLT_QUERYSTUB,
+ SLT_IF,
+ SLT_WHILE,
+ SLT_ASSIGNMENT
+};
+
+struct ScriptLine {
+ ScriptLineType type;
+ string *querystub=NULL;
+ string *destvar=NULL;
+ Expression *expr=NULL;
+ Script *block=NULL;
+
+ ~ScriptLine(void);
+ vector<QueryResult> execute(map<string,Table>&,unordered_map<string,QueryResult>&);
+};
+
+struct Script {
+ vector<ScriptLine> lines;
+
+ vector<QueryResult> execute(map<string,Table>&);
+ vector<QueryResult> execute(map<string,Table>&,unordered_map<string,QueryResult>&);
+};
+
+//just hands over pointer, CALLING FUNCTION TAKES OWNERSHIP
+Query* resolveQueryStub(const string &stub,map<string,Table>&,unordered_map<string,QueryResult>&);