summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/help.txt2
-rw-r--r--docs/stats.txt2
-rw-r--r--docs/version.txt2
-rwxr-xr-xfypebin448574 -> 449199 bytes
-rw-r--r--src/build.h2
-rw-r--r--src/core/convert.c5
-rw-r--r--src/core/interpret.c11
-rw-r--r--src/core/symbol.c8
-rw-r--r--src/core/symbol.h2
-rw-r--r--src/core/token.c7
-rw-r--r--src/data/array.c23
-rw-r--r--src/data/array.h2
-rw-r--r--tags3
-rw-r--r--tmp/test.fy8
-rw-r--r--tmp/test.out28
15 files changed, 71 insertions, 34 deletions
diff --git a/docs/help.txt b/docs/help.txt
index 687d983..54bb8cb 100644
--- a/docs/help.txt
+++ b/docs/help.txt
@@ -1,4 +1,4 @@
-Fype v0.1-devel Build 9323
+Fype v0.1-devel Build 9328
(c) Paul C. Buetow (2005 - 2008) <fype@dev.buetow.org>
-e Executes given code string (see synopses)
-h Prints this help
diff --git a/docs/stats.txt b/docs/stats.txt
index e0195c6..ba901aa 100644
--- a/docs/stats.txt
+++ b/docs/stats.txt
@@ -1,4 +1,4 @@
===> Num of C source files : 44
-===> Num of C source lines : 7832
+===> Num of C source lines : 7874
===> Num of Fype source examples : 14
===> Num of Fype source lines : 362
diff --git a/docs/version.txt b/docs/version.txt
index e24a456..8457f26 100644
--- a/docs/version.txt
+++ b/docs/version.txt
@@ -1 +1 @@
-Fype v0.1-devel Build 9323
+Fype v0.1-devel Build 9328
diff --git a/fype b/fype
index 0ac468b..0039bf7 100755
--- a/fype
+++ b/fype
Binary files differ
diff --git a/src/build.h b/src/build.h
index e185370..9b4930d 100644
--- a/src/build.h
+++ b/src/build.h
@@ -35,7 +35,7 @@
#ifndef BUILD_H
#define BUILD_H
-#define BUILDNR 9325
+#define BUILDNR 9335
#define OS_FREEBSD
#endif
diff --git a/src/core/convert.c b/src/core/convert.c
index a5f910d..aac54d1 100644
--- a/src/core/convert.c
+++ b/src/core/convert.c
@@ -33,6 +33,7 @@
*:*/
#include "convert.h"
+#include "../data/array.h"
void
convert_to_integer(Token *p_token) {
@@ -47,6 +48,10 @@ convert_to_integer(Token *p_token) {
token_set_tt(p_token, TT_INTEGER);
token_set_ival(p_token, atoi(token_get_val(p_token)));
break;
+ case TT_ARRAY:
+ token_set_tt(p_token, TT_INTEGER);
+ token_set_ival(p_token, array_get_size(p_token->p_array));
+ break;
default:
ERROR("Ouups(%s)", tt_get_name(token_get_tt(p_token)));
break;
diff --git a/src/core/interpret.c b/src/core/interpret.c
index d2956e2..aced534 100644
--- a/src/core/interpret.c
+++ b/src/core/interpret.c
@@ -948,7 +948,8 @@ _term(Interpret *p_interpret) {
}
break;
- /* Reference operator */
+ /*
+ // Reference operator
case TT_AAND:
{
_NEXT
@@ -956,7 +957,9 @@ _term(Interpret *p_interpret) {
_INTERPRET_ERROR("Expexted identifier for '&'",
p_interpret->p_token);
-
+ char *c_name = token_get_val(p_interpret->p_token);
+ Symbol *p_symbol = scope_get(p_interpret->p_scope, c_name);
+
_INTERPRET_ERROR("nyi", p_interpret->p_token);
_NEXT;
@@ -964,7 +967,7 @@ _term(Interpret *p_interpret) {
}
break;
- /* Dereference opeator */
+ // Dereference opeator
case TT_MULT:
{
_NEXT
@@ -972,11 +975,13 @@ _term(Interpret *p_interpret) {
_INTERPRET_ERROR("Expexted identifier for '*'",
p_interpret->p_token);
+
_INTERPRET_ERROR("nyi", p_interpret->p_token);
_NEXT;
return (1);
}
break;
+ */
/*
case TT_PARANT_AL:
diff --git a/src/core/symbol.c b/src/core/symbol.c
index b9a8b24..19801a7 100644
--- a/src/core/symbol.c
+++ b/src/core/symbol.c
@@ -57,6 +57,8 @@ symbol_delete(Symbol *p_symbol) {
List *p_list_token = symbol_get_val(p_symbol);
list_delete(p_list_token);
}
+ case SYM_ARRAY:
+ symbol_delete(symbol_get_val(p_symbol));
break;
NO_DEFAULT;
}
@@ -81,7 +83,7 @@ symbol_print(Symbol *p_symbol, char *c_key) {
case SYM_FUNCTION:
//list_iterate(symbol_get_val(p_symbol), token_print_cb);
break;
- case SYM_REFERENCE:
+ case SYM_ARRAY:
break;
case SYM_VARIABLE:
printf(" ");
@@ -102,8 +104,8 @@ sym_get_name(SymbolType sym) {
switch (sym) {
case SYM_CONSTANT:
return ("SYM_CONSTANT");
- case SYM_REFERENCE:
- return ("SYM_REFERENCE");
+ case SYM_ARRAY:
+ return ("SYM_ARRAY");
case SYM_VARIABLE:
return ("SYM_VARIABLE");
case SYM_BUILDIN:
diff --git a/src/core/symbol.h b/src/core/symbol.h
index 4c498f2..49a8d99 100644
--- a/src/core/symbol.h
+++ b/src/core/symbol.h
@@ -50,7 +50,7 @@ typedef enum {
SYM_CONSTANT,
SYM_FUNCTION,
SYM_PROCEDURE,
- SYM_REFERENCE,
+ SYM_ARRAY,
SYM_VARIABLE,
} SymbolType;
diff --git a/src/core/token.c b/src/core/token.c
index 9d56736..ee2a0b8 100644
--- a/src/core/token.c
+++ b/src/core/token.c
@@ -317,6 +317,9 @@ void token_copy_vals(Token *p_token_to, Token *p_token_from) {
p_token_to->i_line_nr = p_token_from->i_line_nr;
p_token_to->i_pos_nr = p_token_from->i_pos_nr;
p_token_to->c_filename = p_token_from->c_filename;
+
+ if (NULL != p_token_from->p_array)
+ p_token_to->p_array = array_new_copy(p_token_from);
}
void
@@ -346,8 +349,10 @@ token_delete(Token *p_token) {
if (p_token->c_val)
free(p_token->c_val);
- if (p_token->p_array)
+ if (NULL != p_token->p_array) {
+ array_iterate(p_token->p_array, token_delete_cb);
array_delete(p_token->p_array);
+ }
free(p_token);
}
diff --git a/src/data/array.c b/src/data/array.c
index 09022ff..6a2b1fa 100644
--- a/src/data/array.c
+++ b/src/data/array.c
@@ -44,6 +44,29 @@ array_new() {
return (p_array);
}
+Array*
+array_new_size(int i_size) {
+ Array *p_array = malloc(sizeof(Array));
+
+ p_array->i_size = 0;
+ p_array->pp_ae = NULL;
+ array_resize(p_array, i_size);
+
+ return (p_array);
+}
+
+void
+_array_new_copy_cb(void *p_array, void *p_void) {
+ array_unshift(p_array, p_void);
+}
+
+Array*
+array_new_copy(Array *p_array) {
+ Array *p_array_cpy = array_new_size(array_get_size(p_array));
+ array_iterate2(p_array, _array_new_copy_cb, p_array_cpy);
+
+ return (p_array_cpy);
+}
void
array_delete(Array *p_array) {
diff --git a/src/data/array.h b/src/data/array.h
index f89c0ff..75f6365 100644
--- a/src/data/array.h
+++ b/src/data/array.h
@@ -61,6 +61,8 @@ typedef struct {
} ArrayIterator;
Array *array_new();
+Array *array_new_size(int i_size);
+Array *array_new_copy(Array *p_array);
void array_delete(Array *p_array);
void array_set(Array *p_array, int i_index, void *p_val);
void array_insert(Array *p_array, int i_index, void *p_val);
diff --git a/tags b/tags
index ff2fa1b..86ed559 100644
--- a/tags
+++ b/tags
@@ -6,6 +6,7 @@ _GARBAGE_ERROR ./src/core/garbage.c /^#define _GARBAGE_ERROR(m) \\$/
_Garbage ./src/core/garbage.c /^} _Garbage;$/
_INTERPRET_ERROR ./src/core/interpret.c /^#define _INTERPRET_ERROR(m,t) \\$/
_add_semicolon_to_list ./src/core/scanner.c /^_add_semicolon_to_list(Scanner *p_scanner) {$/
+_array_new_copy_cb ./src/data/array.c /^_array_new_copy_cb(void *p_array, void *p_void) {$/
_block ./src/core/interpret.c /^_block(Interpret *p_interpret) {$/
_block_get ./src/core/interpret.c /^_block_get(Interpret *p_interpret, List *p_list_bl/
_block_skip ./src/core/interpret.c /^_block_skip(Interpret *p_interpret) {$/
@@ -54,6 +55,8 @@ array_insert ./src/data/array.c /^array_insert(Array *p_array, int i_index, void
array_iterate ./src/data/array.c /^array_iterate(Array *p_array, void (*func)(void *)/
array_iterate2 ./src/data/array.c /^array_iterate2(Array *p_array, void (*func)(void */
array_new ./src/data/array.c /^array_new() {$/
+array_new_copy ./src/data/array.c /^array_new_copy(Array *p_array) {$/
+array_new_size ./src/data/array.c /^array_new_size(int i_size) {$/
array_print_int ./src/data/array.c /^array_print_int(Array *p_array) {$/
array_push ./src/data/array.c /^array_push(Array *p_array, void *p_void) {$/
array_remove ./src/data/array.c /^array_remove(Array *p_array, int i_index) {$/
diff --git a/tmp/test.fy b/tmp/test.fy
index 609f0c2..8fe78a1 100644
--- a/tmp/test.fy
+++ b/tmp/test.fy
@@ -1,8 +1,6 @@
#*
- * Examples of how to use references
+ * Examples of how to use arrays
*#
-# Create a variable foo, and bar is a reference to foo
-my foo = "foo";
-my bar = &foo;
-
+my foo = 1, bar = 2;
+my arr = [foo bar];
diff --git a/tmp/test.out b/tmp/test.out
index eae02b0..79fda72 100644
--- a/tmp/test.out
+++ b/tmp/test.out
@@ -1,20 +1,14 @@
#*
- * Examples of how to use references
+ * Examples of how to use arrays
*#
-# Create a variable foo, and bar is a reference to foo
-my foo = "foo";
-my bar = &foo;
-
-Token (id=00000, line=00006, pos=0003, type=TT_MY, val=my, ival=0, dval=0.000000, refs=1)
-Token (id=00001, line=00006, pos=0007, type=TT_IDENT, val=foo, ival=0, dval=0.000000, refs=1)
-Token (id=00002, line=00006, pos=0009, type=TT_ASSIGN, val==, ival=0, dval=0.000000, refs=1)
-Token (id=00003, line=00006, pos=0010, type=TT_STRING, val=foo, ival=0, dval=0.000000, refs=1)
-Token (id=00004, line=00006, pos=0012, type=TT_SEMICOLON, val=;, ival=0, dval=0.000000, refs=1)
-Token (id=00005, line=00007, pos=0003, type=TT_MY, val=my, ival=0, dval=0.000000, refs=1)
-Token (id=00006, line=00007, pos=0007, type=TT_IDENT, val=bar, ival=0, dval=0.000000, refs=1)
-Token (id=00007, line=00007, pos=0009, type=TT_ASSIGN, val==, ival=0, dval=0.000000, refs=1)
-Token (id=00008, line=00007, pos=0011, type=TT_AAND, val=&, ival=0, dval=0.000000, refs=1)
-Token (id=00009, line=00007, pos=0014, type=TT_IDENT, val=foo, ival=0, dval=0.000000, refs=1)
-Token (id=00010, line=00007, pos=0015, type=TT_SEMICOLON, val=;, ival=0, dval=0.000000, refs=1)
-nyi: Interpret error in ./tmp/test.fy line 7 pos 14 near 'foo' (Fype @ ./src/core/interpret.c line 960)
+my foo = 1, bar = 2;
+Token (id=00000, line=00005, pos=0003, type=TT_MY, val=my, ival=0, dval=0.000000, refs=1)
+Token (id=00001, line=00005, pos=0007, type=TT_IDENT, val=foo, ival=0, dval=0.000000, refs=1)
+Token (id=00002, line=00005, pos=0009, type=TT_ASSIGN, val==, ival=0, dval=0.000000, refs=1)
+Token (id=00003, line=00005, pos=0011, type=TT_INTEGER, val=1, ival=1, dval=0.000000, refs=1)
+Token (id=00004, line=00005, pos=0012, type=TT_COMMA, val=,, ival=0, dval=0.000000, refs=1)
+Token (id=00005, line=00005, pos=0016, type=TT_IDENT, val=bar, ival=0, dval=0.000000, refs=1)
+Token (id=00006, line=00005, pos=0018, type=TT_ASSIGN, val==, ival=0, dval=0.000000, refs=1)
+Token (id=00007, line=00005, pos=0020, type=TT_INTEGER, val=2, ival=2, dval=0.000000, refs=1)
+Token (id=00008, line=00005, pos=0021, type=TT_SEMICOLON, val=;, ival=0, dval=0.000000, refs=1)