diff options
Diffstat (limited to 'src/core/convert.c')
| -rw-r--r-- | src/core/convert.c | 65 |
1 files changed, 17 insertions, 48 deletions
diff --git a/src/core/convert.c b/src/core/convert.c index cf8987e..73fb8a2 100644 --- a/src/core/convert.c +++ b/src/core/convert.c @@ -1,14 +1,13 @@ /*:* *: File: ./src/core/convert.c *: A simple interpreter - *: - *: WWW : http://fype.buetow.org - *: AUTHOR : http://paul.buetow.org - *: E-Mail : fype at dev.buetow.org - *: - *: Copyright (c) 2005 - 2009, Dipl.-Inform. (FH) Paul C. Buetow + *: + *: WWW : http://fype.buetow.org + *: E-Mail : fype@dev.buetow.org + *: + *: Copyright (c) 2005 2006 2007 2008, Dipl.-Inf. (FH) Paul C. Buetow *: All rights reserved. - *: + *: *: Redistribution and use in source and binary forms, with or without modi- *: fication, are permitted provided that the following conditions are met: *: * Redistributions of source code must retain the above copyright @@ -16,25 +15,24 @@ *: * Redistributions in binary form must reproduce the above copyright *: notice, this list of conditions and the following disclaimer in the *: documentation and/or other materials provided with the distribution. - *: * Neither the name of buetow.org nor the names of its contributors may - *: be used to endorse or promote products derived from this software + *: * Neither the name of P. B. Labs nor the names of its contributors may + *: be used to endorse or promote products derived from this software *: without specific prior written permission. - *: - *: THIS SOFTWARE IS PROVIDED BY PAUL C. BUETOW AS IS'' AND ANY EXPRESS OR - *: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + *: + *: THIS SOFTWARE IS PROVIDED BY Paul Buetow AS IS'' AND ANY EXPRESS OR + *: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED *: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - *: DISCLAIMED. IN NO EVENT SHALL PAUL C. BUETOW BE LIABLE FOR ANY DIRECT, - *: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - *: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - *: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + *: DISCLAIMED. IN NO EVENT SHALL Paul Buetow BE LIABLE FOR ANY DIRECT, + *: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + *: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + *: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - *: STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - *: IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + *: STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + *: IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *: POSSIBILITY OF SUCH DAMAGE. *:*/ #include "convert.h" -#include "../data/array.h" void convert_to_integer(Token *p_token) { @@ -49,10 +47,6 @@ 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; @@ -68,9 +62,6 @@ convert_to_integer_get(Token *p_token) { return ((int) token_get_dval(p_token)); case TT_STRING: return (atoi(token_get_val(p_token))); - case TT_ARRAY: - return (array_get_size(p_token->p_array)); - break; default: ERROR("Ouups(%s)", tt_get_name(token_get_tt(p_token))); } @@ -91,10 +82,6 @@ convert_to_double(Token *p_token) { token_set_tt(p_token, TT_DOUBLE); token_set_dval(p_token, atof(token_get_val(p_token))); break; - case TT_ARRAY: - token_set_tt(p_token, TT_DOUBLE); - token_set_dval(p_token, array_get_size(p_token->p_array)); - break; default: token_print_val(p_token); ERROR("Datatype conversion error '%s'", token_get_val(p_token)); @@ -126,16 +113,6 @@ convert_to_string(Token *p_token) { strcpy(p_token->c_val, c_tmp); p_token->c_val[i_len] = 0; } - case TT_ARRAY: - { - token_set_tt(p_token, TT_STRING); - char c_tmp[1024]; - sprintf(c_tmp, "%d", array_get_size(p_token->p_array)); - int i_len = strlen(c_tmp); - p_token->c_val = realloc(p_token->c_val, sizeof(char) * (i_len + 1)); - strcpy(p_token->c_val, c_tmp); - p_token->c_val[i_len] = 0; - } break; case TT_STRING: break; @@ -146,11 +123,6 @@ convert_to_string(Token *p_token) { } void -convert_to_array(Token *p_token) { - ERROR("not yet implemented"); -} - -void convert_to_tt(Token *p_token, TokenType tt) { switch (tt) { case TT_INTEGER: @@ -162,9 +134,6 @@ convert_to_tt(Token *p_token, TokenType tt) { case TT_STRING: convert_to_string(p_token); break; - case TT_ARRAY: - convert_to_array(p_token); - break; default: ERROR("Ouups!"); } |
