aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LuaSL_LSL_tree.h
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-13 10:18:06 +1000
committerDavid Walter Seikel2012-01-13 10:18:06 +1000
commit23b491733ab314bd9769ce9e9f2a4f375cb46fae (patch)
tree98b5a75f68bad06cbc637f17dab07c0ea9feb2aa /LuaSL/src/LuaSL_LSL_tree.h
parentBig comment about type casting and the various operations an types. (diff)
downloadSledjHamr-23b491733ab314bd9769ce9e9f2a4f375cb46fae.zip
SledjHamr-23b491733ab314bd9769ce9e9f2a4f375cb46fae.tar.gz
SledjHamr-23b491733ab314bd9769ce9e9f2a4f375cb46fae.tar.bz2
SledjHamr-23b491733ab314bd9769ce9e9f2a4f375cb46fae.tar.xz
Generic type handling, and add the float type.
Diffstat (limited to '')
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.h95
1 files changed, 94 insertions, 1 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h
index 558dc8d..d2d767c 100644
--- a/LuaSL/src/LuaSL_LSL_tree.h
+++ b/LuaSL/src/LuaSL_LSL_tree.h
@@ -30,6 +30,7 @@ extern int yydebug;
30// http://w-hat.com/stackdepth is a useful discussion about some aspects of the LL parser. 30// http://w-hat.com/stackdepth is a useful discussion about some aspects of the LL parser.
31 31
32 32
33typedef struct _allowedTypes allowedTypes;
33typedef struct _LSL_Token LSL_Token; 34typedef struct _LSL_Token LSL_Token;
34typedef struct _LSL_Leaf LSL_Leaf; 35typedef struct _LSL_Leaf LSL_Leaf;
35typedef struct _LSL_Parenthesis LSL_Parenthesis; 36typedef struct _LSL_Parenthesis LSL_Parenthesis;
@@ -47,7 +48,7 @@ typedef int LSL_Type;
47 48
48typedef void (*convertToken2Lua) (FILE *file, LSL_Leaf *content); 49typedef void (*convertToken2Lua) (FILE *file, LSL_Leaf *content);
49typedef void (*outputToken) (FILE *file, LSL_Leaf *content); 50typedef void (*outputToken) (FILE *file, LSL_Leaf *content);
50typedef void (*evaluateToken) (LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); 51typedef LSL_Leaf * (*evaluateToken) (LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right);
51 52
52#ifndef FALSE 53#ifndef FALSE
53typedef enum 54typedef enum
@@ -69,9 +70,99 @@ typedef enum
69 LSL_NOIGNORE = 64 70 LSL_NOIGNORE = 64
70} LSL_Flags; 71} LSL_Flags;
71 72
73typedef enum
74{
75 OT_nothing,
76
77 OT_bool,
78 OT_integer,
79 OT_float,
80 OT_key,
81 OT_list,
82 OT_rotation,
83 OT_string,
84 OT_vector,
85 OT_other,
86
87 OT_boolBool,
88 OT_intInt,
89 OT_intFloat,
90 OT_floatInt,
91 OT_floatFloat,
92 OT_keyString,
93 OT_stringKey,
94 OT_stringString,
95 OT_listList,
96 OT_listInt,
97 OT_listFloat,
98 OT_intList,
99 OT_floatList,
100 OT_listOther,
101 OT_vectorVector,
102 OT_vectorFloat,
103 OT_vectorRotation,
104 OT_rotationRotation,
105 OT_otherOther,
106 OT_invalid
107} opType;
108
109/*
110Each op is of a specific type -
111
112bool !
113int - ~
114float -
115
116bool bool && || == != =
117int int * / + - % == != < > <= >= = += -= *= /= %= & | ^ << >>
118int float cast to float float
119float int cast to float float
120float float * / + - == != < > <= >= = += -= *= /=
121
122key string cast to string string
123string key cast to string string
124string string + == != = +=
125
126list list + == != = +=
127list integer/float + < > <= >= = +=
128integer/float list + < > <= >=
129list other + = +=
130
131vector vector * / + - % == != = += -= *= /= %=
132vector float * /
133vector rotation * /
134
135rotation rotation * / + - == != = += -= *= /=
136*/
137
138typedef enum
139{
140 ST_NONE = 0,
141 ST_ASSIGNMENT = 1, // -= *= /=
142 ST_BIT_NOT = 2, // ~
143 ST_BOOL_NOT = 4, // !
144 ST_BITWISE = 8, // & | ^ << >>
145 ST_BOOLEAN = 16, // && !!
146 ST_COMPARISON = 32, // < > <= >=
147 ST_CONCATENATION = 64, // = +=
148 ST_EQUALITY = 128, // == !=
149 ST_ADD = 512, // +
150 ST_SUBTRACT = 1024, // -
151 ST_NEGATE = 2048, // -
152 ST_MULTIPLY = 4096, // * /
153 ST_MODULO = 8192 // % %=
154} opSubType;
155
156struct _allowedTypes
157{
158 opType result;
159 int subTypes;
160};
161
72struct _LSL_Token 162struct _LSL_Token
73{ 163{
74 LSL_Type type; 164 LSL_Type type;
165 opSubType subType;
75 char *token; 166 char *token;
76 LSL_Flags flags; 167 LSL_Flags flags;
77 outputToken output; 168 outputToken output;
@@ -86,8 +177,10 @@ struct _LSL_Leaf
86 LSL_Token *token; 177 LSL_Token *token;
87 char *ignorableText; 178 char *ignorableText;
88 int line, column; 179 int line, column;
180 opType basicType;
89 union 181 union
90 { 182 {
183 opType operationValue;
91 LSL_Parenthesis *parenthesis; 184 LSL_Parenthesis *parenthesis;
92 185
93 float floatValue; 186 float floatValue;