summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-11-04 21:20:56 +0000
committerPaul Buetow <paul@buetow.org>2008-11-04 21:20:56 +0000
commitff0828f06a1f317681c45402feda48bde592a076 (patch)
tree7c94275d5ab8b140cd41659d567c09bdc7ca9f16 /src/core
parent48cf82bfc6cd65cc95f7658582fc532602a85ac0 (diff)
array_new_size
array_new_copy implemented
Diffstat (limited to 'src/core')
-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
5 files changed, 25 insertions, 8 deletions
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);
}