Browse Source

Sol Part 30: astyle -tSjp -A2 -k3 -W3 is Best Style!

Graham Northup 5 years ago
parent
commit
45891fa325
14 changed files with 1311 additions and 1312 deletions
  1. 1
    1
      ast.h
  2. 26
    26
      astprint.c
  3. 73
    73
      builtins.c
  4. 6
    6
      cdata.c
  5. 28
    28
      cdata.h
  6. 1013
    1013
      lex.yy.c
  7. 9
    9
      object.c
  8. 68
    68
      parser.tab.c
  9. 71
    72
      parser.tab.h
  10. 7
    7
      runtime.c
  11. 1
    1
      sol.h
  12. 3
    3
      solrun.c
  13. 3
    3
      state.c
  14. 2
    2
      util.c

+ 1
- 1
ast.h View File

@@ -135,7 +135,7 @@ typedef struct {
135 135
 } iter_node;
136 136
 
137 137
 typedef struct {
138
-    expr_node *ret;
138
+	expr_node *ret;
139 139
 } ret_node;
140 140
 
141 141
 typedef struct tag_stmtlist_node {

+ 26
- 26
astprint.c View File

@@ -28,27 +28,27 @@ void prst(sol_state_t *state, stmt_node *node, int lev) {
28 28
 	switch(node->type) {
29 29
 		case ST_EXPR:
30 30
 			prlev(state, lev, "Stmt<Expr>:");
31
-			prex(state, node->expr, lev+1);
31
+			prex(state, node->expr, lev + 1);
32 32
 			break;
33 33
 
34 34
 		case ST_IFELSE:
35 35
 			prlev(state, lev, "Stmt<IfElse>:");
36 36
 			lev++;
37 37
 			prlev(state, lev, "Cond:");
38
-			prex(state, node->ifelse->cond, lev+1);
38
+			prex(state, node->ifelse->cond, lev + 1);
39 39
 			prlev(state, lev, "IfTrue:");
40
-			prst(state, node->ifelse->iftrue, lev+1);
40
+			prst(state, node->ifelse->iftrue, lev + 1);
41 41
 			prlev(state, lev, "IfFalse:");
42
-			prst(state, node->ifelse->iffalse, lev+1);
42
+			prst(state, node->ifelse->iffalse, lev + 1);
43 43
 			break;
44 44
 
45 45
 		case ST_LOOP:
46 46
 			prlev(state, lev, "Stmt<Loop>:");
47 47
 			lev++;
48 48
 			prlev(state, lev, "Cond:");
49
-			prex(state, node->loop->cond, lev+1);
49
+			prex(state, node->loop->cond, lev + 1);
50 50
 			prlev(state, lev, "Loop:");
51
-			prst(state, node->loop->loop, lev+1);
51
+			prst(state, node->loop->loop, lev + 1);
52 52
 			break;
53 53
 
54 54
 		case ST_ITER:
@@ -56,23 +56,23 @@ void prst(sol_state_t *state, stmt_node *node, int lev) {
56 56
 			lev++;
57 57
 			prlev(state, lev, "Var: %s", node->iter->var);
58 58
 			prlev(state, lev, "Iter:");
59
-			prex(state, node->iter->iter, lev+1);
59
+			prex(state, node->iter->iter, lev + 1);
60 60
 			prlev(state, lev, "Loop:");
61
-			prst(state, node->iter->loop, lev+1);
61
+			prst(state, node->iter->loop, lev + 1);
62 62
 			break;
63 63
 
64 64
 		case ST_LIST:
65 65
 			prlev(state, lev, "Stmt<List>:");
66 66
 			stmtlist_node *cur = node->stmtlist;
67 67
 			while(cur && cur->stmt) {
68
-				prst(state, cur->stmt, lev+1);
68
+				prst(state, cur->stmt, lev + 1);
69 69
 				cur = cur->next;
70 70
 			}
71 71
 			break;
72 72
 
73 73
 		case ST_RET:
74 74
 			prlev(state, lev, "Stmt<Ret>:");
75
-			prex(state, node->ret->ret, lev+1);
75
+			prex(state, node->ret->ret, lev + 1);
76 76
 			break;
77 77
 
78 78
 		case ST_CONT:
@@ -120,7 +120,7 @@ void prex(sol_state_t *state, expr_node *node, int lev) {
120 120
 			prlev(state, lev, "ListGen:");
121 121
 			cure = node->listgen->list;
122 122
 			while(cure && cure->expr) {
123
-				prex(state, cure->expr, lev+1);
123
+				prex(state, cure->expr, lev + 1);
124 124
 				cure = cure->next;
125 125
 			}
126 126
 			break;
@@ -131,9 +131,9 @@ void prex(sol_state_t *state, expr_node *node, int lev) {
131 131
 			cura = node->mapgen->map;
132 132
 			while(cura && cura->item) {
133 133
 				prlev(state, lev, "<Key>:");
134
-				prex(state, cura->item->key, lev+1);
134
+				prex(state, cura->item->key, lev + 1);
135 135
 				prlev(state, lev, "<Value>:");
136
-				prex(state, cura->item->value, lev+1);
136
+				prex(state, cura->item->value, lev + 1);
137 137
 				cura = cura->next;
138 138
 			}
139 139
 			break;
@@ -215,9 +215,9 @@ void prex(sol_state_t *state, expr_node *node, int lev) {
215 215
 					break;
216 216
 			}
217 217
 			prlev(state, lev, "Left:");
218
-			prex(state, node->binop->left, lev+1);
218
+			prex(state, node->binop->left, lev + 1);
219 219
 			prlev(state, lev, "Right:");
220
-			prex(state, node->binop->right, lev+1);
220
+			prex(state, node->binop->right, lev + 1);
221 221
 			break;
222 222
 
223 223
 		case EX_UNOP:
@@ -241,27 +241,27 @@ void prex(sol_state_t *state, expr_node *node, int lev) {
241 241
 					break;
242 242
 			}
243 243
 			prlev(state, lev, "Expr:");
244
-			prex(state, node->unop->expr, lev+1);
244
+			prex(state, node->unop->expr, lev + 1);
245 245
 			break;
246 246
 
247 247
 		case EX_INDEX:
248 248
 			prlev(state, lev, "Index:");
249 249
 			lev++;
250 250
 			prlev(state, lev, "Expr:");
251
-			prex(state, node->index->expr, lev+1);
251
+			prex(state, node->index->expr, lev + 1);
252 252
 			prlev(state, lev, "Index:");
253
-			prex(state, node->index->index, lev+1);
253
+			prex(state, node->index->index, lev + 1);
254 254
 			break;
255 255
 
256 256
 		case EX_SETINDEX:
257 257
 			prlev(state, lev, "SetIndex:");
258 258
 			lev++;
259 259
 			prlev(state, lev, "Expr:");
260
-			prex(state, node->setindex->expr, lev+1);
260
+			prex(state, node->setindex->expr, lev + 1);
261 261
 			prlev(state, lev, "Index:");
262
-			prex(state, node->setindex->index, lev+1);
262
+			prex(state, node->setindex->index, lev + 1);
263 263
 			prlev(state, lev, "Value:");
264
-			prex(state, node->setindex->value, lev+1);
264
+			prex(state, node->setindex->value, lev + 1);
265 265
 			break;
266 266
 
267 267
 		case EX_ASSIGN:
@@ -269,7 +269,7 @@ void prex(sol_state_t *state, expr_node *node, int lev) {
269 269
 			lev++;
270 270
 			prlev(state, lev, "Ident: %s", node->assign->ident);
271 271
 			prlev(state, lev, "Value:");
272
-			prex(state, node->assign->value, lev+1);
272
+			prex(state, node->assign->value, lev + 1);
273 273
 			break;
274 274
 
275 275
 		case EX_REF:
@@ -280,11 +280,11 @@ void prex(sol_state_t *state, expr_node *node, int lev) {
280 280
 			prlev(state, lev, "Call:");
281 281
 			lev++;
282 282
 			prlev(state, lev, "Expr:");
283
-			prex(state, node->call->expr, lev+1);
283
+			prex(state, node->call->expr, lev + 1);
284 284
 			prlev(state, lev, "Args:");
285 285
 			cure = node->call->args;
286 286
 			while(cure && cure->expr) {
287
-				prex(state, cure->expr, lev+1);
287
+				prex(state, cure->expr, lev + 1);
288 288
 				cure = cure->next;
289 289
 			}
290 290
 			break;
@@ -296,11 +296,11 @@ void prex(sol_state_t *state, expr_node *node, int lev) {
296 296
 			prlev(state, lev, "Args:");
297 297
 			curi = node->funcdecl->args;
298 298
 			while(curi && curi->ident) {
299
-				prlev(state, lev+1, curi->ident);
299
+				prlev(state, lev + 1, curi->ident);
300 300
 				curi = curi->next;
301 301
 			}
302 302
 			prlev(state, lev, "Body:");
303
-			prst(state, node->funcdecl->body, lev+1);
303
+			prst(state, node->funcdecl->body, lev + 1);
304 304
 			break;
305 305
 	}
306 306
 }

+ 73
- 73
builtins.c View File

@@ -31,7 +31,7 @@ sol_object_t *sol_f_not_impl(sol_state_t *state, sol_object_t *args) {
31 31
 
32 32
 sol_object_t *sol_f_default_cmp(sol_state_t *state, sol_object_t *args) {
33 33
 	sol_object_t *a = sol_list_get_index(state, args, 0), *b = sol_list_get_index(state, args, 1);
34
-	sol_object_t *res = sol_new_int(state, a!=b);
34
+	sol_object_t *res = sol_new_int(state, a != b);
35 35
 	sol_obj_free(a);
36 36
 	sol_obj_free(b);
37 37
 	return res;
@@ -121,7 +121,7 @@ sol_object_t *sol_f_type(sol_state_t *state, sol_object_t *args) {
121 121
 	return res;
122 122
 }
123 123
 
124
-static dsl_seq *seen=NULL;
124
+static dsl_seq *seen = NULL;
125 125
 
126 126
 int test_seen(sol_object_t *obj) {
127 127
 	dsl_seq_iter *iter;
@@ -240,7 +240,7 @@ sol_object_t *sol_f_prepr(sol_state_t *state, sol_object_t *args) {
240 240
 	int i, sz = sol_list_len(state, args);
241 241
 	sol_object_t *obj, *str;
242 242
 	seen = dsl_seq_new_array(NULL, NULL);
243
-	for(i=0; i<sz; i++) {
243
+	for(i = 0; i < sz; i++) {
244 244
 		obj = sol_list_get_index(state, args, i);
245 245
 		str = sol_cast_repr(state, obj);
246 246
 		sol_printf(state, "%s", str->str);
@@ -259,7 +259,7 @@ sol_object_t *sol_f_print(sol_state_t *state, sol_object_t *args) {
259 259
 	int i, sz = sol_list_len(state, args);
260 260
 	sol_object_t *obj, *str;
261 261
 	seen = dsl_seq_new_array(NULL, NULL);
262
-	for(i=0; i<sz; i++) {
262
+	for(i = 0; i < sz; i++) {
263 263
 		obj = sol_list_get_index(state, args, i);
264 264
 		str = sol_cast_string(state, obj);
265 265
 		sol_printf(state, "%s", str->str);
@@ -303,7 +303,7 @@ sol_object_t *sol_f_rawset(sol_state_t *state, sol_object_t *args) {
303 303
 sol_object_t *sol_f_range(sol_state_t *state, sol_object_t *args) {
304 304
 	sol_object_t *res = sol_new_list(state), *bound = sol_cast_int(state, sol_list_get_index(state, args, 0));
305 305
 	int i;
306
-	for(i=0; i<bound->ival; i++) {
306
+	for(i = 0; i < bound->ival; i++) {
307 307
 		sol_list_insert(state, res, sol_list_len(state, res), sol_new_int(state, i));
308 308
 	}
309 309
 	sol_obj_free(bound);
@@ -354,13 +354,13 @@ sol_object_t *sol_f_execfile(sol_state_t *state, sol_object_t *args) {
354 354
 	fseek(f, 0, SEEK_END);
355 355
 	sz = ftell(f);
356 356
 	fseek(f, 0, SEEK_SET);
357
-	s = malloc(sz+1);
357
+	s = malloc(sz + 1);
358 358
 	if(!s) {
359 359
 		fclose(f);
360 360
 		return sol_set_error_string(state, "File memory allocation failure");
361 361
 	}
362 362
 	fread(s, 1, sz, f);
363
-	s[sz]=0;
363
+	s[sz] = 0;
364 364
 	fclose(f);
365 365
 
366 366
 	program = sol_compile(s);
@@ -390,7 +390,7 @@ sol_object_t *sol_f_ord(sol_state_t *state, sol_object_t *args) {
390 390
 	sol_object_t *idx = sol_new_int(state, 0), *arg2, *iarg, *res;
391 391
 	size_t len = strlen(str->str);
392 392
 	sol_obj_free(arg);
393
-	if(sol_list_len(state, args)>1) {
393
+	if(sol_list_len(state, args) > 1) {
394 394
 		arg2 = sol_list_get_index(state, args, 1);
395 395
 		iarg = sol_cast_int(state, arg2);
396 396
 		sol_obj_free(arg2);
@@ -410,7 +410,7 @@ sol_object_t *sol_f_ord(sol_state_t *state, sol_object_t *args) {
410 410
 
411 411
 sol_object_t *sol_f_chr(sol_state_t *state, sol_object_t *args) {
412 412
 	sol_object_t *arg = sol_list_get_index(state, args, 0), *iarg = sol_cast_int(state, arg);
413
-	char cbuf[2]= {iarg->ival, 0};
413
+	char cbuf[2] = {iarg->ival, 0};
414 414
 	sol_object_t *res = sol_new_string(state, cbuf);
415 415
 	sol_obj_free(arg);
416 416
 	sol_obj_free(iarg);
@@ -441,7 +441,7 @@ sol_object_t *sol_f_debug_closure(sol_state_t *state, sol_object_t *args) {
441 441
 }
442 442
 
443 443
 sol_object_t *sol_f_debug_globals(sol_state_t *state, sol_object_t *args) {
444
-	return sol_list_get_index(state, state->scopes, sol_list_len(state, state->scopes)-1);
444
+	return sol_list_get_index(state, state->scopes, sol_list_len(state, state->scopes) - 1);
445 445
 }
446 446
 
447 447
 sol_object_t *sol_f_debug_locals(sol_state_t *state, sol_object_t *args) {
@@ -678,7 +678,7 @@ sol_object_t *sol_f_int_bnot(sol_state_t *state, sol_object_t *args) {
678 678
 
679 679
 sol_object_t *sol_f_int_cmp(sol_state_t *state, sol_object_t *args) {
680 680
 	sol_object_t *a = sol_list_get_index(state, args, 0), *b = sol_cast_int(state, sol_list_get_index(state, args, 1));
681
-	sol_object_t *res = sol_new_int(state, a->ival==b->ival? 0 : (a->ival<b->ival? -1 : 1));
681
+	sol_object_t *res = sol_new_int(state, a->ival == b->ival ? 0 : (a->ival < b->ival ? -1 : 1));
682 682
 	sol_obj_free(a);
683 683
 	sol_obj_free(b);
684 684
 	return res;
@@ -766,7 +766,7 @@ sol_object_t *sol_f_float_pow(sol_state_t *state, sol_object_t *args) {
766 766
 
767 767
 sol_object_t *sol_f_float_cmp(sol_state_t *state, sol_object_t *args) {
768 768
 	sol_object_t *a = sol_list_get_index(state, args, 0), *b = sol_cast_float(state, sol_list_get_index(state, args, 1));
769
-	sol_object_t *res = sol_new_int(state, a->fval==b->fval? 0 : (a->fval<b->fval? -1 : 1));
769
+	sol_object_t *res = sol_new_int(state, a->fval == b->fval ? 0 : (a->fval < b->fval ? -1 : 1));
770 770
 	sol_obj_free(a);
771 771
 	sol_obj_free(b);
772 772
 	return res;
@@ -809,7 +809,7 @@ sol_object_t *sol_f_str_mul(sol_state_t *state, sol_object_t *args) {
809 809
 	int n = strlen(a->str) * b->ival + 1;
810 810
 	char *s = malloc(n);
811 811
 	int i;
812
-	s[0]='\0';
812
+	s[0] = '\0';
813 813
 	for(i = 0; i < b->ival; i++) {
814 814
 		strncat(s, a->str, n);
815 815
 	}
@@ -841,7 +841,7 @@ sol_object_t *sol_f_str_len(sol_state_t *state, sol_object_t *args) {
841 841
 
842 842
 sol_object_t *sol_f_str_index(sol_state_t *state, sol_object_t *args) {
843 843
 	sol_object_t *str = sol_list_get_index(state, args, 0), *key = sol_list_get_index(state, args, 1), *idx, *funcs, *res;
844
-	char buf[2]= {0, 0};
844
+	char buf[2] = {0, 0};
845 845
 	if(sol_is_string(key)) {
846 846
 		funcs = sol_get_methods_name(state, "string");
847 847
 		res = sol_map_get(state, funcs, key);
@@ -849,7 +849,7 @@ sol_object_t *sol_f_str_index(sol_state_t *state, sol_object_t *args) {
849 849
 		return res;
850 850
 	}
851 851
 	idx = sol_cast_int(state, key);
852
-	if(idx->ival>=0 && idx->ival<strlen(str->str)) {
852
+	if(idx->ival >= 0 && idx->ival < strlen(str->str)) {
853 853
 		buf[0] = str->str[idx->ival];
854 854
 	}
855 855
 	sol_obj_free(str);
@@ -906,23 +906,23 @@ sol_object_t *sol_f_str_sub(sol_state_t *state, sol_object_t *args) {
906 906
 	}
907 907
 	sol_obj_free(low);
908 908
 	sol_obj_free(high);
909
-	if(ilow->ival<0) {
910
-		ilow->ival+=len;
911
-		if(ilow->ival<0) {
912
-			ilow->ival=0;
909
+	if(ilow->ival < 0) {
910
+		ilow->ival += len;
911
+		if(ilow->ival < 0) {
912
+			ilow->ival = 0;
913 913
 		}
914 914
 	}
915
-	if(ilow->ival>len) {
916
-		ilow->ival=len;
915
+	if(ilow->ival > len) {
916
+		ilow->ival = len;
917 917
 	}
918
-	if(ihigh->ival<0) {
919
-		ihigh->ival+=len;
920
-		if(ihigh->ival<0) {
921
-			ihigh->ival=0;
918
+	if(ihigh->ival < 0) {
919
+		ihigh->ival += len;
920
+		if(ihigh->ival < 0) {
921
+			ihigh->ival = 0;
922 922
 		}
923 923
 	}
924
-	if(ihigh->ival>len) {
925
-		ihigh->ival=len;
924
+	if(ihigh->ival > len) {
925
+		ihigh->ival = len;
926 926
 	}
927 927
 	if(ilow->ival >= ihigh->ival) {
928 928
 		sol_obj_free(ilow);
@@ -931,10 +931,10 @@ sol_object_t *sol_f_str_sub(sol_state_t *state, sol_object_t *args) {
931 931
 		return sol_new_string(state, "");
932 932
 	}
933 933
 	s = malloc(ihigh->ival - ilow->ival + 1);
934
-	for(i=ilow->ival; i<ihigh->ival; i++) {
935
-		s[i-ilow->ival] = str->str[i];
934
+	for(i = ilow->ival; i < ihigh->ival; i++) {
935
+		s[i - ilow->ival] = str->str[i];
936 936
 	}
937
-	s[ihigh->ival-ilow->ival]='\0';
937
+	s[ihigh->ival - ilow->ival] = '\0';
938 938
 	sol_obj_free(ihigh);
939 939
 	sol_obj_free(ilow);
940 940
 	sol_obj_free(str);
@@ -968,7 +968,7 @@ sol_object_t *sol_f_str_split(sol_state_t *state, sol_object_t *args) {
968 968
 sol_object_t *sol_f_str_find(sol_state_t *state, sol_object_t *args) {
969 969
 	sol_object_t *str = sol_list_get_index(state, args, 0), *substr = sol_list_get_index(state, args, 1), *ssubstr = sol_cast_string(state, substr);
970 970
 	char *ptr = strstr(str->str, ssubstr->str);
971
-	sol_object_t *res = sol_new_int(state, ptr?ptr-str->str:-1);
971
+	sol_object_t *res = sol_new_int(state, ptr ? ptr - str->str : -1);
972 972
 	sol_obj_free(str);
973 973
 	sol_obj_free(substr);
974 974
 	sol_obj_free(ssubstr);
@@ -1027,7 +1027,7 @@ sol_object_t *sol_f_list_index(sol_state_t *state, sol_object_t *args) {
1027 1027
 }
1028 1028
 
1029 1029
 sol_object_t *sol_f_list_setindex(sol_state_t *state, sol_object_t *args) {
1030
-	sol_object_t *ls = sol_list_get_index(state, args, 0), *b = sol_cast_int(state, sol_list_get_index(state, args ,1));
1030
+	sol_object_t *ls = sol_list_get_index(state, args, 0), *b = sol_cast_int(state, sol_list_get_index(state, args , 1));
1031 1031
 	sol_object_t *val = sol_list_get_index(state, args, 2);
1032 1032
 	sol_list_set_index(state, ls, b->ival, val);
1033 1033
 	sol_obj_free(ls);
@@ -1107,9 +1107,9 @@ sol_object_t *sol_f_list_truncate(sol_state_t *state, sol_object_t *args) {
1107 1107
 sol_object_t *sol_f_list_map(sol_state_t *state, sol_object_t *args) {
1108 1108
 	sol_object_t *list = sol_list_get_index(state, args, 0), *func = sol_list_get_index(state, args, 1);
1109 1109
 	sol_object_t *fargs = sol_new_list(state), *item;
1110
-	int idx=0, len = sol_list_len(state, list);
1110
+	int idx = 0, len = sol_list_len(state, list);
1111 1111
 	sol_list_insert(state, fargs, 0, func);
1112
-	while(idx<len) {
1112
+	while(idx < len) {
1113 1113
 		item = sol_list_get_index(state, list, idx);
1114 1114
 		sol_list_insert(state, fargs, 1, item);
1115 1115
 		sol_obj_free(item);
@@ -1130,9 +1130,9 @@ sol_object_t *sol_f_list_map(sol_state_t *state, sol_object_t *args) {
1130 1130
 sol_object_t *sol_f_list_filter(sol_state_t *state, sol_object_t *args) {
1131 1131
 	sol_object_t *list = sol_list_get_index(state, args, 0), *func = sol_list_get_index(state, args, 1);
1132 1132
 	sol_object_t *fargs = sol_new_list(state), *item, *ival;
1133
-	int idx=0, len = sol_list_len(state, list);
1133
+	int idx = 0, len = sol_list_len(state, list);
1134 1134
 	sol_list_insert(state, fargs, 0, func);
1135
-	while(idx<len) {
1135
+	while(idx < len) {
1136 1136
 		item = sol_list_get_index(state, list, idx);
1137 1137
 		sol_list_insert(state, fargs, 1, item);
1138 1138
 		sol_obj_free(item);
@@ -1349,7 +1349,7 @@ sol_object_t *sol_f_mcell_tostring(sol_state_t *state, sol_object_t *args) {
1349 1349
 sol_object_t *sol_f_func_index(sol_state_t *state, sol_object_t *args) {
1350 1350
 	sol_object_t *func = sol_list_get_index(state, args, 0), *key = sol_list_get_index(state, args, 1), *res;
1351 1351
 	identlist_node *curi;
1352
-	int i=0;
1352
+	int i = 0;
1353 1353
 	if(!sol_is_string(key)) {
1354 1354
 		res = sol_map_get(state, func->udata, key);
1355 1355
 	} else {
@@ -1428,11 +1428,11 @@ sol_object_t *sol_f_cfunc_tostring(sol_state_t *state, sol_object_t *args) {
1428 1428
 }
1429 1429
 
1430 1430
 sol_object_t *sol_f_astnode_call(sol_state_t *state, sol_object_t *args) {
1431
-	sol_object_t *obj = sol_list_get_index(state, args, 0), *env=NULL, *res;
1431
+	sol_object_t *obj = sol_list_get_index(state, args, 0), *env = NULL, *res;
1432 1432
 	stmt_node *stmt = (stmt_node *) obj->node;
1433 1433
 	expr_node *expr = (expr_node *) obj->node;
1434 1434
 	sol_obj_free(obj);
1435
-	if(sol_list_len(state, args)>1) {
1435
+	if(sol_list_len(state, args) > 1) {
1436 1436
 		env = sol_list_get_index(state, args, 1);
1437 1437
 		sol_state_push_scope(state, env);
1438 1438
 	}
@@ -1450,14 +1450,14 @@ sol_object_t *sol_f_astnode_call(sol_state_t *state, sol_object_t *args) {
1450 1450
 }
1451 1451
 
1452 1452
 sol_object_t *sol_f_astnode_index(sol_state_t *state, sol_object_t *args) {
1453
-	sol_object_t *obj = sol_list_get_index(state, args, 0), *key = sol_list_get_index(state, args, 1), *str = sol_cast_string(state, key), *res=NULL, *pair;
1453
+	sol_object_t *obj = sol_list_get_index(state, args, 0), *key = sol_list_get_index(state, args, 1), *str = sol_cast_string(state, key), *res = NULL, *pair;
1454 1454
 	stmt_node *stmt = (stmt_node *) obj->node;
1455 1455
 	stmtlist_node *curs;
1456 1456
 	expr_node *expr = (expr_node *) obj->node;
1457 1457
 	exprlist_node *cure;
1458 1458
 	assoclist_node *cura;
1459 1459
 	identlist_node *curi;
1460
-	int i=0;
1460
+	int i = 0;
1461 1461
 	if(sol_is_aststmt(obj)) {
1462 1462
 		if(sol_string_eq(state, str, "type")) {
1463 1463
 			res = sol_new_int(state, stmt->type);
@@ -1630,7 +1630,7 @@ sol_object_t *sol_f_astnode_index(sol_state_t *state, sol_object_t *args) {
1630 1630
 
1631 1631
 				case EX_FUNCDECL:
1632 1632
 					if(sol_string_eq(state, str, "name")) {
1633
-						res = sol_new_string(state, (expr->funcdecl->name?expr->funcdecl->name:""));
1633
+						res = sol_new_string(state, (expr->funcdecl->name ? expr->funcdecl->name : ""));
1634 1634
 					} else if(sol_string_eq(state, str, "args")) {
1635 1635
 						res = sol_new_list(state);
1636 1636
 						curi = expr->funcdecl->args;
@@ -1663,7 +1663,7 @@ sol_object_t *sol_f_astnode_setindex(sol_state_t *state, sol_object_t *args) {
1663 1663
 	exprlist_node *cure, *preve = NULL;
1664 1664
 	assoclist_node *cura, *preva = NULL;
1665 1665
 	identlist_node *curi, *previ = NULL;
1666
-	int i=0, len;
1666
+	int i = 0, len;
1667 1667
 	if(sol_is_aststmt(obj)) {
1668 1668
 		if(sol_string_eq(state, str, "type")) {
1669 1669
 			ival = sol_cast_int(state, val);
@@ -1721,10 +1721,10 @@ sol_object_t *sol_f_astnode_setindex(sol_state_t *state, sol_object_t *args) {
1721 1721
 				case ST_LIST:
1722 1722
 					if(sol_string_eq(state, str, "stmtlist") && sol_is_list(val)) {
1723 1723
 						len = sol_list_len(state, val);
1724
-						if(len>0) {
1724
+						if(len > 0) {
1725 1725
 							curs = malloc(sizeof(stmtlist_node));
1726 1726
 							stmt->stmtlist = curs;
1727
-							for(i=0; i<len; i++) {
1727
+							for(i = 0; i < len; i++) {
1728 1728
 								if(sol_is_aststmt(sol_list_get_index(state, val, i))) {
1729 1729
 									curs->stmt = sol_list_get_index(state, val, i)->node;
1730 1730
 									prevs = curs;
@@ -1793,10 +1793,10 @@ sol_object_t *sol_f_astnode_setindex(sol_state_t *state, sol_object_t *args) {
1793 1793
 				case EX_LISTGEN:
1794 1794
 					if(sol_string_eq(state, str, "list") && sol_is_list(val)) {
1795 1795
 						len = sol_list_len(state, val);
1796
-						if(len>0) {
1796
+						if(len > 0) {
1797 1797
 							cure = malloc(sizeof(exprlist_node));
1798 1798
 							expr->listgen->list = cure;
1799
-							for(i=0; i<len; i++) {
1799
+							for(i = 0; i < len; i++) {
1800 1800
 								if(sol_is_astexpr(sol_list_get_index(state, val, i))) {
1801 1801
 									cure->expr = sol_list_get_index(state, val, i)->node;
1802 1802
 									preve = cure;
@@ -1820,10 +1820,10 @@ sol_object_t *sol_f_astnode_setindex(sol_state_t *state, sol_object_t *args) {
1820 1820
 				case EX_MAPGEN:
1821 1821
 					if(sol_string_eq(state, str, "map") && sol_is_list(val)) {
1822 1822
 						len = sol_list_len(state, val);
1823
-						if(len>0) {
1823
+						if(len > 0) {
1824 1824
 							cura = malloc(sizeof(assoclist_node));
1825 1825
 							expr->mapgen->map = cura;
1826
-							for(i=0; i<len; i++) {
1826
+							for(i = 0; i < len; i++) {
1827 1827
 								if(sol_is_list(sol_list_get_index(state, val, i))) {
1828 1828
 									pair = sol_list_get_index(state, val, i);
1829 1829
 									if(sol_list_len(state, pair) >= 2 && sol_is_astexpr(sol_list_get_index(state, pair, 0)) && sol_is_astexpr(sol_list_get_index(state, pair, 1))) {
@@ -1912,10 +1912,10 @@ sol_object_t *sol_f_astnode_setindex(sol_state_t *state, sol_object_t *args) {
1912 1912
 						expr->call->expr = val->node;
1913 1913
 					} else if(sol_string_eq(state, str, "args") && sol_is_list(val)) {
1914 1914
 						len = sol_list_len(state, val);
1915
-						if(len>0) {
1915
+						if(len > 0) {
1916 1916
 							cure = malloc(sizeof(exprlist_node));
1917
-							expr->call->args= cure;
1918
-							for(i=0; i<len; i++) {
1917
+							expr->call->args = cure;
1918
+							for(i = 0; i < len; i++) {
1919 1919
 								if(sol_is_astexpr(sol_list_get_index(state, val, i))) {
1920 1920
 									cure->expr = sol_list_get_index(state, val, i)->node;
1921 1921
 									preve = cure;
@@ -1943,10 +1943,10 @@ sol_object_t *sol_f_astnode_setindex(sol_state_t *state, sol_object_t *args) {
1943 1943
 						sol_obj_free(sval);
1944 1944
 					} else if(sol_string_eq(state, str, "args") && sol_is_list(val)) {
1945 1945
 						len = sol_list_len(state, val);
1946
-						if(len>0) {
1946
+						if(len > 0) {
1947 1947
 							curi = malloc(sizeof(identlist_node));
1948
-							expr->funcdecl->args= curi;
1949
-							for(i=0; i<len; i++) {
1948
+							expr->funcdecl->args = curi;
1949
+							for(i = 0; i < len; i++) {
1950 1950
 								sval = sol_cast_string(state, sol_list_get_index(state, val, i));
1951 1951
 								curi->ident = strdup(sval->str);
1952 1952
 								sol_obj_free(sval);
@@ -1977,8 +1977,8 @@ sol_object_t *sol_f_astnode_setindex(sol_state_t *state, sol_object_t *args) {
1977 1977
 	return val;
1978 1978
 }
1979 1979
 
1980
-static char *sol_StmtNames[]= {"EXPR", "IFSELSE", "LOOP", "ITER", "LIST", "RET", "CONT", "BREAK"};
1981
-static char *sol_ExprNames[]= {"LIT", "LISTGEN", "MAPGEN", "BINOP", "UNOP", "INDEX", "SETINDEX", "ASSIGN", "REF", "CALL", "FUNCDECL"};
1980
+static char *sol_StmtNames[] = {"EXPR", "IFSELSE", "LOOP", "ITER", "LIST", "RET", "CONT", "BREAK"};
1981
+static char *sol_ExprNames[] = {"LIT", "LISTGEN", "MAPGEN", "BINOP", "UNOP", "INDEX", "SETINDEX", "ASSIGN", "REF", "CALL", "FUNCDECL"};
1982 1982
 
1983 1983
 sol_object_t *sol_f_astnode_tostring(sol_state_t *state, sol_object_t *args) {
1984 1984
 	sol_object_t *obj = sol_list_get_index(state, args, 0), *res;
@@ -2027,9 +2027,9 @@ sol_object_t *sol_f_buffer_new(sol_state_t *state, sol_object_t *args) {
2027 2027
 
2028 2028
 sol_object_t *sol_f_buffer_get(sol_state_t *state, sol_object_t *args) {
2029 2029
 	sol_object_t *buf = sol_list_get_index(state, args, 0), *tp = sol_list_get_index(state, args, 1), *off = sol_list_get_index(state, args, 2);
2030
-	sol_object_t *itp = sol_cast_int(state, tp), *ioff, *res=NULL;
2030
+	sol_object_t *itp = sol_cast_int(state, tp), *ioff, *res = NULL;
2031 2031
 	sol_buftype_t buftp = itp->ival;
2032
-	char *data, cbuf[2]= {0, 0};
2032
+	char *data, cbuf[2] = {0, 0};
2033 2033
 	sol_obj_free(tp);
2034 2034
 	sol_obj_free(itp);
2035 2035
 	if(!sol_is_none(state, off)) {
@@ -2043,7 +2043,7 @@ sol_object_t *sol_f_buffer_get(sol_state_t *state, sol_object_t *args) {
2043 2043
 		sol_obj_free(ioff);
2044 2044
 		return sol_incref(state->None);
2045 2045
 	}
2046
-	data = ((char *) buf->buffer)+ioff->ival;
2046
+	data = ((char *) buf->buffer) + ioff->ival;
2047 2047
 	sol_obj_free(buf);
2048 2048
 	sol_obj_free(ioff);
2049 2049
 	switch(buftp) {
@@ -2117,7 +2117,7 @@ sol_object_t *sol_f_buffer_get(sol_state_t *state, sol_object_t *args) {
2117 2117
 			break;
2118 2118
 
2119 2119
 		case BUF_PTR:
2120
-			res = sol_new_buffer(state, ((void *) *((unsigned long *) data)), -1, OWN_NONE, NULL, NULL);
2120
+			res = sol_new_buffer(state, ((void *) * ((unsigned long *) data)), -1, OWN_NONE, NULL, NULL);
2121 2121
 			break;
2122 2122
 	}
2123 2123
 	if(!res) {
@@ -2128,7 +2128,7 @@ sol_object_t *sol_f_buffer_get(sol_state_t *state, sol_object_t *args) {
2128 2128
 
2129 2129
 sol_object_t *sol_f_buffer_set(sol_state_t *state, sol_object_t *args) {
2130 2130
 	sol_object_t *buf = sol_list_get_index(state, args, 0), *tp = sol_list_get_index(state, args, 1), *val = sol_list_get_index(state, args, 2), *off = sol_list_get_index(state, args, 3);
2131
-	sol_object_t *itp = sol_cast_int(state, tp), *ioff, *ival=NULL, *fval=NULL, *sval=NULL;
2131
+	sol_object_t *itp = sol_cast_int(state, tp), *ioff, *ival = NULL, *fval = NULL, *sval = NULL;
2132 2132
 	sol_buftype_t buftp = itp->ival;
2133 2133
 	char *data;
2134 2134
 	sol_obj_free(tp);
@@ -2144,7 +2144,7 @@ sol_object_t *sol_f_buffer_set(sol_state_t *state, sol_object_t *args) {
2144 2144
 		sol_obj_free(ioff);
2145 2145
 		return sol_incref(state->None);
2146 2146
 	}
2147
-	data = ((char *) buf->buffer)+ioff->ival;
2147
+	data = ((char *) buf->buffer) + ioff->ival;
2148 2148
 	sol_obj_free(buf);
2149 2149
 	sol_obj_free(ioff);
2150 2150
 	switch(buftp) {
@@ -2273,7 +2273,7 @@ sol_object_t *sol_f_buffer_size(sol_state_t *state, sol_object_t *args) {
2273 2273
 
2274 2274
 sol_object_t *sol_f_buffer_fromstring(sol_state_t *state, sol_object_t *args) {
2275 2275
 	sol_object_t *val = sol_list_get_index(state, args, 0), *sval = sol_cast_string(state, val);
2276
-	size_t sz = strlen(sval->str)+1;
2276
+	size_t sz = strlen(sval->str) + 1;
2277 2277
 	sol_object_t *buf = sol_new_buffer(state, malloc(sz), sz, OWN_FREE, NULL, NULL);
2278 2278
 	strcpy(buf->buffer, sval->str);
2279 2279
 	sol_obj_free(val);
@@ -2366,8 +2366,8 @@ sol_object_t *sol_f_stream_write(sol_state_t *state, sol_object_t *args) {
2366 2366
 
2367 2367
 sol_object_t *sol_f_stream_read(sol_state_t *state, sol_object_t *args) {
2368 2368
 	sol_object_t *stream = sol_list_get_index(state, args, 0), *amt = sol_list_get_index(state, args, 1), *iamt, *res;
2369
-	char *s=NULL, *p;
2370
-	size_t count=0, max=0, pos, end;
2369
+	char *s = NULL, *p;
2370
+	size_t count = 0, max = 0, pos, end;
2371 2371
 	if(sol_is_string(amt)) {
2372 2372
 		if(sol_string_eq(state, amt, "ALL")) {
2373 2373
 			pos = sol_stream_ftell(state, stream);
@@ -2375,23 +2375,23 @@ sol_object_t *sol_f_stream_read(sol_state_t *state, sol_object_t *args) {
2375 2375
 			end = sol_stream_ftell(state, stream);
2376 2376
 			sol_stream_fseek(state, stream, pos, SEEK_SET);
2377 2377
 			//printf("IO: Reading %ld bytes starting at %ld\n", end-pos, pos);
2378
-			s = malloc((end-pos+1)*sizeof(char));
2379
-			if(sol_stream_fread(state, stream, s, sizeof(char), end-pos)<(end-pos)) {
2378
+			s = malloc((end - pos + 1) * sizeof(char));
2379
+			if(sol_stream_fread(state, stream, s, sizeof(char), end - pos) < (end - pos)) {
2380 2380
 				free(s);
2381 2381
 				sol_obj_free(stream);
2382 2382
 				sol_obj_free(amt);
2383 2383
 				return sol_set_error_string(state, "IO read error");
2384 2384
 			}
2385
-			s[end-pos]='\0';
2385
+			s[end - pos] = '\0';
2386 2386
 		} else if(sol_string_eq(state, amt, "LINE")) {
2387
-			s = malloc(STDIO_CHUNK_SIZE*sizeof(char));
2387
+			s = malloc(STDIO_CHUNK_SIZE * sizeof(char));
2388 2388
 			sol_stream_fgets(state, stream, s, STDIO_CHUNK_SIZE);
2389 2389
 		}
2390 2390
 	} else {
2391 2391
 		iamt = sol_cast_int(state, amt);
2392
-		s = malloc((iamt->ival + 1)*sizeof(char));
2392
+		s = malloc((iamt->ival + 1) * sizeof(char));
2393 2393
 		count = sol_stream_fread(state, stream, s, sizeof(char), iamt->ival);
2394
-		s[count]='\0';
2394
+		s[count] = '\0';
2395 2395
 		sol_obj_free(iamt);
2396 2396
 	}
2397 2397
 	if(s) {
@@ -2437,7 +2437,7 @@ sol_object_t *sol_f_stream_eof(sol_state_t *state, sol_object_t *args) {
2437 2437
 	return res;
2438 2438
 }
2439 2439
 
2440
-static char *sol_FileModes[]= {
2440
+static char *sol_FileModes[] = {
2441 2441
 	NULL,
2442 2442
 	"r",
2443 2443
 	"w",

+ 6
- 6
cdata.c View File

@@ -140,9 +140,9 @@ sol_object_t *sol_f_cstruct_index(sol_state_t *state, sol_object_t *args) {
140 140
 					res = sol_new_int(state, AT(cstruct->data, uint32_t, spec->offset));
141 141
 					break;
142 142
 
143
-					/*case SOL_MT_UINT64:
144
-					    res = sol_new_int(state, AT(cstruct->data, uint64_t, spec->offset));
145
-					    break;*/
143
+				/*case SOL_MT_UINT64:
144
+				    res = sol_new_int(state, AT(cstruct->data, uint64_t, spec->offset));
145
+				    break;*/
146 146
 
147 147
 				case SOL_MT_FLOAT:
148 148
 					res = sol_new_float(state, AT(cstruct->data, float, spec->offset));
@@ -233,9 +233,9 @@ sol_object_t *sol_f_cstruct_setindex(sol_state_t *state, sol_object_t *args) {
233 233
 					AT(cstruct->data, uint32_t, spec->offset) = sol_cast_int(state, val)->ival;
234 234
 					break;
235 235
 
236
-					/*case SOL_MT_UINT64:
237
-					    AT(cstruct->data, uint64_t, spec->offset) = sol_cast_int(state, val)->ival;
238
-					    break;*/
236
+				/*case SOL_MT_UINT64:
237
+				    AT(cstruct->data, uint64_t, spec->offset) = sol_cast_int(state, val)->ival;
238
+				    break;*/
239 239
 
240 240
 				case SOL_MT_FLOAT:
241 241
 					AT(cstruct->data, float, spec->offset) = sol_cast_float(state, val)->fval;

+ 28
- 28
cdata.h View File

@@ -4,44 +4,44 @@
4 4
 #include "sol.h"
5 5
 
6 6
 typedef enum {
7
-    SOL_MT_INT,
8
-    SOL_MT_INT8,
9
-    SOL_MT_INT16,
10
-    SOL_MT_INT32,
11
-    SOL_MT_INT64,
12
-    SOL_MT_UINT,
13
-    SOL_MT_UINT8,
14
-    SOL_MT_UINT16,
15
-    SOL_MT_UINT32,
7
+	SOL_MT_INT,
8
+	SOL_MT_INT8,
9
+	SOL_MT_INT16,
10
+	SOL_MT_INT32,
11
+	SOL_MT_INT64,
12
+	SOL_MT_UINT,
13
+	SOL_MT_UINT8,
14
+	SOL_MT_UINT16,
15
+	SOL_MT_UINT32,
16 16
 //    SOL_MT_UINT64, TODO: Not yet supported
17
-    SOL_MT_FLOAT,
18
-    SOL_MT_DOUBLE,
19
-    SOL_MT_CHAR,
20
-    SOL_MT_CSTR,
21
-    SOL_MT_CFUNC,
22
-    SOL_MT_PTR // Don't use this in add_member--use add_pointer
17
+	SOL_MT_FLOAT,
18
+	SOL_MT_DOUBLE,
19
+	SOL_MT_CHAR,
20
+	SOL_MT_CSTR,
21
+	SOL_MT_CFUNC,
22
+	SOL_MT_PTR // Don't use this in add_member--use add_pointer
23 23
 } sol_memtype_t;
24 24
 
25 25
 typedef enum {
26
-    SOL_CS_MEMBER,
27
-    SOL_CS_CFUNC
26
+	SOL_CS_MEMBER,
27
+	SOL_CS_CFUNC
28 28
 } sol_spec_t;
29 29
 
30 30
 typedef struct {
31
-    sol_spec_t type;
32
-    union {
33
-        struct {
34
-            sol_memtype_t memtype;
35
-            int offset;
36
-            sol_object_t *specs;
37
-        };
38
-        sol_cfunc_t cfunc;
39
-    };
31
+	sol_spec_t type;
32
+	union {
33
+		struct {
34
+			sol_memtype_t memtype;
35
+			int offset;
36
+			sol_object_t *specs;
37
+		};
38
+		sol_cfunc_t cfunc;
39
+	};
40 40
 } sol_memspec_t;
41 41
 
42 42
 typedef struct {
43
-    void *data;
44
-    sol_object_t *specs;
43
+	void *data;
44
+	sol_object_t *specs;
45 45
 } sol_cstruct_t;
46 46
 
47 47
 sol_object_t *sol_new_cstruct_specs(sol_state_t *);

+ 1013
- 1013
lex.yy.c
File diff suppressed because it is too large
View File


+ 9
- 9
object.c View File

@@ -160,35 +160,35 @@ sol_object_t *sol_list_sublist(sol_state_t *state, sol_object_t *list, int idx)
160 160
 		return sol_set_error_string(state, "Create sublist at negative index");
161 161
 	}
162 162
 	subl = dsl_seq_copy(list->seq);
163
-	for(i=0; i<idx; i++) {
163
+	for(i = 0; i < idx; i++) {
164 164
 		dsl_seq_delete(subl, 0);
165 165
 	}
166 166
 	return sol_list_from_seq(state, subl);
167 167
 }
168 168
 
169 169
 sol_object_t *sol_list_get_index(sol_state_t *state, sol_object_t *list, int idx) {
170
-	if(idx<0 || idx>=dsl_seq_len(list->seq)) {
170
+	if(idx < 0 || idx >= dsl_seq_len(list->seq)) {
171 171
 		return sol_incref(state->None);
172 172
 	}
173 173
 	return sol_incref(AS_OBJ(dsl_seq_get(list->seq, idx)));
174 174
 }
175 175
 
176 176
 void sol_list_set_index(sol_state_t *state, sol_object_t *list, int idx, sol_object_t *obj) {
177
-	if(idx<0 || idx>=dsl_seq_len(list->seq)) {
177
+	if(idx < 0 || idx >= dsl_seq_len(list->seq)) {
178 178
 		return;
179 179
 	}
180 180
 	dsl_seq_set(list->seq, idx, obj);
181 181
 }
182 182
 
183 183
 void sol_list_insert(sol_state_t *state, sol_object_t *list, int idx, sol_object_t *obj) {
184
-	if(idx<0 || idx>dsl_seq_len(list->seq)) {
184
+	if(idx < 0 || idx > dsl_seq_len(list->seq)) {
185 185
 		return;
186 186
 	}
187 187
 	dsl_seq_insert(list->seq, idx, obj);
188 188
 }
189 189
 
190 190
 sol_object_t *sol_list_remove(sol_state_t *state, sol_object_t *list, int idx) {
191
-	if(idx<0 || idx>=dsl_seq_len(list->seq)) {
191
+	if(idx < 0 || idx >= dsl_seq_len(list->seq)) {
192 192
 		return sol_incref(state->None);
193 193
 	}
194 194
 	return dsl_seq_remove(list->seq, idx);
@@ -204,8 +204,8 @@ sol_object_t *sol_list_truncate(sol_state_t *state, sol_object_t *list, int len)
204 204
 	int pos = dsl_seq_iter_seek(iter, len);
205 205
 	int sz = dsl_seq_len(newseq);
206 206
 	int i;
207
-	if(pos>=len) {
208
-		for(i=0; i<sz-pos; i++) {
207
+	if(pos >= len) {
208
+		for(i = 0; i < sz - pos; i++) {
209 209
 			dsl_seq_iter_delete_at(iter);
210 210
 		}
211 211
 	}
@@ -350,7 +350,7 @@ sol_object_t *sol_map_get_name(sol_state_t *state, sol_object_t *map, char *name
350 350
 }
351 351
 
352 352
 void sol_map_set(sol_state_t *state, sol_object_t *map, sol_object_t *key, sol_object_t *val) {
353
-	sol_object_t *mcell =sol_map_mcell(state, map, key), *newcell, *temp;
353
+	sol_object_t *mcell = sol_map_mcell(state, map, key), *newcell, *temp;
354 354
 	if(sol_is_none(state, mcell)) {
355 355
 		newcell = sol_alloc_object(state);
356 356
 		newcell->type = SOL_MCELL;
@@ -373,7 +373,7 @@ void sol_map_set_name(sol_state_t *state, sol_object_t *map, char *name, sol_obj
373 373
 }
374 374
 
375 375
 void sol_map_set_existing(sol_state_t *state, sol_object_t *map, sol_object_t *key, sol_object_t *val) {
376
-	sol_object_t *mcell =sol_map_mcell(state, map, key), *temp;
376
+	sol_object_t *mcell = sol_map_mcell(state, map, key), *temp;
377 377
 	if(!sol_is_none(state, mcell)) {
378 378
 		temp = mcell->val;
379 379
 		mcell->val = sol_incref(val);

+ 68
- 68
parser.tab.c View File

@@ -110,63 +110,63 @@ extern int yydebug;
110 110
 /* Put the tokens into the symbol table, so that GDB and other debuggers
111 111
    know about them.  */
112 112
 enum yytokentype {
113
-    IF = 258,
114
-    THEN = 259,
115
-    ELSE = 260,
116
-    WHILE = 261,
117
-    FOR = 262,
118
-    IN = 263,
119
-    DO = 264,
120
-    FUNC = 265,
121
-    RETURN = 266,
122
-    BREAK = 267,
123
-    CONTINUE = 268,
124
-    END = 269,
125
-    NONE = 270,
126
-    IDENT = 271,
127
-    INT = 272,
128
-    FLOAT = 273,
129
-    STRING = 274,
130
-    PLUS = 275,
131
-    MINUS = 276,
132
-    STAR = 277,
133
-    SLASH = 278,
134
-    PERCENT = 279,
135
-    DSTAR = 280,
136
-    BAND = 281,
137
-    BOR = 282,
138
-    BXOR = 283,
139
-    BNOT = 284,
140
-    LAND = 285,
141
-    LOR = 286,
142
-    LNOT = 287,
143
-    ASSIGN = 288,
144
-    ASSIGNPLUS = 289,
145
-    ASSIGNMINUS = 290,
146
-    ASSIGNSTAR = 291,
147
-    ASSIGNSLASH = 292,
148
-    ASSIGNDSTAR = 293,
149
-    ASSIGNBAND = 294,
150
-    ASSIGNBOR = 295,
151
-    ASSIGNBXOR = 296,
152
-    EQUAL = 297,
153
-    LESS = 298,
154
-    GREATER = 299,
155
-    LESSEQ = 300,
156
-    GREATEREQ = 301,
157
-    RSHIFT = 302,
158
-    LSHIFT = 303,
159
-    LBRACE = 304,
160
-    RBRACE = 305,
161
-    LPAREN = 306,
162
-    RPAREN = 307,
163
-    LBRACKET = 308,
164
-    RBRACKET = 309,
165
-    DOT = 310,
166
-    COLON = 311,
167
-    SEMICOLON = 312,
168
-    COMMA = 313,
169
-    POUND = 314
113
+	IF = 258,
114
+	THEN = 259,
115
+	ELSE = 260,
116
+	WHILE = 261,
117
+	FOR = 262,
118
+	IN = 263,
119
+	DO = 264,
120
+	FUNC = 265,
121
+	RETURN = 266,
122
+	BREAK = 267,
123
+	CONTINUE = 268,
124
+	END = 269,
125
+	NONE = 270,
126
+	IDENT = 271,
127
+	INT = 272,
128
+	FLOAT = 273,
129
+	STRING = 274,
130
+	PLUS = 275,
131
+	MINUS = 276,
132
+	STAR = 277,
133
+	SLASH = 278,
134
+	PERCENT = 279,
135
+	DSTAR = 280,
136
+	BAND = 281,
137
+	BOR = 282,
138
+	BXOR = 283,
139
+	BNOT = 284,
140
+	LAND = 285,
141
+	LOR = 286,
142
+	LNOT = 287,
143
+	ASSIGN = 288,
144
+	ASSIGNPLUS = 289,
145
+	ASSIGNMINUS = 290,
146
+	ASSIGNSTAR = 291,
147
+	ASSIGNSLASH = 292,
148
+	ASSIGNDSTAR = 293,
149
+	ASSIGNBAND = 294,
150
+	ASSIGNBOR = 295,
151
+	ASSIGNBXOR = 296,
152
+	EQUAL = 297,
153
+	LESS = 298,
154
+	GREATER = 299,
155
+	LESSEQ = 300,
156
+	GREATEREQ = 301,
157
+	RSHIFT = 302,
158
+	LSHIFT = 303,
159
+	LBRACE = 304,
160
+	RBRACE = 305,
161
+	LPAREN = 306,
162
+	RPAREN = 307,
163
+	LBRACKET = 308,
164
+	RBRACKET = 309,
165
+	DOT = 310,
166
+	COLON = 311,
167
+	SEMICOLON = 312,
168
+	COMMA = 313,
169
+	POUND = 314
170 170
 };
171 171
 #endif
172 172
 
@@ -965,12 +965,12 @@ __attribute__((__unused__))
965 965
 #if (defined __STDC__ || defined __C99__FUNC__ \
966 966
      || defined __cplusplus || defined _MSC_VER)
967 967
 static unsigned
968
-yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
968
+yy_location_print_ (FILE *yyo, YYLTYPE const *const yylocp)
969 969
 #else
970 970
 static unsigned
971 971
 yy_location_print_ (yyo, yylocp)
972 972
 FILE *yyo;
973
-YYLTYPE const * const yylocp;
973
+YYLTYPE const *const yylocp;
974 974
 #endif
975 975
 {
976 976
 	unsigned res = 0;
@@ -1044,14 +1044,14 @@ do {									  \
1044 1044
 #if (defined __STDC__ || defined __C99__FUNC__ \
1045 1045
      || defined __cplusplus || defined _MSC_VER)
1046 1046
 static void
1047
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, stmt_node **program)
1047
+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const *const yyvaluep, YYLTYPE const *const yylocationp, stmt_node **program)
1048 1048
 #else
1049 1049
 static void
1050 1050
 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, program)
1051 1051
 FILE *yyoutput;
1052 1052
 int yytype;
1053
-YYSTYPE const * const yyvaluep;
1054
-YYLTYPE const * const yylocationp;
1053
+YYSTYPE const *const yyvaluep;
1054
+YYLTYPE const *const yylocationp;
1055 1055
 stmt_node **program;
1056 1056
 #endif
1057 1057
 {
@@ -1080,14 +1080,14 @@ stmt_node **program;
1080 1080
 #if (defined __STDC__ || defined __C99__FUNC__ \
1081 1081
      || defined __cplusplus || defined _MSC_VER)
1082 1082
 static void
1083
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, stmt_node **program)
1083
+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const *const yyvaluep, YYLTYPE const *const yylocationp, stmt_node **program)
1084 1084
 #else
1085 1085
 static void
1086 1086
 yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, program)
1087 1087
 FILE *yyoutput;
1088 1088
 int yytype;
1089
-YYSTYPE const * const yyvaluep;
1090
-YYLTYPE const * const yylocationp;
1089
+YYSTYPE const *const yyvaluep;
1090
+YYLTYPE const *const yylocationp;
1091 1091
 stmt_node **program;
1092 1092
 #endif
1093 1093
 {
@@ -1279,7 +1279,7 @@ yytnamerr (char *yyres, const char *yystr) {
1279 1279
 					if (*++yyp != '\\') {
1280 1280
 						goto do_not_strip_quotes;
1281 1281
 					}
1282
-					/* Fall through.  */
1282
+				/* Fall through.  */
1283 1283
 				default:
1284 1284
 					if (yyres) {
1285 1285
 						yyres[yyn] = *yyp;
@@ -1787,7 +1787,7 @@ yyreduce:
1787 1787
 	   users should not rely upon it.  Assigning to YYVAL
1788 1788
 	   unconditionally makes the parser a bit smaller, and it avoids a
1789 1789
 	   GCC warning that YYVAL may be used uninitialized.  */
1790
-	yyval = yyvsp[1-yylen];
1790
+	yyval = yyvsp[1 - yylen];
1791 1791
 
1792 1792
 	/* Default location.  */
1793 1793
 	YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
@@ -3108,7 +3108,7 @@ yyerrorlab:
3108 3108
 		goto yyerrorlab;
3109 3109
 	}
3110 3110
 
3111
-	yyerror_range[1] = yylsp[1-yylen];
3111
+	yyerror_range[1] = yylsp[1 - yylen];
3112 3112
 	/* Do not reclaim the symbols of the rule which action triggered
3113 3113
 	   this YYERROR.  */
3114 3114
 	YYPOPSTACK (yylen);

+ 71
- 72
parser.tab.h View File

@@ -1,19 +1,19 @@
1 1
 /* A Bison parser, made by GNU Bison 2.7.12-4996.  */
2 2
 
3 3
 /* Bison interface for Yacc-like parsers in C
4
-   
4
+
5 5
       Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
6
-   
6
+
7 7
    This program is free software: you can redistribute it and/or modify
8 8
    it under the terms of the GNU General Public License as published by
9 9
    the Free Software Foundation, either version 3 of the License, or
10 10
    (at your option) any later version.
11
-   
11
+
12 12
    This program is distributed in the hope that it will be useful,
13 13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 15
    GNU General Public License for more details.
16
-   
16
+
17 17
    You should have received a copy of the GNU General Public License
18 18
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19 19
 
@@ -26,7 +26,7 @@
26 26
    special exception, which will cause the skeleton and the resulting
27 27
    Bison output files to be licensed under the GNU General Public
28 28
    License without this special exception.
29
-   
29
+
30 30
    This special exception was added by the Free Software Foundation in
31 31
    version 2.2 of Bison.  */
32 32
 
@@ -43,67 +43,67 @@ extern int yydebug;
43 43
 /* Tokens.  */
44 44
 #ifndef YYTOKENTYPE
45 45
 # define YYTOKENTYPE
46
-   /* Put the tokens into the symbol table, so that GDB and other debuggers
47
-      know about them.  */
48
-   enum yytokentype {
49
-     IF = 258,
50
-     THEN = 259,
51
-     ELSE = 260,
52
-     WHILE = 261,
53
-     FOR = 262,
54
-     IN = 263,
55
-     DO = 264,
56
-     FUNC = 265,
57
-     RETURN = 266,
58
-     BREAK = 267,
59
-     CONTINUE = 268,
60
-     END = 269,
61
-     NONE = 270,
62
-     IDENT = 271,
63
-     INT = 272,
64
-     FLOAT = 273,
65
-     STRING = 274,
66
-     PLUS = 275,
67
-     MINUS = 276,
68
-     STAR = 277,
69
-     SLASH = 278,
70
-     PERCENT = 279,
71
-     DSTAR = 280,
72
-     BAND = 281,
73
-     BOR = 282,
74
-     BXOR = 283,
75
-     BNOT = 284,
76
-     LAND = 285,
77
-     LOR = 286,
78
-     LNOT = 287,
79
-     ASSIGN = 288,
80
-     ASSIGNPLUS = 289,
81
-     ASSIGNMINUS = 290,
82
-     ASSIGNSTAR = 291,
83
-     ASSIGNSLASH = 292,
84
-     ASSIGNDSTAR = 293,
85
-     ASSIGNBAND = 294,
86
-     ASSIGNBOR = 295,
87
-     ASSIGNBXOR = 296,
88
-     EQUAL = 297,
89
-     LESS = 298,
90
-     GREATER = 299,
91
-     LESSEQ = 300,
92
-     GREATEREQ = 301,
93
-     RSHIFT = 302,
94
-     LSHIFT = 303,
95
-     LBRACE = 304,
96
-     RBRACE = 305,
97
-     LPAREN = 306,
98
-     RPAREN = 307,
99
-     LBRACKET = 308,
100
-     RBRACKET = 309,
101
-     DOT = 310,
102
-     COLON = 311,
103
-     SEMICOLON = 312,
104
-     COMMA = 313,
105
-     POUND = 314
106
-   };
46
+/* Put the tokens into the symbol table, so that GDB and other debuggers
47
+   know about them.  */
48
+enum yytokentype {
49
+	IF = 258,
50
+	THEN = 259,
51
+	ELSE = 260,
52
+	WHILE = 261,
53
+	FOR = 262,
54
+	IN = 263,
55
+	DO = 264,
56
+	FUNC = 265,
57
+	RETURN = 266,
58
+	BREAK = 267,
59
+	CONTINUE = 268,
60
+	END = 269,
61
+	NONE = 270,
62
+	IDENT = 271,
63
+	INT = 272,
64
+	FLOAT = 273,
65
+	STRING = 274,
66
+	PLUS = 275,
67
+	MINUS = 276,
68
+	STAR = 277,
69
+	SLASH = 278,
70
+	PERCENT = 279,
71
+	DSTAR = 280,
72
+	BAND = 281,
73
+	BOR = 282,
74
+	BXOR = 283,
75
+	BNOT = 284,
76
+	LAND = 285,
77
+	LOR = 286,
78
+	LNOT = 287,
79
+	ASSIGN = 288,
80
+	ASSIGNPLUS = 289,
81
+	ASSIGNMINUS = 290,
82
+	ASSIGNSTAR = 291,
83
+	ASSIGNSLASH = 292,
84
+	ASSIGNDSTAR = 293,
85
+	ASSIGNBAND = 294,
86
+	ASSIGNBOR = 295,
87
+	ASSIGNBXOR = 296,
88
+	EQUAL = 297,
89
+	LESS = 298,
90
+	GREATER = 299,
91
+	LESSEQ = 300,
92
+	GREATEREQ = 301,
93
+	RSHIFT = 302,
94
+	LSHIFT = 303,
95
+	LBRACE = 304,
96
+	RBRACE = 305,
97
+	LPAREN = 306,
98
+	RPAREN = 307,
99
+	LBRACKET = 308,
100
+	RBRACKET = 309,
101
+	DOT = 310,
102
+	COLON = 311,
103
+	SEMICOLON = 312,
104
+	COMMA = 313,
105
+	POUND = 314
106
+};
107 107
 #endif
108 108
 
109 109
 
@@ -115,12 +115,11 @@ typedef int YYSTYPE;
115 115
 #endif
116 116
 
117 117
 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
118
-typedef struct YYLTYPE
119
-{
120
-  int first_line;
121
-  int first_column;
122
-  int last_line;
123
-  int last_column;
118
+typedef struct YYLTYPE {
119
+	int first_line;
120
+	int first_column;
121
+	int last_line;
122
+	int last_column;
124 123
 } YYLTYPE;
125 124
 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
126 125
 # define YYLTYPE_IS_DECLARED 1

+ 7
- 7
runtime.c View File

@@ -303,23 +303,23 @@ sol_object_t *sol_eval_inner(sol_state_t *state, expr_node *expr, jmp_buf jmp) {
303 303
 					break;
304 304
 
305 305
 				case OP_EQUAL:
306
-					res = sol_new_int(state, BOOL_TO_INT(sol_cast_int(state, left->ops->cmp(state, list))->ival==0));
306
+					res = sol_new_int(state, BOOL_TO_INT(sol_cast_int(state, left->ops->cmp(state, list))->ival == 0));
307 307
 					break;
308 308
 
309 309
 				case OP_LESS:
310
-					res = sol_new_int(state, BOOL_TO_INT(sol_cast_int(state, left->ops->cmp(state, list))->ival<0));
310
+					res = sol_new_int(state, BOOL_TO_INT(sol_cast_int(state, left->ops->cmp(state, list))->ival < 0));
311 311
 					break;
312 312
 
313 313
 				case OP_GREATER:
314
-					res = sol_new_int(state, BOOL_TO_INT(sol_cast_int(state, left->ops->cmp(state, list))->ival>0));
314
+					res = sol_new_int(state, BOOL_TO_INT(sol_cast_int(state, left->ops->cmp(state, list))->ival > 0));
315 315
 					break;
316 316
 
317 317
 				case OP_LESSEQ:
318
-					res = sol_new_int(state, BOOL_TO_INT(sol_cast_int(state, left->ops->cmp(state, list))->ival<=0));
318
+					res = sol_new_int(state, BOOL_TO_INT(sol_cast_int(state, left->ops->cmp(state, list))->ival <= 0));
319 319
 					break;
320 320
 
321 321
 				case OP_GREATEREQ:
322
-					res = sol_new_int(state, BOOL_TO_INT(sol_cast_int(state, left->ops->cmp(state, list))->ival>=0));
322
+					res = sol_new_int(state, BOOL_TO_INT(sol_cast_int(state, left->ops->cmp(state, list))->ival >= 0));
323 323
 					break;
324 324
 
325 325
 				case OP_LSHIFT:
@@ -533,7 +533,7 @@ void sol_exec(sol_state_t *state, stmt_node *stmt) {
533 533
 			} else {
534 534
 				iter = value;
535 535
 			}
536
-			if(!iter->ops->call || iter->ops->call==sol_f_not_impl) {
536
+			if(!iter->ops->call || iter->ops->call == sol_f_not_impl) {
537 537
 				sol_obj_free(sol_set_error_string(state, "Iterate over non-iterable"));
538 538
 				return;
539 539
 			}
@@ -656,7 +656,7 @@ sol_object_t *sol_new_func(sol_state_t *state, identlist_node *identlist, stmt_n
656 656
 	sol_object_t *obj = sol_alloc_object(state);
657 657
 	obj->func = body;
658 658
 	obj->args = identlist;
659
-	obj->fname = (name?strdup(name):NULL);
659
+	obj->fname = (name ? strdup(name) : NULL);
660 660
 	obj->closure = sol_new_map(state);
661 661
 	obj->udata = sol_new_map(state);
662 662
 	obj->type = SOL_FUNCTION;

+ 1
- 1
sol.h View File

@@ -360,7 +360,7 @@ sol_object_t *sol_f_buffer_fromstring(sol_state_t *, sol_object_t *);
360 360
 sol_object_t *sol_f_buffer_fromobject(sol_state_t *, sol_object_t *);
361 361
 sol_object_t *sol_f_buffer_fromaddress(sol_state_t *, sol_object_t *);
362 362
 
363
-sol_object_t *sol_f_dylib_index(sol_state_t *, sol_object_t *); 
363
+sol_object_t *sol_f_dylib_index(sol_state_t *, sol_object_t *);
364 364
 sol_object_t *sol_f_dylib_tostring(sol_state_t *, sol_object_t *);
365 365
 
366 366
 sol_object_t *sol_f_dylib_open(sol_state_t *, sol_object_t *);

+ 3
- 3
solrun.c View File

@@ -9,7 +9,7 @@ int main(int argc, char **argv) {
9 9
 	int printtree = 0;
10 10
 	FILE *prgstream = stdin;
11 11
 
12
-	if(argc>1) {
12
+	if(argc > 1) {
13 13
 		c = argv[1];
14 14
 		while(*c) {
15 15
 			switch(*c) {
@@ -22,7 +22,7 @@ int main(int argc, char **argv) {
22 22
 					break;
23 23
 
24 24
 				case 'r':
25
-					if(argc<2) {
25
+					if(argc < 2) {
26 26
 						printf("r option requires file\n");
27 27
 						return 1;
28 28
 					}
@@ -39,7 +39,7 @@ int main(int argc, char **argv) {
39 39
 
40 40
 	program = sol_compile_file(prgstream);
41 41
 
42
-	if(prgstream!=stdin) {
42
+	if(prgstream != stdin) {
43 43
 		fclose(prgstream);
44 44
 	}
45 45
 

+ 3
- 3
state.c View File

@@ -467,14 +467,14 @@ void sol_state_assign(sol_state_t *state, sol_object_t *key, sol_object_t *val)
467 467
 		return;
468 468
 	}
469 469
 
470
-	active = sol_list_get_index(state, state->scopes, sol_list_len(state, state->scopes)-1);
470
+	active = sol_list_get_index(state, state->scopes, sol_list_len(state, state->scopes) - 1);
471 471
 
472 472
 	if(!active || sol_is_none(state, cur)) {
473 473
 		sol_set_error_string(state, "No scopes exist");
474 474
 		return;
475 475
 	}
476 476
 
477
-	args=sol_new_list(state);
477
+	args = sol_new_list(state);
478 478
 	sol_list_insert(state, args, 0, active);
479 479
 	sol_list_insert(state, args, 1, key);
480 480
 	sol_list_insert(state, args, 2, val);
@@ -503,7 +503,7 @@ void sol_state_assign_l(sol_state_t *state, sol_object_t *key, sol_object_t *val
503 503
 		return;
504 504
 	}
505 505
 
506
-	args=sol_new_list(state);
506
+	args = sol_new_list(state);
507 507
 	sol_list_insert(state, args, 0, cur);
508 508
 	sol_list_insert(state, args, 1, key);
509 509
 	sol_list_insert(state, args, 2, val);

+ 2
- 2
util.c View File

@@ -17,8 +17,8 @@ sol_object_t *sol_util_call(sol_state_t *state, sol_object_t *func, int *error,
17 17
 	sol_list_insert(state, args, 0, func);
18 18
 
19 19
 	va_start(va, elems);
20
-	for(i=0; i<elems; i++) {
21
-		sol_list_insert(state, args, i+1, va_arg(va, sol_object_t *));
20
+	for(i = 0; i < elems; i++) {
21
+		sol_list_insert(state, args, i + 1, va_arg(va, sol_object_t *));
22 22
 	}
23 23
 	va_end(va);
24 24
 

Loading…
Cancel
Save