Commit 5bf810a4a4b4e31466cf6cc8f165950e95ed8270

Authored by Georg Hopp
1 parent 933d4d7b

some code cleanups

1 -nobase_include_HEADERS = tepal.h helper.h \  
2 - evalExpr.h evalCond.h expValue.h \  
3 - ident.h identList.h bbtree.h \  
4 - variable.h assign.h cast.h \  
5 - statement.h stmtQueue.h block.h 1 +nobase_include_HEADERS = tepal.h helper.h \
  2 + evalExpr.h evalCond.h expValue.h \
  3 + ident.h identList.h bbtree.h \
  4 + variable.h assign.h cast.h \
  5 + statement.h stmtQueue.h block.h
6 6
@@ -4,6 +4,6 @@ @@ -4,6 +4,6 @@
4 #include <ident.h> 4 #include <ident.h>
5 #include <expValue.h> 5 #include <expValue.h>
6 6
7 -s_expVal * assign (s_ident *, s_expVal *); 7 +s_expVal * assign(s_ident *, s_expVal *);
8 8
9 #endif /* _ASSIGN_H_ */ 9 #endif /* _ASSIGN_H_ */
@@ -15,10 +15,10 @@ struct bbTreeNode @@ -15,10 +15,10 @@ struct bbTreeNode
15 15
16 } s_bbTreeNode; 16 } s_bbTreeNode;
17 17
18 -#define BBTREE_LEFT_HEIGHT(t) ((t)->left ? (t)->left->height : -1)  
19 -#define BBTREE_RIGHT_HEIGHT(t) ((t)->right ? (t)->right->height : -1)  
20 -#define BBTREE_AVL(t) (BBTREE_RIGHT_HEIGHT ((t)) - \  
21 - BBTREE_LEFT_HEIGHT ((t))) 18 +#define BBTREE_LEFT_HEIGHT(t) ((t)->left ? (t)->left->height : -1)
  19 +#define BBTREE_RIGHT_HEIGHT(t) ((t)->right ? (t)->right->height : -1)
  20 +#define BBTREE_AVL(t) (BBTREE_RIGHT_HEIGHT ((t)) - \
  21 + BBTREE_LEFT_HEIGHT ((t)))
22 22
23 23
24 /* 24 /*
@@ -27,13 +27,13 @@ struct bbTreeNode @@ -27,13 +27,13 @@ struct bbTreeNode
27 * with bbTreeNew. 27 * with bbTreeNew.
28 * 28 *
29 * params: 29 * params:
30 - * left: pointer to left value  
31 - * right: pointer to right value 30 + * left: pointer to left value
  31 + * right: pointer to right value
32 * 32 *
33 * returns: 33 * returns:
34 - * 0: if values equal  
35 - * 1: if right greater left  
36 - * -1: if left greater right 34 + * 0: if values equal
  35 + * 1: if right greater left
  36 + * -1: if left greater right
37 */ 37 */
38 typedef int (* t_bbTreeCmp) (void *, void *); 38 typedef int (* t_bbTreeCmp) (void *, void *);
39 39
@@ -47,20 +47,20 @@ struct bbTree @@ -47,20 +47,20 @@ struct bbTree
47 47
48 48
49 /* constructor, destructor */ 49 /* constructor, destructor */
50 -s_bbTree * bbTreeNew (t_bbTreeCmp);  
51 -void bbTreeFree (s_bbTree *); 50 +s_bbTree * bbTreeNew(t_bbTreeCmp);
  51 +void bbTreeFree(s_bbTree *);
52 52
53 /* data manipulation */ 53 /* data manipulation */
54 -void * bbTreeInsert (s_bbTree *, void *);  
55 -void * bbTreeSeek (s_bbTree *, void *);  
56 -void * bbTreeRemove (s_bbTree *, void *); 54 +void * bbTreeInsert(s_bbTree *, void *);
  55 +void * bbTreeSeek(s_bbTree *, void *);
  56 +void * bbTreeRemove(s_bbTree *, void *);
57 57
58 /* analysation */ 58 /* analysation */
59 -void * bbTreeMin (s_bbTree *);  
60 -void * bbTreeMax (s_bbTree *);  
61 -int bbTreeSize (s_bbTree *); 59 +void * bbTreeMin(s_bbTree *);
  60 +void * bbTreeMax(s_bbTree *);
  61 +int bbTreeSize(s_bbTree *);
62 62
63 /* bbTree to other Datastructure */ 63 /* bbTree to other Datastructure */
64 -void ** bbTreeInOrder (s_bbTree *, void **); 64 +void ** bbTreeInOrder(s_bbTree *, void **);
65 65
66 #endif /* _BBTREE_H_ */ 66 #endif /* _BBTREE_H_ */
@@ -6,14 +6,15 @@ typedef struct block s_block; @@ -6,14 +6,15 @@ typedef struct block s_block;
6 #include <identList.h> 6 #include <identList.h>
7 #include <stmtQueue.h> 7 #include <stmtQueue.h>
8 8
9 -s_block * blockNew (s_stmtQueue *);  
10 -void blockFree (s_block *);  
11 -void blockSetNonLocalId (s_block *, s_ident *);  
12 -s_block * blockPush (s_block **, s_block *);  
13 -s_block * blockPop (s_block **);  
14 -s_block * blockPrev (s_block *);  
15 -s_stmtQueue * blockStmts (s_block *);  
16 -s_identList * blockIdl (s_block *); 9 +s_block * blockNew(s_stmtQueue *);
  10 +void blockFree(s_block *);
  11 +void blockSetNonLocalId(s_block *, s_ident *);
  12 +s_block * blockPush(s_block **, s_block *);
  13 +s_block * blockPop(s_block **);
  14 +s_block * blockPrev(s_block *);
  15 +s_stmtQueue * blockStmts(s_block *);
  16 +s_identList * blockIdl(s_block *);
  17 +
  18 +s_identList * blockGetIdl(s_block *);
17 19
18 -s_identList * blockGetIdl (s_block *);  
19 #endif /* _BLOCK_H_ */ 20 #endif /* _BLOCK_H_ */
@@ -3,8 +3,8 @@ @@ -3,8 +3,8 @@
3 3
4 #include "expValue.h" 4 #include "expValue.h"
5 5
6 -s_expVal * castExprToInt (s_expVal *);  
7 -s_expVal * castExprToFloat (s_expVal *);  
8 -s_expVal * castExprToString (s_expVal *); 6 +s_expVal * castExprToInt(s_expVal *);
  7 +s_expVal * castExprToFloat(s_expVal *);
  8 +s_expVal * castExprToString(s_expVal *);
9 9
10 #endif /* _CAST_H_ */ 10 #endif /* _CAST_H_ */
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 3
4 #include "expValue.h" 4 #include "expValue.h"
5 5
6 -int evalCondExpr (s_expVal *);  
7 -int evalComp (int, s_expVal *, s_expVal *); 6 +int evalCondExpr(s_expVal *);
  7 +int evalComp(int, s_expVal *, s_expVal *);
8 8
9 #endif /* _EVALCOND_H_ */ 9 #endif /* _EVALCOND_H_ */
@@ -10,6 +10,6 @@ @@ -10,6 +10,6 @@
10 #define OVER '/' 10 #define OVER '/'
11 #define MODULO '%' 11 #define MODULO '%'
12 12
13 -s_expVal * evalExpr (int, s_expVal *, s_expVal *); 13 +s_expVal * evalExpr(int, s_expVal *, s_expVal *);
14 14
15 #endif /* _EVAL_EXPR_H_ */ 15 #endif /* _EVAL_EXPR_H_ */
@@ -10,22 +10,21 @@ typedef struct expVal s_expVal; @@ -10,22 +10,21 @@ typedef struct expVal s_expVal;
10 10
11 11
12 /* Constructoren / Destructoren */ 12 /* Constructoren / Destructoren */
13 -s_expVal * expValueIntNew (long);  
14 -s_expVal * expValueFloatNew (double);  
15 -s_expVal * expValueStringNew (char *); 13 +s_expVal * expValueIntNew(long);
  14 +s_expVal * expValueFloatNew(double);
  15 +s_expVal * expValueStringNew(char *);
16 16
17 -s_expVal * expValueClone (s_expVal *); 17 +s_expVal * expValueClone(s_expVal *);
18 18
19 -void expValueFree (s_expVal *); 19 +void expValueFree(s_expVal *);
20 20
21 21
22 /* Accessors */ 22 /* Accessors */
23 -long expValueInt (s_expVal *);  
24 -double expValueFloat (s_expVal *);  
25 -char * expValueString (s_expVal *); 23 +long expValueInt(s_expVal *);
  24 +double expValueFloat(s_expVal *);
  25 +char * expValueString(s_expVal *);
26 26
27 /* analyse expValue */ 27 /* analyse expValue */
28 -int expValueGetType (s_expVal *);  
29 - 28 +int expValueGetType(s_expVal *);
30 29
31 #endif /* _EXP_VALUE_H_ */ 30 #endif /* _EXP_VALUE_H_ */
@@ -12,24 +12,24 @@ typedef struct ident s_ident; @@ -12,24 +12,24 @@ typedef struct ident s_ident;
12 #include <identList.h> 12 #include <identList.h>
13 13
14 /* identifier constructors/destructors */ 14 /* identifier constructors/destructors */
15 -s_ident * identNew (int, const char *);  
16 -s_ident * identUndefNew (int, const char *);  
17 -s_ident * identExpNew (int, const char *, s_expVal *);  
18 -s_ident * identIdlNew (int, const char *, s_identList *);  
19 -void identFree (s_ident *); 15 +s_ident * identNew(int, const char *);
  16 +s_ident * identUndefNew(int, const char *);
  17 +s_ident * identExpNew(int, const char *, s_expVal *);
  18 +s_ident * identIdlNew(int, const char *, s_identList *);
  19 +void identFree(s_ident *);
20 20
21 /* analyse ident */ 21 /* analyse ident */
22 -int identIsQueued (s_ident *);  
23 -void identEnqueue (s_ident *);  
24 -void identDequeue (s_ident *);  
25 -int identGetType (s_ident *);  
26 -char * identGetKey (s_ident *);  
27 -int identGetIdx (s_ident *); 22 +int identIsQueued(s_ident *);
  23 +void identEnqueue(s_ident *);
  24 +void identDequeue(s_ident *);
  25 +int identGetType(s_ident *);
  26 +char * identGetKey(s_ident *);
  27 +int identGetIdx(s_ident *);
28 28
29 /* identifier to value */ 29 /* identifier to value */
30 -s_expVal * identExp (s_ident *);  
31 -s_identList * identIdl (s_ident *);  
32 -s_ident * identSetExp (s_ident *, s_expVal *);  
33 -s_ident * identSetIdl (s_ident *, s_identList *); 30 +s_expVal * identExp(s_ident *);
  31 +s_identList * identIdl(s_ident *);
  32 +s_ident * identSetExp(s_ident *, s_expVal *);
  33 +s_ident * identSetIdl(s_ident *, s_identList *);
34 34
35 #endif /* _IDENT_H_ */ 35 #endif /* _IDENT_H_ */
@@ -7,23 +7,23 @@ typedef struct identList s_identList; @@ -7,23 +7,23 @@ typedef struct identList s_identList;
7 #include <expValue.h> 7 #include <expValue.h>
8 8
9 /* constructor/destructor for new identList */ 9 /* constructor/destructor for new identList */
10 -s_identList * identListNew (void);  
11 -void identListFree (s_identList *); 10 +s_identList * identListNew(void);
  11 +void identListFree(s_identList *);
12 12
13 /* insertions or deletion into a list */ 13 /* insertions or deletion into a list */
14 -s_ident * identListPutVal (s_identList *, s_ident *);  
15 -s_ident * identListPutExpByIdx (s_identList *, int, s_expVal *);  
16 -s_ident * identListPutIdlByIdx (s_identList *, int, s_identList *);  
17 -s_ident * identListPutExpByKey (s_identList *, const char *, s_expVal *);  
18 -s_ident * identListPutIdlByKey (s_identList *, const char *, s_identList *);  
19 -void identListRemoveByIdx (s_identList *, int);  
20 -void identListRemoveByKey (s_identList *, const char *); 14 +s_ident * identListPutVal(s_identList *, s_ident *);
  15 +s_ident * identListPutExpByIdx(s_identList *, int, s_expVal *);
  16 +s_ident * identListPutIdlByIdx(s_identList *, int, s_identList *);
  17 +s_ident * identListPutExpByKey(s_identList *, const char *, s_expVal *);
  18 +s_ident * identListPutIdlByKey(s_identList *, const char *, s_identList *);
  19 +void identListRemoveByIdx(s_identList *, int);
  20 +void identListRemoveByKey(s_identList *, const char *);
21 21
22 /* seeking in list */ 22 /* seeking in list */
23 -s_ident * identListSeekIdx (s_identList *, int);  
24 -s_ident * identListSeekKey (s_identList *, const char *); 23 +s_ident * identListSeekIdx(s_identList *, int);
  24 +s_ident * identListSeekKey(s_identList *, const char *);
25 25
26 /* identList to other DataStructures */ 26 /* identList to other DataStructures */
27 -s_ident ** identListToArray (s_identList *); 27 +s_ident ** identListToArray(s_identList *);
28 28
29 #endif /* _IDENT_LIST_H_ */ 29 #endif /* _IDENT_LIST_H_ */
1 #ifndef _STMT_H_ 1 #ifndef _STMT_H_
2 #define _STMT_H_ 2 #define _STMT_H_
3 3
4 -#define STMT_CONST 0  
5 -#define STMT_BLOCK 1 4 +#define STMT_CONST 0
  5 +#define STMT_BLOCK 1
6 6
7 -#define STMT_PRINT 10  
8 -#define STMT_IF 11  
9 -#define STMT_FOREACH 12  
10 -#define STMT_REPEAT 13  
11 -#define STMT_ASSIGN 14  
12 -#define STMT_UNSET 15 7 +#define STMT_PRINT 10
  8 +#define STMT_IF 11
  9 +#define STMT_FOREACH 12
  10 +#define STMT_REPEAT 13
  11 +#define STMT_ASSIGN 14
  12 +#define STMT_UNSET 15
13 13
14 #define STMT_EVAL_PLUS 20 14 #define STMT_EVAL_PLUS 20
15 #define STMT_EVAL_MINUS 21 15 #define STMT_EVAL_MINUS 21
@@ -26,24 +26,24 @@ @@ -26,24 +26,24 @@
26 #define STMT_CAST_FLOAT 41 26 #define STMT_CAST_FLOAT 41
27 #define STMT_CAST_STRING 42 27 #define STMT_CAST_STRING 42
28 28
29 -#define STMT_COMP_EQ 50  
30 -#define STMT_COMP_NE 51  
31 -#define STMT_COMP_LT 52  
32 -#define STMT_COMP_GT 53  
33 -#define STMT_COMP_LE 54  
34 -#define STMT_COMP_GE 55 29 +#define STMT_COMP_EQ 50
  30 +#define STMT_COMP_NE 51
  31 +#define STMT_COMP_LT 52
  32 +#define STMT_COMP_GT 53
  33 +#define STMT_COMP_LE 54
  34 +#define STMT_COMP_GE 55
35 35
36 -#define STMT_COND_EXPR 60  
37 -#define STMT_COND_AND 61  
38 -#define STMT_COND_OR 62  
39 -#define STMT_COND_NEG 63 36 +#define STMT_COND_EXPR 60
  37 +#define STMT_COND_AND 61
  38 +#define STMT_COND_OR 62
  39 +#define STMT_COND_NEG 63
40 40
41 41
42 42
43 -#define STYP_NONE 0  
44 -#define STYP_COND 1  
45 -#define STYP_EVAL 2  
46 -#define STYP_IDVAL 3 43 +#define STYP_NONE 0
  44 +#define STYP_COND 1
  45 +#define STYP_EVAL 2
  46 +#define STYP_IDVAL 3
47 47
48 /* 48 /*
49 * Deklaration und Definition 49 * Deklaration und Definition
@@ -52,7 +52,7 @@ union stmtType @@ -52,7 +52,7 @@ union stmtType
52 { 52 {
53 int cond; 53 int cond;
54 struct expVal * eVal; 54 struct expVal * eVal;
55 - struct ident * idVal; 55 + struct ident * idVal;
56 }; 56 };
57 57
58 typedef struct stmt s_stmt; 58 typedef struct stmt s_stmt;
@@ -64,11 +64,11 @@ typedef union stmtType u_stmtType; @@ -64,11 +64,11 @@ typedef union stmtType u_stmtType;
64 /* 64 /*
65 * Interface 65 * Interface
66 */ 66 */
67 -s_stmt * stmtNew (int, s_stmtQueue *, int, u_stmtType);  
68 -void stmtFree (s_stmt *);  
69 -s_stmtQueue * stmtGetArgs (s_stmt *);  
70 -u_stmtType stmtGetVal (s_stmt *);  
71 -int stmtGetConstTyp (s_stmt *);  
72 -u_stmtType stmtDo (s_stmt *, s_block *); 67 +s_stmt * stmtNew(int, s_stmtQueue *, int, u_stmtType);
  68 +void stmtFree(s_stmt *);
  69 +s_stmtQueue * stmtGetArgs(s_stmt *);
  70 +u_stmtType stmtGetVal(s_stmt *);
  71 +int stmtGetConstTyp(s_stmt *);
  72 +u_stmtType stmtDo(s_stmt *, s_block *);
73 73
74 #endif /* _STMT_H_ */ 74 #endif /* _STMT_H_ */
@@ -7,16 +7,16 @@ typedef struct stmtQueue s_stmtQueue; @@ -7,16 +7,16 @@ typedef struct stmtQueue s_stmtQueue;
7 7
8 #include <statement.h> 8 #include <statement.h>
9 9
10 -s_stmtQueue * stmtQueueNew (void);  
11 -void stmtQueueFree (s_stmtQueue *); 10 +s_stmtQueue * stmtQueueNew(void);
  11 +void stmtQueueFree(s_stmtQueue *);
12 12
13 -void stmtQueueEnqueue (s_stmtQueue *, s_stmt *);  
14 -s_stmt * stmtQueueDequeue (s_stmtQueue *);  
15 -s_stmtQueue * stmtQueueConcat (s_stmtQueue *, s_stmtQueue *); 13 +void stmtQueueEnqueue(s_stmtQueue *, s_stmt *);
  14 +s_stmt * stmtQueueDequeue(s_stmtQueue *);
  15 +s_stmtQueue * stmtQueueConcat(s_stmtQueue *, s_stmtQueue *);
16 16
17 -s_stmt * stmtQueueGet (s_stmtQueue *, unsigned int);  
18 -void stmtQueueDo (s_stmtQueue *); 17 +s_stmt * stmtQueueGet(s_stmtQueue *, unsigned int);
  18 +void stmtQueueDo(s_stmtQueue *);
19 19
20 -unsigned int stmtQueueGetSize (s_stmtQueue *); 20 +unsigned int stmtQueueGetSize(s_stmtQueue *);
21 21
22 #endif /* _STMT_QUEUE_H_ */ 22 #endif /* _STMT_QUEUE_H_ */
@@ -3,12 +3,12 @@ @@ -3,12 +3,12 @@
3 3
4 #include "expValue.h" 4 #include "expValue.h"
5 5
6 -#define ERR_UNDEF_VAR 0  
7 -#define ERR_NO_INDEX 1  
8 -#define ERR_STRING_OPERATOR 2  
9 -#define ERR_FLOAT_OPERATOR 3 6 +#define ERR_UNDEF_VAR 0
  7 +#define ERR_NO_INDEX 1
  8 +#define ERR_STRING_OPERATOR 2
  9 +#define ERR_FLOAT_OPERATOR 3
10 10
11 -void exitError (int, ...);  
12 -void printExpr (s_expVal *); 11 +void exitError(int, ...);
  12 +void printExpr(s_expVal *);
13 13
14 #endif /* __HTMLPARS_H__ */ 14 #endif /* __HTMLPARS_H__ */
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 #include <expValue.h> 5 #include <expValue.h>
6 #include <block.h> 6 #include <block.h>
7 7
8 -s_ident * getVariable (s_identList *, char *);  
9 -s_ident * getArray (s_ident *, s_expVal *); 8 +s_ident * getVariable(s_identList *, char *);
  9 +s_ident * getArray(s_ident *, s_expVal *);
