summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-08-24 19:30:11 +0000
committerPaul Buetow <paul@buetow.org>2008-08-24 19:30:11 +0000
commit7f3055c1f4429a81de3715d5d4173353382e2de2 (patch)
treeb90ec08f692d6216ddb7673525a512c3c31fc6e1 /src/core
parente95e69c55c8e38c39e7ded141272e5e793d05623 (diff)
some mods
Diffstat (limited to 'src/core')
-rw-r--r--src/core/convert.c30
-rw-r--r--src/core/convert.h30
-rw-r--r--src/core/function.c166
-rw-r--r--src/core/function.h34
-rw-r--r--src/core/garbage.c30
-rw-r--r--src/core/garbage.h30
-rw-r--r--src/core/interpret.c72
-rw-r--r--src/core/interpret.h30
-rw-r--r--src/core/scanner.c89
-rw-r--r--src/core/scanner.h31
-rw-r--r--src/core/scope.c30
-rw-r--r--src/core/scope.h30
-rw-r--r--src/core/symbol.c30
-rw-r--r--src/core/symbol.h30
-rw-r--r--src/core/token.c30
-rw-r--r--src/core/token.h30
16 files changed, 384 insertions, 338 deletions
diff --git a/src/core/convert.c b/src/core/convert.c
index af36c34..73fb8a2 100644
--- a/src/core/convert.c
+++ b/src/core/convert.c
@@ -1,13 +1,13 @@
/*:*
*: File: ./src/core/convert.c
*: A simple interpreter
- *:
+ *:
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
- *:
- *: Copyright (c) 2005 2006 2007 2008, Dipl.-Inf. (FH) Paul C. Buetow
+ *:
+ *: 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
@@ -15,20 +15,20 @@
*: * 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 P. B. Labs 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 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 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.
*:*/
diff --git a/src/core/convert.h b/src/core/convert.h
index e38f0e6..0c8b7da 100644
--- a/src/core/convert.h
+++ b/src/core/convert.h
@@ -1,13 +1,13 @@
/*:*
*: File: ./src/core/convert.h
*: A simple interpreter
- *:
+ *:
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
- *:
- *: Copyright (c) 2005 2006 2007 2008, Dipl.-Inf. (FH) Paul C. Buetow
+ *:
+ *: 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
@@ -15,20 +15,20 @@
*: * 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 P. B. Labs 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 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 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.
*:*/
diff --git a/src/core/function.c b/src/core/function.c
index 7912cf7..06e89bb 100644
--- a/src/core/function.c
+++ b/src/core/function.c
@@ -1,13 +1,13 @@
/*:*
*: File: ./src/core/function.c
*: A simple interpreter
- *:
+ *:
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
- *:
- *: Copyright (c) 2005 2006 2007 2008, Dipl.-Inf. (FH) Paul C. Buetow
+ *:
+ *: 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
@@ -15,20 +15,20 @@
*: * 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 P. B. Labs 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 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 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.
*:*/
@@ -53,12 +53,19 @@
void
_process(Interpret *p_interpret, Token *p_token_store, Token *p_token_op,
- Token *p_token_next) {
+ Token *p_token_op2, Token *p_token_next) {
TokenType tt_op = token_get_tt(p_token_op);
+ TokenType tt_op2 = p_token_op2 == NULL
+ ? TT_NONE
+ : token_get_tt(p_token_op2);
#ifdef DEBUG_FUNCTION_PROCESS
- printf("PROCESS OPERATOR %s\n", tt_get_name(tt_op));
+ if (p_token_op2 == NULL)
+ printf("PROCESS OPERATOR %s\n", tt_get_name(tt_op));
+ else
+ printf("PROCESS OPERATOR %s %s\n", tt_get_name(tt_op),
+ tt_get_name(tt_op2));
token_print(p_token_next);
printf("\n");
@@ -66,34 +73,79 @@ _process(Interpret *p_interpret, Token *p_token_store, Token *p_token_op,
printf("\n");
#endif /* DEBUG_FUNCTION_PROCESS */
+ if (p_token_op2 != NULL) {
+#ifdef DEBUG_FUNCTION_PROCESS
+ printf("===> %s %s %s %s\n",
+ tt_get_name(tt_highest),
+ tt_get_name(tt_op),
+ tt_get_name(tt_op2),
+ tt_get_name(tt_highest));
+#endif /* DEBUG_FUNCTION_PROCESS */
- switch (tt_op) {
- case TT_ASSIGN:
- {
- Token *p_token_assign = p_interpret->p_token_temp;
- TokenType tt_assign = token_get_tt(p_token_assign);
-
- if (tt_assign != TT_IDENT) {
- _FUNCTION_ERROR("Can only assign to symbols",
- p_token_store);
+ switch (tt_op) {
+ case TT_NOT:
+ switch (tt_op2) {
+ case TT_ASSIGN:
+ tt_op = TT_NEQ;
+ default:
+ break;
+ }
+ case TT_ASSIGN:
+ switch (tt_op2) {
+ case TT_ASSIGN:
+ tt_op = TT_EQ;
+ break;
+ default:
+ break;
+ }
+ case TT_LT:
+ switch (tt_op2) {
+ case TT_ASSIGN:
+ tt_op = TT_LE;
+ break;
+ default:
+ break;
+ }
+ case TT_GT:
+ switch (tt_op2) {
+ case TT_ASSIGN:
+ tt_op = TT_GE;
+ break;
+ default:
+ break;
+ }
+ default:
+ break;
}
+ } else {
+ switch (tt_op) {
+ case TT_ASSIGN:
+ {
+ Token *p_token_assign = p_interpret->p_token_temp;
+ TokenType tt_assign = token_get_tt(p_token_assign);
+
+ if (tt_assign != TT_IDENT) {
+ _FUNCTION_ERROR("Can only assign to symbols",
+ p_token_store);
+ }
- Symbol *p_symbol = scope_get(p_interpret->p_scope,
- token_get_val(p_token_assign));
+ Symbol *p_symbol = scope_get(p_interpret->p_scope,
+ token_get_val(p_token_assign));
- if (p_symbol == NULL) {
- _FUNCTION_ERROR("No such symbol",
- p_token_assign);
- }
+ if (p_symbol == NULL) {
+ _FUNCTION_ERROR("No such symbol",
+ p_token_assign);
+ }
- symbol_set_val(p_symbol, p_token_store);
- symbol_set_sym(p_symbol, SYM_VARIABLE);
+ symbol_set_val(p_symbol, p_token_store);
+ symbol_set_sym(p_symbol, SYM_VARIABLE);
- return;
- }
+ return;
+ }
- break;
- NO_DEFAULT;
+ break;
+ NO_DEFAULT;
+ }
}
p_token_next = token_new_copy(p_token_next);
@@ -234,89 +286,90 @@ _process(Interpret *p_interpret, Token *p_token_store, Token *p_token_op,
NO_DEFAULT;
}
break;
- case TT_LT:
+ case TT_LE:
+ printf("DFDF\n");
switch (tt_highest) {
case TT_INTEGER:
token_set_ival(p_token_store,
- (int) token_get_ival(p_token_next) <
+ (int) token_get_ival(p_token_next) <=
token_get_ival(p_token_store));
break;
case TT_DOUBLE:
token_set_ival(p_token_store,
- token_get_dval(p_token_next) <
+ token_get_dval(p_token_next) <=
token_get_dval(p_token_store));
token_set_tt(p_token_store, TT_INTEGER);
break;
case TT_STRING:
token_set_ival(p_token_store,
strcmp(token_get_val(p_token_next),
- token_get_val(p_token_store)) < 0);
+ token_get_val(p_token_store)) <= 0);
token_set_tt(p_token_store, TT_INTEGER);
break;
NO_DEFAULT;
}
break;
- case TT_GT:
+ case TT_GE:
switch (tt_highest) {
case TT_INTEGER:
token_set_ival(p_token_store,
- (int) token_get_ival(p_token_next) >
+ (int) token_get_ival(p_token_next) >=
token_get_ival(p_token_store));
break;
case TT_DOUBLE:
token_set_ival(p_token_store,
- token_get_dval(p_token_next) >
+ token_get_dval(p_token_next) >=
token_get_dval(p_token_store));
token_set_tt(p_token_store, TT_INTEGER);
break;
case TT_STRING:
token_set_ival(p_token_store,
strcmp(token_get_val(p_token_next),
- token_get_val(p_token_store)) > 0);
+ token_get_val(p_token_store)) >= 0);
token_set_tt(p_token_store, TT_INTEGER);
break;
NO_DEFAULT;
}
break;
- case TT_LE:
+ case TT_LT:
switch (tt_highest) {
case TT_INTEGER:
token_set_ival(p_token_store,
- (int) token_get_ival(p_token_next) <=
+ (int) token_get_ival(p_token_next) <
token_get_ival(p_token_store));
break;
case TT_DOUBLE:
token_set_ival(p_token_store,
- token_get_dval(p_token_next) <=
+ token_get_dval(p_token_next) <
token_get_dval(p_token_store));
token_set_tt(p_token_store, TT_INTEGER);
break;
case TT_STRING:
token_set_ival(p_token_store,
strcmp(token_get_val(p_token_next),
- token_get_val(p_token_store)) <= 0);
+ token_get_val(p_token_store)) < 0);
token_set_tt(p_token_store, TT_INTEGER);
break;
NO_DEFAULT;
}
break;
- case TT_GE:
+ case TT_GT:
switch (tt_highest) {
case TT_INTEGER:
token_set_ival(p_token_store,
- (int) token_get_ival(p_token_next) >=
+ (int) token_get_ival(p_token_next) >
token_get_ival(p_token_store));
break;
case TT_DOUBLE:
token_set_ival(p_token_store,
- token_get_dval(p_token_next) >=
+ token_get_dval(p_token_next) >
token_get_dval(p_token_store));
token_set_tt(p_token_store, TT_INTEGER);
break;
case TT_STRING:
token_set_ival(p_token_store,
strcmp(token_get_val(p_token_next),
- token_get_val(p_token_store)) >= 0);
+ token_get_val(p_token_store)) > 0);
token_set_tt(p_token_store, TT_INTEGER);
break;
NO_DEFAULT;
@@ -336,14 +389,15 @@ _process(Interpret *p_interpret, Token *p_token_store, Token *p_token_op,
void
function_process(Interpret *p_interpret, Token *p_token_op,
- Stack *p_stack_args, int i_args) {
+ Token *p_token_op2, Stack *p_stack_args, int i_args) {
Token *p_token_store = token_new_copy(stack_pop(p_stack_args));
for (int i = 0; i < i_args -1 && !stack_empty(p_stack_args); ++i) {
Token *p_token_next = stack_pop(p_stack_args);
- _process(p_interpret, p_token_store, p_token_op, p_token_next);
+ _process(p_interpret, p_token_store, p_token_op,
+ p_token_op2, p_token_next);
}
stack_push(p_stack_args, p_token_store);
diff --git a/src/core/function.h b/src/core/function.h
index 7355190..618ed94 100644
--- a/src/core/function.h
+++ b/src/core/function.h
@@ -1,13 +1,13 @@
/*:*
*: File: ./src/core/function.h
*: A simple interpreter
- *:
+ *:
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
- *:
- *: Copyright (c) 2005 2006 2007 2008, Dipl.-Inf. (FH) Paul C. Buetow
+ *:
+ *: 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
@@ -15,20 +15,20 @@
*: * 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 P. B. Labs 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 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 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.
*:*/
@@ -40,8 +40,8 @@
#include "interpret.h"
#include "../data/stack.h"
-void function_process(Interpret *p_interp, Token *p_token_op, Stack
- *p_stack_args, int i_args);
+void function_process(Interpret *p_interp, Token *p_token_op,
+ Token *p_token_op2, Stack *p_stack_args, int i_args);
_Bool function_is_buildin(Token *p_token_ident);
void function_process_buildin(Interpret *p_interpret, Token *p_token_ident, Stack *p_stack_args);
_Bool function_is_self_defined(Interpret *p_interpret);
diff --git a/src/core/garbage.c b/src/core/garbage.c
index 8d78344..aba19c4 100644
--- a/src/core/garbage.c
+++ b/src/core/garbage.c
@@ -1,13 +1,13 @@
/*:*
*: File: ./src/core/garbage.c
*: A simple interpreter
- *:
+ *:
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
- *:
- *: Copyright (c) 2005 2006 2007 2008, Dipl.-Inf. (FH) Paul C. Buetow
+ *:
+ *: 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
@@ -15,20 +15,20 @@
*: * 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 P. B. Labs 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 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 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.
*:*/
diff --git a/src/core/garbage.h b/src/core/garbage.h
index 8d13f5b..8a8a820 100644
--- a/src/core/garbage.h
+++ b/src/core/garbage.h
@@ -1,13 +1,13 @@
/*:*
*: File: ./src/core/garbage.h
*: A simple interpreter
- *:
+ *:
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
- *:
- *: Copyright (c) 2005 2006 2007 2008, Dipl.-Inf. (FH) Paul C. Buetow
+ *:
+ *: 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
@@ -15,20 +15,20 @@
*: * 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 P. B. Labs 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 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 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.
*:*/
diff --git a/src/core/interpret.c b/src/core/interpret.c
index 6053f17..25f4a0d 100644
--- a/src/core/interpret.c
+++ b/src/core/interpret.c
@@ -1,13 +1,13 @@
/*:*
*: File: ./src/core/interpret.c
*: A simple interpreter
- *:
+ *:
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
- *:
- *: Copyright (c) 2005 2006 2007 2008, Dipl.-Inf. (FH) Paul C. Buetow
+ *:
+ *: 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
@@ -15,20 +15,20 @@
*: * 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 P. B. Labs 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 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 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.
*:*/
@@ -605,21 +605,35 @@ _compare(Interpret *p_interpret) {
_Bool b_flag = true;
do {
+ /*
+ ! = < > !! != !< !> =! == =< => <! <= << <> >! >= >< >>
+ */
switch (p_interpret->tt) {
- case TT_EQ:
- case TT_NEQ:
+ case TT_NOT:
+ case TT_ASSIGN:
case TT_LT:
case TT_GT:
- case TT_LE:
- case TT_GE:
{
- Token *p_token = p_interpret->p_token;
+ Token *p_token_op = p_interpret->p_token;
+ Token *p_token_op2 = NULL;
_NEXT
+ switch (p_interpret->tt) {
+ case TT_NOT:
+ case TT_ASSIGN:
+ case TT_LT:
+ case TT_GT:
+ p_token_op2 = p_interpret->p_token;
+ _NEXT
+ default:
+ break;
+ }
+
if (!_sum(p_interpret))
_INTERPRET_ERROR("Expected sum", p_interpret->p_token);
- function_process(p_interpret, p_token, p_interpret->p_stack, 2);
+ function_process(p_interpret, p_token_op, p_token_op2,
+ p_interpret->p_stack, 2);
}
break; /* case */
@@ -649,13 +663,14 @@ _sum(Interpret *p_interpret) {
case TT_ADD:
case TT_SUB:
{
- Token *p_token = p_interpret->p_token;
+ Token *p_token_op = p_interpret->p_token;
_NEXT
if (!_product(p_interpret))
- _INTERPRET_ERROR("Expected product", p_token);
+ _INTERPRET_ERROR("Expected product", p_token_op);
- function_process(p_interpret, p_token, p_interpret->p_stack, 2);
+ function_process(p_interpret, p_token_op, NULL,
+ p_interpret->p_stack, 2);
}
break; /* case */
@@ -692,7 +707,8 @@ _product(Interpret *p_interpret) {
if (!_product2(p_interpret))
_INTERPRET_ERROR("Expected product2", p_token);
- function_process(p_interpret, p_token, p_interpret->p_stack, 2);
+ function_process(p_interpret, p_token, NULL,
+ p_interpret->p_stack, 2);
}
break; /* case */
@@ -730,7 +746,8 @@ _product2(Interpret *p_interpret) {
_INTERPRET_ERROR("Expected expression", p_token);
p_interpret->p_token_temp = p_token_temp;
- function_process(p_interpret, p_token, p_interpret->p_stack, 2);
+ function_process(p_interpret, p_token, NULL,
+ p_interpret->p_stack, 2);
p_interpret->p_token_temp = NULL;
}
@@ -778,7 +795,8 @@ _term(Interpret *p_interpret) {
_SKIP
}
- function_process_buildin(p_interpret, p_token, p_interpret->p_stack);
+ function_process_buildin(p_interpret, p_token,
+ p_interpret->p_stack);
stack_merge(p_stack, p_interpret->p_stack);
stack_delete(p_interpret->p_stack);
diff --git a/src/core/interpret.h b/src/core/interpret.h
index 4fc79e2..6e50e8d 100644
--- a/src/core/interpret.h
+++ b/src/core/interpret.h
@@ -1,13 +1,13 @@
/*:*
*: File: ./src/core/interpret.h
*: A simple interpreter
- *:
+ *:
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
- *:
- *: Copyright (c) 2005 2006 2007 2008, Dipl.-Inf. (FH) Paul C. Buetow
+ *:
+ *: 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
@@ -15,20 +15,20 @@
*: * 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 P. B. Labs 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 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 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.
*:*/
diff --git a/src/core/scanner.c b/src/core/scanner.c
index 9e49557..2e599eb 100644
--- a/src/core/scanner.c
+++ b/src/core/scanner.c
@@ -1,13 +1,1