6 #include <spiderscript.h>
8 typedef struct sAST_Script tAST_Script;
9 typedef struct sAST_Function tAST_Function;
10 typedef struct sAST_Node tAST_Node;
11 typedef enum eAST_NodeTypes tAST_NodeType;
20 NODETYPE_BLOCK, //!< Node Block
22 NODETYPE_VARIABLE, //!< Variable
23 NODETYPE_CONSTANT, //!< Runtime Constant
24 NODETYPE_STRING, //!< String Constant
25 NODETYPE_INTEGER, //!< Integer Constant
26 NODETYPE_REAL, //!< Real Constant
28 NODETYPE_RETURN, //!< Return from a function (reserved word)
29 NODETYPE_ASSIGN, //!< Variable assignment operator
30 NODETYPE_FUNCTIONCALL, //!< Call a function
32 NODETYPE_LOGICALAND, //!< Logical AND operator
33 NODETYPE_LOGICALOR, //!< Logical OR operator
34 NODETYPE_LOGICALXOR, //!< Logical XOR operator
36 NODETYPE_EQUALS, //!< Comparison Equals
37 NODETYPE_LESSTHAN, //!< Comparison Less Than
38 NODETYPE_GREATERTHAN, //!< Comparison Greater Than
40 NODETYPE_BWAND, //!< Bitwise AND
41 NODETYPE_BWOR, //!< Bitwise OR
42 NODETYPE_BWXOR, //!< Bitwise XOR
44 NODETYPE_BITSHIFTLEFT, //!< Bitwise Shift Left (Grow)
45 NODETYPE_BITSHIFTRIGHT, //!< Bitwise Shift Right (Shrink)
46 NODETYPE_BITROTATELEFT, //!< Bitwise Rotate Left (Grow)
48 NODETYPE_ADD, //!< Add
49 NODETYPE_SUBTRACT, //!< Subtract
50 NODETYPE_MULTIPLY, //!< Multiply
51 NODETYPE_DIVIDE, //!< Divide
52 NODETYPE_MODULO, //!< Modulus
57 tSpiderVariant *Variant;
63 tAST_Function *Functions;
64 tAST_Function *LastFunction;
72 tAST_Node *Arguments; // HACKJOB (Only NODETYPE_VARIABLE is allowed)
77 tAST_Node *NextSibling;
83 tAST_Node *FirstChild;
114 * \note Used for \a NODETYPE_VARIABLE and \a NODETYPE_CONSTANT
117 char _unused; // Shut GCC up
127 tAST_Script *AST_NewScript(void);
129 tAST_Function *AST_AppendFunction(tAST_Script *Script, const char *Name);
130 void AST_AppendFunctionArg(tAST_Function *Function, int Type, tAST_Node *Arg);
131 void AST_SetFunctionCode(tAST_Function *Function, tAST_Node *Root);
133 tAST_Node *AST_NewString(const char *String, int Length);
134 tAST_Node *AST_NewInteger(uint64_t Value);
135 tAST_Node *AST_NewVariable(const char *Name);
136 tAST_Node *AST_NewConstant(const char *Name);
137 tAST_Node *AST_NewFunctionCall(const char *Name);
138 void AST_AppendFunctionCallArg(tAST_Node *Node, tAST_Node *Arg);
140 tAST_Node *AST_NewCodeBlock(void);
141 void AST_AppendNode(tAST_Node *Parent, tAST_Node *Child);
142 tAST_Node *AST_NewAssign(int Operation, tAST_Node *Dest, tAST_Node *Value);
143 tAST_Node *AST_NewBinOp(int Operation, tAST_Node *Left, tAST_Node *Right);
145 void AST_FreeNode(tAST_Node *Node);
147 tSpiderVariable *AST_ExecuteNode(tSpiderScript *Script, tAST_Node *Node);