10 10
11 #endif /* _VARIABLE_H_ */ 11 #endif /* _VARIABLE_H_ */
@@ -8,17 +8,16 @@ @@ -8,17 +8,16 @@
8 #include <tepal.h> 8 #include <tepal.h>
9 9
10 s_expVal * 10 s_expVal *
11 -assign (s_ident * to, s_expVal * from)  
12 -{  
13 - if (identGetType (to) == ID_TYP_IDL)  
14 - {  
15 - char * key = identGetKey (to);  
16 - exitError (ERR_NO_INDEX, key); 11 +assign(s_ident * to, s_expVal * from)
  12 +{
  13 + if (identGetType (to) == ID_TYP_IDL) {
  14 + char * key = identGetKey(to);
  15 + exitError(ERR_NO_INDEX, key);
17 } 16 }
18 17
19 /* !!!IMPORTANT!!! work here */ 18 /* !!!IMPORTANT!!! work here */
20 /*identListPutVal (block, to);*/ 19 /*identListPutVal (block, to);*/
21 - identSetExp (to, from); 20 + identSetExp(to, from);
22 21
23 return from; 22 return from;
24 } 23 }
@@ -8,15 +8,14 @@ @@ -8,15 +8,14 @@
8 #include <helper.h> 8 #include <helper.h>
9 #include <bbtree.h> 9 #include <bbtree.h>
10 10
11 -  
12 /* 11 /*
13 * statisch Funktionen 12 * statisch Funktionen
14 */ 13 */
15 static 14 static
16 s_bbTreeNode * 15 s_bbTreeNode *
17 -bbTreeNodeNew (void * value) 16 +bbTreeNodeNew(void * value)
18 { 17 {
19 - s_bbTreeNode * new = (s_bbTreeNode *) malloc (sizeof (s_bbTreeNode)); 18 + s_bbTreeNode * new = (s_bbTreeNode*)malloc(sizeof(s_bbTreeNode));
20 19
21 new->value = value; 20 new->value = value;
22 new->left = NULL; 21 new->left = NULL;
@@ -28,20 +27,18 @@ bbTreeNodeNew (void * value) @@ -28,20 +27,18 @@ bbTreeNodeNew (void * value)
28 27
29 static 28 static
30 void 29 void
31 -bbTreeNodeFree (s_bbTreeNode * t) 30 +bbTreeNodeFree(s_bbTreeNode * t)
32 { 31 {
33 if (t == NULL) 32 if (t == NULL)
34 return; 33 return;
35 34
36 - while (t->left != NULL)  
37 - {  
38 - bbTreeNodeFree (t->left); 35 + while (t->left != NULL) {
  36 + bbTreeNodeFree(t->left);
39 t->left = NULL; 37 t->left = NULL;
40 } 38 }
41 39
42 - while (t->right != NULL)  
43 - {  
44 - bbTreeNodeFree (t->right); 40 + while (t->right != NULL) {
  41 + bbTreeNodeFree(t->right);
45 t->right = NULL; 42 t->right = NULL;
46 } 43 }
47 44
@@ -50,11 +47,11 @@ bbTreeNodeFree (s_bbTreeNode * t) @@ -50,11 +47,11 @@ bbTreeNodeFree (s_bbTreeNode * t)
50 47
51 static 48 static
52 void 49 void
53 -bbTreeNodeRotLeft (s_bbTreeNode * node) 50 +bbTreeNodeRotLeft(s_bbTreeNode * node)
54 { 51 {
55 s_bbTreeNode * left = node->left; 52 s_bbTreeNode * left = node->left;
56 s_bbTreeNode * right = node->right; 53 s_bbTreeNode * right = node->right;
57 - void * value = node->value; 54 + void * value = node->value;
58 55
59 node->right = right->right; 56 node->right = right->right;
60 node->left = right; 57 node->left = right;
@@ -64,18 +61,18 @@ bbTreeNodeRotLeft (s_bbTreeNode * node) @@ -64,18 +61,18 @@ bbTreeNodeRotLeft (s_bbTreeNode * node)
64 node->value = right->value; 61 node->value = right->value;
65 right->value = value; 62 right->value = value;
66 63
67 - node->right->height =  
68 - 1 + MAX (BBTREE_LEFT_HEIGHT (node->left),  
69 - BBTREE_RIGHT_HEIGHT (node->left)); 64 + node->right->height =
  65 + 1 + MAX(BBTREE_LEFT_HEIGHT(node->left),
  66 + BBTREE_RIGHT_HEIGHT(node->left));
70 } 67 }
71 68
72 static 69 static
73 void 70 void
74 -bbTreeNodeRotRight (s_bbTreeNode * node) 71 +bbTreeNodeRotRight(s_bbTreeNode * node)
75 { 72 {
76 s_bbTreeNode * left = node->left; 73 s_bbTreeNode * left = node->left;
77 s_bbTreeNode * right = node->right; 74 s_bbTreeNode * right = node->right;
78 - void * value = node->value; 75 + void * value = node->value;
79 76
80 node->left = left->left; 77 node->left = left->left;
81 node->right = left; 78 node->right = left;
@@ -85,29 +82,27 @@ bbTreeNodeRotRight (s_bbTreeNode * node) @@ -85,29 +82,27 @@ bbTreeNodeRotRight (s_bbTreeNode * node)
85 node->value = left->value; 82 node->value = left->value;
86 left->value = value; 83 left->value = value;
87 84
88 - node->right->height =  
89 - 1 + MAX (BBTREE_LEFT_HEIGHT (node->right),  
90 - BBTREE_RIGHT_HEIGHT (node->right)); 85 + node->right->height =
  86 + 1 + MAX(BBTREE_LEFT_HEIGHT(node->right),
  87 + BBTREE_RIGHT_HEIGHT(node->right));
91 } 88 }
92 89
93 static 90 static
94 void 91 void
95 -bbTreeNodeBalance (s_bbTreeNode * node) 92 +bbTreeNodeBalance(s_bbTreeNode * node)
96 { 93 {
97 - if (BBTREE_AVL (node) == -2) 94 + if (BBTREE_AVL(node) == -2) {
98 /* left is to long */ 95 /* left is to long */
99 - {  
100 - if (BBTREE_AVL (node->left) == 1)  
101 - bbTreeNodeRotLeft (node->left);  
102 - bbTreeNodeRotRight (node); 96 + if (BBTREE_AVL(node->left) == 1)
  97 + bbTreeNodeRotLeft(node->left);
  98 + bbTreeNodeRotRight(node);
103 } 99 }
104 100
105 - if (BBTREE_AVL (node) == -2) 101 + if (BBTREE_AVL(node) == -2) {
106 /* right is to long */ 102 /* right is to long */
107 - {  
108 - if (BBTREE_AVL (node->right) == 1)  
109 - bbTreeNodeRotRight (node->right);  
110 - bbTreeNodeRotLeft (node); 103 + if (BBTREE_AVL(node->right) == 1)
  104 + bbTreeNodeRotRight(node->right);
  105 + bbTreeNodeRotLeft(node);
111 } 106 }
112 } 107 }
113 108
@@ -117,57 +112,57 @@ bbTreeNodeBalance (s_bbTreeNode * node) @@ -117,57 +112,57 @@ bbTreeNodeBalance (s_bbTreeNode * node)
117 */ 112 */
118 static 113 static
119 s_bbTreeNode * 114 s_bbTreeNode *
120 -bbTreeNodeInsert (s_bbTreeNode ** _node, t_bbTreeCmp cmp, void * value) 115 +bbTreeNodeInsert(s_bbTreeNode ** _node, t_bbTreeCmp cmp, void * value)
121 { 116 {
122 s_bbTreeNode * node = *_node; 117 s_bbTreeNode * node = *_node;
123 s_bbTreeNode * ret; 118 s_bbTreeNode * ret;
124 119
125 - if (node == NULL) 120 + if (node == NULL) {
126 /* This happens only when bbTree::root is NULL 121 /* This happens only when bbTree::root is NULL
127 * on bbTreeInsert call */ 122 * on bbTreeInsert call */
128 - {  
129 - *_node = bbTreeNodeNew (value); 123 + *_node = bbTreeNodeNew(value);
130 return NULL; 124 return NULL;
131 } 125 }
132 126
133 - if (cmp (value, node->value) == 0) 127 + if (cmp(value, node->value) == 0) {
134 /* The key is already in the tree. 128 /* The key is already in the tree.
135 * In this case a node containing the old value is returned. */ 129 * In this case a node containing the old value is returned. */
136 - {  
137 - ret = bbTreeNodeNew (node->value); 130 + ret = bbTreeNodeNew(node->value);
138 node->value = value; 131 node->value = value;
139 return ret; 132 return ret;
140 } 133 }
141 134
142 - if (cmp (value, node->value) < 0)  
143 - if (node->left == NULL)  
144 - {  
145 - node->left = bbTreeNodeNew (value); 135 + if (cmp(value, node->value) < 0) {
  136 + if (node->left == NULL) {
  137 + node->left = bbTreeNodeNew(value);
146 ret = NULL; 138 ret = NULL;
147 139
148 - if (BBTREE_AVL (node) == -2 || BBTREE_AVL (node) == 2)  
149 - bbTreeNodeBalance (node); 140 + if (BBTREE_AVL(node) == -2 || BBTREE_AVL(node) == 2)
  141 + bbTreeNodeBalance(node);
150 142
151 - node->height = 1 + MAX (  
152 - BBTREE_LEFT_HEIGHT (node), BBTREE_RIGHT_HEIGHT (node)); 143 + node->height = 1 + MAX(
  144 + BBTREE_LEFT_HEIGHT(node), BBTREE_RIGHT_HEIGHT(node));
153 } 145 }
154 - else  
155 - ret = bbTreeNodeInsert (&node->left, cmp, value); 146 + else {
  147 + ret = bbTreeNodeInsert(&node->left, cmp, value);
  148 + }
  149 + }
156 150
157 - if (cmp (value, node->value) > 0)  
158 - if (node->right == NULL)  
159 - {  
160 - node->right = bbTreeNodeNew (value); 151 + if (cmp(value, node->value) > 0) {
  152 + if (node->right == NULL) {
  153 + node->right = bbTreeNodeNew(value);
161 ret = NULL; 154 ret = NULL;
162 155
163 - if (BBTREE_AVL (node) == -2 || BBTREE_AVL (node) == 2)  
164 - bbTreeNodeBalance (node); 156 + if (BBTREE_AVL(node) == -2 || BBTREE_AVL(node) == 2)
  157 + bbTreeNodeBalance(node);
165 158
166 - node->height = 1 + MAX (  
167 - BBTREE_LEFT_HEIGHT (node), BBTREE_RIGHT_HEIGHT (node)); 159 + node->height = 1 + MAX(
  160 + BBTREE_LEFT_HEIGHT(node), BBTREE_RIGHT_HEIGHT(node));
  161 + }
  162 + else {
  163 + ret = bbTreeNodeInsert(&node->right, cmp, value);
168 } 164 }
169 - else  
170 - ret = bbTreeNodeInsert (&node->right, cmp, value); 165 + }
171 166
172 /* if we come here a new node was inserted a returned node 167 /* if we come here a new node was inserted a returned node
173 * containing {NULL, NULL} as value reflects this fact. */ 168 * containing {NULL, NULL} as value reflects this fact. */
@@ -176,18 +171,18 @@ bbTreeNodeInsert (s_bbTreeNode ** _node, t_bbTreeCmp cmp, void * value) @@ -176,18 +171,18 @@ bbTreeNodeInsert (s_bbTreeNode ** _node, t_bbTreeCmp cmp, void * value)
176 171
177 static 172 static
178 s_bbTreeNode * 173 s_bbTreeNode *
179 -bbTreeNodeSeek (s_bbTreeNode * node, t_bbTreeCmp cmp, void * value) 174 +bbTreeNodeSeek(s_bbTreeNode * node, t_bbTreeCmp cmp, void * value)
180 { 175 {
181 if (node == NULL) 176 if (node == NULL)
182 return NULL; 177 return NULL;
183 178
184 - if (cmp (value, node->value) == 0) 179 + if (cmp(value, node->value) == 0)
185 return node; 180 return node;
186 181
187 - if (cmp (value, node->value) < 0) 182 + if (cmp(value, node->value) < 0)
188 return bbTreeNodeSeek (node->left, cmp, value); 183 return bbTreeNodeSeek (node->left, cmp, value);
189 184
190 - if (cmp (value, node->value) > 0) 185 + if (cmp(value, node->value) > 0)
191 return bbTreeNodeSeek (node->right, cmp, value); 186 return bbTreeNodeSeek (node->right, cmp, value);
192 187
193 return NULL; 188 return NULL;
@@ -195,35 +190,35 @@ bbTreeNodeSeek (s_bbTreeNode * node, t_bbTreeCmp cmp, void * value) @@ -195,35 +190,35 @@ bbTreeNodeSeek (s_bbTreeNode * node, t_bbTreeCmp cmp, void * value)
195 190
196 static 191 static
197 s_bbTreeNode * 192 s_bbTreeNode *
198 -bbTreeNodeMax (s_bbTreeNode * node) 193 +bbTreeNodeMax(s_bbTreeNode * node)
199 { 194 {
200 if (node != NULL && node->right != NULL) 195 if (node != NULL && node->right != NULL)
201 - return bbTreeNodeMax (node->right); 196 + return bbTreeNodeMax(node->right);
202 197
203 return node; 198 return node;
204 } 199 }
205 200
206 static 201 static
207 s_bbTreeNode * 202 s_bbTreeNode *
208 -bbTreeNodeMin (s_bbTreeNode * node) 203 +bbTreeNodeMin(s_bbTreeNode * node)
209 { 204 {
210 if (node != NULL && node->left != NULL) 205 if (node != NULL && node->left != NULL)
211 - return bbTreeNodeMin (node->left); 206 + return bbTreeNodeMin(node->left);
212 207
213 return node; 208 return node;
214 } 209 }
215 210
216 static 211 static
217 int 212 int
218 -bbTreeNodeSize (s_bbTreeNode * node) 213 +bbTreeNodeSize(s_bbTreeNode * node)
219 { 214 {
220 int size = 0; 215 int size = 0;
221 216
222 if (node == NULL) 217 if (node == NULL)
223 return 0; 218 return 0;
224 219
225 - size += bbTreeNodeSize (node->left);  
226 - size += bbTreeNodeSize (node->right); 220 + size += bbTreeNodeSize(node->left);
  221 + size += bbTreeNodeSize(node->right);
227 222
228 return size + 1; 223 return size + 1;
229 } 224 }
@@ -235,7 +230,7 @@ bbTreeNodeSize (s_bbTreeNode * node) @@ -235,7 +230,7 @@ bbTreeNodeSize (s_bbTreeNode * node)
235 */ 230 */
236 static 231 static
237 s_bbTreeNode * 232 s_bbTreeNode *
238 -bbTreeNodeRemove (s_bbTreeNode ** _node, t_bbTreeCmp cmp, void * value) 233 +bbTreeNodeRemove(s_bbTreeNode ** _node, t_bbTreeCmp cmp, void * value)
239 { 234 {
240 s_bbTreeNode * ret = NULL; 235 s_bbTreeNode * ret = NULL;
241 s_bbTreeNode * node = *_node; 236 s_bbTreeNode * node = *_node;
@@ -243,49 +238,43 @@ bbTreeNodeRemove (s_bbTreeNode ** _node, t_bbTreeCmp cmp, void * value) @@ -243,49 +238,43 @@ bbTreeNodeRemove (s_bbTreeNode ** _node, t_bbTreeCmp cmp, void * value)
243 if (node == NULL) 238 if (node == NULL)
244 return NULL; 239 return NULL;
245 240
246 - if (cmp (value, node->value) == 0) 241 + if (cmp (value, node->value) == 0) {
247 /* found the element left */ 242 /* found the element left */
248 - {  
249 - if (node->left == NULL && node->right == NULL) 243 + if (node->left == NULL && node->right == NULL) {
250 /* found a leaf */ 244 /* found a leaf */
251 - {  
252 - ret = bbTreeNodeNew (node->value);  
253 - free (node); 245 + ret = bbTreeNodeNew(node->value);
  246 + free(node);
254 *_node = NULL; 247 *_node = NULL;
255 } 248 }
256 - else if (node->left != NULL && node->left != NULL) 249 + else if (node->left != NULL && node->left != NULL) {
257 /* left & right subtree exists use either max(left) or min(right) */ 250 /* left & right subtree exists use either max(left) or min(right) */
258 - {  
259 s_bbTreeNode * maxLeft; 251 s_bbTreeNode * maxLeft;
260 252
261 - maxLeft = bbTreeNodeMax (node->left); 253 + maxLeft = bbTreeNodeMax(node->left);
262 node->value = maxLeft->value; 254 node->value = maxLeft->value;
263 - ret = bbTreeNodeRemove (&node->left, cmp, maxLeft->value); 255 + ret = bbTreeNodeRemove(&node->left, cmp, maxLeft->value);
264 256
265 - if (BBTREE_AVL (node) == -2 || BBTREE_AVL (node) == 2) 257 + if (BBTREE_AVL(node) == -2 || BBTREE_AVL(node) == 2)
266 bbTreeNodeBalance (node); 258 bbTreeNodeBalance (node);
267 259
268 - node->height = 1 + MAX (  
269 - BBTREE_LEFT_HEIGHT (node), BBTREE_RIGHT_HEIGHT (node)); 260 + node->height = 1 + MAX(
  261 + BBTREE_LEFT_HEIGHT(node), BBTREE_RIGHT_HEIGHT(node));
270 } 262 }
271 - else if ((node->left == NULL) != (node->right == NULL) /* ^^ */) 263 + else if ((node->left == NULL) != (node->right == NULL) /* ^^ */) {
272 /* there is only one subtree */ 264 /* there is only one subtree */
273 /* This subtree must be a leaf, because the tree is balanced */ 265 /* This subtree must be a leaf, because the tree is balanced */
274 - {  
275 - ret = bbTreeNodeNew (node->value); 266 + ret = bbTreeNodeNew(node->value);
276 267
277 - if (node->left != NULL) 268 + if (node->left != NULL) {
278 /* found left node */ 269 /* found left node */
279 - {  
280 node->value = node->left->value; 270 node->value = node->left->value;
281 - free (node->left); 271 + free(node->left);
282 node->left = NULL; 272 node->left = NULL;
283 } 273 }
284 - else 274 + else {
285 /* found right node */ 275 /* found right node */
286 - {  
287 node->value = node->right->value; 276 node->value = node->right->value;
288 - free (node->right); 277 + free(node->right);
289 node->right = NULL; 278 node->right = NULL;
290 } 279 }
291 } 280 }
@@ -293,36 +282,36 @@ bbTreeNodeRemove (s_bbTreeNode ** _node, t_bbTreeCmp cmp, void * value) @@ -293,36 +282,36 @@ bbTreeNodeRemove (s_bbTreeNode ** _node, t_bbTreeCmp cmp, void * value)
293 return ret; 282 return ret;
294 } 283 }
295 284
296 - if (cmp (value, node->value) < 0)  
297 - ret = bbTreeNodeRemove (&node->left, cmp, value); 285 + if (cmp(value, node->value) < 0)
  286 + ret = bbTreeNodeRemove(&node->left, cmp, value);
298 287
299 - if (cmp (value, node->value) > 0)  
300 - ret = bbTreeNodeRemove (&node->right, cmp, value); 288 + if (cmp(value, node->value) > 0)
  289 + ret = bbTreeNodeRemove(&node->right, cmp, value);
301 290
302 return ret; 291 return ret;
303 } 292 }
304 293
305 static 294 static
306 void 295 void
307 -bbTreeNodeInOrder (const s_bbTreeNode * node, void *** ret) 296 +bbTreeNodeInOrder(const s_bbTreeNode * node, void *** ret)
308 { 297 {
309 if (node != NULL && node->left != NULL) 298 if (node != NULL && node->left != NULL)
310 - bbTreeNodeInOrder (node->left, ret); 299 + bbTreeNodeInOrder(node->left, ret);
311 300
312 if (node != NULL) 301 if (node != NULL)
313 **ret = node->value; (*ret)++; 302 **ret = node->value; (*ret)++;
314 303
315 if (node != NULL && node->right != NULL) 304 if (node != NULL && node->right != NULL)
316 - bbTreeNodeInOrder (node->right, ret); 305 + bbTreeNodeInOrder(node->right, ret);
317 } 306 }
318 307
319 /* 308 /*
320 * Interface (non-static functions) 309 * Interface (non-static functions)
321 */ 310 */
322 s_bbTree * 311 s_bbTree *
323 -bbTreeNew (t_bbTreeCmp cmp) 312 +bbTreeNew(t_bbTreeCmp cmp)
324 { 313 {
325 - s_bbTree * new = (s_bbTree *) malloc (sizeof (s_bbTree)); 314 + s_bbTree * new = (s_bbTree*)malloc(sizeof(s_bbTree));
326 315
327 new->root = NULL; 316 new->root = NULL;
328 new->cmp = cmp; 317 new->cmp = cmp;
@@ -331,22 +320,21 @@ bbTreeNew (t_bbTreeCmp cmp) @@ -331,22 +320,21 @@ bbTreeNew (t_bbTreeCmp cmp)
331 } 320 }
332 321
333 void 322 void
334 -bbTreeFree (s_bbTree * t) 323 +bbTreeFree(s_bbTree * t)
335 { 324 {
336 - bbTreeNodeFree (t->root); 325 + bbTreeNodeFree(t->root);
337 326
338 - free (t); 327 + free(t);
339 } 328 }
340 329
341 void * 330 void *
342 -bbTreeInsert (s_bbTree * t, void * value) 331 +bbTreeInsert(s_bbTree * t, void * value)
343 { 332 {
344 - s_bbTreeNode * oldNode = bbTreeNodeInsert (&t->root, t->cmp, value);  
345 -  
346 - if (oldNode != NULL)  
347 - { 333 + s_bbTreeNode * oldNode = bbTreeNodeInsert(&t->root, t->cmp, value);
  334 +
  335 + if (oldNode != NULL) {
348 value = oldNode->value; 336 value = oldNode->value;
349 - free (oldNode); 337 + free(oldNode);
350 338
351 return value; 339 return value;
352 } 340 }
@@ -355,22 +343,21 @@ bbTreeInsert (s_bbTree * t, void * value) @@ -355,22 +343,21 @@ bbTreeInsert (s_bbTree * t, void * value)
355 } 343 }
356 344
357 void * 345 void *
358 -bbTreeSeek (s_bbTree * t, void * value) 346 +bbTreeSeek(s_bbTree * t, void * value)
359 { 347 {
360 - s_bbTreeNode * seek = bbTreeNodeSeek (t->root, t->cmp, value); 348 + s_bbTreeNode * seek = bbTreeNodeSeek(t->root, t->cmp, value);
361 349
362 return (seek != NULL) ? seek->value : NULL; 350 return (seek != NULL) ? seek->value : NULL;
363 } 351 }
364 352
365 void * 353 void *
366 -bbTreeRemove (s_bbTree * t, void * value) 354 +bbTreeRemove(s_bbTree * t, void * value)
367 { 355 {
368 - s_bbTreeNode * oldNode = bbTreeNodeRemove (&t->root, t->cmp, value); 356 + s_bbTreeNode * oldNode = bbTreeNodeRemove(&t->root, t->cmp, value);
369 357
370 - if (oldNode != NULL)  
371 - { 358 + if (oldNode != NULL) {
372 value = oldNode->value; 359 value = oldNode->value;
373 - free (oldNode); 360 + free(oldNode);
374 361
375 return value; 362 return value;
376 } 363 }
@@ -379,33 +366,33 @@ bbTreeRemove (s_bbTree * t, void * value) @@ -379,33 +366,33 @@ bbTreeRemove (s_bbTree * t, void * value)
379 } 366 }
380 367
381 void * 368 void *
382 -bbTreeMax (s_bbTree * t) 369 +bbTreeMax(s_bbTree * t)
383 { 370 {
384 - s_bbTreeNode * max = bbTreeNodeMax (t->root); 371 + s_bbTreeNode * max = bbTreeNodeMax(t->root);
385 372
386 return max == NULL ? max : max->value; 373 return max == NULL ? max : max->value;
387 } 374 }
388 375
389 void * 376 void *
390 -bbTreeMin (s_bbTree * t) 377 +bbTreeMin(s_bbTree * t)
391 { 378 {
392 - s_bbTreeNode * max = bbTreeNodeMin (t->root); 379 + s_bbTreeNode * max = bbTreeNodeMin(t->root);
393 380
394 return max == NULL ? max : max->value; 381 return max == NULL ? max : max->value;
395 } 382 }
396 383
397 int 384 int
398 -bbTreeSize (s_bbTree * t) 385 +bbTreeSize(s_bbTree * t)
399 { 386 {
400 - return bbTreeNodeSize (t->root); 387 + return bbTreeNodeSize(t->root);
401 } 388 }
402 389
403 void ** 390 void **
404 -bbTreeInOrder (s_bbTree * t, void ** buffer) 391 +bbTreeInOrder(s_bbTree * t, void ** buffer)
405 { 392 {
406 void ** tmp = buffer; 393 void ** tmp = buffer;
407 394
408 - bbTreeNodeInOrder (t->root, &tmp); 395 + bbTreeNodeInOrder(t->root, &tmp);
409 396
410 return buffer; 397 return buffer;
411 } 398 }
@@ -12,26 +12,27 @@ struct block /* a stack of used blocks. */ @@ -12,26 +12,27 @@ struct block /* a stack of used blocks. */
12 }; 12 };
13 13
14 14
15 -s_identList *  
16 -blockGetIdl (s_block * block) 15 + s_identList *
  16 +blockGetIdl(s_block * block)
17 { 17 {
18 return block->idl; 18 return block->idl;
19 } 19 }
  20 +
20 s_block * 21 s_block *
21 -blockNew (s_stmtQueue * stmts) 22 +blockNew(s_stmtQueue * stmts)
22 { 23 {
23 s_block * new = (s_block *) malloc (sizeof (s_block)); 24 s_block * new = (s_block *) malloc (sizeof (s_block));
24 25
25 new->stmts = stmts; 26 new->stmts = stmts;
26 new->prev = NULL; 27 new->prev = NULL;
27 new->idl = identListNew (); /* !!!FIXME: i guess idl should know about 28 new->idl = identListNew (); /* !!!FIXME: i guess idl should know about
28 - its block! (Give the block as arg) */ 29 + its block! (Give the block as arg) */
29 30
30 return new; 31 return new;
31 } 32 }
32 33
33 void 34 void
34 -blockFree (s_block * bs) 35 +blockFree(s_block * bs)
35 { 36 {
36 if (bs->prev != NULL) 37 if (bs->prev != NULL)
37 blockFree (bs->prev); 38 blockFree (bs->prev);
@@ -39,50 +40,47 @@ blockFree (s_block * bs) @@ -39,50 +40,47 @@ blockFree (s_block * bs)
39 if (bs->stmts != NULL) 40 if (bs->stmts != NULL)
40 stmtQueueFree (bs->stmts); 41 stmtQueueFree (bs->stmts);
41 42
42 - identListFree (bs->idl); 43 + identListFree(bs->idl);
43 44
44 free (bs); 45 free (bs);
45 } 46 }
46 47
47 void 48 void
48 -blockSetNonLocalId (s_block * bs, s_ident * id) 49 +blockSetNonLocalId(s_block * bs, s_ident * id)
49 { 50 {
50 - s_identListPutVal (bs->idl, id); 51 + s_identListPutVal(bs->idl, id);
51 } 52 }
52 53
53 s_block * 54 s_block *
54 -blockPush (s_block ** bs, s_block * new) 55 +blockPush(s_block ** bs, s_block * new)
55 { 56 {
56 - new->prev = *bs;  
57 -  
58 - *bs = new;  
59 - 57 + new->prev = *bs;
  58 + *bs = new;
60 return *bs; 59 return *bs;
61 } 60 }
62 61
63 s_block * 62 s_block *
64 -blockPop (s_block ** bs) 63 +blockPop(s_block ** bs)
65 { 64 {
66 s_block * ret = *bs; 65 s_block * ret = *bs;
67 - *bs = (*bs)->prev;  
68 - 66 + *bs = (*bs)->prev;
69 return ret; 67 return ret;
70 } 68 }
71 69
72 s_block * 70 s_block *
73 -blockPrev (s_block * bs) 71 +blockPrev(s_block * bs)
74 { 72 {
75 return bs->prev; 73 return bs->prev;
76 } 74 }
77 75
78 s_stmtQueue * 76 s_stmtQueue *
79 -blockStmts (s_block * bs) 77 +blockStmts(s_block * bs)
80 { 78 {
81 return bs->stmts; 79 return bs->stmts;
82 } 80 }
83 81
84 s_identList * 82 s_identList *
85 -blockIdl (s_block * bs) 83 +blockIdl(s_block * bs)
86 { 84 {
87 return bs->idl; 85 return bs->idl;
88 } 86 }
@@ -7,24 +7,24 @@ @@ -7,24 +7,24 @@
7 #include <cast.h> 7 #include <cast.h>
8 8
9 s_expVal * 9 s_expVal *
10 -castExprToInt (s_expVal * eVal) 10 +castExprToInt(s_expVal * eVal)
11 { 11 {
12 - return expValueIntNew (expValueInt (eVal)); 12 + return expValueIntNew(expValueInt (eVal));
13 } 13 }
14 14
15 s_expVal * 15 s_expVal *
16 -castExprToFloat (s_expVal * eVal) 16 +castExprToFloat(s_expVal * eVal)
17 { 17 {
18 - return expValueFloatNew (expValueFloat (eVal)); 18 + return expValueFloatNew(expValueFloat (eVal));
19 } 19 }
20 20
21 s_expVal * 21 s_expVal *
22 -castExprToString (s_expVal * eVal) 22 +castExprToString(s_expVal * eVal)
23 { 23 {
24 - char * val = expValueString (eVal);  
25 - s_expVal * ret = expValueStringNew (val); 24 + char * val = expValueString(eVal);
  25 + s_expVal * ret = expValueStringNew(val);
26 26
27 - free (val); 27 + free(val);
28 28
29 return ret; 29 return ret;
30 } 30 }
@@ -12,60 +12,57 @@ @@ -12,60 +12,57 @@
12 */ 12 */
13 static 13 static
14 int 14 int
15 -evalIntComp (int op, s_expVal * _op1, s_expVal * _op2) 15 +evalIntComp(int op, s_expVal * _op1, s_expVal * _op2)
16 { 16 {
17 - long op1 = expValueInt (_op1);  
18 - long op2 = expValueInt (_op2);  
19 -  
20 - switch (op)  
21 - {  
22 - case EQ: return (op1 == op2);  
23 - case NE: return (op1 != op2);  
24 - case LT: return (op1 < op2);  
25 - case GT: return (op1 > op2);  
26 - case LE: return (op1 <= op2);  
27 - case GE: return (op1 >= op2); 17 + long op1 = expValueInt(_op1);
  18 + long op2 = expValueInt(_op2);
  19 +
  20 + switch (op) {
  21 + case EQ: return (op1 == op2);
  22 + case NE: return (op1 != op2);
  23 + case LT: return (op1 < op2);
  24 + case GT: return (op1 > op2);
  25 + case LE: return (op1 <= op2);
  26 + case GE: return (op1 >= op2);
28 } 27 }
29 } 28 }
30 29
31 static 30 static
32 int 31 int
33 -evalFloatComp (int op, s_expVal * _op1, s_expVal * _op2) 32 +evalFloatComp(int op, s_expVal * _op1, s_expVal * _op2)
34 { 33 {
35 - double op1 = expValueFloat (_op1);  
36 - double op2 = expValueFloat (_op2);  
37 -  
38 - switch (op)  
39 - {  
40 - case EQ: return (op1 == op2);  
41 - case NE: return (op1 != op2);  
42 - case LT: return (op1 < op2);  
43 - case GT: return (op1 > op2);  
44 - case LE: return (op1 <= op2);  
45 - case GE: return (op1 >= op2); 34 + double op1 = expValueFloat(_op1);
  35 + double op2 = expValueFloat(_op2);
  36 +
  37 + switch (op) {
  38 + case EQ: return (op1 == op2);
  39 + case NE: return (op1 != op2);
  40 + case LT: return (op1 < op2);
  41 + case GT: return (op1 > op2);
  42 + case LE: return (op1 <= op2);
  43 + case GE: return (op1 >= op2);
46 } 44 }
47 } 45 }
48 46
49 static 47 static
50 int 48 int
51 -evalStringComp (int op, s_expVal * _op1, s_expVal * _op2) 49 +evalStringComp(int op, s_expVal * _op1, s_expVal * _op2)
52 { 50 {
53 - char * op1 = expValueString (_op1);  
54 - char * op2 = expValueString (_op2); 51 + char * op1 = expValueString(_op1);
  52 + char * op2 = expValueString(_op2);
55 long ret; 53 long ret;
56 54
57 - switch (op)  
58 - {  
59 - case EQ: ret = (! strcmp (op1, op2));  
60 - case NE: ret = strcmp (op1, op2);  
61 - case LT: ret = (strcmp (op1, op2) < 0) ? 1 : 0;  
62 - case GT: ret = (strcmp (op1, op2) > 0) ? 1 : 0;  
63 - case LE: ret = (strcmp (op1, op2) <= 0) ? 1 : 0;  
64 - case GE: ret = (strcmp (op1, op2) >= 0) ? 1 : 0; 55 + switch (op) {
  56 + case EQ: ret = (! strcmp(op1, op2));
  57 + case NE: ret = strcmp(op1, op2);
  58 + case LT: ret = (strcmp(op1, op2) < 0) ? 1 : 0;
  59 + case GT: ret = (strcmp(op1, op2) > 0) ? 1 : 0;
  60 + case LE: ret = (strcmp(op1, op2) <= 0) ? 1 : 0;
  61 + case GE: ret = (strcmp(op1, op2) >= 0) ? 1 : 0;
65 } 62 }
66 63
67 - free (op1);  
68 - free (op2); 64 + free(op1);
  65 + free(op2);
69 66
70 return ret; 67 return ret;
71 } 68 }
@@ -76,38 +73,34 @@ evalStringComp (int op, s_expVal * _op1, s_expVal * _op2) @@ -76,38 +73,34 @@ evalStringComp (int op, s_expVal * _op1, s_expVal * _op2)
76 * public functions (interface) 73 * public functions (interface)
77 */ 74 */
78 int 75 int
79 -evalCondExpr (s_expVal * _op) 76 +evalCondExpr(s_expVal * _op)
80 { 77 {
81 - switch (expValueGetType (_op))  
82 - {  
83 - case EXP_TYP_INT: return expValueInt (_op);  
84 - case EXP_TYP_FLOAT: return expValueInt (_op); 78 + switch (expValueGetType(_op)) {
  79 + case EXP_TYP_INT:
  80 + return expValueInt(_op);
  81 + case EXP_TYP_FLOAT:
  82 + return expValueInt(_op);
85 case EXP_TYP_STRING: 83 case EXP_TYP_STRING:
86 - {  
87 - char * op = expValueString (_op);  
88 - long ret = strlen (op);  
89 -  
90 - free (op);  
91 -  
92 - return ret;  
93 - } 84 + {
  85 + char * op = expValueString(_op);
  86 + long ret = strlen(op);
  87 + free(op);
  88 + return ret;
  89 + }
94 } 90 }
95 91
96 return 0; 92 return 0;
97 } 93 }
98 94
99 int 95 int
100 -evalComp (int op, s_expVal * op1, s_expVal * op2) 96 +evalComp(int op, s_expVal * op1, s_expVal * op2)
101 { 97 {
102 - switch (expValueGetType (op1))  
103 - { 98 + switch (expValueGetType(op1)) {
104 case EXP_TYP_INT: 99 case EXP_TYP_INT:
105 - return evalIntComp (op, op1, op2);  
106 - 100 + return evalIntComp(op, op1, op2);
107 case EXP_TYP_FLOAT: 101 case EXP_TYP_FLOAT:
108 - return evalFloatComp (op, op1, op2);  
109 - 102 + return evalFloatComp(op, op1, op2);
110 case EXP_TYP_STRING: 103 case EXP_TYP_STRING:
111 - return evalStringComp (op, op1, op2); 104 + return evalStringComp(op, op1, op2);
112 } 105 }
113 } 106 }
@@ -15,21 +15,21 @@ @@ -15,21 +15,21 @@
15 static 15 static
16 inline 16 inline
17 s_expVal * 17 s_expVal *
18 -stringPlus (s_expVal * _op1, s_expVal * _op2) 18 +stringPlus(s_expVal * _op1, s_expVal * _op2)
19 { 19 {
20 s_expVal * ret; 20 s_expVal * ret;
21 - char * op1 = expValueString (_op1);  
22 - char * op2 = expValueString (_op2);  
23 - char * retVal = (char *) malloc (  
24 - sizeof (char) * (strlen (op1) + strlen (op2) + 1)); 21 + char * op1 = expValueString (_op1);
  22 + char * op2 = expValueString (_op2);
  23 + char * retVal =
  24 + (char *)malloc(sizeof(char) * (strlen(op1) + strlen(op2) + 1));
25 25
26 - strcpy (retVal, op1);  
27 - strcat (retVal, op2);  
28 - ret = expValueStringNew (retVal); 26 + strcpy(retVal, op1);
  27 + strcat(retVal, op2);
  28 + ret = expValueStringNew(retVal);
29 29
30 - free (retVal);  
31 - free (op2);  
32 - free (op1); 30 + free(retVal);
  31 + free(op2);
  32 + free(op1);
33 33
34 return ret; 34 return ret;
35 } 35 }
@@ -37,83 +37,74 @@ stringPlus (s_expVal * _op1, s_expVal * _op2) @@ -37,83 +37,74 @@ stringPlus (s_expVal * _op1, s_expVal * _op2)
37 static 37 static
38 inline 38 inline
39 s_expVal * 39 s_expVal *
40 -stringNeg (s_expVal * _op) 40 +stringNeg(s_expVal * _op)
41 { 41 {
42 s_expVal * ret; 42 s_expVal * ret;
43 int i; 43 int i;
44 44
45 - char * op = expValueString (_op);  
46 - int len = strlen (op) - 1; 45 + char * op = expValueString(_op);
  46 + int len = strlen(op) - 1;
47 47
48 - for (i=0; i<=(len/2); i++)  
49 - { 48 + for (i=0; i<=(len/2); i++) {
50 char tmp = op[i]; 49 char tmp = op[i];
51 op[i] = op[len-i]; 50 op[i] = op[len-i];
52 op[len-i] = tmp; 51 op[len-i] = tmp;
53 } 52 }
54 53
55 - ret = expValueStringNew (op);  
56 - free (op); 54 + ret = expValueStringNew(op);
  55 + free(op);
57 return ret; 56 return ret;
58 } 57 }
59 58
60 static 59 static
61 inline 60 inline
62 s_expVal * 61 s_expVal *
63 -evalIntExp (int op, s_expVal * _op1, s_expVal * _op2) 62 +evalIntExp(int op, s_expVal * _op1, s_expVal * _op2)
64 { 63 {
65 - long op1 = expValueInt (_op1);  
66 - long op2 = (_op2 != NULL) ? expValueInt (_op2) : 0; 64 + long op1 = expValueInt(_op1);
  65 + long op2 = (_op2 != NULL) ? expValueInt(_op2) : 0;
67 66
68 - if (op == NEG) return expValueIntNew (- op1); 67 + if (op == NEG) return expValueIntNew(- op1);
69 68
70 - switch (expValueGetType (_op2))  
71 - { 69 + switch (expValueGetType(_op2)) {
72 case EXP_TYP_INT: 70 case EXP_TYP_INT:
73 case EXP_TYP_FLOAT: 71 case EXP_TYP_FLOAT:
74 - switch (op)  
75 - {  
76 - case PLUS: return expValueIntNew (op1 + op2);  
77 - case MINUS: return expValueIntNew (op1 - op2);  
78 - case TIMES: return expValueIntNew (op1 * op2);  
79 - case OVER: return expValueIntNew (op1 / op2);  
80 - case MODULO: return expValueIntNew (op1 % op2); 72 + switch (op) {
  73 + case PLUS: return expValueIntNew(op1 + op2);
  74 + case MINUS: return expValueIntNew(op1 - op2);
  75 + case TIMES: return expValueIntNew(op1 * op2);
  76 + case OVER: return expValueIntNew(op1 / op2);
  77 + case MODULO: return expValueIntNew(op1 % op2);
81 } 78 }
82 -  
83 case EXP_TYP_STRING: 79 case EXP_TYP_STRING:
84 - if (op == PLUS)  
85 - return stringPlus (_op1, _op2);  
86 - exitError (ERR_STRING_OPERATOR, op); 80 + if (op == PLUS) return stringPlus(_op1, _op2);
  81 + exitError(ERR_STRING_OPERATOR, op);
87 } 82 }
88 } 83 }
89 84
90 static 85 static
91 inline 86 inline
92 s_expVal * 87 s_expVal *
93 -evalFloatExp (int op, s_expVal * _op1, s_expVal * _op2) 88 +evalFloatExp(int op, s_expVal * _op1, s_expVal * _op2)
94 { 89 {
95 double op1 = expValueFloat (_op1); 90 double op1 = expValueFloat (_op1);
96 - double op2 = (_op2 != NULL) ? expValueFloat (_op2) : 0.0; 91 + double op2 = (_op2 != NULL) ? expValueFloat(_op2) : 0.0;
97 92
98 - if (op == NEG) return expValueFloatNew (- op1); 93 + if (op == NEG) return expValueFloatNew(- op1);
99 94
100 - switch (expValueGetType (_op2))  
101 - { 95 + switch (expValueGetType(_op2)) {
102 case EXP_TYP_INT: 96 case EXP_TYP_INT:
103 case EXP_TYP_FLOAT: 97 case EXP_TYP_FLOAT:
104 - switch (op)  
105 - {  
106 - case MODULO: exitError (ERR_FLOAT_OPERATOR, op);  
107 - case PLUS: return expValueFloatNew (op1 + op2);  
108 - case MINUS: return expValueFloatNew (op1 - op2);  
109 - case TIMES: return expValueFloatNew (op1 * op2);  
110 - case OVER: return expValueFloatNew (op1 / op2); 98 + switch (op) {
  99 + case MODULO: exitError(ERR_FLOAT_OPERATOR, op);
  100 + case PLUS: return expValueFloatNew(op1 + op2);
  101 + case MINUS: return expValueFloatNew(op1 - op2);
  102 + case TIMES: return expValueFloatNew(op1 * op2);
  103 + case OVER: return expValueFloatNew(op1 / op2);
111 } 104 }
112 -  
113 case EXP_TYP_STRING: 105 case EXP_TYP_STRING:
114 - if (op == PLUS)  
115 - return stringPlus (_op1, _op2);  
116 - exitError (ERR_STRING_OPERATOR, op); 106 + if (op == PLUS) return stringPlus(_op1, _op2);
  107 + exitError(ERR_STRING_OPERATOR, op);
117 } 108 }
118 } 109 }
119 110
@@ -123,23 +114,17 @@ evalFloatExp (int op, s_expVal * _op1, s_expVal * _op2) @@ -123,23 +114,17 @@ evalFloatExp (int op, s_expVal * _op1, s_expVal * _op2)
123 * public functions (interface) 114 * public functions (interface)
124 */ 115 */
125 s_expVal * 116 s_expVal *
126 -evalExpr (int op, s_expVal * op1, s_expVal * op2) 117 +evalExpr(int op, s_expVal * op1, s_expVal * op2)
127 { 118 {
128 - switch (expValueGetType (op1))  
129 - { 119 + switch (expValueGetType(op1)) {
130 case EXP_TYP_INT: 120 case EXP_TYP_INT:
131 - return evalIntExp (op, op1, op2);  
132 - 121 + return evalIntExp(op, op1, op2);
133 case EXP_TYP_FLOAT: 122 case EXP_TYP_FLOAT:
134 - if (op != MODULO)  
135 - return evalFloatExp (op, op1, op2); 123 + if (op != MODULO) return evalFloatExp(op, op1, op2);
136 exitError (ERR_FLOAT_OPERATOR, op); 124 exitError (ERR_FLOAT_OPERATOR, op);
137 -  
138 case EXP_TYP_STRING: 125 case EXP_TYP_STRING:
139 - if (op == PLUS)  
140 - return stringPlus (op1, op2);  
141 - if (op == NEG)  
142 - return stringNeg (op1);  
143 - exitError (ERR_STRING_OPERATOR, op); 126 + if (op == PLUS) return stringPlus(op1, op2);
  127 + if (op == NEG) return stringNeg(op1);
  128 + exitError(ERR_STRING_OPERATOR, op);
144 } 129 }
145 } 130 }
@@ -22,9 +22,9 @@ struct expVal @@ -22,9 +22,9 @@ struct expVal
22 * Constructoren / Destructoren 22 * Constructoren / Destructoren
23 */ 23 */
24 s_expVal * 24 s_expVal *
25 -expValueIntNew (long val) 25 +expValueIntNew(long val)
26 { 26 {
27 - s_expVal * ret = (s_expVal *) malloc (sizeof (s_expVal)); 27 + s_expVal * ret = (s_expVal *)malloc(sizeof(s_expVal));
28 28
29 ret->type = EXP_TYP_INT; 29 ret->type = EXP_TYP_INT;
30 ret->val.iVal = val; 30 ret->val.iVal = val;
@@ -33,9 +33,9 @@ expValueIntNew (long val) @@ -33,9 +33,9 @@ expValueIntNew (long val)
33 } 33 }
34 34
35 s_expVal * 35 s_expVal *
36 -expValueFloatNew (double val) 36 +expValueFloatNew(double val)
37 { 37 {
38 - s_expVal * ret = (s_expVal *) malloc (sizeof (s_expVal)); 38 + s_expVal * ret = (s_expVal *)malloc(sizeof(s_expVal));
39 39
40 ret->type = EXP_TYP_FLOAT; 40 ret->type = EXP_TYP_FLOAT;
41 ret->val.fVal = val; 41 ret->val.fVal = val;
@@ -44,33 +44,34 @@ expValueFloatNew (double val) @@ -44,33 +44,34 @@ expValueFloatNew (double val)
44 } 44 }
45 45
46 s_expVal * 46 s_expVal *
47 -expValueStringNew (char * val) 47 +expValueStringNew(char * val)
48 { 48 {
49 - s_expVal * ret = (s_expVal *) malloc (sizeof (s_expVal)); 49 + s_expVal * ret = (s_expVal *)malloc(sizeof(s_expVal));
50 50
51 ret->type = EXP_TYP_STRING; 51 ret->type = EXP_TYP_STRING;
52 - ret->val.cPtr = (char *) malloc (sizeof (char) * (strlen (val) + 1));  
53 - strcpy (ret->val.cPtr, val); 52 + ret->val.cPtr = (char *)malloc(sizeof(char) * (strlen(val) + 1));
  53 + strcpy(ret->val.cPtr, val);
54 54
55 return ret; 55 return ret;
56 } 56 }
57 57
58 - s_expVal *  
59 -expValueClone (s_expVal * eVal) 58 + s_expVal *
  59 +expValueClone(s_expVal * eVal)
60 { 60 {
61 - s_expVal * ret = (s_expVal *) malloc (sizeof (s_expVal)); 61 + s_expVal * ret = (s_expVal *)malloc(sizeof(s_expVal));
62 62
63 ret->type = eVal->type; 63 ret->type = eVal->type;
64 64
65 - switch (eVal->type)  
66 - {  
67 - case EXP_TYP_INT: ret->val.iVal = eVal->val.iVal; break;  
68 - case EXP_TYP_FLOAT: ret->val.fVal = eVal->val.fVal; break;  
69 - case EXP_TYP_STRING: 65 + switch (eVal->type) {
  66 + case EXP_TYP_INT:
  67 + ret->val.iVal = eVal->val.iVal; break;
  68 + case EXP_TYP_FLOAT:
  69 + ret->val.fVal = eVal->val.fVal; break;
  70 + case EXP_TYP_STRING:
70 { 71 {
71 - ret->val.cPtr = (char *) malloc (  
72 - sizeof (char) * (strlen (eVal->val.cPtr) + 1));  
73 - strcpy (ret->val.cPtr, eVal->val.cPtr); 72 + ret->val.cPtr = (char *)malloc(
  73 + sizeof(char) * (strlen(eVal->val.cPtr) + 1));
  74 + strcpy(ret->val.cPtr, eVal->val.cPtr);
74 } 75 }
75 } 76 }
76 77
@@ -78,11 +79,10 @@ expValueClone (s_expVal * eVal) @@ -78,11 +79,10 @@ expValueClone (s_expVal * eVal)
78 } 79 }
79 80
80 void 81 void
81 -expValueFree (s_expVal * eVal) 82 +expValueFree(s_expVal * eVal)
82 { 83 {
83 - if (eVal->type == EXP_TYP_STRING)  
84 - free (eVal->val.cPtr);  
85 - free (eVal); 84 + if (eVal->type == EXP_TYP_STRING) free(eVal->val.cPtr);
  85 + free(eVal);
86 } 86 }
87 87
88 88
@@ -90,50 +90,45 @@ expValueFree (s_expVal * eVal) @@ -90,50 +90,45 @@ expValueFree (s_expVal * eVal)
90 * Accessors 90 * Accessors
91 */ 91 */
92 long 92 long
93 -expValueInt (s_expVal * eVal) 93 +expValueInt(s_expVal * eVal)
94 { 94 {
95 - switch (eVal->type)  
96 - {  
97 - case EXP_TYP_INT: return eVal->val.iVal;  
98 - case EXP_TYP_FLOAT: return (long) eVal->val.fVal;  
99 - case EXP_TYP_STRING: return atoi (eVal->val.cPtr); 95 + switch (eVal->type) {
  96 + case EXP_TYP_INT: return eVal->val.iVal;
  97 + case EXP_TYP_FLOAT: return (long)eVal->val.fVal;
  98 + case EXP_TYP_STRING: return atoi(eVal->val.cPtr);
100 } 99 }
101 } 100 }
102 101
103 double 102 double
104 -expValueFloat (s_expVal * eVal) 103 +expValueFloat(s_expVal * eVal)
105 { 104 {
106 - switch (eVal->type)  
107 - {  
108 - case EXP_TYP_INT: return (double) eVal->val.iVal;  
109 - case EXP_TYP_FLOAT: return eVal->val.fVal;  
110 - case EXP_TYP_STRING: return atof (eVal->val.cPtr); 105 + switch (eVal->type) {
  106 + case EXP_TYP_INT: return (double) eVal->val.iVal;
  107 + case EXP_TYP_FLOAT: return eVal->val.fVal;
  108 + case EXP_TYP_STRING: return atof(eVal->val.cPtr);
111 } 109 }
112 } 110 }
113 111
114 char * 112 char *
115 -expValueString (s_expVal * eVal) 113 +expValueString(s_expVal * eVal)
116 { 114 {
117 char buf[40]; 115 char buf[40];
118 char * ret = NULL; 116 char * ret = NULL;
119 117
120 - switch (eVal->type)  
121 - { 118 + switch (eVal->type) {
122 case EXP_TYP_INT: 119 case EXP_TYP_INT:
123 - sprintf (buf, "%d", eVal->val.iVal);  
124 - ret = (char *) malloc (sizeof (char) * (strlen (buf) + 1));  
125 - strcpy (ret, buf); 120 + sprintf(buf, "%d", eVal->val.iVal);
  121 + ret = (char*)malloc(sizeof(char) * (strlen(buf) + 1));
  122 + strcpy(ret, buf);
126 break; 123 break;
127 -  
128 - case EXP_TYP_FLOAT:  
129 - sprintf (buf, "%f", eVal->val.fVal);  
130 - ret = (char *) malloc (sizeof (char) * (strlen (buf) + 1));  
131 - strcpy (ret, buf); 124 + case EXP_TYP_FLOAT:
  125 + sprintf(buf, "%f", eVal->val.fVal);
  126 + ret = (char*)malloc(sizeof(char) * (strlen(buf) + 1));
  127 + strcpy(ret, buf);
132 break; 128 break;
133 -  
134 case EXP_TYP_STRING: 129 case EXP_TYP_STRING:
135 - ret = (char *) malloc (sizeof (char) * (strlen (eVal->val.cPtr) + 1));  
136 - strcpy (ret, eVal->val.cPtr); 130 + ret = (char*)malloc(sizeof(char) * (strlen(eVal->val.cPtr) + 1));
  131 + strcpy(ret, eVal->val.cPtr);
137 break; 132 break;
138 } 133 }
139 134
@@ -141,10 +136,10 @@ expValueString (s_expVal * eVal) @@ -141,10 +136,10 @@ expValueString (s_expVal * eVal)
141 } 136 }
142 137
143 /* 138 /*
144 - * analyse expValue 139 + * analyse expValue
145 */ 140 */
146 int 141 int
147 -expValueGetType (s_expVal * eVal) 142 +expValueGetType(s_expVal * eVal)
148 { 143 {
149 return eVal->type; 144 return eVal->type;
150 } 145 }
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 */ 14 */
15 union identTypes 15 union identTypes
16 { 16 {
17 - s_expVal * base; 17 + s_expVal * base;
18 s_identList * idl; 18 s_identList * idl;
19 }; 19 };
20 20
@@ -41,19 +41,18 @@ struct ident @@ -41,19 +41,18 @@ struct ident
41 * Contructors / Destructors for ident 41 * Contructors / Destructors for ident
42 */ 42 */
43 s_ident * 43 s_ident *
44 -identNew (int idx, const char * key) 44 +identNew(int idx, const char * key)
45 { 45 {
46 - int keyLen = (key == NULL) ? 2 : 2 + strlen (key);  
47 - s_ident * ident = (s_ident *) malloc (sizeof (s_ident)); 46 + int keyLen = (key == NULL) ? 2 : 2 + strlen(key);
  47 + s_ident * ident = (s_ident*)malloc(sizeof(s_ident));
48 48
49 ident->idx = idx; 49 ident->idx = idx;
50 - ident->key = (char *) malloc (sizeof (char) * keyLen); 50 + ident->key = (char*)malloc(sizeof(char) * keyLen);
51 51
52 ident->key[0] = ID_TYP_UNDEF; 52 ident->key[0] = ID_TYP_UNDEF;
53 ident->key[1] = '\0'; 53 ident->key[1] = '\0';
54 54
55 - if (key != NULL)  
56 - strcpy (ident->key + 1, key); 55 + if (key != NULL) strcpy(ident->key + 1, key);
57 56
58 ident->queued = 0; 57 ident->queued = 0;
59 58
@@ -61,37 +60,37 @@ identNew (int idx, const char * key) @@ -61,37 +60,37 @@ identNew (int idx, const char * key)
61 } 60 }
62 61
63 s_ident * 62 s_ident *
64 -identUndefNew (int idx, const char * key) 63 +identUndefNew(int idx, const char * key)
65 { 64 {
66 #ifdef DEBUG2 65 #ifdef DEBUG2
67 - printf ("[!DEBUG!] identUndefNew: %d/%s\n", idx, key); 66 + printf("[!DEBUG!] identUndefNew: %d/%s\n", idx, key);
68 #endif 67 #endif
69 68
70 - return identNew (idx, key); 69 + return identNew(idx, key);
71 } 70 }
72 71
73 s_ident * 72 s_ident *
74 -identExpNew (int idx, const char * key, s_expVal * val) 73 +identExpNew(int idx, const char * key, s_expVal * val)
75 { 74 {
76 - s_ident * ident = identNew (idx, key); 75 + s_ident * ident = identNew(idx, key);
77 76
78 #ifdef DEBUG2 77 #ifdef DEBUG2
79 - printf ("[!DEBUG!] identExpNew: %d/%s\n", idx, key); 78 + printf("[!DEBUG!] identExpNew: %d/%s\n", idx, key);
80 #endif 79 #endif
81 80
82 ident->key[0] = ID_TYP_EXP; 81 ident->key[0] = ID_TYP_EXP;
83 - ident->val.base = expValueClone (val); 82 + ident->val.base = expValueClone(val);
84 83
85 return ident; 84 return ident;
86 } 85 }
87 86
88 s_ident * 87 s_ident *
89 -identIdlNew (int idx, const char * key, s_identList * val) 88 +identIdlNew(int idx, const char * key, s_identList * val)
90 { 89 {
91 - s_ident * ident = identNew (idx, key); 90 + s_ident * ident = identNew(idx, key);
92 91
93 #ifdef DEBUG2 92 #ifdef DEBUG2
94 - printf ("[!DEBUG!] identIdlNew: %d/%s\n", idx, key); 93 + printf("[!DEBUG!] identIdlNew: %d/%s\n", idx, key);
95 #endif 94 #endif
96 95
97 ident->key[0] = ID_TYP_IDL; 96 ident->key[0] = ID_TYP_IDL;
@@ -101,117 +100,107 @@ identIdlNew (int idx, const char * key, s_identList * val) @@ -101,117 +100,107 @@ identIdlNew (int idx, const char * key, s_identList * val)
101 } 100 }
102 101
103 void 102 void
104 -identFree (s_ident * id) 103 +identFree(s_ident * id)
105 { 104 {
106 #ifdef DEBUG2 105 #ifdef DEBUG2
107 - printf ("[!DEBUG!] identFree: %d/%s\n", id->idx, id->key); 106 + printf("[!DEBUG!] identFree: %d/%s\n", id->idx, id->key);
108 #endif 107 #endif
109 108
110 - switch (identGetType (id))  
111 - {  
112 - case ID_TYP_EXP: expValueFree (id->val.base); break;  
113 - case ID_TYP_IDL: identListFree (id->val.idl); break; 109 + switch (identGetType(id)) {
  110 + case ID_TYP_EXP: expValueFree (id->val.base); break;
  111 + case ID_TYP_IDL: identListFree (id->val.idl); break;
114 } 112 }
115 113
116 - free (id->key);  
117 - free (id); 114 + free(id->key);
  115 + free(id);
118 } 116 }
119 117
120 /* 118 /*
121 * analyse ident 119 * analyse ident
122 */ 120 */
123 int 121 int
124 -identIsQueued (s_ident * id) 122 +identIsQueued(s_ident * id)
125 { 123 {
126 return id->queued; 124 return id->queued;
127 } 125 }
128 126
129 void 127 void
130 -identEnqueue (s_ident * id) 128 +identEnqueue(s_ident * id)
131 { 129 {
132 - id->queued ++; 130 + id->queued++;
133 } 131 }
134 132
135 void 133 void
136 -identDequeue (s_ident * id) 134 +identDequeue(s_ident * id)
137 { 135 {
138 - id->queued --; 136 + id->queued--;
139 } 137 }
140 138
141 int 139 int
142 -identGetType (s_ident * id) 140 +identGetType(s_ident * id)
143 { 141 {
144 return id->key[0]; 142 return id->key[0];
145 } 143 }
146 144
147 char * 145 char *
148 -identGetKey (s_ident * id) 146 +identGetKey(s_ident * id)
149 { 147 {
150 return id->key + 1; 148 return id->key + 1;
151 } 149 }
152 150
153 int 151 int
154 -identGetIdx (s_ident * id) 152 +identGetIdx(s_ident * id)
155 { 153 {
156 return id->idx; 154 return id->idx;
157 } 155 }
158 156
159 /* identifier to value */ 157 /* identifier to value */
160 s_expVal * 158 s_expVal *
161 -identExp (s_ident * id) 159 +identExp(s_ident * id)
162 { 160 {
163 s_expVal * ret = NULL; 161 s_expVal * ret = NULL;
164 162
165 - if (id == NULL)  
166 - exitError (ERR_UNDEF_VAR, identGetKey (id)); 163 + if (id == NULL) exitError (ERR_UNDEF_VAR, identGetKey (id));
167 164
168 - if (identGetType (id) == ID_TYP_EXP)  
169 - {  
170 - ret = expValueClone (id->val.base);  
171 - } 165 + if (identGetType (id) == ID_TYP_EXP) ret = expValueClone(id->val.base);
172 166
173 return ret; 167 return ret;
174 } 168 }
175 169
176 s_identList * 170 s_identList *
177 -identIdl (s_ident * id) 171 +identIdl(s_ident * id)
178 { 172 {
179 s_identList * ret = NULL; 173 s_identList * ret = NULL;
180 174
181 - if (identGetType (id) == ID_TYP_IDL)  
182 - {  
183 - ret = id->val.idl;  
184 - } 175 + if (identGetType(id) == ID_TYP_IDL) ret = id->val.idl;
185 176
186 return ret; 177 return ret;
187 } 178 }
188 179
189 s_ident * 180 s_ident *
190 -identSetExp (s_ident * id, s_expVal * val) 181 +identSetExp(s_ident * id, s_expVal * val)
191 { 182 {
192 - switch (identGetType (id))  
193 - {  
194 - case ID_TYP_EXP: expValueFree (id->val.base); break;  
195 - case ID_TYP_IDL: identListFree (id->val.idl); break; 183 + switch (identGetType(id)) {
  184 + case ID_TYP_EXP: expValueFree(id->val.base); break;
  185 + case ID_TYP_IDL: identListFree(id->val.idl); break;
196 } 186 }
197 187
198 id->key[0] = ID_TYP_EXP; 188 id->key[0] = ID_TYP_EXP;
199 - id->val.base = expValueClone (val); 189 + id->val.base = expValueClone(val);
200 190
201 return id; 191 return id;
202 } 192 }
203 193
204 s_ident * 194 s_ident *
205 -identSetIdl (s_ident * id, s_identList * val) 195 +identSetIdl(s_ident * id, s_identList * val)
206 { 196 {
207 - switch (identGetType (id))  
208 - {  
209 - case ID_TYP_EXP: expValueFree (id->val.base);  
210 - case ID_TYP_IDL: identListFree (id->val.idl); 197 + switch (identGetType (id)) {
  198 + case ID_TYP_EXP: expValueFree (id->val.base);
  199 + case ID_TYP_IDL: identListFree (id->val.idl);
211 } 200 }
212 201
213 id->key[0] = ID_TYP_IDL; 202 id->key[0] = ID_TYP_IDL;
214 id->val.idl = val; 203 id->val.idl = val;
215 - 204 +
216 return id; 205 return id;
217 } 206 }
@@ -21,20 +21,20 @@ struct identList @@ -21,20 +21,20 @@ struct identList
21 */ 21 */
22 static 22 static
23 int 23 int
24 -idHashCmp (void * _a, void * _b) 24 +idHashCmp(void * _a, void * _b)
25 { 25 {
26 - s_ident * a = (s_ident *) _a;  
27 - s_ident * b = (s_ident *) _b; 26 + s_ident * a = (s_ident *)_a;
  27 + s_ident * b = (s_ident *)_b;
28 28
29 - return strcmp (identGetKey (a), identGetKey (b)); 29 + return strcmp(identGetKey (a), identGetKey (b));
30 } 30 }
31 31
32 static 32 static
33 int 33 int
34 -idIdxCmp (void * _a, void * _b) 34 +idIdxCmp(void * _a, void * _b)
35 { 35 {
36 - s_ident * a = (s_ident *) _a;  
37 - s_ident * b = (s_ident *) _b; 36 + s_ident * a = (s_ident *)_a;
  37 + s_ident * b = (s_ident *)_b;
38 38
39 return identGetIdx (a) - identGetIdx (b); 39 return identGetIdx (a) - identGetIdx (b);
40 } 40 }
@@ -48,140 +48,134 @@ idIdxCmp (void * _a, void * _b) @@ -48,140 +48,134 @@ idIdxCmp (void * _a, void * _b)
48 * Contructors / Destructors for identList 48 * Contructors / Destructors for identList
49 */ 49 */
50 s_identList * 50 s_identList *
51 -identListNew (void) 51 +identListNew(void)
52 { 52 {
53 - s_identList * ret = (s_identList *) malloc (sizeof (s_identList)); 53 + s_identList * ret = (s_identList *)malloc(sizeof(s_identList));
54 54
55 - ret->idIdx = bbTreeNew (idIdxCmp);  
56 - ret->idHash = bbTreeNew (idHashCmp); 55 + ret->idIdx = bbTreeNew(idIdxCmp);
  56 + ret->idHash = bbTreeNew(idHashCmp);
57 57
58 return ret; 58 return ret;
59 } 59 }
60 60
61 void 61 void
62 -identListFree (s_identList * l) 62 +identListFree(s_identList * l)
63 { 63 {
64 s_ident ** idArray, 64 s_ident ** idArray,
65 ** _run; 65 ** _run;
66 66
67 - for (_run = idArray = (s_ident **) identListToArray (l); 67 + for (
  68 + _run = idArray = (s_ident **)identListToArray(l);
68 *_run != NULL; 69 *_run != NULL;
69 - _run++) 70 + _run++ )
70 { 71 {
71 - identDequeue (*_run);  
72 - if (! identIsQueued (*_run))  
73 - identFree (*_run); 72 + identDequeue(*_run);
  73 + if (! identIsQueued(*_run)) identFree(*_run);
74 } 74 }
75 -  
76 - free (idArray);  
77 75
78 - bbTreeFree (l->idIdx);  
79 - bbTreeFree (l->idHash); 76 + free(idArray);
80 77
81 - free (l); 78 + bbTreeFree(l->idIdx);
  79 + bbTreeFree(l->idHash);
  80 +
  81 + free(l);
82 } 82 }
83 83
84 /* 84 /*
85 * insertions or deletion into a identList 85 * insertions or deletion into a identList
86 */ 86 */
87 s_ident * 87 s_ident *
88 -identListPutVal (s_identList * l, s_ident * val) 88 +identListPutVal(s_identList * l, s_ident * val)
89 { 89 {
90 s_ident * oldVal; 90 s_ident * oldVal;
91 - int idx = identGetIdx (val);  
92 - char * key = identGetKey (val); 91 + int idx = identGetIdx(val);
  92 + char * key = identGetKey(val);
93 93
94 - identEnqueue (val); 94 + identEnqueue(val);
95 95
96 - if ((idx < 0 && key[0] == '\0') || idx != -1 && key[0] != '\0') 96 + if ((idx < 0 && key[0] == '\0') || idx != -1 && key[0] != '\0') {
97 /* calling error: either key or idx must be valid. But not both. */ 97 /* calling error: either key or idx must be valid. But not both. */
98 return NULL; 98 return NULL;
  99 + }
99 100
100 - if (idx >= 0)  
101 - oldVal = (s_ident *) bbTreeInsert (l->idIdx, val);  
102 - else  
103 - oldVal = (s_ident *) bbTreeInsert (l->idHash, val);  
104 -  
105 - if (oldVal != NULL)  
106 - /*  
107 - * these are few lines with a lot behind them. The not obvious question  
108 - * here is: What happens if oldval points to the same address than val?  
109 - * well, this could only happen if val was was formally queued, because  
110 - * else oldVal would be NULL. Knowing this makes clear that the queue  
111 - * state is not changed at all, because first it was increased above with  
112 - * identEnqueue and the it will be decreased in this if block again. But as  
113 - * it was formally queued it will not be freed (Good)!  
114 - */  
115 - {  
116 - identDequeue (oldVal);  
117 - if (! identIsQueued (oldVal))  
118 - identFree (oldVal); 101 + if (idx >= 0) oldVal = (s_ident*)bbTreeInsert(l->idIdx, val);
  102 + else oldVal = (s_ident*)bbTreeInsert(l->idHash, val);
  103 +
  104 + if (oldVal != NULL) {
  105 + /*
  106 + * these are few lines with a lot behind them. The not obvious
  107 + * question here is: What happens if oldval points to the same address
  108 + * than val? well, this could only happen if val was was formally
  109 + * queued, because else oldVal would be NULL. Knowing this makes clear
  110 + * that the queue state is not changed at all, because first it was
  111 + * increased above with identEnqueue and the it will be decreased in
  112 + * this if block again. But as it was formally queued it will not be
  113 + * freed (Good)!
  114 + */
  115 + identDequeue(oldVal);
  116 + if (! identIsQueued(oldVal)) identFree(oldVal);
119 } 117 }
120 118
121 return val; 119 return val;
122 } 120 }
123 121
124 s_ident * 122 s_ident *
125 -identListPutExpByIdx (s_identList * l, int idx, s_expVal * val) 123 +identListPutExpByIdx(s_identList * l, int idx, s_expVal * val)
126 { 124 {
127 - return identListPutVal (l, identExpNew (idx, NULL, val)); 125 + return identListPutVal(l, identExpNew(idx, NULL, val));
128 } 126 }
129 127
130 s_ident * 128 s_ident *
131 -identListPutIdlByIdx (s_identList * l, int idx, s_identList * val) 129 +identListPutIdlByIdx(s_identList * l, int idx, s_identList * val)
132 { 130 {
133 - return identListPutVal (l, identIdlNew (idx, NULL, val)); 131 + return identListPutVal(l, identIdlNew(idx, NULL, val));
134 } 132 }
135 133
136 s_ident * 134 s_ident *
137 -identListPutExpByKey (s_identList * l, const char * key, s_expVal * val) 135 +identListPutExpByKey(s_identList * l, const char * key, s_expVal * val)
138 { 136 {
139 - return identListPutVal (l, identExpNew (-1, key, val)); 137 + return identListPutVal(l, identExpNew(-1, key, val));
140 } 138 }
141 139
142 s_ident * 140 s_ident *
143 -identListPutIdlByKey (s_identList * l, const char * key, s_identList * val) 141 +identListPutIdlByKey(s_identList * l, const char * key, s_identList * val)
144 { 142 {
145 - return identListPutVal (l, identIdlNew (-1, key, val)); 143 + return identListPutVal(l, identIdlNew(-1, key, val));
146 } 144 }
147 145
148 void 146 void
149 -identListRemoveByIdx (s_identList * l, int idx) 147 +identListRemoveByIdx(s_identList * l, int idx)
150 { 148 {
151 - s_ident * seek = (s_ident *) identNew (idx, NULL);  
152 - s_ident * val = bbTreeRemove (l->idIdx, seek); 149 + s_ident * seek = (s_ident*)identNew(idx, NULL);
  150 + s_ident * val = bbTreeRemove(l->idIdx, seek);
153 151
154 #ifdef DEBUG2 152 #ifdef DEBUG2
155 - printf ("[!DEBUG!] seek (remove) identNew: %d/%s\n", idx, ""); 153 + printf("[!DEBUG!] seek (remove) identNew: %d/%s\n", idx, "");
156 #endif 154 #endif
157 155
158 - identFree (seek); 156 + identFree(seek);
159 157
160 - if (val != NULL)  
161 - {  
162 - identDequeue (val);  
163 - if (! identIsQueued (val))  
164 - identFree (val); 158 + if (val != NULL) {
  159 + identDequeue(val);
  160 + if (! identIsQueued(val)) identFree(val);
165 } 161 }
166 } 162 }
167 163
168 void 164 void
169 -identListRemoveByKey (s_identList * l, const char * key) 165 +identListRemoveByKey(s_identList * l, const char * key)
170 { 166 {
171 - s_ident * seek = (s_ident *) identNew (-1, key);  
172 - s_ident * val = bbTreeRemove (l->idIdx, seek); 167 + s_ident * seek = (s_ident*)identNew(-1, key);
  168 + s_ident * val = bbTreeRemove(l->idIdx, seek);
173 169
174 #ifdef DEBUG2 170 #ifdef DEBUG2
175 - printf ("[!DEBUG!] seek (remove) identNew: %d/%s\n", -1, key); 171 + printf("[!DEBUG!] seek (remove) identNew: %d/%s\n", -1, key);
176 #endif 172 #endif
177 173
178 - identFree (seek); 174 + identFree(seek);
179 175
180 - if (val != NULL)  
181 - {  
182 - identDequeue (val);  
183 - if (! identIsQueued (val))  
184 - identFree (val); 176 + if (val != NULL) {
  177 + identDequeue(val);
  178 + if (! identIsQueued(val)) identFree(val);
185 } 179 }
186 } 180 }
187 181
@@ -189,50 +183,50 @@ identListRemoveByKey (s_identList * l, const char * key) @@ -189,50 +183,50 @@ identListRemoveByKey (s_identList * l, const char * key)
189 * seeking in identList 183 * seeking in identList
190 */ 184 */
191 s_ident * 185 s_ident *
192 -identListSeekIdx (s_identList * l, int idx) 186 +identListSeekIdx(s_identList * l, int idx)
193 { 187 {
194 - s_ident * seek = (s_ident *) identNew (idx, NULL);  
195 - s_ident * val = (s_ident *) bbTreeSeek (l->idIdx, seek); 188 + s_ident * seek = (s_ident*)identNew(idx, NULL);
  189 + s_ident * val = (s_ident*)bbTreeSeek(l->idIdx, seek);
196 190
197 #ifdef DEBUG2 191 #ifdef DEBUG2
198 - printf ("[!DEBUG!] seek identNew: %d/%s\n", idx, ""); 192 + printf("[!DEBUG!] seek identNew: %d/%s\n", idx, "");
199 #endif 193 #endif
200 194
201 - identFree (seek); 195 + identFree(seek);
202 196
203 return val; 197 return val;
204 } 198 }
205 199
206 s_ident * 200 s_ident *
207 -identListSeekKey (s_identList * l, const char * key) 201 +identListSeekKey(s_identList * l, const char * key)
208 { 202 {
209 - s_ident * seek = (s_ident *) identNew (-1, key);  
210 - s_ident * val = (s_ident *) bbTreeSeek (l->idHash, seek); 203 + s_ident * seek = (s_ident*)identNew(-1, key);
  204 + s_ident * val = (s_ident*)bbTreeSeek(l->idHash, seek);
211 205
212 #ifdef DEBUG2 206 #ifdef DEBUG2
213 - printf ("[!DEBUG!] seek identNew: %d/%s\n", -1, key); 207 + printf("[!DEBUG!] seek identNew: %d/%s\n", -1, key);
214 #endif 208 #endif
215 209
216 - identFree (seek); 210 + identFree(seek);
217 211
218 return val; 212 return val;
219 } 213 }
220 214
221 /* 215 /*
222 - * identList to other DataStructures 216 + * identList to other DataStructures
223 */ 217 */
224 s_ident ** 218 s_ident **
225 -identListToArray (s_identList * l) 219 +identListToArray(s_identList * l)
226 { 220 {
227 - int idIdxLen = bbTreeSize (l->idIdx);  
228 - int idHashLen = bbTreeSize (l->idHash); 221 + int idIdxLen = bbTreeSize(l->idIdx);
  222 + int idHashLen = bbTreeSize(l->idHash);
229 int retLen = idIdxLen + idHashLen + 1; 223 int retLen = idIdxLen + idHashLen + 1;
230 - s_ident ** ret = (s_ident **) malloc (sizeof (s_ident *) * retLen); 224 + s_ident ** ret = (s_ident**)malloc(sizeof(s_ident*) * retLen);
231 225
232 - memset (ret, 0, sizeof (s_ident **) * retLen); 226 + memset(ret, 0, sizeof(s_ident**) * retLen);
233 227
234 - bbTreeInOrder (l->idIdx, (void **) ret);  
235 - bbTreeInOrder (l->idHash, (void **) &(ret[idIdxLen])); 228 + bbTreeInOrder(l->idIdx, (void**) ret);
  229 + bbTreeInOrder(l->idHash, (void**) &(ret[idIdxLen]));
236 230
237 return ret; 231 return ret;
238 } 232 }
@@ -32,343 +32,331 @@ struct stmt @@ -32,343 +32,331 @@ struct stmt
32 static 32 static
33 inline 33 inline
34 u_stmtType 34 u_stmtType
35 -stmtEval (s_stmt * stmt, s_block * actBlock, int op) 35 +stmtEval(s_stmt * stmt, s_block * actBlock, int op)
36 { 36 {
37 s_stmtQueue * args = stmt->sQueue; 37 s_stmtQueue * args = stmt->sQueue;
38 - s_expVal * op1 = stmtDo (stmtQueueGet (args, 0), actBlock).eVal,  
39 - * op2 = stmtDo (stmtQueueGet (args, 1), actBlock).eVal,  
40 - * ret;  
41 -  
42 - ret = evalExpr (op, op1, op2); 38 + s_expVal * op1 = stmtDo(stmtQueueGet(args, 0), actBlock).eVal,
  39 + * op2 = stmtDo(stmtQueueGet(args, 1), actBlock).eVal,
  40 + * ret;
43 41
44 - if (op1 != NULL) expValueFree (op1);  
45 - if (op2 != NULL) expValueFree (op2); 42 + ret = evalExpr(op, op1, op2);
46 43
47 - return (u_stmtType) ret; 44 + if (op1 != NULL) expValueFree(op1);
  45 + if (op2 != NULL) expValueFree(op2);
  46 +
  47 + return (u_stmtType)ret;
48 } 48 }
49 49
50 static 50 static
51 inline 51 inline
52 u_stmtType 52 u_stmtType
53 -stmtIdentVar (s_stmt * stmt, s_block * actBlock) 53 +stmtIdentVar(s_stmt * stmt, s_block * actBlock)
54 { 54 {
55 s_ident * ret = NULL; 55 s_ident * ret = NULL;
56 56
57 s_stmtQueue * args = stmt->sQueue; 57 s_stmtQueue * args = stmt->sQueue;
58 - s_expVal * _op = stmtDo (stmtQueueGet (args, 0), actBlock).eVal;  
59 - char * op = expValueString (_op); 58 + s_expVal * _op = stmtDo(stmtQueueGet(args, 0), actBlock).eVal;
  59 + char * op = expValueString(_op);
60 s_block * run = actBlock; 60 s_block * run = actBlock;
61 61
62 - while (ret == NULL && run != NULL)  
63 - {  
64 - ret = identListSeekKey (blockIdl (run), op);  
65 - run = blockPrev (run); 62 + while (ret == NULL && run != NULL) {
  63 + ret = identListSeekKey(blockIdl(run), op);
  64 + run = blockPrev(run);
66 } 65 }
67 66
68 - if (ret == NULL)  
69 - ret = identListPutVal (blockIdl (actBlock), identUndefNew (-1, op)); 67 + if (ret == NULL) {
  68 + ret = identListPutVal(blockIdl(actBlock), identUndefNew(-1, op));
  69 + }
70 70
71 - expValueFree (_op);  
72 - free (op); 71 + expValueFree(_op);
  72 + free(op);
73 73
74 - return (u_stmtType) ret; 74 + return (u_stmtType)ret;
75 } 75 }
76 76
77 static 77 static
78 inline 78 inline
79 u_stmtType 79 u_stmtType
80 -stmtIdentArray (s_stmt * stmt, s_block * actBlock) 80 +stmtIdentArray(s_stmt * stmt, s_block * actBlock)
81 { 81 {
82 s_stmtQueue * args = stmt->sQueue; 82 s_stmtQueue * args = stmt->sQueue;
83 - s_ident * op1 = stmtDo (stmtQueueGet (args, 0), actBlock).idVal;  
84 - s_expVal * op2 = stmtDo (stmtQueueGet (args, 1), actBlock).eVal; 83 + s_ident * op1 = stmtDo(stmtQueueGet(args, 0), actBlock).idVal;
  84 + s_expVal * op2 = stmtDo(stmtQueueGet(args, 1), actBlock).eVal;
85 s_ident * ret; 85 s_ident * ret;
86 86
87 - ret = getArray (op1, op2); 87 + ret = getArray(op1, op2);
88 88
89 - if (op2 != NULL) expValueFree (op2); 89 + if (op2 != NULL) expValueFree(op2);
90 90
91 - return (u_stmtType) ret; 91 + return (u_stmtType)ret;
92 } 92 }
93 93
94 static 94 static
95 inline 95 inline
96 u_stmtType 96 u_stmtType
97 -stmtIdentVal (s_stmt * stmt, s_block * actBlock) 97 +stmtIdentVal(s_stmt * stmt, s_block * actBlock)
98 { 98 {
99 s_stmtQueue * args = stmt->sQueue; 99 s_stmtQueue * args = stmt->sQueue;
100 - s_ident * op1 = stmtDo (stmtQueueGet (args, 0), actBlock).idVal; 100 + s_ident * op1 = stmtDo(stmtQueueGet(args, 0), actBlock).idVal;
101 101
102 - return (u_stmtType) identExp (op1); 102 + return (u_stmtType)identExp(op1);
103 } 103 }
104 104
105 static 105 static
106 inline 106 inline
107 u_stmtType 107 u_stmtType
108 -stmtEvalComp (s_stmt * stmt, s_block * actBlock, int op) 108 +stmtEvalComp(s_stmt * stmt, s_block * actBlock, int op)
109 { 109 {
110 s_stmtQueue * args = stmt->sQueue; 110 s_stmtQueue * args = stmt->sQueue;
111 - s_expVal * op1 = stmtDo (stmtQueueGet (args, 0), actBlock).eVal,  
112 - * op2 = stmtDo (stmtQueueGet (args, 1), actBlock).eVal;  
113 - int ret;  
114 -  
115 - ret = evalComp (op, op1, op2); 111 + s_expVal * op1 = stmtDo(stmtQueueGet(args, 0), actBlock).eVal,
  112 + * op2 = stmtDo(stmtQueueGet(args, 1), actBlock).eVal;
  113 + int ret;
  114 +
  115 + ret = evalComp(op, op1, op2);
116 116
117 - if (op1 != NULL) expValueFree (op1);  
118 - if (op2 != NULL) expValueFree (op2); 117 + if (op1 != NULL) expValueFree(op1);
  118 + if (op2 != NULL) expValueFree(op2);
119 119
120 - return (u_stmtType) ret; 120 + return (u_stmtType)ret;
121 } 121 }
122 122
123 static 123 static
124 inline 124 inline
125 u_stmtType 125 u_stmtType
126 -stmtAssign (s_stmt * stmt, s_block * actBlock) 126 +stmtAssign(s_stmt * stmt, s_block * actBlock)
127 { 127 {
128 s_stmtQueue * args = stmt->sQueue; 128 s_stmtQueue * args = stmt->sQueue;
129 - s_ident * op1 = stmtDo (stmtQueueGet (args, 0), actBlock).idVal;  
130 - s_expVal * op2 = stmtDo (stmtQueueGet (args, 1), actBlock).eVal,  
131 - * ret; 129 + s_ident * op1 = stmtDo(stmtQueueGet(args, 0), actBlock).idVal;
  130 + s_expVal * op2 = stmtDo(stmtQueueGet(args, 1), actBlock).eVal,
  131 + * ret;
132 132
133 - if (op1 == NULL)  
134 - op1 = getVariable (NULL, NULL); 133 + if (op1 == NULL) op1 = getVariable(NULL, NULL);
135 134
136 - ret = assign (op1, op2); 135 + ret = assign(op1, op2);
137 136
138 - if (op2 != NULL) expValueFree (op2); 137 + if (op2 != NULL) expValueFree(op2);
139 138
140 - return (u_stmtType) ret; 139 + return (u_stmtType)ret;
141 } 140 }
142 141
143 static 142 static
144 inline 143 inline
145 u_stmtType 144 u_stmtType
146 -stmtPrint (s_stmt * stmt, s_block * actBlock) 145 +stmtPrint(s_stmt * stmt, s_block * actBlock)
147 { 146 {
148 s_stmtQueue * args = stmt->sQueue; 147 s_stmtQueue * args = stmt->sQueue;
149 - s_expVal * op = stmtDo (stmtQueueGet (args, 0), actBlock).eVal; 148 + s_expVal * op = stmtDo(stmtQueueGet(args, 0), actBlock).eVal;
150 149
151 - if (op != NULL)  
152 - {  
153 - printExpr (op);  
154 - expValueFree (op); 150 + if (op != NULL) {
  151 + printExpr(op);
  152 + expValueFree(op);
155 } 153 }
156 154
157 - return (u_stmtType) 0; 155 + return (u_stmtType)0;
158 } 156 }
159 157
160 static 158 static
161 inline 159 inline
162 u_stmtType 160 u_stmtType
163 -stmtEvalCondExpr (s_stmt * stmt, s_block * actBlock) 161 +stmtEvalCondExpr(s_stmt * stmt, s_block * actBlock)
164 { 162 {
165 s_stmtQueue * args = stmt->sQueue; 163 s_stmtQueue * args = stmt->sQueue;
166 - s_expVal * op = stmtDo (stmtQueueGet (args, 0), actBlock).eVal;  
167 - int ret; 164 + s_expVal * op = stmtDo(stmtQueueGet(args, 0), actBlock).eVal;
  165 + int ret;
168 166
169 - ret = evalCondExpr (op); 167 + ret = evalCondExpr(op);
170 168
171 - if (op != NULL) expValueFree (op); 169 + if (op != NULL) expValueFree(op);
172 170
173 - return (u_stmtType) ret; 171 + return (u_stmtType)ret;
174 } 172 }
175 173
176 static 174 static
177 inline 175 inline
178 u_stmtType 176 u_stmtType
179 -stmtEvalCond (s_stmt * stmt, s_block * actBlock, int op) 177 +stmtEvalCond(s_stmt * stmt, s_block * actBlock, int op)
180 { 178 {
181 s_stmtQueue * args = stmt->sQueue; 179 s_stmtQueue * args = stmt->sQueue;
182 - int op1 = stmtDo (stmtQueueGet (args, 0), actBlock).cond; 180 + int op1 = stmtDo(stmtQueueGet(args, 0), actBlock).cond;
183 181
184 - switch (op)  
185 - { 182 + switch (op) {
186 case LOGAND: 183 case LOGAND:
187 { 184 {
188 - int op2 = stmtDo (stmtQueueGet (args, 1), actBlock).cond;  
189 - return (u_stmtType) (op1 && op2); 185 + int op2 = stmtDo(stmtQueueGet(args, 1), actBlock).cond;
  186 + return (u_stmtType)(op1 && op2);
190 } 187 }
191 -  
192 case LOGOR: 188 case LOGOR:
193 { 189 {
194 - int op2 = stmtDo (stmtQueueGet (args, 1), actBlock).cond;  
195 - return (u_stmtType) (op1 || op2); 190 + int op2 = stmtDo(stmtQueueGet(args, 1), actBlock).cond;
  191 + return (u_stmtType)(op1 || op2);
196 } 192 }
197 -  
198 case LOGNEG: 193 case LOGNEG:
199 - return (u_stmtType) (! op1); 194 + return (u_stmtType)(! op1);
200 } 195 }
201 } 196 }
202 197
203 static 198 static
204 inline 199 inline
205 u_stmtType 200 u_stmtType
206 -stmtCastInt (s_stmt * stmt, s_block * actBlock) 201 +stmtCastInt(s_stmt * stmt, s_block * actBlock)
207 { 202 {
208 s_stmtQueue * args = stmt->sQueue; 203 s_stmtQueue * args = stmt->sQueue;
209 - s_expVal * op = stmtDo (stmtQueueGet (args, 0), actBlock).eVal,  
210 - * ret; 204 + s_expVal * op = stmtDo(stmtQueueGet(args, 0), actBlock).eVal,
  205 + * ret;
211 206
212 - ret = castExprToInt (op); 207 + ret = castExprToInt(op);
213 208
214 - if (op != NULL) expValueFree (op); 209 + if (op != NULL) expValueFree(op);
215 210
216 - return (u_stmtType) ret; 211 + return (u_stmtType)ret;
217 } 212 }
218 213
219 static 214 static
220 inline 215 inline
221 u_stmtType 216 u_stmtType
222 -stmtCastFloat (s_stmt * stmt, s_block * actBlock) 217 +stmtCastFloat(s_stmt * stmt, s_block * actBlock)
223 { 218 {
224 s_stmtQueue * args = stmt->sQueue; 219 s_stmtQueue * args = stmt->sQueue;
225 s_expVal * op = stmtDo (stmtQueueGet (args, 0), actBlock).eVal, 220 s_expVal * op = stmtDo (stmtQueueGet (args, 0), actBlock).eVal,
226 * ret; 221 * ret;
227 222
228 - ret = castExprToFloat (op); 223 + ret = castExprToFloat(op);
229 224
230 - if (op != NULL) expValueFree (op); 225 + if (op != NULL) expValueFree(op);
231 226
232 - return (u_stmtType) ret; 227 + return (u_stmtType)ret;
233 } 228 }
234 229
235 static 230 static
236 inline 231 inline
237 u_stmtType 232 u_stmtType
238 -stmtCastString (s_stmt * stmt, s_block * actBlock) 233 +stmtCastString(s_stmt * stmt, s_block * actBlock)
239 { 234 {
240 s_stmtQueue * args = stmt->sQueue; 235 s_stmtQueue * args = stmt->sQueue;
241 - s_expVal * op = stmtDo (stmtQueueGet (args, 0), actBlock).eVal,  
242 - * ret; 236 + s_expVal * op = stmtDo(stmtQueueGet (args, 0), actBlock).eVal,
  237 + * ret;
243 238
244 - ret = castExprToString (op); 239 + ret = castExprToString(op);
245 240
246 - if (op != NULL) expValueFree (op); 241 + if (op != NULL) expValueFree(op);
247 242
248 - return (u_stmtType) ret; 243 + return (u_stmtType)ret;
249 } 244 }
250 245
251 static 246 static
252 inline 247 inline
253 u_stmtType 248 u_stmtType
254 -stmtBlock (s_stmt * stmt, s_block * actBlock) 249 +stmtBlock(s_stmt * stmt, s_block * actBlock)
255 { 250 {
256 unsigned int i; 251 unsigned int i;
257 252
258 - s_stmtQueue * gIds = stmtQueueGet (stmt->sQueue, 0)->sQueue;  
259 - s_stmtQueue * args = stmtQueueGet (stmt->sQueue, 1)->sQueue; 253 + s_stmtQueue * gIds = stmtQueueGet(stmt->sQueue, 0)->sQueue;
  254 + s_stmtQueue * args = stmtQueueGet(stmt->sQueue, 1)->sQueue;
260 s_block * gBlock = NULL; 255 s_block * gBlock = NULL;
261 256
262 - gBlock = actBlock = blockPush (&actBlock, blockNew (args)); 257 + gBlock = actBlock = blockPush(&actBlock, blockNew (args));
263 258
264 /* find the global block */ 259 /* find the global block */
265 - while (blockPrev (gBlock) != NULL)  
266 - gBlock = blockPrev (gBlock);  
267 -  
268 - if (gIds != NULL)  
269 - {  
270 - for (i = 0; i < stmtQueueGetSize (gIds); i++)  
271 - {  
272 - s_expVal * tmp = stmtDo (stmtQueueGet (gIds, i), actBlock).eVal; 260 + while (blockPrev(gBlock) != NULL)
  261 + gBlock = blockPrev(gBlock);
  262 +
  263 + if (gIds != NULL) {
  264 + for (i=0; i < stmtQueueGetSize(gIds); i++) {
  265 + s_expVal * tmp = stmtDo(stmtQueueGet (gIds, i), actBlock).eVal;
273 char * _id; 266 char * _id;
274 s_ident * id; 267 s_ident * id;
275 268
276 - if (tmp == NULL)  
277 - exitError (0); 269 + if (tmp == NULL) exitError (0);
278 270
279 - _id = expValueString (tmp);  
280 - id = identListSeekKey (blockGetIdl (gBlock), _id);  
281 - expValueFree (tmp);  
282 - free (_id); 271 + _id = expValueString(tmp);
  272 + id = identListSeekKey(blockGetIdl (gBlock), _id);
  273 + expValueFree(tmp);
  274 + free(_id);
283 275
284 - if (id == NULL)  
285 - exitError (0); 276 + if (id == NULL) exitError (0);
286 277
287 - blockSetNonLocalId (gBlock, id); 278 + blockSetNonLocalId(gBlock, id);
288 } 279 }
289 } 280 }
290 281
291 - blockDo (actBlock);  
292 - blockFree (actBlock); 282 + blockDo(actBlock);
  283 + blockFree(actBlock);
293 284
294 - return (u_stmtType) 0; 285 + return (u_stmtType)0;
295 } 286 }
296 287
297 static 288 static
298 inline 289 inline
299 u_stmtType 290 u_stmtType
300 -stmtIf (s_stmt * stmt, s_block * actBlock) 291 +stmtIf(s_stmt * stmt, s_block * actBlock)
301 { 292 {
302 s_stmtQueue * args = stmt->sQueue; 293 s_stmtQueue * args = stmt->sQueue;
303 - int cond = stmtDo (stmtQueueGet (args, 0), actBlock).cond; 294 + int cond = stmtDo(stmtQueueGet (args, 0), actBlock).cond;
304 s_stmt * _do; 295 s_stmt * _do;
305 296
306 - if (cond)  
307 - _do = stmtQueueGet (args, 1);  
308 - else  
309 - _do = stmtQueueGet (args, 2); 297 + if (cond) _do = stmtQueueGet(args, 1);
  298 + else _do = stmtQueueGet(args, 2);
310 299
311 - if (_do != NULL)  
312 - stmtDo (_do, actBlock); 300 + if (_do != NULL) stmtDo(_do, actBlock);
313 301
314 - return (u_stmtType) 0; 302 + return (u_stmtType)0;
315 } 303 }
316 304
317 static 305 static
318 inline 306 inline
319 u_stmtType 307 u_stmtType
320 -stmtForeach (s_stmt * stmt, s_block * actBlock) 308 +stmtForeach(s_stmt * stmt, s_block * actBlock)
321 { 309 {
322 s_stmtQueue * args = stmt->sQueue; 310 s_stmtQueue * args = stmt->sQueue;
323 - s_expVal * _id = stmtDo (stmtQueueGet (args, 0), actBlock).eVal,  
324 - * _key = stmtDo (stmtQueueGet (args, 1), actBlock).eVal,  
325 - * _val = stmtDo (stmtQueueGet (args, 2), actBlock).eVal;  
326 - char * id = expValueString (_id);  
327 - char * key = expValueString (_key);  
328 - char * val = expValueString (_val);  
329 -  
330 - printf ("[DEBUG]found foreach statement: id=%s, key=%s, val=%s\n", 311 + s_expVal * _id = stmtDo(stmtQueueGet (args, 0), actBlock).eVal,
  312 + * _key = stmtDo(stmtQueueGet (args, 1), actBlock).eVal,
  313 + * _val = stmtDo(stmtQueueGet (args, 2), actBlock).eVal;
  314 + char * id = expValueString(_id);
  315 + char * key = expValueString(_key);
  316 + char * val = expValueString(_val);
  317 +
  318 + printf("[DEBUG]found foreach statement: id=%s, key=%s, val=%s\n",
331 id, key, val); 319 id, key, val);
332 320
333 - free (id);  
334 - free (key);  
335 - free (val); 321 + free(id);
  322 + free(key);
  323 + free(val);
336 324
337 - expValueFree (_id);  
338 - expValueFree (_key);  
339 - expValueFree (_val); 325 + expValueFree(_id);
  326 + expValueFree(_key);
  327 + expValueFree(_val);
340 328
341 - return (u_stmtType) 0; 329 + return (u_stmtType)0;
342 } 330 }
343 331
344 static 332 static
345 inline 333 inline
346 u_stmtType 334 u_stmtType
347 -stmtRepeat (s_stmt * stmt, s_block * actBlock) 335 +stmtRepeat(s_stmt * stmt, s_block * actBlock)
348 { 336 {
349 s_stmtQueue * args = stmt->sQueue; 337 s_stmtQueue * args = stmt->sQueue;
350 - s_expVal * _id = stmtDo (stmtQueueGet (args, 0), actBlock).eVal,  
351 - * _count = stmtDo (stmtQueueGet (args, 1), actBlock).eVal;  
352 - char * id = expValueString (_id);  
353 - int count = expValueInt (_count); 338 + s_expVal * _id = stmtDo(stmtQueueGet (args, 0), actBlock).eVal,
  339 + * _count = stmtDo(stmtQueueGet (args, 1), actBlock).eVal;
  340 + char * id = expValueString(_id);
  341 + int count = expValueInt(_count);
354 342
355 - printf ("[DEBUG]found repeat statement: id=%s, count=%d\n", id, count); 343 + printf("[DEBUG]found repeat statement: id=%s, count=%d\n", id, count);
356 344
357 - free (id); 345 + free(id);
358 346
359 - expValueFree (_id);  
360 - expValueFree (_count); 347 + expValueFree(_id);
  348 + expValueFree(_count);
361 349
362 - return (u_stmtType) 0; 350 + return (u_stmtType)0;
363 } 351 }
364 352
365 /* 353 /*
366 * Interface 354 * Interface
367 */ 355 */
368 s_stmt * 356 s_stmt *
369 -stmtNew (int id, s_stmtQueue * queue, int conTyp, u_stmtType con) 357 +stmtNew(int id, s_stmtQueue * queue, int conTyp, u_stmtType con)
370 { 358 {
371 - s_stmt * new = (s_stmt *) malloc (sizeof (s_stmt)); 359 + s_stmt * new = (s_stmt *)malloc(sizeof(s_stmt));
372 360
373 new->sId = id; 361 new->sId = id;
374 new->sQueue = queue; 362 new->sQueue = queue;
@@ -379,82 +367,102 @@ stmtNew (int id, s_stmtQueue * queue, int conTyp, u_stmtType con) @@ -379,82 +367,102 @@ stmtNew (int id, s_stmtQueue * queue, int conTyp, u_stmtType con)
379 } 367 }
380 368
381 s_stmtQueue * 369 s_stmtQueue *
382 -stmtGetArgs (s_stmt * stmt) 370 +stmtGetArgs(s_stmt * stmt)
383 { 371 {
384 return stmt->sQueue; 372 return stmt->sQueue;
385 } 373 }
386 374
387 u_stmtType 375 u_stmtType
388 -stmtGetVal (s_stmt * stmt) 376 +stmtGetVal(s_stmt * stmt)
389 { 377 {
390 return stmt->sConst; 378 return stmt->sConst;
391 } 379 }
392 380
393 int 381 int
394 -stmtGetConstTyp (s_stmt * stmt) 382 +stmtGetConstTyp(s_stmt * stmt)
395 { 383 {
396 return stmt->sConstTyp; 384 return stmt->sConstTyp;
397 } 385 }
398 386
399 void 387 void
400 -stmtFree (s_stmt * stmt) 388 +stmtFree(s_stmt * stmt)
401 { 389 {
402 - if (stmt == NULL)  
403 - return;  
404 -  
405 - switch (stmt->sConstTyp)  
406 - {  
407 - case STYP_NONE: stmtQueueFree (stmt->sQueue); break;  
408 - case STYP_EVAL: expValueFree (stmt->sConst.eVal); break;  
409 - case STYP_IDVAL: identFree (stmt->sConst.idVal); break; 390 + if (stmt == NULL) return;
  391 +
  392 + switch(stmt->sConstTyp) {
  393 + case STYP_NONE: stmtQueueFree (stmt->sQueue); break;
  394 + case STYP_EVAL: expValueFree (stmt->sConst.eVal); break;
  395 + case STYP_IDVAL: identFree (stmt->sConst.idVal); break;
410 } 396 }
411 397
412 - free (stmt); 398 + free(stmt);
413 } 399 }
414 400
415 u_stmtType 401 u_stmtType
416 -stmtDo (s_stmt * stmt, s_block * actBlock) 402 +stmtDo(s_stmt * stmt, s_block * actBlock)
417 { 403 {
418 - if (stmt == NULL)  
419 - return (u_stmtType) 0;  
420 -  
421 - switch (stmt->sId)  
422 - {  
423 - case STMT_CONST: return (u_stmtType) expValueClone (stmt->sConst.eVal);  
424 - case STMT_BLOCK: return stmtBlock (stmt, actBlock);  
425 -  
426 - case STMT_PRINT: return stmtPrint (stmt, actBlock);  
427 - case STMT_IF: return stmtIf (stmt, actBlock);  
428 - case STMT_FOREACH: return stmtForeach (stmt, actBlock);  
429 - case STMT_REPEAT: return stmtRepeat (stmt, actBlock);  
430 - case STMT_ASSIGN: return stmtAssign (stmt, actBlock);  
431 - case STMT_UNSET: return (u_stmtType) 0;  
432 -  
433 - case STMT_EVAL_PLUS: return stmtEval (stmt, actBlock, PLUS);  
434 - case STMT_EVAL_MINUS: return stmtEval (stmt, actBlock, MINUS);  
435 - case STMT_EVAL_TIMES: return stmtEval (stmt, actBlock, TIMES);  
436 - case STMT_EVAL_OVER: return stmtEval (stmt, actBlock, OVER);  
437 - case STMT_EVAL_MODULO: return stmtEval (stmt, actBlock, MODULO);  
438 - case STMT_EVAL_NEG: return stmtEval (stmt, actBlock, NEG);  
439 -  
440 - case STMT_IDENT_VAR: return stmtIdentVar (stmt, actBlock);  
441 - case STMT_IDENT_ARRAY: return stmtIdentArray (stmt, actBlock);  
442 - case STMT_IDENT_VAL: return stmtIdentVal (stmt, actBlock);  
443 -  
444 - case STMT_CAST_INT: return stmtCastInt (stmt, actBlock);  
445 - case STMT_CAST_FLOAT: return stmtCastFloat (stmt, actBlock);  
446 - case STMT_CAST_STRING: return stmtCastString (stmt, actBlock);  
447 -  
448 - case STMT_COMP_EQ: return stmtEvalComp (stmt, actBlock, EQ);  
449 - case STMT_COMP_NE: return stmtEvalComp (stmt, actBlock, NE);  
450 - case STMT_COMP_LT: return stmtEvalComp (stmt, actBlock, LT);  
451 - case STMT_COMP_GT: return stmtEvalComp (stmt, actBlock, GT);  
452 - case STMT_COMP_LE: return stmtEvalComp (stmt, actBlock, LE);  
453 - case STMT_COMP_GE: return stmtEvalComp (stmt, actBlock, GE);  
454 -  
455 - case STMT_COND_EXPR: return stmtEvalCondExpr (stmt, actBlock);  
456 - case STMT_COND_AND: return stmtEvalCond (stmt, actBlock, LOGAND);  
457 - case STMT_COND_OR: return stmtEvalCond (stmt, actBlock, LOGOR);  
458 - case STMT_COND_NEG: return stmtEvalCond (stmt, actBlock, LOGNEG); 404 + if (stmt == NULL) return (u_stmtType)0;
  405 +
  406 + switch (stmt->sId) {
  407 + case STMT_CONST:
  408 + return (u_stmtType)expValueClone(stmt->sConst.eVal);
  409 + case STMT_BLOCK:
  410 + return stmtBlock(stmt, actBlock);
  411 + case STMT_PRINT:
  412 + return stmtPrint(stmt, actBlock);
  413 + case STMT_IF:
  414 + return stmtIf(stmt, actBlock);
  415 + case STMT_FOREACH:
  416 + return stmtForeach(stmt, actBlock);
  417 + case STMT_REPEAT:
  418 + return stmtRepeat(stmt, actBlock);
  419 + case STMT_ASSIGN:
  420 + return stmtAssign(stmt, actBlock);
  421 + case STMT_UNSET:
  422 + return (u_stmtType)0;
  423 + case STMT_EVAL_PLUS:
  424 + return stmtEval(stmt, actBlock, PLUS);
  425 + case STMT_EVAL_MINUS:
  426 + return stmtEval(stmt, actBlock, MINUS);
  427 + case STMT_EVAL_TIMES:
  428 + return stmtEval(stmt, actBlock, TIMES);
  429 + case STMT_EVAL_OVER:
  430 + return stmtEval(stmt, actBlock, OVER);
  431 + case STMT_EVAL_MODULO:
  432 + return stmtEval(stmt, actBlock, MODULO);
  433 + case STMT_EVAL_NEG:
  434 + return stmtEval(stmt, actBlock, NEG);
  435 + case STMT_IDENT_VAR:
  436 + return stmtIdentVar(stmt, actBlock);
  437 + case STMT_IDENT_ARRAY:
  438 + return stmtIdentArray(stmt, actBlock);
  439 + case STMT_IDENT_VAL:
  440 + return stmtIdentVal(stmt, actBlock);
  441 + case STMT_CAST_INT:
  442 + return stmtCastInt(stmt, actBlock);
  443 + case STMT_CAST_FLOAT:
  444 + return stmtCastFloat(stmt, actBlock);
  445 + case STMT_CAST_STRING:
  446 + return stmtCastString(stmt, actBlock);
  447 + case STMT_COMP_EQ:
  448 + return stmtEvalComp(stmt, actBlock, EQ);
  449 + case STMT_COMP_NE:
  450 + return stmtEvalComp(stmt, actBlock, NE);
  451 + case STMT_COMP_LT:
  452 + return stmtEvalComp(stmt, actBlock, LT);
  453 + case STMT_COMP_GT:
  454 + return stmtEvalComp(stmt, actBlock, GT);
  455 + case STMT_COMP_LE:
  456 + return stmtEvalComp(stmt, actBlock, LE);
  457 + case STMT_COMP_GE:
  458 + return stmtEvalComp(stmt, actBlock, GE);
  459 + case STMT_COND_EXPR:
  460 + return stmtEvalCondExpr(stmt, actBlock);
  461 + case STMT_COND_AND:
  462 + return stmtEvalCond(stmt, actBlock, LOGAND);
  463 + case STMT_COND_OR:
  464 + return stmtEvalCond(stmt, actBlock, LOGOR);
  465 + case STMT_COND_NEG:
  466 + return stmtEvalCond(stmt, actBlock, LOGNEG);
459 } 467 }
460 } 468 }
@@ -8,26 +8,26 @@ @@ -8,26 +8,26 @@
8 #include <stmtQueue.h> 8 #include <stmtQueue.h>
9 9
10 /* give the queue an initial size for 10 statements */ 10 /* give the queue an initial size for 10 statements */
11 -#define QUEUE_GROW_SIZE 10 11 +#define QUEUE_GROW_SIZE 10
12 12
13 13
14 struct stmtQueue 14 struct stmtQueue
15 { 15 {
16 - s_stmt ** stmts; /* a dynamically growing array of statements. */ 16 + s_stmt ** stmts; /* a dynamically growing array of statements. */
17 17
18 - unsigned int size; /* the actual size of the array in statements */  
19 - unsigned int maxIdx; /* the maximum index used in the array. */ 18 + unsigned int size; /* the actual size of the array in statements */
  19 + unsigned int maxIdx; /* the maximum index used in the array. */
20 }; 20 };
21 21
22 s_stmtQueue * 22 s_stmtQueue *
23 -stmtQueueNew (void) 23 +stmtQueueNew(void)
24 { 24 {
25 - s_stmtQueue * new = (s_stmtQueue *) malloc (sizeof (s_stmtQueue)); 25 + s_stmtQueue * new = (s_stmtQueue*)malloc(sizeof(s_stmtQueue));
26 26
27 new->size = QUEUE_GROW_SIZE; 27 new->size = QUEUE_GROW_SIZE;
28 new->maxIdx = 0; 28 new->maxIdx = 0;
29 - new->stmts = (s_stmt **) calloc (sizeof (s_stmt *), new->size);  
30 - memset (new->stmts, 0, sizeof (s_stmt *) * new->size); 29 + new->stmts = (s_stmt**)calloc(sizeof(s_stmt*), new->size);
  30 + memset(new->stmts, 0, sizeof(s_stmt *) * new->size);
31 31
32 return new; 32 return new;
33 } 33 }
@@ -36,92 +36,88 @@ stmtQueueNew (void) @@ -36,92 +36,88 @@ stmtQueueNew (void)
36 * This concat does not change a or b, as opposed to the c strcat function 36 * This concat does not change a or b, as opposed to the c strcat function
37 */ 37 */
38 s_stmtQueue * 38 s_stmtQueue *
39 -stmtQueueConcat (s_stmtQueue * a, s_stmtQueue * b) 39 +stmtQueueConcat(s_stmtQueue * a, s_stmtQueue * b)
40 { 40 {
41 - s_stmtQueue * new = (s_stmtQueue *) malloc (sizeof (s_stmtQueue)); 41 + s_stmtQueue * new = (s_stmtQueue*)malloc(sizeof(s_stmtQueue));
42 42
43 new->size = a->size + b->size; 43 new->size = a->size + b->size;
44 new->maxIdx = a->maxIdx + b->maxIdx; 44 new->maxIdx = a->maxIdx + b->maxIdx;
45 - new->stmts = (s_stmt **) calloc (sizeof (s_stmt *), new->size);  
46 - memset (new->stmts, 0, sizeof (s_stmt *) * new->size); 45 + new->stmts = (s_stmt**)calloc(sizeof(s_stmt*), new->size);
  46 + memset(new->stmts, 0, sizeof(s_stmt*) * new->size);
47 47
48 - memcpy (new->stmts, a->stmts, sizeof (s_stmt *) * a->maxIdx);  
49 - memcpy (&(new->stmts[a->maxIdx]), b->stmts, sizeof (s_stmt *) * b->maxIdx); 48 + memcpy(new->stmts, a->stmts, sizeof(s_stmt*) * a->maxIdx);
  49 + memcpy(&(new->stmts[a->maxIdx]), b->stmts, sizeof(s_stmt*) * b->maxIdx);
50 50
51 return new; 51 return new;
52 } 52 }
53 53
54 void 54 void
55 -stmtQueueFree (s_stmtQueue * sQueue) 55 +stmtQueueFree(s_stmtQueue * sQueue)
56 { 56 {
57 unsigned int i; 57 unsigned int i;
58 58
59 - if (sQueue == NULL)  
60 - return; 59 + if (sQueue == NULL) return;
61 60
62 /* freeing the queue is the final step. All stmts should be freed too! */ 61 /* freeing the queue is the final step. All stmts should be freed too! */
63 - for (i = 0; i < sQueue->maxIdx; i++)  
64 - stmtFree (sQueue->stmts [i]); 62 + for (i=0; i < sQueue->maxIdx; i++)
  63 + stmtFree(sQueue->stmts[i]);
65 64
66 - free (sQueue->stmts);  
67 - free (sQueue); 65 + free(sQueue->stmts);
  66 + free(sQueue);
68 } 67 }
69 68
70 void 69 void
71 -stmtQueueEnqueue (s_stmtQueue * sQueue, s_stmt * stmt) 70 +stmtQueueEnqueue(s_stmtQueue * sQueue, s_stmt * stmt)
72 { 71 {
73 if (sQueue->maxIdx >= sQueue->size) 72 if (sQueue->maxIdx >= sQueue->size)
74 { 73 {
75 s_stmt ** stmtsOld = sQueue->stmts; 74 s_stmt ** stmtsOld = sQueue->stmts;
76 unsigned int newSize = sQueue->size + QUEUE_GROW_SIZE; 75 unsigned int newSize = sQueue->size + QUEUE_GROW_SIZE;
77 76
78 - sQueue->stmts = (s_stmt **) calloc (sizeof (s_stmt *), newSize);  
79 - memcpy (sQueue->stmts, stmtsOld, sizeof (s_stmt **) * sQueue->size);  
80 - free (stmtsOld); /* free the old queue but keep the statements */  
81 - memset (  
82 - &(sQueue->stmts[sQueue->size]),  
83 - 0,  
84 - sizeof (s_stmt **) * QUEUE_GROW_SIZE);  
85 - sQueue->size = newSize;; 77 + sQueue->stmts = (s_stmt**)calloc(sizeof(s_stmt*), newSize);
  78 + memcpy (sQueue->stmts, stmtsOld, sizeof(s_stmt**) * sQueue->size);
  79 + free(stmtsOld); /* free the old queue but keep the statements */
  80 + memset(
  81 + &(sQueue->stmts[sQueue->size]),
  82 + 0,
  83 + sizeof(s_stmt**) * QUEUE_GROW_SIZE);
  84 + sQueue->size = newSize;
86 } 85 }
87 86
88 - sQueue->stmts[sQueue->maxIdx ++] = stmt; 87 + sQueue->stmts[sQueue->maxIdx++] = stmt;
89 } 88 }
90 89
91 s_stmt * 90 s_stmt *
92 -stmtQueueDequeue (s_stmtQueue * sQueue) 91 +stmtQueueDequeue(s_stmtQueue * sQueue)
93 { 92 {
94 s_stmt * ret = sQueue->stmts[sQueue->maxIdx - 1]; 93 s_stmt * ret = sQueue->stmts[sQueue->maxIdx - 1];
95 94
96 - sQueue->stmts[-- sQueue->maxIdx] = NULL; 95 + sQueue->stmts[--sQueue->maxIdx] = NULL;
97 96
98 return ret; 97 return ret;
99 } 98 }
100 99
101 s_stmt * 100 s_stmt *
102 -stmtQueueGet (s_stmtQueue * sQueue, unsigned int idx) 101 +stmtQueueGet(s_stmtQueue * sQueue, unsigned int idx)
103 { 102 {
104 - if (idx < sQueue->size)  
105 - return sQueue->stmts [idx];  
106 - else  
107 - return NULL; 103 + if (idx < sQueue->size) return sQueue->stmts[idx];
  104 + else return NULL;
108 } 105 }
109 106
110 void 107 void
111 -stmtQueueDo (s_stmtQueue * sQueue) 108 +stmtQueueDo(s_stmtQueue * sQueue)
112 { 109 {
113 int i; 110 int i;
114 111
115 - if (sQueue == NULL)  
116 - return; 112 + if (sQueue == NULL) return;
117 113
118 for (i = 0; i < sQueue->maxIdx; i++) 114 for (i = 0; i < sQueue->maxIdx; i++)
119 - stmtDo (sQueue->stmts[i], NULL /* !!!FIXME: give me a sane value!!! */); 115 + stmtDo(sQueue->stmts[i], NULL /* !!!FIXME: give me a sane value!!! */);
120 } 116 }
121 117
122 - unsigned 118 +unsigned
123 int 119 int
124 -stmtQueueGetSize (s_stmtQueue * sQueue) 120 +stmtQueueGetSize(s_stmtQueue * sQueue)
125 { 121 {
126 return sQueue->size; 122 return sQueue->size;
127 } 123 }
@@ -18,47 +18,44 @@ char * tepalErrMsg[] = @@ -18,47 +18,44 @@ char * tepalErrMsg[] =
18 }; 18 };
19 19
20 void 20 void
21 -exitError (int errNum, ...) 21 +exitError(int errNum, ...)
22 { 22 {
23 va_list ap; 23 va_list ap;
24 24
25 - va_start (ap, errNum); 25 + va_start(ap, errNum);
26 26
27 - switch (errNum)  
28 - { 27 + switch (errNum) {
29 case ERR_UNDEF_VAR: 28 case ERR_UNDEF_VAR:
30 - fprintf (stderr, tepalErrMsg[errNum], va_arg(ap, char *)); 29 + fprintf(stderr, tepalErrMsg[errNum], va_arg(ap, char *));
31 break; 30 break;
32 -  
33 case ERR_NO_INDEX: 31 case ERR_NO_INDEX:
34 - fprintf (stderr, tepalErrMsg[errNum], va_arg(ap, char *)); 32 + fprintf(stderr, tepalErrMsg[errNum], va_arg(ap, char *));
35 break; 33 break;
36 -  
37 case ERR_STRING_OPERATOR: 34 case ERR_STRING_OPERATOR:
38 - fprintf (stderr, tepalErrMsg[errNum], va_arg(ap, int)); 35 + fprintf(stderr, tepalErrMsg[errNum], va_arg(ap, int));
39 break; 36 break;
40 -  
41 case ERR_FLOAT_OPERATOR: 37 case ERR_FLOAT_OPERATOR:
42 - fprintf (stderr, tepalErrMsg[errNum], va_arg(ap, int)); 38 + fprintf(stderr, tepalErrMsg[errNum], va_arg(ap, int));
43 break; 39 break;
44 } 40 }
45 41
46 - va_end (ap);  
47 - exit (errNum); 42 + va_end(ap);
  43 + exit(errNum);
48 } 44 }
49 45
50 void 46 void
51 printExpr (s_expVal * val) 47 printExpr (s_expVal * val)
52 { 48 {
53 - switch (expValueGetType (val))  
54 - {  
55 - case EXP_TYP_INT: printf ("%d", expValueInt (val)); break;  
56 - case EXP_TYP_FLOAT: printf ("%f", expValueFloat (val)); break;  
57 - case EXP_TYP_STRING: 49 + switch (expValueGetType (val)) {
  50 + case EXP_TYP_INT:
  51 + printf("%d", expValueInt (val)); break;
  52 + case EXP_TYP_FLOAT:
  53 + printf("%f", expValueFloat (val)); break;
  54 + case EXP_TYP_STRING:
58 { 55 {
59 - char * v = expValueString (val);  
60 - printf (v);  
61 - free (v); 56 + char * v = expValueString(val);
  57 + printf(v);
  58 + free(v);
62 } 59 }
63 } 60 }
64 } 61 }
@@ -18,25 +18,25 @@ @@ -18,25 +18,25 @@
18 18
19 extern int yylex (void); 19 extern int yylex (void);
20 20
21 - int 21 + int
22 yywrap () 22 yywrap ()
23 -{  
24 - return 1; 23 +{
  24 + return 1;
25 } 25 }
26 26
27 - void 27 + void
28 yyerror (char const * s) 28 yyerror (char const * s)
29 { 29 {
30 fprintf(stderr, "%s\n", s); 30 fprintf(stderr, "%s\n", s);
31 } 31 }
32 32
33 -/* 33 +/*
34 * globale Variablen 34 * globale Variablen
35 */ 35 */
36 -extern FILE * yyin;  
37 -extern s_block * _globalBlock_; 36 +extern FILE * yyin;
  37 +extern s_block * _globalBlock_;
38 38
39 -s_stmtQueue * astRoot; 39 +s_stmtQueue * astRoot;
40 40
41 /* 41 /*
42 * statische Funktionen (zum lokalen gebrauch) 42 * statische Funktionen (zum lokalen gebrauch)
@@ -59,9 +59,9 @@ enqGlobId (s_stmtQueue * sQueue, char * id) @@ -59,9 +59,9 @@ enqGlobId (s_stmtQueue * sQueue, char * id)
59 { 59 {
60 s_stmtQueue * ret = (sQueue == NULL) ? stmtQueueNew () : sQueue; 60 s_stmtQueue * ret = (sQueue == NULL) ? stmtQueueNew () : sQueue;
61 s_stmt * val = stmtNew ( 61 s_stmt * val = stmtNew (
62 - STMT_CONST,  
63 - NULL,  
64 - STYP_EVAL, 62 + STMT_CONST,
  63 + NULL,
  64 + STYP_EVAL,
65 (u_stmtType) expValueStringNew (id)); 65 (u_stmtType) expValueStringNew (id));
66 66
67 stmtQueueEnqueue (ret, val); 67 stmtQueueEnqueue (ret, val);
@@ -117,9 +117,8 @@ genStringStmt (s_stmt * stmt, char * string) @@ -117,9 +117,8 @@ genStringStmt (s_stmt * stmt, char * string)
117 s_expVal * eVal = NULL; 117 s_expVal * eVal = NULL;
118 118
119 char * new = NULL; 119 char * new = NULL;
120 -  
121 - if (stmt != NULL)  
122 - { 120 +
  121 + if (stmt != NULL) {
123 char * old = expValueString (stmtGetVal (stmt).eVal); 122 char * old = expValueString (stmtGetVal (stmt).eVal);
124 size_t len = strlen (old) + strlen (string) + 1; 123 size_t len = strlen (old) + strlen (string) + 1;
125 124
@@ -130,8 +129,7 @@ genStringStmt (s_stmt * stmt, char * string) @@ -130,8 +129,7 @@ genStringStmt (s_stmt * stmt, char * string)
130 stmtFree (stmt); 129 stmtFree (stmt);
131 free (old); 130 free (old);
132 } 131 }
133 - else  
134 - { 132 + else {
135 new = (char *)calloc (sizeof (char), strlen (string) + 1); 133 new = (char *)calloc (sizeof (char), strlen (string) + 1);
136 strcpy (new, string); 134 strcpy (new, string);
137 } 135 }
@@ -187,7 +185,7 @@ genRepStmt (char * _ident, long _count, s_stmt * stmt) @@ -187,7 +185,7 @@ genRepStmt (char * _ident, long _count, s_stmt * stmt)
187 u_stmtType _co = (u_stmtType) expValueIntNew (_count); 185 u_stmtType _co = (u_stmtType) expValueIntNew (_count);
188 s_stmt * ident = stmtNew (STMT_CONST, NULL, STYP_EVAL, _id); 186 s_stmt * ident = stmtNew (STMT_CONST, NULL, STYP_EVAL, _id);
189 s_stmt * count = stmtNew (STMT_CONST, NULL, STYP_EVAL, _co); 187 s_stmt * count = stmtNew (STMT_CONST, NULL, STYP_EVAL, _co);
190 - 188 +
191 s_stmtQueue * sQueue = stmtQueueNew (); 189 s_stmtQueue * sQueue = stmtQueueNew ();
192 190
193 free (_ident); 191 free (_ident);
@@ -366,24 +364,24 @@ genCastStringStmt (s_stmt * stmt) @@ -366,24 +364,24 @@ genCastStringStmt (s_stmt * stmt)
366 364
367 %} 365 %}
368 366
369 -%token STMT_END ';' REPEAT COUNT FOREACH AS IF ELSE BLOCK_END UNSET  
370 -%token ICAST FCAST SCAST GLOBAL PARENT /* for explicit casts */  
371 -%token <cPtr> IDENT  
372 -%token <cPtr> HTML  
373 -%token <iVal> INT  
374 -%token <fVal> FLOAT  
375 -%token <cPtr> STRING  
376 -%token <cPtr> EOL  
377 -  
378 -%left LOGAND LOGOR  
379 -%left LOGNEG  
380 -%nonassoc NE EQ LT GT LE GE  
381 -  
382 -%right '='  
383 -%left '+' '-'  
384 -%left '*' '/' '%'  
385 -%left NEG  
386 -%nonassoc '(' ')' 367 +%token STMT_END ';' REPEAT COUNT FOREACH AS IF ELSE BLOCK_END UNSET
  368 +%token ICAST FCAST SCAST GLOBAL PARENT /* for explicit casts */
  369 +%token <cPtr> IDENT
  370 +%token <cPtr> HTML
  371 +%token <iVal> INT
  372 +%token <fVal> FLOAT
  373 +%token <cPtr> STRING
  374 +%token <cPtr> EOL
  375 +
  376 +%left LOGAND LOGOR
  377 +%left LOGNEG
  378 +%nonassoc NE EQ LT GT LE GE
  379 +
  380 +%right '='
  381 +%left '+' '-'
  382 +%left '*' '/' '%'
  383 +%left NEG
  384 +%nonassoc '(' ')'
387 385
388 %union { 386 %union {
389 long iVal; 387 long iVal;
@@ -396,22 +394,22 @@ genCastStringStmt (s_stmt * stmt) @@ -396,22 +394,22 @@ genCastStringStmt (s_stmt * stmt)
396 /* Es wird wohl darauf hinauslaufen das alles erstmal ein stmt wird 394 /* Es wird wohl darauf hinauslaufen das alles erstmal ein stmt wird
397 und in den AST wandert, und erst dann ausgewertet wird. Anders 395 und in den AST wandert, und erst dann ausgewertet wird. Anders
398 wird es wohl nicht gehen. */ 396 wird es wohl nicht gehen. */
399 -%type <stmt> assig;  
400 -%type <stmt> ident;  
401 -%type <stmt> cond;  
402 -%type <stmt> comp;  
403 -%type <stmt> expr;  
404 -%type <stmt> html;  
405 -%type <stmt> block_stmt;  
406 -%type <stmt> simple_stmt;  
407 -%type <stmt> if_stmt;  
408 -%type <stmt> rep_stmt;  
409 -%type <stmt> fore_stmt;  
410 -%type <stmt> stmt;  
411 -%type <sQue> stmt_queue;  
412 -%type <sQue> block_queue;  
413 -%type <sQue> glob_decl;  
414 -%type <sQue> gdecl_block; 397 +%type <stmt> assig;
  398 +%type <stmt> ident;
  399 +%type <stmt> cond;
  400 +%type <stmt> comp;
  401 +%type <stmt> expr;
  402 +%type <stmt> html;
  403 +%type <stmt> block_stmt;
  404 +%type <stmt> simple_stmt;
  405 +%type <stmt> if_stmt;
  406 +%type <stmt> rep_stmt;
  407 +%type <stmt> fore_stmt;
  408 +%type <stmt> stmt;
  409 +%type <sQue> stmt_queue;
  410 +%type <sQue> block_queue;
  411 +%type <sQue> glob_decl;
  412 +%type <sQue> gdecl_block;
415 413
416 %expect 1 414 %expect 1
417 415
@@ -419,41 +417,33 @@ genCastStringStmt (s_stmt * stmt) @@ -419,41 +417,33 @@ genCastStringStmt (s_stmt * stmt)
419 417
420 %% 418 %%
421 419
422 -script : stmt_queue { astRoot = $1; }  
423 -; 420 +script : stmt_queue { astRoot = $1; };
424 421
425 -stmt_queue : stmt { $$ = enqStmt (NULL, $1); }  
426 - | stmt_queue stmt { $$ = enqStmt ($1, $2); }  
427 -; 422 +stmt_queue : stmt { $$ = enqStmt (NULL, $1); }
  423 + | stmt_queue stmt { $$ = enqStmt ($1, $2); };
428 424
429 -stmt : simple_stmt  
430 - | block_stmt  
431 - | if_stmt  
432 - | rep_stmt  
433 - | fore_stmt  
434 - | stmt_end stmt { $$ = $2; }  
435 -; 425 +stmt : simple_stmt
  426 + | block_stmt
  427 + | if_stmt
  428 + | rep_stmt
  429 + | fore_stmt
  430 + | stmt_end stmt { $$ = $2; };
436 431
437 -simple_stmt : html stmt_end { $$ = genPrintStmt ($1); }  
438 - | expr stmt_end { $$ = genPrintStmt ($1); }  
439 - | assig stmt_end  
440 -; 432 +simple_stmt : html stmt_end { $$ = genPrintStmt ($1); }
  433 + | expr stmt_end { $$ = genPrintStmt ($1); }
  434 + | assig stmt_end;
441 435
442 -html : HTML { $$ = genStringStmt (NULL, $1); }  
443 - | html HTML { $$ = genStringStmt ($1, $2); }  
444 -; 436 +html : HTML { $$ = genStringStmt (NULL, $1); }
  437 + | html HTML { $$ = genStringStmt ($1, $2); };
445 438
446 -stmt_end : STMT_END  
447 - | ';'  
448 -; 439 +stmt_end : STMT_END
  440 + | ';';
449 441
450 -block_stmt : ':' BLOCK_END { $$ = genBlockStmt (NULL); }  
451 - | ':' block_queue BLOCK_END { $$ = genBlockStmt ($2); }  
452 -; 442 +block_stmt : ':' BLOCK_END { $$ = genBlockStmt (NULL); }
  443 + | ':' block_queue BLOCK_END { $$ = genBlockStmt ($2); };
453 444
454 -block_queue : stmt_queue { $$ = genBlockQue (NULL, $1); }  
455 - | gdecl_block stmt_queue { $$ = genBlockQue ($1, $2); }  
456 -; 445 +block_queue : stmt_queue { $$ = genBlockQue (NULL, $1); }
  446 + | gdecl_block stmt_queue { $$ = genBlockQue ($1, $2); };
457 447
458 /* 448 /*
459 * Here follows the definitions for the "globals definition block" 449 * Here follows the definitions for the "globals definition block"
@@ -462,77 +452,64 @@ block_queue : stmt_queue { $$ = genBlockQue (NULL, $1); } @@ -462,77 +452,64 @@ block_queue : stmt_queue { $$ = genBlockQue (NULL, $1); }
462 * block a newline should not be interpreted as statmend-end. 452 * block a newline should not be interpreted as statmend-end.
463 * ------ 453 * ------
464 */ 454 */
465 -gdecl_block : GLOBAL ':' glob_decl BLOCK_END  
466 - { $$ = $3; }  
467 -; 455 +gdecl_block : GLOBAL ':' glob_decl BLOCK_END { $$ = $3; };
468 456
469 -glob_decl : IDENT { $$ = enqGlobId (NULL, $1); }  
470 - | glob_decl ',' IDENT { $$ = enqGlobId ($1, $3); }  
471 -; 457 +glob_decl : IDENT { $$ = enqGlobId (NULL, $1); }
  458 + | glob_decl ',' IDENT { $$ = enqGlobId ($1, $3); };
472 /* 459 /*
473 * ------ 460 * ------
474 */ 461 */
475 462
476 /* here is 1 shift/reduce conflict, but thats ok. */ 463 /* here is 1 shift/reduce conflict, but thats ok. */
477 -if_stmt : IF '(' cond ')' stmt { $$ = genIfStmt ($3, $5, NULL); }  
478 - | IF '(' cond ')' stmt ELSE stmt  
479 - { $$ = genIfStmt ($3, $5, $7); }  
480 -;  
481 -  
482 -rep_stmt : REPEAT '(' IDENT COUNT '=' INT ')' stmt  
483 - { $$ = genRepStmt ($3, $6, $8); }  
484 -;  
485 -  
486 -fore_stmt : FOREACH '(' IDENT AS IDENT ',' IDENT ')' stmt  
487 - { $$ = genForeStmt ($3, $5, $7, $9); }  
488 -;  
489 -  
490 -cond : expr { $$ = genCondExprStmt ($1); }  
491 - | comp { $$ = $1; }  
492 - | '(' comp ')' { $$ = $2; }  
493 - | '!' cond %prec LOGNEG { $$ = genOpStmt (LOGNEG, $2, NULL); }  
494 - | '(' '!' cond ')' %prec LOGNEG  
495 - { $$ = genOpStmt (LOGNEG, $3, NULL); }  
496 - | cond LOGAND cond { $$ = genOpStmt (LOGAND, $1, $3); }  
497 - | '(' cond LOGAND cond ')' { $$ = genOpStmt (LOGAND, $2, $4); }  
498 - | cond LOGOR cond { $$ = genOpStmt (LOGOR, $1, $3); }  
499 - | '(' cond LOGOR cond ')' { $$ = genOpStmt (LOGOR, $2, $4); }  
500 -;  
501 -  
502 -comp : expr EQ expr { $$ = genOpStmt (EQ, $1, $3); }  
503 - | expr NE expr { $$ = genOpStmt (NE, $1, $3); }  
504 - | expr LT expr { $$ = genOpStmt (LT, $1, $3); }  
505 - | expr GT expr { $$ = genOpStmt (GT, $1, $3); }  
506 - | expr LE expr { $$ = genOpStmt (LE, $1, $3); }  
507 - | expr GE expr { $$ = genOpStmt (GE, $1, $3); }  
508 -;  
509 -  
510 -assig : ident '=' expr { $$ = genAssignStmt ($1, $3); }  
511 - | ident '=' assig { $$ = genAssignStmt ($1, $3); }  
512 -;  
513 -  
514 -ident : IDENT { $$ = genIdentVarStmt ($1); }  
515 - | ident '[' expr ']' { $$ = genIdentArrStmt ($1, $3); }  
516 -;  
517 -  
518 -expr : ident { $$ = genIdentValStmt ($1); }  
519 - | INT { $$ = genIntStmt ($1); }  
520 - | FLOAT { $$ = genFloatStmt ($1); }  
521 - | STRING { $$ = genStringStmt (NULL, $1); }  
522 - | EOL { $$ = genStringStmt (NULL, $1); }  
523 -  
524 - | '(' ICAST ')' expr { $$ = genCastIntStmt ($4); }  
525 - | '(' FCAST ')' expr { $$ = genCastFloatStmt ($4); }  
526 - | '(' SCAST ')' expr { $$ = genCastStringStmt ($4); }  
527 - | '(' expr ')' { $$ = $2; }  
528 -  
529 - | '-' expr %prec NEG { $$ = genOpStmt (NEG, $2, NULL); }  
530 - | expr '+' expr { $$ = genOpStmt (PLUS, $1, $3); }  
531 - | expr '-' expr { $$ = genOpStmt (MINUS, $1, $3); }  
532 - | expr '*' expr { $$ = genOpStmt (TIMES, $1, $3); }  
533 - | expr '/' expr { $$ = genOpStmt (OVER, $1, $3); }  
534 - | expr '%' expr { $$ = genOpStmt (MODULO, $1, $3); }  
535 -; 464 +if_stmt : IF '(' cond ')' stmt { $$ = genIfStmt ($3, $5, NULL); }
  465 + | IF '(' cond ')' stmt ELSE stmt { $$ = genIfStmt ($3, $5, $7); };
  466 +
  467 +rep_stmt : REPEAT '(' IDENT COUNT '=' INT ')' stmt {
  468 + $$ = genRepStmt($3, $6, $8); };
  469 +
  470 +fore_stmt : FOREACH '(' IDENT AS IDENT ',' IDENT ')' stmt {
  471 + $$ = genForeStmt($3, $5, $7, $9); };
  472 +
  473 +cond : expr { $$ = genCondExprStmt($1); }
  474 + | comp { $$ = $1; }
  475 + | '(' comp ')' { $$ = $2; }
  476 + | '!' cond %prec LOGNEG { $$ = genOpStmt(LOGNEG, $2, NULL); }
  477 + | '(' '!' cond ')' %prec LOGNEG { $$ = genOpStmt(LOGNEG, $3, NULL); }
  478 + | cond LOGAND cond { $$ = genOpStmt(LOGAND, $1, $3); }
  479 + | '(' cond LOGAND cond ')' { $$ = genOpStmt(LOGAND, $2, $4); }
  480 + | cond LOGOR cond { $$ = genOpStmt(LOGOR, $1, $3); }
  481 + | '(' cond LOGOR cond ')' { $$ = genOpStmt(LOGOR, $2, $4); };
  482 +
  483 +comp : expr EQ expr { $$ = genOpStmt(EQ, $1, $3); }
  484 + | expr NE expr { $$ = genOpStmt(NE, $1, $3); }
  485 + | expr LT expr { $$ = genOpStmt(LT, $1, $3); }
  486 + | expr GT expr { $$ = genOpStmt(GT, $1, $3); }
  487 + | expr LE expr { $$ = genOpStmt(LE, $1, $3); }
  488 + | expr GE expr { $$ = genOpStmt(GE, $1, $3); };
  489 +
  490 +assig : ident '=' expr { $$ = genAssignStmt ($1, $3); }
  491 + | ident '=' assig { $$ = genAssignStmt ($1, $3); };
  492 +
  493 +ident : IDENT { $$ = genIdentVarStmt ($1); }
  494 + | ident '[' expr ']' { $$ = genIdentArrStmt ($1, $3); };
  495 +
  496 +expr : ident { $$ = genIdentValStmt ($1); }
  497 + | INT { $$ = genIntStmt ($1); }
  498 + | FLOAT { $$ = genFloatStmt ($1); }
  499 + | STRING { $$ = genStringStmt (NULL, $1); }
  500 + | EOL { $$ = genStringStmt (NULL, $1); }
  501 +
  502 + | '(' ICAST ')' expr { $$ = genCastIntStmt ($4); }
  503 + | '(' FCAST ')' expr { $$ = genCastFloatStmt ($4); }
  504 + | '(' SCAST ')' expr { $$ = genCastStringStmt ($4); }
  505 + | '(' expr ')' { $$ = $2; }
  506 +
  507 + | '-' expr %prec NEG { $$ = genOpStmt (NEG, $2, NULL); }
  508 + | expr '+' expr { $$ = genOpStmt (PLUS, $1, $3); }
  509 + | expr '-' expr { $$ = genOpStmt (MINUS, $1, $3); }
  510 + | expr '*' expr { $$ = genOpStmt (TIMES, $1, $3); }
  511 + | expr '/' expr { $$ = genOpStmt (OVER, $1, $3); }
  512 + | expr '%' expr { $$ = genOpStmt (MODULO, $1, $3); };
536 513
537 %% 514 %%
538 515
@@ -548,8 +525,8 @@ main (int argc, void * argv []) @@ -548,8 +525,8 @@ main (int argc, void * argv [])
548 yyin = stdin; 525 yyin = stdin;
549 } 526 }
550 } 527 }
551 - /*  
552 - * normally we would read from stdin if no file is given but for 528 + /*
  529 + * normally we would read from stdin if no file is given but for
553 * demonstration purpose we read a file from a standard location. 530 * demonstration purpose we read a file from a standard location.
554 */ 531 */
555 else 532 else
@@ -6,290 +6,264 @@ @@ -6,290 +6,264 @@
6 #include <tepal_pars.h> 6 #include <tepal_pars.h>
7 %} 7 %}
8 8
9 -%x TOK 9 +%x TOK
10 10
11 -DIGITS [0-9]+  
12 -INT {DIGITS}  
13 -FLOAT {DIGITS}(.{DIGITS})?  
14 -STRING ('[^']*')|(\"[^\"]*\")  
15 -IDENT [a-zA-Z][_0-9a-zA-Z]*|_[0-9a-zA-Z]+  
16 -OPERATOR [+\-*/%=,!:\[\]\(\);] 11 +DIGITS [0-9]+
  12 +INT {DIGITS}
  13 +FLOAT {DIGITS}(.{DIGITS})?
  14 +STRING ('[^']*')|(\"[^\"]*\")
  15 +IDENT [a-zA-Z][_0-9a-zA-Z]*|_[0-9a-zA-Z]+
  16 +OPERATOR [+\-*/%=,!:\[\]\(\);]
