From d4b977d0904a1dea37922dac60d3bb37f9769230 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Thu, 5 Jan 2012 04:47:56 +1000 Subject: Add a simple flex + btyacc stub. Will be fleshed out soon with LSL grammer. --- LuaSL/src/LuaSL_LSL_tree.h | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 LuaSL/src/LuaSL_LSL_tree.h (limited to 'LuaSL/src/LuaSL_LSL_tree.h') diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h new file mode 100644 index 0000000..6d89672 --- /dev/null +++ b/LuaSL/src/LuaSL_LSL_tree.h @@ -0,0 +1,55 @@ +/* + * Definition of the structure used to build the abstract syntax tree. + */ +#ifndef __EXPRESSION_H__ +#define __EXPRESSION_H__ + +/** + * @brief The operation type + */ +typedef enum tagEOperationType +{ + eVALUE, + eMULTIPLY, + ePLUS +}EOperationType; + +/** + * @brief The expression structure + */ +typedef struct tagSExpression +{ + EOperationType type;///< type of operation + + int value;///< valid only when type is eVALUE + struct tagSExpression* left; ///< left side of the tree + struct tagSExpression* right;///< right side of the tree +}SExpression; + +/** + * @brief It creates an identifier + * @param value The number value + * @return The expression or NULL in case of no memory + */ +SExpression* createNumber(int value); + +/** + * @brief It creates an operation + * @param type The operation type + * @param left The left operand + * @param right The right operand + * @return The expression or NULL in case of no memory + */ +SExpression* createOperation( + EOperationType type, + SExpression *left, + SExpression *right); + +/** + * @brief Deletes a expression + * @param b The expression + */ +void deleteExpression(SExpression *b); + +#endif // __EXPRESSION_H__ + -- cgit v1.1