17 17
18 -ICAST int  
19 -FCAST float  
20 -SCAST string 18 +ICAST int
  19 +FCAST float
  20 +SCAST string
21 21
22 -S_TOK [ \t]*<#  
23 -E_TOK #>  
24 -TEXT (\<[^#].*)|([^\<]*) 22 +S_TOK [ \t]*<#
  23 +E_TOK #>
  24 +TEXT (\<[^#].*)|([^\<]*)
25 25
26 %% 26 %%
27 27
28 -{TEXT} {  
29 - char tok[2];  
30 - size_t len = strlen (yytext);  
31 -  
32 - yylval.cPtr = (char *) malloc (len + 2);  
33 - memset (yylval.cPtr, 0, len + 2);  
34 - memcpy (yylval.cPtr, yytext, len);  
35 -  
36 - tok[0] = input ();  
37 - tok[1] = input ();  
38 -  
39 - if (tok[1] == '#' || tok[0] == EOF)  
40 - {  
41 - unput ('#');  
42 - unput ('<');  
43 - }  
44 - else  
45 - {  
46 - if (tok[1] != EOF)  
47 - unput (tok[1]);  
48 - yylval.cPtr[len] = tok[0];  
49 - }  
50 -  
51 - #ifdef DEBUG  
52 - printf ("[TOKEN] HTML\n");  
53 - #endif  
54 -  
55 - return HTML;  
56 - }  
57 -  
58 -{S_TOK} {  
59 - BEGIN (TOK);  
60 - #ifdef DEBUG  
61 - printf ("[TOKEN] STMT_END {[ \\t]*<#}\n");  
62 - #endif  
63 - return STMT_END;  
64 - }  
65 -  
66 -<TOK>{E_TOK}\n? {  
67 - BEGIN (INITIAL);  
68 -  
69 - #ifdef DEBUG  
70 - printf ("[TOKEN] STMT_END {#>\\n?}\n");  
71 - #endif  
72 -  
73 - return STMT_END;  
74 - }  
75 -  
76 -<TOK>{OPERATOR} {  
77 - #ifdef DEBUG  
78 - printf ("[TOKEN] %c\n", yytext[0]);  
79 - #endif  
80 - yylval.iVal = yytext[0];  
81 - return yytext[0];  
82 - }  
83 -  
84 -<TOK>== {  
85 - #ifdef DEBUG  
86 - printf ("[TOKEN] EQ\n");  
87 - #endif  
88 -  
89 - return EQ;  
90 - }  
91 -<TOK>!= {  
92 - #ifdef DEBUG  
93 - printf ("[TOKEN] NE\n");  
94 - #endif  
95 -  
96 - return NE;  
97 - }  
98 -<TOK>\< {  
99 - #ifdef DEBUG  
100 - printf ("[TOKEN] EQ\n");  
101 - #endif  
102 -  
103 - return LT;  
104 - }  
105 -<TOK>\> {  
106 - #ifdef DEBUG  
107 - printf ("[TOKEN] EQ\n");  
108 - #endif  
109 -  
110 - return GT;  
111 - }  
112 -<TOK>\<= {  
113 - #ifdef DEBUG  
114 - printf ("[TOKEN] EQ\n");  
115 - #endif  
116 -  
117 - return LE;  
118 - }  
119 -<TOK>\>= {  
120 - #ifdef DEBUG  
121 - printf ("[TOKEN] EQ\n");  
122 - #endif  
123 -  
124 - return GE;  
125 - }  
126 -  
127 -<TOK>&& {  
128 - #ifdef DEBUG  
129 - printf ("[TOKEN] LOGAND\n");  
130 - #endif  
131 -  
132 - return LOGAND;  
133 - }  
134 -<TOK>\|\| {  
135 - #ifdef DEBUG  
136 - printf ("[TOKEN] LOGOR\n");  
137 - #endif  
138 -  
139 - return LOGOR;  
140 - }  
141 -  
142 -<TOK>{INT} {  
143 - yylval.iVal = atol (yytext);  
144 -  
145 - #ifdef DEBUG  
146 - printf ("[TOKEN] INT\n");  
147 - #endif  
148 -  
149 - return INT;  
150 - }  
151 -  
152 -<TOK>{FLOAT} {  
153 - yylval.fVal = atof (yytext);  
154 -  
155 - #ifdef DEBUG  
156 - printf ("[TOKEN] FLOAT\n");  
157 - #endif  
158 -  
159 - return FLOAT;  
160 - }  
161 -  
162 -<TOK>{STRING} {  
163 - yylval.cPtr = (char *) malloc (strlen (yytext) - 1);  
164 - memset (yylval.cPtr, 0, strlen (yytext) - 1);  
165 - memcpy (yylval.cPtr, yytext + 1, strlen (yytext) - 2);  
166 -  
167 - #ifdef DEBUG  
168 - printf ("[TOKEN] STRING\n");  
169 - #endif  
170 -  
171 - return STRING;  
172 - }  
173 -  
174 -<TOK>repeat {  
175 - #ifdef DEBUG  
176 - printf ("[TOKEN] REPEAT\n");  
177 - #endif  
178 -  
179 - return REPEAT;  
180 - }  
181 -<TOK>count {  
182 - #ifdef DEBUG  
183 - printf ("[TOKEN] COUNT\n");  
184 - #endif  
185 -  
186 - return COUNT;  
187 - }  
188 -  
189 -<TOK>foreach {  
190 - #ifdef DEBUG  
191 - printf ("[TOKEN] FOREACH\n");  
192 - #endif  
193 -  
194 - return FOREACH;  
195 - }  
196 -<TOK>as {  
197 - #ifdef DEBUG  
198 - printf ("[TOKEN] AS\n");  
199 - #endif  
200 -  
201 - return AS;  
202 - }  
203 -  
204 -<TOK>if {  
205 - #ifdef DEBUG  
206 - printf ("[TOKEN] IF\n");  
207 - #endif  
208 -  
209 - return IF;  
210 - }  
211 -<TOK>else {  
212 - #ifdef DEBUG  
213 - printf ("[TOKEN] ELSE\n");  
214 - #endif  
215 -  
216 - return ELSE;  
217 - }  
218 -  
219 -<TOK>end {  
220 - #ifdef DEBUG  
221 - printf ("[TOKEN] BLOCK_END\n");  
222 - #endif  
223 -  
224 - return BLOCK_END;  
225 - }  
226 -  
227 -<TOK>unset {  
228 - #ifdef DEBUG  
229 - printf ("[TOKEN] UNSET\n");  
230 - #endif  
231 -  
232 - return UNSET;  
233 - }  
234 -  
235 -<TOK>eol {  
236 - yylval.cPtr = (char *) calloc (sizeof (char), 2);  
237 - yylval.cPtr[0] = '\n';  
238 - yylval.cPtr[1] = '\0';  
239 - #ifdef DEBUG  
240 - printf ("[TOKEN] EOL\n");  
241 - #endif  
242 -  
243 - return EOL;  
244 - }  
245 -  
246 -<TOK>parent {  
247 - #ifdef DEBUG  
248 - printf ("[TOKEN] PARENT\n");  
249 - #endif  
250 -  
251 - return PARENT;  
252 - }  
253 -  
254 -<TOK>global {  
255 - #ifdef DEBUG  
256 - printf ("[TOKEN] GLOBAL\n");  
257 - #endif  
258 -  
259 - return GLOBAL;  
260 - }  
261 -  
262 -<TOK>{ICAST} {  
263 - #ifdef DEBUG  
264 - printf ("[TOKEN] ICAST\n");  
265 - #endif  
266 -  
267 - return ICAST;  
268 - }  
269 -<TOK>{FCAST} {  
270 - #ifdef DEBUG  
271 - printf ("[TOKEN] FCAST\n");  
272 - #endif  
273 -  
274 - return FCAST;  
275 - }  
276 -<TOK>{SCAST} {  
277 - #ifdef DEBUG  
278 - printf ("[TOKEN] SCAST\n");  
279 - #endif  
280 -  
281 - return SCAST;  
282 - }  
283 -  
284 -<TOK>{IDENT} {  
285 - yylval.cPtr = (char *) malloc (strlen (yytext) + 1);  
286 - strcpy (yylval.cPtr, yytext);  
287 -  
288 - #ifdef DEBUG  
289 - printf ("[TOKEN] IDENT\n");  
290 - #endif  
291 -  
292 - return IDENT;  
293 - }  
294 -  
295 -<TOK>[ \t\r\n] { /* eat tokens */ } 28 +{TEXT} {
  29 + char tok[2];
  30 + size_t len = strlen(yytext);
  31 +
  32 + yylval.cPtr = (char *)malloc(len + 2);
  33 + memset (yylval.cPtr, 0, len + 2);
  34 + memcpy (yylval.cPtr, yytext, len);
  35 +
  36 + tok[0] = input();
  37 + tok[1] = input();
  38 +
  39 + if (tok[1] == '#' || tok[0] == EOF) {
  40 + unput('#');
  41 + unput('<');
  42 + }
  43 + else {
  44 + if (tok[1] != EOF)
  45 + unput(tok[1]);
  46 + yylval.cPtr[len] = tok[0];
  47 + }
  48 +
  49 +#ifdef DEBUG
  50 + fputs("[TOKEN] HTML", stderr);
  51 +#endif
  52 + return HTML;
  53 +}
  54 +
  55 +{S_TOK} {
  56 + BEGIN(TOK);
  57 +#ifdef DEBUG
  58 + fputs("[TOKEN] STMT_END {[ \\t]*<#}", stderr);
  59 +#endif
  60 + return STMT_END;
  61 +}
  62 +
  63 +<TOK>{E_TOK}\n? {
  64 + BEGIN(INITIAL);
  65 +#ifdef DEBUG
  66 + fputs("[TOKEN] STMT_END {#>\\n?}", stderr);
  67 +#endif
  68 + return STMT_END;
  69 +}
  70 +
  71 +<TOK>{OPERATOR} {
  72 +#ifdef DEBUG
  73 + fprintf(stderr, "[TOKEN] %c\n", yytext[0]);
  74 +#endif
  75 + yylval.iVal = yytext[0];
  76 + return yytext[0];
  77 +}
  78 +
  79 +<TOK>== {
  80 +#ifdef DEBUG
  81 + fputs("[TOKEN] EQ", stderr);
  82 +#endif
  83 + return EQ;
  84 +}
  85 +
  86 +<TOK>!= {
  87 +#ifdef DEBUG
  88 + fputs("[TOKEN] NE", stderr);
  89 +#endif
  90 + return NE;
  91 +}
  92 +
  93 +<TOK>\< {
  94 +#ifdef DEBUG
  95 + fputs("[TOKEN] LT", stderr);
  96 +#endif
  97 + return LT;
  98 +}
  99 +
  100 +<TOK>\> {
  101 +#ifdef DEBUG
  102 + fputs("[TOKEN] GT", stderr);
  103 +#endif
  104 + return GT;
  105 +}
  106 +
  107 +<TOK>\<= {
  108 +#ifdef DEBUG
  109 + fputs("[TOKEN] LE", stderr);
  110 +#endif
  111 + return LE;
  112 +}
  113 +
  114 +<TOK>\>= {
  115 +#ifdef DEBUG
  116 + fputs("[TOKEN] GE", stderr);
  117 +#endif
  118 + return GE;
  119 +}
  120 +
  121 +<TOK>&& {
  122 +#ifdef DEBUG
  123 + fputs("[TOKEN] LOGAND", stderr);
  124 +#endif
  125 + return LOGAND;
  126 +}
  127 +<TOK>\|\| {
  128 +#ifdef DEBUG
  129 + fputs("[TOKEN] LOGOR", stderr);
  130 +#endif
  131 + return LOGOR;
  132 +}
  133 +
  134 +<TOK>{INT} {
  135 + yylval.iVal = atol (yytext);
  136 +#ifdef DEBUG
  137 + fputs("[TOKEN] INT", stderr);
  138 +#endif
  139 + return INT;
  140 +}
  141 +
  142 +<TOK>{FLOAT} {
  143 + yylval.fVal = atof(yytext);
  144 +#ifdef DEBUG
  145 + fputs("[TOKEN] FLOAT", stderr);
  146 +#endif
  147 + return FLOAT;
  148 +}
  149 +
  150 +<TOK>{STRING} {
  151 + yylval.cPtr = (char *)malloc(strlen (yytext) - 1);
  152 + memset (yylval.cPtr, 0, strlen(yytext) - 1);
  153 + memcpy (yylval.cPtr, yytext + 1, strlen(yytext) - 2);
  154 +#ifdef DEBUG
  155 + fputs("[TOKEN] STRING", stderr);
  156 +#endif
  157 + return STRING;
  158 +}
  159 +
  160 +<TOK>repeat {
  161 +#ifdef DEBUG
  162 + fputs("[TOKEN] REPEAT", stderr);
  163 +#endif
  164 + return REPEAT;
  165 +}
  166 +
  167 +<TOK>count {
  168 +#ifdef DEBUG
  169 + fputs("[TOKEN] COUNT", stderr);
  170 +#endif
  171 + return COUNT;
  172 +}
  173 +
  174 +<TOK>foreach {
  175 +#ifdef DEBUG
  176 + fputs("[TOKEN] FOREACH", stderr);
  177 +#endif
  178 + return FOREACH;
  179 +}
  180 +
  181 +<TOK>as {
  182 +#ifdef DEBUG
  183 + fputs("[TOKEN] AS", stderr);
  184 +#endif
  185 + return AS;
  186 +}
  187 +
  188 +<TOK>if {
  189 +#ifdef DEBUG
  190 + fputs("[TOKEN] IF", stderr);
  191 +#endif
  192 + return IF;
  193 +}
  194 +
  195 +<TOK>else {
  196 +#ifdef DEBUG
  197 + fputs("[TOKEN] ELSE", stderr);
  198 +#endif
  199 + return ELSE;
  200 +}
  201 +
  202 +<TOK>end {
  203 +#ifdef DEBUG
  204 + fputs("[TOKEN] BLOCK_END", stderr);
  205 +#endif
  206 + return BLOCK_END;
  207 +}
  208 +
  209 +<TOK>unset {
  210 +#ifdef DEBUG
  211 + fputs("[TOKEN] UNSET", stderr);
  212 +#endif
  213 + return UNSET;
  214 +}
  215 +
  216 +<TOK>eol {
  217 + yylval.cPtr = (char *)calloc(sizeof (char), 2);
  218 + yylval.cPtr[0] = '\n';
  219 + yylval.cPtr[1] = '\0';
  220 +#ifdef DEBUG
  221 + fputs("[TOKEN] EOL", stderr);
  222 +#endif
  223 + return EOL;
  224 +}
  225 +
  226 +<TOK>parent {
  227 +#ifdef DEBUG
  228 + fputs("[TOKEN] PARENT", stderr);
  229 +#endif
  230 + return PARENT;
  231 +}
  232 +
  233 +<TOK>global {
  234 +#ifdef DEBUG
  235 + fputs("[TOKEN] GLOBAL", stderr);
  236 +#endif
  237 + return GLOBAL;
  238 +}
  239 +
  240 +<TOK>{ICAST} {
  241 +#ifdef DEBUG
  242 + fputs("[TOKEN] ICAST", stderr);
  243 +#endif
  244 + return ICAST;
  245 +}
  246 +
  247 +<TOK>{FCAST} {
  248 +#ifdef DEBUG
  249 + fputs("[TOKEN] FCAST", stderr);
  250 +#endif
  251 + return FCAST;
  252 +}
  253 +<TOK>{SCAST} {
  254 +#ifdef DEBUG
  255 + fputs("[TOKEN] SCAST", stderr);
  256 +#endif
  257 + return SCAST;
  258 +}
  259 +
  260 +<TOK>{IDENT} {
  261 + yylval.cPtr = (char *)malloc(strlen(yytext) + 1);
  262 + strcpy(yylval.cPtr, yytext);
  263 +#ifdef DEBUG
  264 + fputs("[TOKEN] IDENT", stderr);
  265 +#endif
  266 + return IDENT;
  267 +}
  268 +
  269 +<TOK>[ \t\r\n] { /* eat tokens */ }
@@ -8,47 +8,46 @@ @@ -8,47 +8,46 @@
8 8
9 9
10 s_ident * 10 s_ident *
11 -getVariable (s_identList * iList, char * id) 11 +getVariable(s_identList * iList, char * id)
12 { 12 {
13 - return identListSeekKey (iList, id); 13 + return identListSeekKey(iList, id);
14 } 14 }
15 15
16 s_ident * 16 s_ident *
17 -getArray (s_ident * var, s_expVal * eVal)  
18 -{ 17 +getArray(s_ident * var, s_expVal * eVal)
  18 +{
19 s_ident * ret = NULL; 19 s_ident * ret = NULL;
20 20
21 /* generate new idl if ident isn't, discard prev val */ 21 /* generate new idl if ident isn't, discard prev val */
22 if (identGetType (var) != ID_TYP_IDL) 22 if (identGetType (var) != ID_TYP_IDL)
23 - identSetIdl (var, identListNew ()); 23 + identSetIdl (var, identListNew());
24 24
25 /* now seek or generate the actual ident */ 25 /* now seek or generate the actual ident */
26 - switch (expValueGetType (eVal)) 26 + switch (expValueGetType(eVal))
27 { 27 {
28 case EXP_TYP_INT: 28 case EXP_TYP_INT:
29 { 29 {
30 - int idx = expValueInt (eVal); 30 + int idx = expValueInt(eVal);
31 31
32 - ret = identListSeekIdx (identIdl (var), idx); 32 + ret = identListSeekIdx(identIdl(var), idx);
33 33
34 if (ret == NULL) 34 if (ret == NULL)
35 - ret = identListPutVal ( 35 + ret = identListPutVal(
36 identIdl (var), identUndefNew (idx, NULL)); 36 identIdl (var), identUndefNew (idx, NULL));
37 37
38 break; 38 break;
39 } 39 }
40 -  
41 case EXP_TYP_STRING: 40 case EXP_TYP_STRING:
42 { 41 {
43 - char * key = expValueString (eVal); 42 + char * key = expValueString(eVal);
44 43
45 - ret = identListSeekKey (identIdl (var), key); 44 + ret = identListSeekKey(identIdl(var), key);
46 45
47 if (ret == NULL) 46 if (ret == NULL)
48 - ret = identListPutVal ( 47 + ret = identListPutVal(
49 identIdl (var), identUndefNew (-1, key)); 48 identIdl (var), identUndefNew (-1, key));
50 49
51 - free (key); 50 + free(key);
52 } 51 }
53 } 52 }
54 53
Please register or login to post a comment