summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoradmin (centauri.fritz.box) <puppet@mx.buetow.org>2014-06-30 23:25:25 +0200
committeradmin (centauri.fritz.box) <puppet@mx.buetow.org>2014-06-30 23:25:25 +0200
commit63cf3028445d8d213ffc774f77aafd7283cb4fbd (patch)
tree07eab753ba9ebed866ac13c7b39288589b5b43be /src
parent337c1c8abbe199670259bb043b95b541945427f4 (diff)
parenta90467d4be3bcf91cab299b4521bf5f762abb1d5 (diff)
Merge remote-tracking branch 'remotes/github/build-010388-scheme' into build-010388-schemebuild-010388-scheme
Diffstat (limited to 'src')
-rw-r--r--src/argv.c41
-rw-r--r--src/argv.h41
-rw-r--r--src/build.h41
-rw-r--r--src/core/frame.c152
-rw-r--r--src/core/frame.h68
-rw-r--r--src/core/interpret.c1255
-rw-r--r--src/core/interpret.h80
-rw-r--r--src/core/lambda.c98
-rw-r--r--src/core/lambda.h55
-rw-r--r--src/core/promise.c60
-rw-r--r--src/core/promise.h49
-rw-r--r--src/core/scanner.c169
-rw-r--r--src/core/scanner.h42
-rw-r--r--src/core/token.c369
-rw-r--r--src/core/token.h172
-rw-r--r--src/core/tools.c64
-rw-r--r--src/core/tools.h42
-rw-r--r--src/core/variable.c59
-rw-r--r--src/core/variable.h52
-rw-r--r--src/data/array.c39
-rw-r--r--src/data/array.h39
-rw-r--r--src/data/cons.c88
-rw-r--r--src/data/cons.h55
-rw-r--r--src/data/dat.c39
-rw-r--r--src/data/dat.h39
-rw-r--r--src/data/hash.c47
-rw-r--r--src/data/hash.h48
-rw-r--r--src/data/list.c108
-rw-r--r--src/data/list.h56
-rw-r--r--src/data/map.c39
-rw-r--r--src/data/map.h39
-rw-r--r--src/data/queue.c39
-rw-r--r--src/data/queue.h39
-rw-r--r--src/data/stack.c39
-rw-r--r--src/data/stack.h39
-rw-r--r--src/data/tree.c86
-rw-r--r--src/data/tree.h41
-rw-r--r--src/data/tupel.c39
-rw-r--r--src/data/tupel.h39
-rw-r--r--src/data/types.h39
-rw-r--r--src/defines.h59
-rw-r--r--src/fype.c65
-rw-r--r--src/fype.h47
-rw-r--r--src/main.c39
44 files changed, 1910 insertions, 2245 deletions
diff --git a/src/argv.c b/src/argv.c
index 926e854..dc938d9 100644
--- a/src/argv.c
+++ b/src/argv.c
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/argv.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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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.
*:*/
@@ -47,7 +46,7 @@
char *BINARY;
void
-argv_run(Fype *p_fype, int i_argc, char **pc_argv) {
+argv_run(PBSc *p_fype, int i_argc, char **pc_argv) {
Dat *p_dat_string = dat_new();
BINARY = pc_argv[0];
diff --git a/src/argv.h b/src/argv.h
index 18baa8c..a7575d2 100644
--- a/src/argv.h
+++ b/src/argv.h
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/argv.h
- *: 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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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.
*:*/
@@ -39,7 +38,7 @@
#include "data/tupel.h"
#include "fype.h"
-void argv_run(Fype *p_fype, int i_argc, char **pc_argv);
+void argv_run(PBSc *p_fype, int i_argc, char **pc_argv);
void argv_switch(char c_arg, Tupel *p_tupel_argv, unsigned i_argc_left);
void argv_synopsis(Tupel *p_tupel_argv);
void argv_help();
diff --git a/src/build.h b/src/build.h
index 27dbb5c..1e6006e 100644
--- a/src/build.h
+++ b/src/build.h
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/build.h
- *: 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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,27 +15,27 @@
*: * 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 buetow.org 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 C. 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 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)
*: 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.
*:*/
#ifndef BUILD_H
#define BUILD_H
-#define BUILDNR 9669
+#define BUILDNR 10388
#define OS_LINUX
#endif
diff --git a/src/core/frame.c b/src/core/frame.c
new file mode 100644
index 0000000..9143a0d
--- /dev/null
+++ b/src/core/frame.c
@@ -0,0 +1,152 @@
+/*:*
+ *: File: ./src/core/frame.c
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
+ *: 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
+ *: notice, this list of conditions and the following disclaimer.
+ *: * 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
+ *: 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
+ *: 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)
+ *: 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
+ *: POSSIBILITY OF SUCH DAMAGE.
+ *:*/
+
+#include "frame.h"
+#include "lambda.h"
+#include "variable.h"
+
+unsigned _I_FRAME_ID_COUNT = 0;
+
+Symbol*
+symbol_new(SymbolType st, void *p_val) {
+ Symbol *p_symbol = malloc(sizeof(Symbol));
+
+ p_symbol->st = st;
+ p_symbol->p_val = p_val;
+
+ return (p_symbol);
+}
+
+void
+symbol_delete(Symbol *p_symbol) {
+ switch (p_symbol->st) {
+ case ST_LAMBDA:
+ lambda_delete(p_symbol->p_val);
+ break;
+ case ST_VARIABLE:
+ variable_delete(p_symbol->p_val);
+ break;
+ }
+
+ free(p_symbol);
+}
+
+void
+symbol_delete_cb(void *p_symbol) {
+ symbol_delete(p_symbol);
+}
+
+char*
+symbol_get_type_name(Symbol *p_symbol) {
+ switch (p_symbol->st) {
+ case ST_LAMBDA:
+ return ("ST_LAMBDA");
+ case ST_VARIABLE:
+ return ("ST_VARIABLE");
+ }
+
+ return ("ST_UNKNOWN");
+}
+
+Frame*
+frame_new(Frame *p_parent_frame) {
+ Frame *p_frame = malloc(sizeof(Frame));
+
+ p_frame->p_parent_frame = p_parent_frame;
+ p_frame->p_hash_symbols = hash_new(8);
+ p_frame->i_frame_id = _I_FRAME_ID_COUNT++;
+
+ return (p_frame);
+}
+
+void
+frame_delete(Frame *p_frame) {
+ Hash *p_hash_symbols = p_frame->p_hash_symbols;
+
+ hash_iterate(p_hash_symbols, symbol_delete_cb);
+ hash_delete(p_hash_symbols);
+}
+
+_Bool
+frame_add_symbol(Frame *p_frame, char *c_name, SymbolType st, void *p_val) {
+ Hash *p_hash_symbols = p_frame->p_hash_symbols;
+
+ if (hash_key_exists(p_hash_symbols, c_name))
+ return (false);
+
+
+ Symbol *p_symbol = symbol_new(st, p_val);
+ hash_insert(p_hash_symbols, c_name, p_symbol);
+
+ return (true);
+}
+
+Symbol*
+frame_get_symbol(Frame *p_frame, char *c_name) {
+ void *p_val = hash_get(p_frame->p_hash_symbols, c_name);
+
+ if (!p_val && p_frame->p_parent_frame)
+ return (frame_get_symbol(p_frame->p_parent_frame, c_name));
+
+ return (p_val);
+}
+
+void
+_symbol_print_cb(void *p_val, char *c_name) {
+ Symbol *p_symbol = p_val;
+ switch (p_symbol->st) {
+ case ST_LAMBDA:
+ lambda_print(p_symbol->p_val);
+ break;
+ case ST_VARIABLE:
+ variable_print(p_symbol->p_val);
+ break;
+ }
+}
+
+void
+_frame_print(Frame *p_frame, int i_frame_nr) {
+ printf("FRAME(id=%u) %d:\n", p_frame->i_frame_id, i_frame_nr);
+
+ Hash *p_hash_symbols = p_frame->p_hash_symbols;
+ hash_iterate_key(p_hash_symbols, _symbol_print_cb);
+
+ if (p_frame->p_parent_frame)
+ _frame_print(p_frame->p_parent_frame, i_frame_nr + 1);
+}
+
+void
+frame_print(Frame *p_frame) {
+ _frame_print(p_frame, 0);
+}
diff --git a/src/core/frame.h b/src/core/frame.h
new file mode 100644
index 0000000..d1e01f5
--- /dev/null
+++ b/src/core/frame.h
@@ -0,0 +1,68 @@
+/*:*
+ *: File: ./src/core/frame.h
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
+ *: 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
+ *: notice, this list of conditions and the following disclaimer.
+ *: * 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
+ *: 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
+ *: 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)
+ *: 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
+ *: POSSIBILITY OF SUCH DAMAGE.
+ *:*/
+
+#ifndef FRAME_H
+#define FRAME_H
+
+#include "../defines.h"
+#include "../data/hash.h"
+
+typedef enum {
+ ST_LAMBDA,
+ ST_VARIABLE,
+} SymbolType;
+
+typedef struct {
+ SymbolType st;
+ void *p_val;
+} Symbol;
+
+typedef struct _Frame {
+ struct _Frame *p_parent_frame;
+ Hash *p_hash_symbols;
+ unsigned i_frame_id;
+} Frame;
+
+Symbol* symbol_new(SymbolType st, void *p_val);
+void symbol_delete(Symbol *p_symbol);
+void symbol_delete_cb(void *p_symbol);
+char* symbol_get_type_name(Symbol *p_symbol);
+
+Frame* frame_new(Frame *p_parent_frame);
+void frame_delete(Frame *p_frame);
+_Bool frame_add_symbol(Frame *p_frame, char *c_name, SymbolType st, void *p_val);
+Symbol *frame_get_symbol(Frame *p_frame, char *c_name);
+void frame_print(Frame *p_frame);
+
+#endif
diff --git a/src/core/interpret.c b/src/core/interpret.c
index 49fab69..28239ef 100644
--- a/src/core/interpret.c
+++ b/src/core/interpret.c
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/core/interpret.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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,1057 +15,365 @@
*: * 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 buetow.org 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 C. 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 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)
*: 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 "interpret.h"
+#include "promise.h"
+#include "variable.h"
+#include "tools.h"
-#include "../defines.h"
-#include "convert.h"
-#include "functions.h"
-#include "symbol.h"
-
-#define _INTERPRET_ERROR(m,t) \
- ERROR(\
- "%s: Interpret error in %s line %d pos %d near '%s'", m, \
- token_get_filename(t), \
- token_get_line_nr(t), \
- token_get_pos_nr(t), \
- token_get_val(t) \
- )
-
-#define _CHECK if (p_interpret->p_token == NULL) return (0);
-#define _HAS_NEXT listiterator_has_next(p_interpret->p_iter)
-#define _NEXT_ORG _next(p_interpret);
-#define _NEXT if (!_next(p_interpret)) { return (2); }
-#define _NEXT2 _NEXT _NEXT
-#define _NEXT_TT _next_tt(p_interpret)
-#define _SKIP _next(p_interpret);
-
-int _block(Interpret *p_interpret);
-int _block_get(Interpret *p_interpret, List *p_list_block);
-int _block_skip(Interpret *p_interpret);
-int _compare(Interpret *p_interpret);
-int _control(Interpret *p_interpret);
-int _expression(Interpret *p_interpret);
-int _expression_(Interpret *p_interpret);
-int _expression_get(Interpret *p_interpret, List *p_list_block);
-int _func_decl(Interpret *p_interpret);
-int _next(Interpret *p_interpret);
-int _proc_decl(Interpret *p_interpret);
-int _product(Interpret *p_interpret);
-int _product2(Interpret *p_interpret);
-int _program(Interpret *p_interpret);
-int _statement(Interpret *p_interpret);
-int _sum(Interpret *p_interpret);
-int _term(Interpret *p_interpret);
-int _var_assign(Interpret *p_interpret);
-int _var_decl(Interpret *p_interpret);
-int _var_list(Interpret *p_interpret);
-void _print_lookahead(Interpret *p_interpret);
+void _eval(Interpret *p_inter);
Interpret*
-interpret_new(List *p_list_token, Hash *p_hash_syms) {
- Interpret *p_interpret = malloc(sizeof(Interpret));
+interpret_new(List *p_list_token) {
+ Interpret *p_inter = malloc(sizeof(Interpret));
- /* No subprocess */
- if (p_hash_syms != NULL) {
- p_interpret->p_scope = scope_new(p_hash_syms);
- p_interpret->b_scope_delete = true;
+ p_inter->p_frame = frame_new(NULL);
- /* Subprocess */
- } else {
- p_interpret->p_scope = NULL;
- p_interpret->b_scope_delete = false;
- }
-
- p_interpret->p_list_token = p_list_token;
- p_interpret->p_stack = stack_new();
- p_interpret->tt = TT_NONE;
- p_interpret->p_token = NULL;
- p_interpret->tt_prev = TT_NONE;
- p_interpret->p_token_prev = NULL;
- p_interpret->p_token_temp = NULL;
- p_interpret->ct = CONTROL_NONE;
-
- return (p_interpret);
-}
-
-void
-interpret_delete(Interpret *p_interpret) {
- if (!p_interpret)
- return;
-
- if (p_interpret->b_scope_delete)
- scope_delete(p_interpret->p_scope);
-
- stack_delete(p_interpret->p_stack);
- free(p_interpret);
-}
-
-void
-_print_lookahead(Interpret *p_interpret) {
- ListIterator *p_iter = p_interpret->p_iter;
- ListIteratorState *p_state = listiterator_get_state(p_iter);
+ p_inter->p_list_token = p_list_token;
+ p_inter->p_token = NULL;
- printf("LOOLAHEAD:\n");
+ p_inter->i_pcount = 0;
- token_print(p_interpret->p_token);
- printf("\n");
+ p_inter->b_is_lambda_interpretation = false;
+ p_inter->p_lambda = NULL;
- while (listiterator_has_next(p_iter)) {
- Token *p_token = listiterator_next(p_iter);
- token_print(p_token);
- printf("\n");
- }
-
- listiterator_set_state(p_iter, p_state);
- listiteratorstate_delete(p_state);
+ return (p_inter);
}
-int
-_next(Interpret *p_interpret) {
- if (listiterator_has_next(p_interpret->p_iter)) {
- p_interpret->p_token_prev = p_interpret->p_token;
- p_interpret->tt_prev = p_interpret->tt;
-
- p_interpret->p_token = listiterator_next(p_interpret->p_iter);
- p_interpret->tt = token_get_tt(p_interpret->p_token);
- return (1);
- }
+Interpret*
+interpret_new_lambda(Interpret *p_inter, Lambda *p_lambda) {
+ Interpret *p_inter_up = malloc(sizeof(Interpret));
+ p_inter_up->p_frame = frame_new(p_lambda->p_frame);
+ p_inter_up->p_list_token = NULL;
+ p_inter_up->p_token = NULL;
+ p_inter_up->i_pcount = 0;
- p_interpret->p_token = NULL;
- p_interpret->tt = TT_NONE;
- //printf("==>\n");
+ p_inter_up->b_is_lambda_interpretation = true;
+ p_inter_up->p_lambda = p_lambda;
- return (0);
+ return (p_inter_up);
}
-TokenType
-_next_tt(Interpret *p_interpret) {
- if (listiterator_has_next(p_interpret->p_iter)) {
- Token *p_token = listiterator_current(p_interpret->p_iter);
- return (token_get_tt(p_token));
- }
-
- return (TT_NONE);
+void
+interpret_delete(Interpret *p_inter) {
+ frame_delete(p_inter->p_frame);
+ free(p_inter);
}
-int
-_program(Interpret *p_interpret) {
- _CHECK TRACK
+void
+interpret_run(PBSc *p_fype) {
+ Interpret *p_inter =
+ interpret_new(p_fype->p_list_token);
- while (_statement(p_interpret) == 1)
- garbage_collect();
+ _eval(p_inter);
- return (1);
+ interpret_delete(p_inter);
}
-int
-_var_decl(Interpret *p_interpret) {
- _CHECK TRACK
-
- switch (p_interpret->tt) {
- case TT_MY:
- {
- if (_NEXT_TT != TT_IDENT)
- _INTERPRET_ERROR("'my' expects identifier", p_interpret->p_token);
-
- _NEXT
-
- Token *p_token_ident = p_interpret->p_token;
-
- _var_assign(p_interpret);
- _var_list(p_interpret);
-
- if (p_interpret->tt == TT_SEMICOLON) {
- _NEXT
- return (1);
-
- } else if (p_interpret->p_token != NULL) {
- _INTERPRET_ERROR("Expected ';'", p_interpret->p_token);
-
- } else {
- _INTERPRET_ERROR("Expected ';' after", p_token_ident);
+void
+_def(Interpret *p_inter, Token *p_token, ListIterator *p_iter) {
+ Frame *p_frame = p_inter->p_frame;
+ _Bool b_success;
+
+ if (!listiterator_has_next(p_iter))
+ ERROR_EOB;
+
+ p_token = listiterator_next(p_iter);
+ char *c_name;
+
+ if (p_token->tt_cur == TT_IDENT) {
+ c_name = p_token->c_val;
+
+ ListElem *p_listelem = listiterator_current_elem(p_iter);
+
+ if (!listiterator_has_next(p_iter))
+ ERROR_EOB;
+
+ p_token = listiterator_next(p_iter);
+
+ switch (p_token->tt_cur) {
+ case TT_PARANT_L: {
+ tool_skip_block(p_iter, 0);
+ ListElem *p_listelem_end = listiterator_current_elem(p_iter);
+ Lambda *p_lambda = lambda_new(
+ c_name,
+ NULL,
+ p_listelem,
+ p_listelem_end,
+ p_inter->p_frame);
+ //printf("::1\n");
+ b_success = frame_add_symbol(p_frame, c_name, ST_LAMBDA, p_lambda);
}
- }
- default:
break;
- }
-
- return (0);
-}
-
-int
-_var_assign(Interpret *p_interpret) {
- _CHECK TRACK
-
- if (p_interpret->tt == TT_IDENT) {
- Token *p_token = p_interpret->p_token;
- _NEXT
-
- char *c_name = token_get_val(p_token);
- if (scope_exists(p_interpret->p_scope, c_name)) {
- _INTERPRET_ERROR("Symbol already defined", p_token);
- }
-
- if (p_interpret->tt == TT_ASSIGN) {
- _NEXT
-
- if (p_interpret->tt == TT_VID) {
- _NEXT
- if (p_interpret->tt != TT_IDENT)
- _INTERPRET_ERROR("Expected identifier", 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_);
-
- if (p_symbol == NULL)
- _INTERPRET_ERROR("No such symbol", p_interpret->p_token);
-
- symbol_ref_up(p_symbol);
- scope_newset(p_interpret->p_scope, c_name, p_symbol);
- _NEXT
-
- } else {
- Stack *p_stack = p_interpret->p_stack;
- p_interpret->p_stack = stack_new();
-
- if (_expression_(p_interpret)) {
- 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);
- p_interpret->p_stack = p_stack;
-
- p_token = stack_top(p_interpret->p_stack);
- Symbol *p_symbol = symbol_new(SYM_VARIABLE, p_token);
- scope_newset(p_interpret->p_scope, c_name, p_symbol);
- } else {
- return (0);
- }
- }
- } else {
- Token *p_token = token_new_integer(0);
- Symbol *p_symbol = symbol_new(SYM_VARIABLE, p_token);
- scope_newset(p_interpret->p_scope, c_name, p_symbol);
- }
- }
-
- return (1);
-}
-
-int
-_var_list(Interpret *p_interpret) {
- _CHECK TRACK
-
- if (p_interpret->tt == TT_COMMA) {
- _NEXT
- _var_assign(p_interpret);
- _var_list(p_interpret);
- }
-
- return (1);
-}
-
-int
-_block_get(Interpret *p_interpret, List *p_list_block) {
- if (p_interpret->tt != TT_PARANT_CL)
- _INTERPRET_ERROR("Expected '{'", p_interpret->p_token);
- _NEXT
-
- int i_num_parant = 0;
-
- for (;;) {
- if (p_interpret->tt == TT_PARANT_CL) {
- ++i_num_parant;
-
- } else if (p_interpret->tt == TT_PARANT_CR) {
- if (--i_num_parant == -1) {
- _NEXT
- break; /* for */
- }
+ case TT_IDENT: {
+ Variable *p_variable = variable_new(
+ c_name,
+ p_token,
+ p_inter->p_frame);
+ b_success = frame_add_symbol(p_frame,
+ c_name, ST_VARIABLE, p_variable);
+ if (!listiterator_has_next(p_iter))
+ ERROR_EOB;
+ Token *p_token2 = listiterator_next(p_iter);
+ if (p_token2->tt_cur != TT_PARANT_R)
+ ERROR_INTERPRET("Expected ) or (", p_token);
}
-
- list_add_back(p_list_block, p_interpret->p_token);
-
- _NEXT
- }
-
-#ifdef DEBUG_BLOCK_GET
- printf("DEBUG::BLOCK::GET: ====>\n");
- list_iterate(p_list_block, token_print_cb);
- printf("DEBUG::BLOCK::GET: <====\n");
-#endif /* DEBUG_BLOCK_GET */
-
- return (1);
-}
-
-int
-_expression_get(Interpret *p_interpret, List *p_list_expression) {
- for (;;) {
- if (p_interpret->tt == TT_PARANT_CL) {
- break; /* for */
+ break;
+ default:
+ ERROR_INTERPRET("Expected ( or identifier", p_token);
}
- list_add_back(p_list_expression, p_interpret->p_token);
+ } else if (p_token->tt_cur == TT_PARANT_L) {
+ List *p_list_args = list_new();
- _NEXT
- }
+ if (!listiterator_has_next(p_iter))
+ ERROR_INTERPRET("Expected identifier", p_token);
-#ifdef DEBUG_EXPRESSION_GET
- printf("DEBUG::EXPRESSION::GET: ====>\n");
- list_iterate(p_list_expression, token_print_cb);
- printf("DEBUG::EXPRESSION::GET: <====\n");
-#endif /* DEBUG_EXPRESSION_GET */
+ p_token = listiterator_next(p_iter);
+ if (p_token->tt_cur != TT_IDENT)
+ ERROR_INTERPRET("Expected identifier", p_token);
- return (1);
-}
+ c_name = p_token->c_val;
+ while (listiterator_has_next(p_iter)) {
+ p_token = listiterator_next(p_iter);
-int
-_block_skip(Interpret *p_interpret) {
- if (p_interpret->tt != TT_PARANT_CL)
- _INTERPRET_ERROR("Expected '{'", p_interpret->p_token);
- _NEXT
-
- int i_num_parant = 0;
-
- for (;;) {
- if (p_interpret->tt == TT_PARANT_CL) {
- ++i_num_parant;
+ if (p_token->tt_cur != TT_IDENT) {
+ if (p_token->tt_cur != TT_PARANT_R)
+ ERROR_INTERPRET("Expected identifier or )", p_token);
+ break;
- } else if (p_interpret->tt == TT_PARANT_CR) {
- if (--i_num_parant == -1) {
- _NEXT
- break; /* for */
+ } else {
+ list_add_back(p_list_args, p_token->c_val);
}
}
- _NEXT
- }
-
- return (1);
-}
-
-int
-_proc_decl(Interpret *p_interpret) {
- _CHECK TRACK
-
- if (p_interpret->tt == TT_PROC) {
- _NEXT
-
- if (p_interpret->tt != TT_IDENT)
- _INTERPRET_ERROR("Expected identifier", p_interpret->p_token);
-
- Token *p_token_ident = p_interpret->p_token;
- _NEXT
-
- if (scope_exists(p_interpret->p_scope, token_get_val(p_token_ident))) {
- _INTERPRET_ERROR("Symbol already defined", p_token_ident);
- }
-
- List *p_list_proc = list_new();
-
- if (_block_get(p_interpret, p_list_proc)) {
-
- Symbol *p_symbol = symbol_new(SYM_PROCEDURE, p_list_proc);
- scope_newset(p_interpret->p_scope, token_get_val(p_token_ident),
- p_symbol);
-
- return (1);
- }
-
- list_delete(p_list_proc);
- }
-
- return (0);
-}
-
-int
-_func_decl(Interpret *p_interpret) {
- _CHECK TRACK
-
- if (p_interpret->tt == TT_FUNC) {
- _NEXT
-
- if (p_interpret->tt != TT_IDENT)
- _INTERPRET_ERROR("Expected identifier", p_interpret->p_token);
-
- Token *p_token_ident = p_interpret->p_token;
- _NEXT
-
- if (scope_exists(p_interpret->p_scope, token_get_val(p_token_ident))) {
- _INTERPRET_ERROR("Symbol already defined", p_token_ident);
- }
-
- List *p_list_proc = list_new();
-
- if (_block_get(p_interpret, p_list_proc)) {
-
- Symbol *p_symbol = symbol_new(SYM_FUNCTION, p_list_proc);
- scope_newset(p_interpret->p_scope, token_get_val(p_token_ident),
- p_symbol);
-
- return (1);
- }
-
- list_delete(p_list_proc);
- }
-
- return (0);
-}
-
-int
-_statement(Interpret *p_interpret) {
- _CHECK TRACK
-
- for (int i = 0; i < 2; ++i) {
- if (_proc_decl(p_interpret)) return (1);
- if (_func_decl(p_interpret)) return (1);
- if (_var_decl(p_interpret)) return (1);
- if (_control(p_interpret)) return (1);
- if (_expression(p_interpret)) return (1);
- if (_block(p_interpret)) return (1);
- }
-
- return (0);
-}
-
-int
-_block(Interpret *p_interpret) {
- if (p_interpret->tt == TT_PARANT_CL) {
- List *p_list_block = list_new();
-
- if (_block_get(p_interpret, p_list_block)) {
- scope_up(p_interpret->p_scope);
- interpret_subprocess(p_interpret, p_list_block);
- scope_down(p_interpret->p_scope);
- list_delete(p_list_block);
- return (1);
- }
-
- list_delete(p_list_block);
+ ListElem *p_listelem = listiterator_next_elem(p_iter);
+ //printf("::2\n");
+ tool_skip_block(p_iter, 2);
+ ListElem *p_listelem_end = listiterator_current_elem(p_iter);
+
+ Lambda *p_lambda = lambda_new(
+ c_name,
+ p_list_args,
+ p_listelem,
+ p_listelem_end,
+ p_inter->p_frame);
+ b_success = frame_add_symbol(p_frame, c_name, ST_LAMBDA, p_lambda);
+ } else {
+ ERROR_INTERPRET("Expected identifier or (", p_token);
}
- return (0);
+ if (!b_success)
+ ERROR("Forbidden to redef symbol \"%s\" @ current frame", c_name);
}
-int
-_expression(Interpret *p_interpret) {
- _CHECK TRACK
-
- if (_expression_(p_interpret)) {
- TokenType tt = p_interpret->tt;
- if (tt == TT_SEMICOLON || tt == TT_NONE) {
- _NEXT
-
- } else {
- _INTERPRET_ERROR("Expected ';'", p_interpret->p_token);
+void
+_say(Interpret *p_inter, Token *p_token, ListIterator *p_iter) {
+ while (listiterator_has_next(p_iter)) {
+ Token *p_token = listiterator_next(p_iter);
+ switch (p_token->tt_cur) {
+ case TT_IDENT:
+ case TT_INTEGER:
+ case TT_STRING:
+ printf("%s\n", p_token->c_val);
+ break;
+ case TT_PARANT_L:
+ ERROR("Not yet implemented");
+ break;
+ case TT_PARANT_R:
+ return;
+ NO_DEFAULT;
}
-
- stack_clear(p_interpret->p_stack);
- return (1);
}
-
- return (0);
-}
-
-int
-_expression_(Interpret *p_interpret) {
- return (_compare(p_interpret));
}
-int
-_control(Interpret *p_interpret) {
- _CHECK TRACK
-
- Token *p_token = p_interpret->p_token;
-
- switch (p_interpret->tt) {
- case TT_IF:
- case TT_IFNOT:
- {
- TokenType tt = p_interpret->tt;
- _NEXT
- if (_expression_(p_interpret)) {
- Token *p_token_top = stack_pop(p_interpret->p_stack);
- List *p_list_block = list_new();
- _block_get(p_interpret, p_list_block);
- int ret = 0;
-
- switch (tt) {
- case TT_IF:
- if (convert_to_integer_get(p_token_top)) {
- scope_up(p_interpret->p_scope);
- ret = interpret_subprocess(p_interpret, p_list_block);
- scope_down(p_interpret->p_scope);
+void
+_eval_lambda(Interpret *p_inter, Lambda *p_lambda, ListIterator *p_iter) {
+ Interpret *p_inter_local = interpret_new_lambda(p_inter, p_lambda);
+ Frame *p_frame_local = p_inter_local->p_frame;
+ ListIterator *p_iter_args = NULL;
+
+
+ if (p_lambda->p_list_args)
+ p_iter_args = listiterator_new(p_lambda->p_list_args);
+
+ Token *p_token = listiterator_current(p_iter);
+
+ if (p_iter_args) {
+ while (listiterator_has_next(p_iter_args)) {
+ char *c_name = listiterator_next(p_iter_args);
+
+ if (!listiterator_has_next(p_iter))
+ ERROR_EOB;
+ ListElem *p_listelem = listiterator_current_elem(p_iter);
+ p_token = listiterator_next(p_iter);
+
+ switch (p_token->tt_cur) {
+ case TT_PARANT_L: {
+ //printf("::3\n");
+ tool_skip_block(p_iter, 1 );
+ ListElem *p_listelem_end = listiterator_current_elem(p_iter);
+ Lambda *p_lambda_ = lambda_new(
+ c_name,
+ NULL,
+ p_listelem,
+ p_listelem_end,
+ p_frame_local);
+ if (!frame_add_symbol(p_frame_local,
+ c_name,
+ ST_LAMBDA,
+ p_lambda_)) {
+ printf("Illegal reuse of parameter '%s' @ function '%s'",
+ c_name, p_lambda->c_name);
+ ERROR_INTERPRET(". Error binding local lambda", p_token);
}
+ }
+ break;
+ case TT_PARANT_R:
+ ERROR_INTERPRET("Didn't expect ) here", p_token);
break;
- case TT_IFNOT:
- if (!convert_to_integer_get(p_token_top)) {
- scope_up(p_interpret->p_scope);
- ret = interpret_subprocess(p_interpret, p_list_block);
- scope_down(p_interpret->p_scope);
+ default: {
+ Variable *p_variable = variable_new(c_name,
+ p_token,
+ p_frame_local);
+ if (!frame_add_symbol(p_frame_local,
+ c_name,
+ ST_VARIABLE,
+ p_variable)) {
+ printf("Illegal reuse of parameter '%s' @ function '%s'\n",
+ c_name, p_lambda->c_name);
+ frame_print(p_frame_local);
+ ERROR_INTERPRET("Fatal", p_token);
}
- break;
- NO_DEFAULT;
}
-
- list_delete(p_list_block);
- return (1);
-
- } else {
- _INTERPRET_ERROR("Expected expression after control keyword", p_token);
- }
- }
- break;
- case TT_WHILE:
- case TT_UNTIL:
- {
- TokenType tt = p_interpret->tt;
- List *p_list_expr = list_new(), *p_list_block = list_new();
- _Bool b_flag = true;
-
- _NEXT
-
- _expression_get(p_interpret, p_list_expr);
- _block_get(p_interpret, p_list_block);
- Token *p_token_backup = p_interpret->p_token;
-
- do {
- Stack *p_stack_backup = p_interpret->p_stack;
- p_interpret->p_stack = stack_new();
-
- ListIterator *p_iter_backup = p_interpret->p_iter;
- p_interpret->p_iter = listiterator_new(p_list_expr);
-
- _NEXT
-
- /* Dont use if here, because we want to check the p_itnerpret->ct */
- if (_expression_(p_interpret)) {
- Token *p_token_top = stack_pop(p_interpret->p_stack);
-
- if (p_token_top == NULL) {
- printf("FOO\n");
- exit(0);
- }
- if (tt == TT_WHILE) {
- if (convert_to_integer_get(p_token_top)) {
- scope_up(p_interpret->p_scope);
- interpret_subprocess(p_interpret, p_list_block);
- scope_down(p_interpret->p_scope);
-
- } else {
- b_flag = false;
- }
-
- } else if (tt == TT_UNTIL) {
- if (!convert_to_integer_get(p_token_top)) {
- scope_up(p_interpret->p_scope);
- interpret_subprocess(p_interpret, p_list_block);
- scope_down(p_interpret->p_scope);
-
- } else {
- b_flag = false;
- }
- }
-
- /*
- switch (p_interpret->ct) {
- case CONTROL_BREAK:
- p_interpret->ct = CONTROL_NONE;
- b_flag = false;
- break;
- case CONTROL_NEXT:
- p_interpret->ct = CONTROL_NONE;
- break;
- NO_DEFAULT;
- }
- */
-
- } else {
- _INTERPRET_ERROR("Expected expression after control keyword",
- p_token);
+ break;
}
+ }
- listiterator_delete(p_interpret->p_iter);
- p_interpret->p_iter = p_iter_backup;
-
- stack_delete(p_interpret->p_stack);
- p_interpret->p_stack = p_stack_backup;
-
- } while (b_flag);
-
- list_delete(p_list_expr);
- list_delete(p_list_block);
- p_interpret->p_token = p_token_backup;
- p_interpret->tt = token_get_tt(p_token_backup);
-
- return (1);
- }
- break;
- NO_DEFAULT;
+ listiterator_delete(p_iter_args);
}
- return (0);
-}
-
-int
-_compare(Interpret *p_interpret) {
- _CHECK TRACK
-
- if (_sum(p_interpret)) {
- _Bool b_flag = true;
-
- do {
- switch (p_interpret->tt) {
- case TT_NOT:
- case TT_ASSIGN:
- case TT_LT:
- case TT_GT:
- {
- 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_op, p_token_op2,
- p_interpret->p_stack, 2);
- }
- break; /* case */
+ if (!listiterator_has_next(p_iter))
+ ERROR_EOB;
- default:
- b_flag = false;
- break;
-
- } /* switch */
-
- } while (b_flag);
-
- return (1);
- }
-
- return (0);
+ _eval(p_inter_local);
+ interpret_delete(p_inter_local);
}
-int
-_sum(Interpret *p_interpret) {
- _CHECK TRACK
-
- if (_product(p_interpret)) {
- _Bool b_flag = true;
-
- do {
- Token *p_token_op2 = NULL, *p_token_tmp = NULL;
-
- switch (p_interpret->tt) {
- case TT_DDOT:
- p_token_tmp = p_interpret->p_token;
- _NEXT
- case TT_ADD:
- case TT_SUB:
- case TT_AND:
- case TT_OR:
- case TT_XOR:
- {
- Token *p_token_op = p_interpret->p_token;
- _NEXT
-
- if (p_token_tmp != NULL) {
- p_token_op2 = p_token_op;
- p_token_op = p_token_tmp;;
- }
-
- if (!_product(p_interpret))
- _INTERPRET_ERROR("Expected product", p_token_op);
-
- function_process(p_interpret, p_token_op, p_token_op2,
- p_interpret->p_stack, 2);
-
- }
- break; /* case */
-
- default:
- b_flag = false;
- break;
-
- } /* switch */
-
- } while (b_flag);
-
- return (1);
+void
+_eval_symbol(Interpret *p_inter, Symbol *p_symbol, ListIterator *p_iter) {
+ switch (p_symbol->st) {
+ case ST_LAMBDA: {
+ _eval_lambda(p_inter, p_symbol->p_val, p_iter);
+ //printf("::EVAL_LAMBDA_END\n");
}
-
- return (0);
-}
-
-int
-_product(Interpret *p_interpret) {
- _CHECK TRACK
-
- if (_product2(p_interpret)) {
- _Bool b_flag = true;
-
- do {
- switch (p_interpret->tt) {
- case TT_MULT:
- case TT_DIV:
- {
- Token *p_token = p_interpret->p_token;
- _NEXT
-
- if (!_product2(p_interpret))
- _INTERPRET_ERROR("Expected product2", p_token);
-
- function_process(p_interpret, p_token, NULL,
- p_interpret->p_stack, 2);
-
- }
- break; /* case */
-
- default:
- b_flag = false;
- break;
-
- } /* switch */
-
- } while (b_flag);
-
- return (1);
+ break;
+ case ST_VARIABLE:
+ break;
}
-
- return (0);
}
-int
-_product2(Interpret *p_interpret) {
- _CHECK TRACK
+Token*
+_parant(Interpret *p_inter, Token *p_token) {
+ //printf("::PARANT<%d>: %s\n", p_inter->i_pcount, p_token->c_val);
+ if (p_token->tt_cur == TT_PARANT_L) {
+ ++p_inter->i_pcount;
- if (_term(p_interpret)) {
- _Bool b_flag = true;
+ } else if (p_token->tt_cur == TT_PARANT_R) {
+ if (--p_inter->i_pcount == 0)
+ return (NULL);
- do {
- if (p_interpret->tt == TT_ASSIGN
- && IS_NOT_OPERATOR(_NEXT_TT)) {
- Token *p_token = p_interpret->p_token;
- Token *p_token_temp = p_interpret->p_token_prev;
- _NEXT
-
- if (!_expression_(p_interpret))
- _INTERPRET_ERROR("Expected expression", p_token);
-
- p_interpret->p_token_temp = p_token_temp;
- function_process(p_interpret, p_token, NULL,
- p_interpret->p_stack, 2);
- p_interpret->p_token_temp = NULL;
-
- } else {
- b_flag = false;
- break;
- } /* if */
- } while (b_flag);
-
- return (1);
+ else if (p_inter->i_pcount < 0)
+ ERROR_INTERPRET("Too many closing )'s",
+ p_token);
}
- return (0);
+ return (p_token);
}
-int
-_term(Interpret *p_interpret) {
- _CHECK TRACK
-
- switch (p_interpret->tt) {
- case TT_ARRAY:
- case TT_STRING:
- case TT_INTEGER:
- case TT_DOUBLE:
- stack_push(p_interpret->p_stack, p_interpret->p_token);
- // Checks if the term is the last element of an array
- // say ["element"] # The "element"
- // or of a function
- // func foo { say 1 } # The 1
- if (_NEXT_TT != TT_PARANT_AR && _NEXT_TT != TT_PARANT_CR)
- _NEXT
- return (1);
-
- case TT_IDENT:
- {
- if (_NEXT_TT != TT_ASSIGN) {
- if (_NEXT_TT == TT_PARANT_AL) {
- Token *p_token_var = p_interpret->p_token;
- char *c_name = token_get_val(p_token_var);
- Symbol *p_symbol = scope_get(p_interpret->p_scope, c_name);
-
- if (p_symbol == NULL)
- _INTERPRET_ERROR("No such symbol", p_token_var);
- Token *p_token_array = symbol_get_val(p_symbol);
- Array *p_array = TOKEN_GET_ARRAY(p_token_array);
- if (p_array == NULL)
- _INTERPRET_ERROR("Expected an array", p_interpret->p_token);
-
- _NEXT2
- Token *p_token_val = array_get(p_array,
- convert_to_integer_get(p_interpret->p_token));
- stack_push(p_interpret->p_stack, p_token_val);
- _NEXT
-
- return (1);
-
- } else if (function_is_buildin(p_interpret->p_token)) {
- Token *p_token = p_interpret->p_token;
- Stack *p_stack = p_interpret->p_stack;
- p_interpret->p_stack = stack_new();
-
- if (_HAS_NEXT) {
- _NEXT
- //if (_expression_(p_interpret));
- _expression_(p_interpret);
-
- } else {
- _SKIP
- }
-
- 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);
- p_interpret->p_stack = p_stack;
-
- return (1);
-
- } else if (function_is_self_defined(p_interpret)) {
- Token *p_token = p_interpret->p_token;
- Stack *p_stack = p_interpret->p_stack;
- p_interpret->p_stack = stack_new();
-
- _NEXT
- if (_expression_(p_interpret));
-
- function_process_self_defined(p_interpret, p_token);
-
- if (stack_empty(p_interpret->p_stack)) {
- Token *p_token = token_new_dummy();
- token_set_tt(p_token, TT_INTEGER);
- token_set_ival(p_token, 0);
- stack_push(p_interpret->p_stack, p_token);
- }
-
- stack_merge(p_stack, p_interpret->p_stack);
- stack_delete(p_interpret->p_stack);
- p_interpret->p_stack = p_stack;
-
- return (1);
- }
- }
+void
+_run_func(Interpret *p_inter, Token *p_token, ListIterator *p_iter) {
+ Frame *p_frame = p_inter->p_frame;
+ Symbol *p_symbol = NULL;
- /* It is not a function, it is a variable or some sort of */
+ if (listiterator_has_next(p_iter)) {
+ if (! (p_token = _parant(p_inter, listiterator_next(p_iter))) )
+ return;
- char *c_name = token_get_val(p_interpret->p_token);
- Symbol *p_symbol = scope_get(p_interpret->p_scope, c_name);
+ //printf("::Interpreting: %s\n", p_token->c_val);
- if (p_symbol == NULL)
- _INTERPRET_ERROR("No such symbol", p_interpret->p_token);
+ if (token_is(p_token, "def")) {
- SymbolType st = symbol_get_sym(p_symbol);
+ _def(p_inter, p_token, p_iter);
- switch (st) {
- case SYM_VARIABLE:
- stack_push(p_interpret->p_stack, symbol_get_val(p_symbol));
- _NEXT
- return (1);
+ } else if (token_is(p_token, "say")) {
+ _say(p_inter, p_token, p_iter);
- /* Example: proc foo { foo = "Hello"; } foo; say foo; */
- case SYM_PROCEDURE:
- stack_push(p_interpret->p_stack, symbol_get_val(p_symbol));
- _NEXT
- return (1);
+ } else if (token_is(p_token, "noop")) {
- NO_DEFAULT;
- }
- }
- break;
- case TT_DEFINED:
- {
- _NEXT
- if (p_interpret->tt != TT_IDENT)
- _INTERPRET_ERROR("Expexted identifier for 'defined'",
- p_interpret->p_token);
+ } else if ( (p_symbol = frame_get_symbol(p_frame, p_token->c_val)) != NULL ) {
+ _eval_symbol(p_inter, p_symbol, p_iter);
- char *c_name = token_get_val(p_interpret->p_token);
- Token *p_token = token_new_integer(0);
+ } else if (token_is(p_token, "show-frames")) {
+ frame_print(p_inter->p_frame);
- if (scope_exists(p_interpret->p_scope, c_name))
- token_set_ival(p_token, 1);
-
- stack_push(p_interpret->p_stack, p_token);
-
- _NEXT;
- return (1);
- }
- break;
-
- case TT_UNDEF:
- {
- _NEXT
- if (p_interpret->tt != TT_IDENT)
- _INTERPRET_ERROR("Expexted identifier for 'defined'",
- p_interpret->p_token);
-
- char *c_name = token_get_val(p_interpret->p_token);
- Token *p_token = NULL;
- Symbol *p_symbol = NULL;
-
- if ((p_symbol = scope_remove(p_interpret->p_scope, c_name))) {
- symbol_delete(p_symbol);
- p_token = token_new_integer(1);
+ } else if (token_is(p_token, "beep")) {
+ printf("BEEP\n");
} else {
- p_token = token_new_integer(0);
+ printf("No symbol '%s' defined @ any frame:\n", p_token->c_val);
+ frame_print(p_frame);
+ ERROR_INTERPRET("Error.", p_token);
}
-
- stack_push(p_interpret->p_stack, p_token);
-
- _NEXT;
- return (1);
}
- break;
-
- case TT_SYMS:
- {
- _NEXT
- if (p_interpret->tt != TT_IDENT)
- _INTERPRET_ERROR("Expexted identifier for 'syms'",
- 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);
- if (p_symbol == NULL)
- _INTERPRET_ERROR("No such symbol", p_interpret->p_token);
-
-
- Token *p_token_num_refs = token_new_integer(p_symbol->i_refs);
- stack_push(p_interpret->p_stack, p_token_num_refs);
-
- _NEXT;
- return (1);
- }
- break;
-
- case TT_PARANT_AL:
- {
- Token *p_token_arr = token_new_array(ARRAY_SIZE);
- Array *p_array = p_token_arr->p_array;
-
- _NEXT
- // Get the array elements
- while (p_interpret->tt != TT_PARANT_AR) {
- TokenType tt = tt = p_interpret->tt;
- if (tt != TT_COMMA && tt != TT_SEMICOLON) {
- UNLESS (_expression_(p_interpret)) {
- Token *p_token = p_interpret->p_token;
- _INTERPRET_ERROR("Expected expression", p_token);
- }
-
- array_unshift(p_array, stack_pop(p_interpret->p_stack));
- }
+}
- _NEXT
- }
+void
+_eval(Interpret *p_inter) {
+ ListIterator *p_iter = NULL;
+ ListElem *p_listelem_end = NULL;
- stack_push(p_interpret->p_stack, p_token_arr);
- _NEXT
- return (1);
+ if (!p_inter->b_is_lambda_interpretation) {
+ p_iter = listiterator_new(p_inter->p_list_token);
+ } else {
+ p_iter = listiterator_new_from_elem(p_inter->p_lambda->p_listelem);
+ p_listelem_end = p_inter->p_lambda->p_listelem_end;
}
- break;
-
- case TT_PARANT_L:
- {
- Token *p_token = p_interpret->p_token;
- _NEXT
-
- if (_expression_(p_interpret)) {
- if (p_interpret->tt != TT_PARANT_R)
- _INTERPRET_ERROR("Expected ')'", p_token);
- } else {
- _INTERPRET_ERROR("Expected expression", p_token);
+ while (listiterator_has_next(p_iter)) {
+ Token *p_token = _parant(p_inter, listiterator_next(p_iter));
+ if (!p_token)
+ break;
+
+ if (p_listelem_end && listiterator_current_elem_equals(
+ p_iter,
+ p_listelem_end))
+ break;
+
+ switch (p_token->tt_cur) {
+ case TT_PARANT_L:
+ _run_func(p_inter, p_token, p_iter);
+ break;
+ case TT_PARANT_R:
+ break;
+ NO_DEFAULT;
}
}
- _NEXT
- return (1);
-
- default:
- break;
- }
-
- return (0);
-}
-
-int
-interpret_process(Interpret *p_interpret) {
- p_interpret->p_iter = listiterator_new(p_interpret->p_list_token);
-
- _NEXT
- _program(p_interpret);
-
- listiterator_delete(p_interpret->p_iter);
-
- return (1);
+ listiterator_delete(p_iter);
}
-
-
-int
-interpret_subprocess(Interpret *p_interpret, List *p_list_token) {
- Interpret *p_interpret_sub = interpret_new(p_list_token,
- NULL);
-
- p_interpret_sub->p_scope = p_interpret->p_scope;
-
- int i_ret = interpret_process(p_interpret_sub);
- p_interpret->ct = p_interpret_sub->ct;
-
- interpret_delete(p_interpret_sub);
-
- return (i_ret);
-}
-
-void
-interpret_run(Fype *p_fype) {
- Interpret *p_interpret =
- interpret_new(p_fype->p_list_token, p_fype->p_hash_syms);
-
- interpret_process(p_interpret);
-
- interpret_delete(p_interpret);
-}
-
diff --git a/src/core/interpret.h b/src/core/interpret.h
index 6ac035a..6d3a4a5 100644
--- a/src/core/interpret.h
+++ b/src/core/interpret.h
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/core/interpret.h
- *: 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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,61 +15,44 @@
*: * 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 buetow.org 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 C. 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 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)
*: 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.
*:*/
#ifndef INTERPRET_H
#define INTERPRET_H
+#include "frame.h"
+#include "token.h"
+#include "lambda.h"
#include "../data/list.h"
-#include "../data/stack.h"
-#include "../data/hash.h"
-
#include "../fype.h"
-#include "garbage.h"
-#include "scope.h"
-#include "token.h"
-
-typedef enum {
- CONTROL_NONE,
- CONTROL_NEXT,
- CONTROL_BREAK,
-} ControlType;
-
-typedef struct {
+typedef struct _Interpret {
List *p_list_token;
- Scope *p_scope;
- _Bool b_scope_delete;
- Stack *p_stack;
- ControlType ct;
-
- ListIterator *p_iter;
+ Frame *p_frame;
Token *p_token;
- TokenType tt;
- Token *p_token_prev;
- TokenType tt_prev;
- Token *p_token_temp;
+ int i_pcount;
+ _Bool b_is_lambda_interpretation;
+ Lambda *p_lambda;
} Interpret;
-Interpret* interpret_new(List *p_list_token, Hash *p_hash_syms);
-void interpret_delete(Interpret *p_interpret);
-void interpret_run(Fype *p_type);
-int interpret_process(Interpret *p_interpret);
-int interpret_subprocess(Interpret *p_interpret, List *p_list_token);
+Interpret* interpret_new(List *p_list_token);
+Interpret* interpret_new_lambda(Interpret *p_inter, Lambda *p_lambda);
+void interpret_delete(Interpret *p_inter);
+void interpret_run(PBSc *p_fype);
#endif /* INTERPRET_H */
diff --git a/src/core/lambda.c b/src/core/lambda.c
new file mode 100644
index 0000000..c6ad9a2
--- /dev/null
+++ b/src/core/lambda.c
@@ -0,0 +1,98 @@
+/*:*
+ *: File: ./src/core/lambda.c
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
+ *: 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
+ *: notice, this list of conditions and the following disclaimer.
+ *: * 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
+ *: 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
+ *: 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)
+ *: 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
+ *: POSSIBILITY OF SUCH DAMAGE.
+ *:*/
+
+#include "lambda.h"
+#include "token.h"
+
+Lambda*
+lambda_new(char *c_name, List *p_list_args, ListElem *p_listelem, ListElem *p_listelem_end, Frame *p_frame) {
+ Lambda *p_lambda = malloc(sizeof(Lambda));
+
+ p_lambda->c_name = c_name;
+ p_lambda->p_list_args = p_list_args;
+ p_lambda->p_listelem = p_listelem;
+ p_lambda->p_listelem_end = p_listelem_end;;
+ p_lambda->p_frame = p_frame;
+
+ return (p_lambda);
+}
+
+void
+lambda_delete(Lambda *p_lambda) {
+ if (p_lambda->p_list_args)
+ list_delete(p_lambda->p_list_args);
+ free(p_lambda);
+}
+
+void
+lambda_print(Lambda *p_lambda) {
+ printf("+ST_LAMBDA(name=%s;args=", p_lambda->c_name);
+
+ if (p_lambda->p_list_args) {
+ unsigned i_count = p_lambda->p_list_args->i_size;
+ ListIterator *p_iter = listiterator_new(p_lambda->p_list_args);
+
+ while (listiterator_has_next(p_iter)) {
+ char *c_name = listiterator_next(p_iter);
+ if (--i_count == 0)
+ printf("%s", c_name);
+ else
+ printf("%s ", c_name);
+ }
+
+ listiterator_delete(p_iter);
+ }
+ printf(")\n( ");
+
+ ListIterator *p_iter = listiterator_new_from_elem(p_lambda->p_listelem);
+ Token *p_token = listiterator_current(p_iter);
+ ListElem *p_listelem_end = p_lambda->p_listelem_end;
+
+
+ while (listiterator_has_next(p_iter)) {
+ p_token = listiterator_next(p_iter);
+ printf("%s ", p_token->c_val);
+
+ if (listiterator_current_elem_equals(p_iter, p_listelem_end))
+ goto LAMBDA_PRINT_END;
+ }
+
+ ERROR_EOB;
+
+LAMBDA_PRINT_END:
+
+ printf("\n");
+ listiterator_delete(p_iter);
+}
+
diff --git a/src/core/lambda.h b/src/core/lambda.h
new file mode 100644
index 0000000..8377c30
--- /dev/null
+++ b/src/core/lambda.h
@@ -0,0 +1,55 @@
+/*:*
+ *: File: ./src/core/lambda.h
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
+ *: 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
+ *: notice, this list of conditions and the following disclaimer.
+ *: * 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
+ *: 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
+ *: 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)
+ *: 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
+ *: POSSIBILITY OF SUCH DAMAGE.
+ *:*/
+
+#ifndef LAMBDA_H
+#define LAMBDA_H
+
+#include "../defines.h"
+#include "../data/list.h"
+#include "frame.h"
+
+typedef struct _Lambda {
+ char *c_name;
+ List *p_list_args;
+ ListElem *p_listelem; // Body code starts here
+ ListElem *p_listelem_end; // Body code ends here
+ Frame *p_frame;
+} Lambda;
+
+Lambda* lambda_new(char *c_name, List *p_list_args, ListElem *p_listelem, ListElem *p_listelem_end, Frame *p_frame);
+void lambda_delete(Lambda *p_lambda);
+void lambda_print(Lambda *p_lambda);
+//void lambda_eval(Lambda *p_pambda, ListIterator *p_iter);
+
+#endif
diff --git a/src/core/promise.c b/src/core/promise.c
new file mode 100644
index 0000000..fa50e78
--- /dev/null
+++ b/src/core/promise.c
@@ -0,0 +1,60 @@
+/*:*
+ *: File: ./src/core/promise.c
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
+ *: 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
+ *: notice, this list of conditions and the following disclaimer.
+ *: * 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
+ *: 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
+ *: 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)
+ *: 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
+ *: POSSIBILITY OF SUCH DAMAGE.
+ *:*/
+
+#include "promise.h"
+
+#define _ERROR(m,t) \
+ ERROR(\
+ "%s: Promise error in %s line %d pos %d near '%s'", m, \
+ t->c_filename, \
+ t->i_line_nr, \
+ t->i_pos_nr, \
+ t->c_val \
+ )
+
+Promise*
+promise_new(Token *p_token_lambda, ListElem *p_elem_start) {
+ Promise *p_promise = malloc(sizeof(Promise));
+
+ p_promise->p_token_lambda = p_token_lambda;
+ p_promise->p_elem_start = p_elem_start;
+
+ return (p_promise);
+}
+
+void
+promise_delete(Promise *p_promise) {
+ free(p_promise);
+}
+
diff --git a/src/core/promise.h b/src/core/promise.h
new file mode 100644
index 0000000..76cd162
--- /dev/null
+++ b/src/core/promise.h
@@ -0,0 +1,49 @@
+/*:*
+ *: File: ./src/core/promise.h
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
+ *: 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
+ *: notice, this list of conditions and the following disclaimer.
+ *: * 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
+ *: 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
+ *: 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)
+ *: 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
+ *: POSSIBILITY OF SUCH DAMAGE.
+ *:*/
+
+#ifndef PROMISE_H
+#define PROMISE_H
+
+#include "../data/list.h"
+#include "token.h"
+
+typedef struct {
+ ListElem *p_elem_start;
+ Token *p_token_lambda;
+} Promise;
+
+Promise* promise_new(Token *p_token_lambda, ListElem *p_elem_start);
+void promise_delete(Promise *p_promise);
+
+#endif /* PROMISE_H */
diff --git a/src/core/scanner.c b/src/core/scanner.c
index 96d3756..a2b2b10 100644
--- a/src/core/scanner.c
+++ b/src/core/scanner.c
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/core/scanner.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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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.
*:*/
@@ -38,8 +37,7 @@
#include <ctype.h>
#include <string.h>
-const char _TOKENENDS[] = "}])+-*/={([<>;:,.!";
-#define _ADD_SEMICOLON_INDEX 2
+const char _TOKEN_ENDS[] = "()";
int _CODESTR_INDEX = 0;
Scanner*
@@ -70,8 +68,8 @@ scanner_new(List *p_list_token, Tupel *p_tupel_argv) {
p_scanner->i_current_line_nr = 1;
p_scanner->i_current_pos_nr = 0;
- p_scanner->i_num_tokenends = strlen(_TOKENENDS);
- p_scanner->tt_last = TT_NONE;
+ p_scanner->i_num_tokenends = strlen(_TOKEN_ENDS);
+ p_scanner->tt_last = TT_IDENT;
return p_scanner;
}
@@ -83,66 +81,6 @@ scanner_delete(Scanner *p_scanner) {
free(p_scanner);
}
-void
-_add_semicolon_to_list(Scanner *p_scanner) {
- int i_token_len = 1;
- char *c_token = calloc(2, sizeof(char*));
- c_token[0] = ';';
- c_token[1] = '\0';
- scanner_add_token(p_scanner, &c_token, &i_token_len, TT_SEMICOLON);
-}
-
-void
-scanner_post_task(Scanner *p_scanner) {
- List *p_list_token = scanner_get_list_token(p_scanner);
- ListIterator *p_iter = listiterator_new(p_list_token);
-
- Token *pt_last[] = { NULL, NULL };
- TokenType tt_last[] = { TT_NONE, TT_NONE };
-
- while (listiterator_has_next(p_iter)) {
- ListElem *p_le = listiterator_next_elem(p_iter);
- Token *p_token = p_le->p_val;
- TokenType tt_cur = token_get_tt(p_token);
-
- if (pt_last[0]) {
- if (tt_cur == TT_INTEGER && tt_last[1] == TT_DOT
- && tt_last[0] == TT_INTEGER) {
-
- token_ref_down(pt_last[0]);
- token_ref_down(pt_last[1]);
-
- char *c_2 = token_get_val(p_token);
- char *c_0 = token_get_val(pt_last[0]);
- int i_len = strlen(c_2) + strlen(c_0) + 1;
- char *c_new = calloc(i_len+1, sizeof(char));
-
- sprintf(c_new, "%s.%s", c_0, c_2);
- free(c_2);
- c_new[i_len] = 0;
-
- token_set_val(p_token, c_new);
- token_set_tt(p_token, TT_DOUBLE);
- token_set_dval(p_token, atof(c_new));
-
- list_remove_elem(p_list_token, p_le->p_prev);
- list_remove_elem(p_list_token, p_le->p_prev);
-
- pt_last[0] = pt_last[1] = NULL;
- tt_last[0] = tt_last[1] = TT_NONE;
- }
- }
-
- tt_last[0] = tt_last[1];
- tt_last[1] = tt_cur;
-
- pt_last[0] = pt_last[1];
- pt_last[1] = p_token;
- }
-
- listiterator_delete(p_iter);
-}
-
_Bool
_scanner_has_next_char(Scanner *p_scanner) {
if (p_scanner->fp)
@@ -160,7 +98,7 @@ _scanner_get_next_char(Scanner *p_scanner) {
}
void
-scanner_run(Fype *p_fype) {
+scanner_run(PBSc *p_fype) {
Scanner *p_scanner = scanner_new(p_fype->p_list_token,
p_fype->p_tupel_argv);
@@ -211,7 +149,6 @@ scanner_run(Fype *p_fype) {
}
{
int i_num_nl = 0;
- //_Bool flag = false;
do {
c = _scanner_get_next_char(p_scanner);
if ( c == '\n' ) {
@@ -229,7 +166,6 @@ scanner_run(Fype *p_fype) {
c_token[i_token_len-1] = '"';
} else {
- //flag = true;
break;
}
@@ -246,9 +182,6 @@ scanner_run(Fype *p_fype) {
if (i_num_nl)
p_scanner->i_current_line_nr += i_num_nl;
-
- //if (flag)
- // _add_semicolon_to_list(p_scanner);
}
break;
@@ -268,27 +201,31 @@ scanner_run(Fype *p_fype) {
break;
+ case '(':
+ case '.':
+ {
+ if (i_token_len) {
+ TokenType tt_cur = scanner_get_tt_cur(c_token);
+ scanner_add_token(p_scanner, &c_token, &i_token_len, tt_cur);
+ }
+ ++i_token_len;
+ c_token = realloc(c_token, sizeof(char) * i_token_len + 1);
+ c_token[i_token_len-1] = c;
+ c_token[i_token_len] = 0;
+ TokenType tt_cur = scanner_get_tt_cur(c_token);
+ scanner_add_token(p_scanner, &c_token, &i_token_len, tt_cur);
+ }
+ break;
+
default:
if (i_token_len) {
TokenType tt_cur = scanner_get_tt_cur(c_token);
- if (tt_cur == TT_PARANT_CR && p_scanner->tt_last == TT_STRING)
- _add_semicolon_to_list(p_scanner);
-
- char d = c_token[i_token_len-1];
- if ((!isalpha(d) && !isdigit(d) /*&& d != '-'*/) &&
- (isalpha(c) || isdigit(c))) {
-
- scanner_add_token(p_scanner, &c_token, &i_token_len, tt_cur);
-
- } else {
- for (int i = 0; i < p_scanner->i_num_tokenends; ++i) {
- if (_TOKENENDS[i] == c) {
- scanner_add_token(p_scanner, &c_token,
- &i_token_len, tt_cur);
- if (i < _ADD_SEMICOLON_INDEX)
- _add_semicolon_to_list(p_scanner);
- break;
- }
+
+ for (int i = 0; i < p_scanner->i_num_tokenends; ++i) {
+ if (_TOKEN_ENDS[i] == c) {
+ scanner_add_token(p_scanner, &c_token,
+ &i_token_len, tt_cur);
+ break;
}
}
}
@@ -305,14 +242,6 @@ scanner_run(Fype *p_fype) {
scanner_add_token(p_scanner, &c_token, &i_token_len, tt_cur);
}
- /* Check if there is a ; missing */
- List *p_list_token = scanner_get_list_token(p_scanner);
- Token *p_last_token = list_last(p_list_token);
- if (token_get_tt(p_last_token) != TT_SEMICOLON)
- _add_semicolon_to_list(p_scanner);
-
- scanner_post_task(p_scanner);
-
char *c_filename = scanner_get_filename(p_scanner);
scanner_delete(p_scanner);
@@ -345,7 +274,6 @@ scanner_add_token(Scanner *p_scanner, char **cc_token, int *p_token_len,
p_scanner->c_filename);
list_add_back(p_list_token, p_token);
- token_ref_up(p_token);
*cc_token = malloc(sizeof(char));
(*cc_token)[0] = 0;
@@ -359,12 +287,7 @@ scanner_get_tt_cur(char *c_token) {
if (isdigit(c_token[0]))
return TT_INTEGER;
- if (c_token[0] == '-' && 1 < strlen(c_token) && isdigit(c_token[1]))
- return TT_INTEGER;
-
- TokenType tt_cur = get_tt(c_token);
-
- return tt_cur == TT_NONE ? TT_IDENT : tt_cur;
+ return (get_tt(c_token));
}
void
diff --git a/src/core/scanner.h b/src/core/scanner.h
index 7fb20d0..b15707b 100644
--- a/src/core/scanner.h
+++ b/src/core/scanner.h
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/core/scanner.h
- *: 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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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.
*:*/
@@ -59,10 +58,9 @@ typedef struct {
TokenType tt_last;
} Scanner;
+void scanner_run(PBSc *p_fype);
Scanner *scanner_new(List *p_list_token, Tupel *p_tupel_argv);
-void scanner_post_task(Scanner *p_scanner);
void scanner_delete(Scanner *p_scanner);
-void scanner_run(Fype *p_fype);
void scanner_add_token(Scanner *p_scanner, char **cc_token, int *p_token_len,
TokenType tt_cur);
TokenType scanner_get_tt_cur(char *c_token);
diff --git a/src/core/token.c b/src/core/token.c
index b019a83..a0a6ad0 100644
--- a/src/core/token.c
+++ b/src/core/token.c
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/core/token.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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,175 +15,54 @@
*: * 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 buetow.org 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 C. 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 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)
*: 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 "token.h"
-#include "garbage.h"
-
#define CHECK(...) if (!strcmp(c_token, __VA_ARGS__)) return
+#define CASE(t,r) case t: return r;
long TOKEN_ID_COUNTER = 0;
TokenType
get_tt(char *c_token) {
- CHECK("if") TT_IF;
- CHECK("ifnot") TT_IFNOT;
- CHECK("else") TT_ELSE;
- CHECK("break") TT_BREAK;
- CHECK("while") TT_WHILE;
- CHECK("until") TT_UNTIL;
- CHECK("int") TT_INT;
- CHECK("next") TT_NEXT;
- CHECK("defined") TT_DEFINED;
- CHECK("undef") TT_UNDEF;
- CHECK("syms") TT_SYMS;
- CHECK("ret") TT_RET;
- CHECK("const") TT_CONST;
- CHECK("proc") TT_PROC;
- CHECK("func") TT_FUNC;
- CHECK("my") TT_MY;
- CHECK("arr") TT_ARR;
- CHECK("!") TT_NOT;
- CHECK("!=") TT_NEQ;
- CHECK("=~") TT_RE;
CHECK("(") TT_PARANT_L;
CHECK(")") TT_PARANT_R;
- CHECK("[") TT_PARANT_AL;
- CHECK("]") TT_PARANT_AR;
- CHECK("*") TT_MULT;
- CHECK("+") TT_ADD;
- CHECK("++") TT_INCR;
- CHECK(",") TT_COMMA;
- CHECK("-") TT_SUB;
- CHECK("--") TT_DECR;
+ CHECK("'") TT_SQUOTE;
CHECK(".") TT_DOT;
- CHECK("/") TT_DIV;
- CHECK("\\") TT_VID;
- CHECK(":") TT_DDOT;
- CHECK("==") TT_EQ;
- CHECK(";") TT_SEMICOLON;
- CHECK("<<") TT_LSHIFT;
- CHECK(">>") TT_RSHIFT;
- CHECK("and") TT_AND;
- CHECK("&") TT_AAND;
- CHECK("or") TT_OR;
- CHECK("xor") TT_XOR;
- CHECK("=") TT_ASSIGN;
- CHECK("<") TT_LT;
- CHECK(">") TT_GT;
- CHECK(">=") TT_GE;
- CHECK("<=") TT_LE;
- CHECK("{") TT_PARANT_CL;
- CHECK("}") TT_PARANT_CR;
- return TT_NONE;
+ return TT_IDENT;
}
-#define CASE(t,r) case t: return r;
-
char*
tt_get_name(TokenType tt_cur) {
switch (tt_cur) {
- CASE(START_TERMINALS, "START_TERMINALS")
- CASE(START_TYPES, "START_TYPES")
- CASE(START_NUMERICAL, "START_NUMERICAL")
- CASE(START_ASSIGNABLES, "START_ASSIGNABLES")
- CASE(TT_IDENT, "TT_IDENT")
- CASE(TT_DOUBLE,"TT_DOUBLE")
- CASE(TT_STRING,"TT_STRING")
- CASE(TT_ARRAY,"TT_ARRAY")
- CASE(TT_INTEGER,"TT_INTEGER")
- CASE(TT_BOOL,"TT_BOOL")
- CASE(END_ASSIGNABLES, "END_ASSIGNABLES")
- CASE(END_NUMERICAL, "END_NUMERICAL")
- CASE(END_TYPES, "END_TYPES")
-
- // Keywords
- CASE(START_KEYWORDS, "START_KEYWORDS")
- CASE(TT_ELSE,"TT_ELSE")
- CASE(TT_BREAK,"TT_BREAK")
- CASE(TT_IF,"TT_IF")
- CASE(TT_IFNOT,"TT_IFNOT")
- CASE(TT_RET,"TT_RET")
- CASE(TT_CONST,"TT_CONST")
- CASE(TT_PROC,"TT_PROC")
- CASE(TT_FUNC,"TT_FUNC")
- CASE(TT_MY,"TT_MY")
- CASE(TT_ARR,"TT_ARR")
- CASE(TT_WHILE,"TT_WHILE")
- CASE(TT_UNTIL,"TT_UNTIL")
- CASE(TT_NEXT,"TT_NEXT")
- CASE(TT_DEFINED,"TT_DEFINED")
- CASE(TT_UNDEF,"TT_UNDEF")
- CASE(TT_SYMS,"TT_SYMS")
- CASE(TT_INT,"TT_INT")
- CASE(END_KEYWORDS, "END_KEYWORDS")
-
- // Braces
- CASE(START_PARANTS, "START_PARANTS")
- CASE(TT_PARANT_CL,"TT_PARANT_CL")
- CASE(TT_PARANT_CR,"TT_PARANT_CR")
- CASE(TT_PARANT_AL,"TT_PARANT_AL")
- CASE(TT_PARANT_AR,"TT_PARANT_AR")
CASE(TT_PARANT_L,"TT_PARANT_L")
CASE(TT_PARANT_R,"TT_PARANT_R")
- CASE(END_PARANTS, "END_PARANTS")
-
- // Operators
- CASE(START_OPERATORS, "START_OPERATORS")
- CASE(TT_ADD,"TT_ADD")
- CASE(TT_ASSIGN,"TT_ASSIGN")
- CASE(TT_COMMA,"TT_COMMA")
- CASE(TT_DDOT,"TT_DDOT")
- CASE(TT_DECR,"TT_DECR")
- CASE(TT_DIV,"TT_DIV")
- CASE(TT_VID,"TT_VID")
+ CASE(TT_INTEGER,"TT_INTEGER")
+ CASE(TT_DOUBLE,"TT_DOUBLE")
+ CASE(TT_STRING,"TT_STRING")
CASE(TT_DOT,"TT_DOT")
- CASE(TT_EQ,"TT_EQ")
- CASE(TT_LE,"TT_LE")
- CASE(TT_LT,"TT_LT")
- CASE(TT_GE,"TT_GE")
- CASE(TT_GT,"TT_GT")
- CASE(TT_INCR,"TT_INCR")
- CASE(TT_LSHIFT,"TT_LSHIFT")
- CASE(TT_RSHIFT,"TT_RSHIFT")
- CASE(TT_AND,"TT_AND")
- CASE(TT_AAND,"TT_AAND")
- CASE(TT_OR,"TT_OR")
- CASE(TT_XOR,"TT_XOR")
- CASE(TT_NOT,"TT_NOT")
- CASE(TT_MULT,"TT_MULT")
- CASE(TT_NEQ,"TT_NEQ")
- CASE(TT_RE,"TT_RE")
- CASE(TT_NOTEQ,"TT_NOTEQ")
- CASE(TT_SEMICOLON,"TT_SEMICOLON")
- CASE(TT_SUB,"TT_SUB")
- CASE(END_OPERATORS, "END_OPERATORS")
- CASE(END_TERMINALS, "END_TERMINALS")
-
- // Diverse
- CASE(TT_NONE,"TT_NONE")
- CASE(TT_END_OF_CODE,"TT_END_OF_CODE")
+ CASE(TT_SQUOTE,"TT_SQUOTE")
+ CASE(TT_IDENT,"TT_IDENT")
}
- // Never reach this point
- return "XXXXXXX";
+ return "TT_IDENT";
}
Token*
@@ -193,140 +71,26 @@ token_new(char *c_val, TokenType tt_cur, int i_line_nr,
Token *p_token = token_new_dummy();
p_token->c_val = c_val;
- p_token->i_val = 0;
- p_token->d_val = 0;
p_token->tt_cur = tt_cur;
p_token->i_line_nr = i_line_nr;
p_token->i_pos_nr = i_pos_nr;
p_token->c_filename = c_filename;
- p_token->p_array = NULL;
-
- switch (tt_cur) {
- case TT_INTEGER:
- p_token->i_val = atoi(c_val);
- break;
- case TT_DOUBLE:
- {
- p_token->d_val = atof(c_val);
- break;
- }
- case TT_ARRAY:
- {
- p_token->p_array = array_new();
- break;
- }
- NO_DEFAULT;
- }
-
- return p_token;
-}
-
-Token*
-token_new_integer(int i_val) {
- Token *p_token = token_new_dummy();
- token_set_tt(p_token, TT_INTEGER);
- token_set_ival(p_token, i_val);
-
- return (p_token);
-}
-
-Token*
-token_new_double(double d_val) {
- Token *p_token = token_new_dummy();
- token_set_tt(p_token, TT_DOUBLE);
- token_set_dval(p_token, d_val);
return (p_token);
}
Token*
-token_new_string(char *c_val) {
- Token *p_token = token_new_dummy();
- token_set_tt(p_token, TT_STRING);
-
- p_token->c_val = calloc(strlen(c_val)+1, sizeof(char));
- strcpy(p_token->c_val, c_val);
-
- return (p_token);
-}
-
-Token*
-token_new_array(int i_size) {
- Token *p_token = token_new_dummy();
-
- token_set_tt(p_token, TT_ARRAY);
- p_token->p_array = array_new();
-
- array_resize(p_token->p_array, i_size);
-
- return (p_token);
-}
-
-
-Token*
-token_new_(char *c_val, TokenType tt_cur, char *c_filename) {
- return token_new(c_val, tt_cur, -1, -1, c_filename);
-}
-
-Token*
token_new_dummy() {
Token *p_token = malloc(sizeof(Token));
p_token->c_val = NULL;
- p_token->tt_cur = TT_NONE;
+ p_token->tt_cur = TT_IDENT;
p_token->i_line_nr = -1;
p_token->i_pos_nr = -1;
p_token->c_filename = NULL;
p_token->u_token_id = TOKEN_ID_COUNTER++;
- p_token->i_ref_count = 0;
- p_token->p_array = NULL;
-
- /* Register the token in the garbage collector */
- garbage_add_token(p_token);
-
- return p_token;
-}
-
-Token*
-token_new_copy(Token *p_token) {
- Token *p_token_copy = malloc(sizeof(Token));
- p_token->u_token_id = TOKEN_ID_COUNTER++;
-
- if (p_token_copy == NULL)
- ERROR("Memory alloc error");
-
- p_token->p_array = NULL;
- token_copy_vals(p_token_copy, p_token);
- p_token_copy->i_ref_count = 0;
-
- /* Register the token in the garbage collector */
- garbage_add_token(p_token_copy);
-
- return (p_token_copy);
-}
-void token_copy_vals(Token *p_token_to, Token *p_token_from) {
- int i_len;
-
- if (p_token_from->c_val) {
- i_len = strlen(p_token_from->c_val);
- p_token_to->c_val = calloc(i_len+1, sizeof(char));
- strcpy(p_token_to->c_val, p_token_from->c_val);
-
- } else {
- p_token_to->c_val = NULL;
- }
-
- p_token_to->tt_cur = p_token_from->tt_cur;
- p_token_to->i_val = p_token_from->i_val;
- p_token_to->d_val = p_token_from->d_val;
- 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)
- // Copy all tokens by reference (pointers)
- p_token_to->p_array = array_new_copy(p_token_from->p_array);
+ return (p_token);
}
void
@@ -335,81 +99,31 @@ token_delete_cb(void *p_void) {
}
void
-token_ref_down_cb(void *p_void) {
- Token *p_token = p_void;
- token_ref_down(p_token);
-}
-
-void*
-token_copy_cb(void *p_void) {
- return (token_new_copy(p_void));
-}
-
-void
token_delete(Token *p_token) {
- if (token_ref_down(p_token) <= 0) {
- if (p_token->i_ref_count == 0) {
-#ifdef DEBUG_TOKEN_REFCOUNT
- printf("DEBUG::TOKEN::REFCOUNT: Token ref count is 0 == %d\n",
- p_token->i_ref_count);
-#endif /* DEBUG_TOKEN_REFCOUNT */
- if (p_token->c_val)
- free(p_token->c_val);
+}
- if (NULL != p_token->p_array)
- array_delete_iterate(p_token->p_array, token_delete_cb);
+_Bool
+token_is(Token *p_token, char *c_str) {
+ if (p_token->tt_cur == TT_IDENT && strcmp(p_token->c_val, c_str) == 0)
+ return true;
- free(p_token);
- }
-#ifdef DEBUG_TOKEN_REFCOUNT
- else {
- printf("DEBUG::TOKEN::REFCOUNT: Token ref count is 0 > %d\n",
- p_token->i_ref_count);
- }
-#endif /* DEBUG_TOKEN_REFCOUNT */
- }
-#ifdef DEBUG_TOKEN_REFCOUNT
- else {
- printf("DEBUG::TOKEN::REFCOUNT: Token ref count is 0 < %d\n",
- p_token->i_ref_count);
- }
-#endif /* DEBUG_TOKEN_REFCOUNT */
+ return false;
}
void
token_print(Token *p_token) {
- printf("(id=%05u, line=%05d, pos=%04d, type=%s, val=%s, ival=%d, dval=%f,"
- " refs=%d)",
+ printf("(id=%05u, line=%05d, pos=%04d, type=%s, val=%s)",
p_token->u_token_id,
p_token->i_line_nr,
p_token->i_pos_nr,
tt_get_name(p_token->tt_cur),
- p_token->c_val,
- p_token->i_val,
- p_token->d_val,
- p_token->i_ref_count);
+ p_token->c_val);
}
void
-token_print_val(Token *p_token) {
- TokenType tt = token_get_tt(p_token);
- switch (tt) {
- case TT_INTEGER:
- printf("(%s, %d)", tt_get_name(tt), token_get_ival(p_token));
- break;
- case TT_DOUBLE:
- printf("(%s, %f)", tt_get_name(tt), token_get_dval(p_token));
- break;
- case TT_STRING:
- printf("(%s, %s)", tt_get_name(tt), token_get_val(p_token));
- break;
- case TT_ARRAY:
- printf("(%s, size:%d)", tt_get_name(tt),
- array_get_size(p_token->p_array));
- break;
- default:
- ERROR("Ouups(%s)!", tt_get_name(tt));
- }
+token_print_ln(Token *p_token) {
+ token_print(p_token);
+ printf("\n");
}
void
@@ -419,4 +133,3 @@ token_print_cb(void *p_void) {
token_print(p_token);
printf("\n");
}
-
diff --git a/src/core/token.h b/src/core/token.h
index 514a02d..8f1ab53 100644
--- a/src/core/token.h
+++ b/src/core/token.h
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/core/token.h
- *: 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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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.
*:*/
@@ -39,157 +38,38 @@
#include "../defines.h"
#include "../data/array.h"
-#define IS_TERMINAL(t) (START_TERMINALS < t && t < END_TERMINALS)
-#define IS_NOT_TERMINAL(t) !IS_TERMINAL(t)
-#define IS_TYPE(t) (START_TYPES < t && t < END_TYPES)
-#define IS_NOT_TYPE(t) !IS_TYPE(t)
-#define IS_KEYWORD(t) (START_KEYWORDS < t && t < END_KEYWORDS)
-#define IS_NOT_KEYWORD(t) !IS_KEYWORD(t)
-#define IS_OPERATOR(t) (START_OPERATORS < t && t < END_OPERATORS)
-#define IS_NOT_OPERATOR(t) !IS_OPERATOR(t)
-#define IS_NON_TERMINAL(t) (START_NON_TERMINALS < t && t < END_NON_TERMINALS)
-#define IS_NOT_NON_TERMINAL(t) !IS_NON_TERMINAL(t)
-#define IS_IDENT(t) (t == TT_IDENT)
-#define IS_NOT_IDENT(t) !(IS_IDENT(t))
-#define IS_ASSIGNABLE(t) (START_ASSIGNABLES < t && t < END_ASSIGNABLES)
-#define IS_NUMERICAL(t) (START_NUMERICAL < t && t < END_NUMERICAL)
-#define IS_NOT_NUMERICAL(t) !(IS_NUMERICAL(t))
-
-#define token_get_filename(t) \
- (t->c_filename != NULL ? t->c_filename : "Code string")
-#define token_get_line_nr(t) t->i_line_nr
-#define token_get_pos_nr(t) t->i_pos_nr
-#define token_get_tt(t) (t ? t->tt_cur : TT_NONE)
-#define token_get_val(t) t->c_val
-#define token_get_ival(t) t->i_val
-#define token_get_dval(t) t->d_val
-#define token_set_tt(t,tt) t->tt_cur = tt
-#define token_set_val(t,c) t->c_val = c
-#define token_set_ival(t,i) t->i_val = i
-#define token_set_dval(t,d) t->d_val = d
-#define token_set_pos(t, l, p) t->i_line_nr = l; t->i_pos_nr = p
-#define token_get_posnr(t) t->i_pos_nr
-#define token_get_linenr(t) t->i_line_nr
-#define token_ref_up(t) ++t->i_ref_count
-#define token_ref_down(t) --t->i_ref_count
-#define TOKEN_GET_ARRAY(t) t->p_array
-
typedef enum {
- // Diverse
- TT_NONE,
- TT_END_OF_CODE,
- TT_BOOL, // Temporaly disabled, maybe NUMERICAL in future again
-
- // Diverse types
- START_TERMINALS,
- START_TYPES,
- START_ASSIGNABLES,
- START_NUMERICAL,
- TT_INTEGER,
- TT_DOUBLE,
- END_NUMERICAL,
- TT_STRING,
- TT_ARRAY,
- END_ASSIGNABLES,
TT_IDENT,
- END_TYPES,
-
- // Keywords
- START_KEYWORDS,
- TT_ELSE,
- TT_BREAK,
- TT_IF,
- TT_IFNOT,
- TT_RET,
- TT_CONST,
- TT_PROC,
- TT_FUNC,
- TT_MY,
- TT_ARR,
- TT_WHILE,
- TT_UNTIL,
- TT_NEXT,
- TT_INT,
- TT_DEFINED,
- TT_UNDEF,
- TT_SYMS,
- END_KEYWORDS,
-
- START_PARANTS,
- TT_PARANT_CL,
- TT_PARANT_CR,
- TT_PARANT_AL,
- TT_PARANT_AR,
TT_PARANT_L,
TT_PARANT_R,
- END_PARANTS,
-
- // Operators
- START_OPERATORS,
- TT_ADD,
- TT_AND,
- TT_AAND,
- TT_ASSIGN,
- TT_COMMA,
- TT_DDOT,
- TT_DECR,
- TT_DIV,
- TT_DOT,
- TT_EQ,
- TT_GE,
- TT_GT,
- TT_INCR,
- TT_LE,
- TT_LSHIFT,
- TT_LT,
- TT_MULT,
- TT_NEQ,
- TT_NOT,
- TT_NOTEQ,
- TT_OR,
- TT_RE,
- TT_RSHIFT,
- TT_SEMICOLON,
- TT_SUB,
- TT_VID,
- TT_XOR,
- END_OPERATORS,
-
- END_TERMINALS,
-
+ TT_INTEGER,
+ TT_DOUBLE,
+ TT_STRING,
+ TT_SQUOTE,
+ TT_DOT
} TokenType;
typedef struct {
TokenType tt_cur;
char *c_val;
- int i_val;
- double d_val;
int i_line_nr;
int i_pos_nr;
char *c_filename;
unsigned int u_token_id;
- int i_ref_count;
- Array *p_array;
} Token;
Token* token_new(char *c_val, TokenType tt_cur, int i_line_nr,
int i_pos_nr, char *c_filename);
-Token* token_new_integer(int i_val);
-Token* token_new_couble(double d_val);
-Token* token_new_string(char *c_val);
-Token* token_new_array(int i_size);
-Token* token_new_copy(Token *p_token);
-Token* token_new_(char *c_val, TokenType tt_cur, char *c_filename);
Token* token_new_dummy();
-void token_copy_vals(Token *p_token_to, Token *p_token_from);
void token_delete(Token *p_token);
void token_delete_cb(void *p_token);
-void token_ref_down_cb(void *p_token);
void* token_copy_cb(void *p_token);
char* tt_get_name(TokenType tt_cur);
void token_print_cb(void *p_void);
void token_print(Token *p_token);
+void token_print_ln(Token *p_token);
void token_print_val(Token *p_token);
+_Bool token_is(Token *p_token, char *c_str);
TokenType get_tt(char *c_token);
#endif
diff --git a/src/core/tools.c b/src/core/tools.c
new file mode 100644
index 0000000..6b6dbab
--- /dev/null
+++ b/src/core/tools.c
@@ -0,0 +1,64 @@
+/*:*
+ *: File: ./src/core/tools.c
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
+ *: 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
+ *: notice, this list of conditions and the following disclaimer.
+ *: * 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
+ *: 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
+ *: 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)
+ *: 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
+ *: POSSIBILITY OF SUCH DAMAGE.
+ *:*/
+
+#include "tools.h"
+#include "token.h"
+#include "../defines.h"
+
+void
+tool_skip_block(ListIterator *p_iter, int i_offset) {
+ Token *p_token = listiterator_current(p_iter);
+
+ do {
+ if (p_token->tt_cur == TT_PARANT_R && --i_offset == 0) {
+ //printf("::DoneSkip<%d>: %s\n", i_offset, p_token->c_val);
+ return;
+
+ } else if (p_token->tt_cur == TT_PARANT_L) {
+ ++i_offset;
+
+ } else if (i_offset < 0) {
+ ERROR_INTERPRET("Fatal Error", p_token);
+ }
+
+ //printf("::Skipping<%d>: %s\n", i_offset, p_token->c_val);
+ p_token = listiterator_next(p_iter);
+ } while (listiterator_has_next(p_iter));
+
+ if (p_token->tt_cur == TT_PARANT_R)
+ return;
+
+ ERROR_EOB;
+}
+
diff --git a/src/core/tools.h b/src/core/tools.h
new file mode 100644
index 0000000..19d9fa6
--- /dev/null
+++ b/src/core/tools.h
@@ -0,0 +1,42 @@
+/*:*
+ *: File: ./src/core/tools.h
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
+ *: 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
+ *: notice, this list of conditions and the following disclaimer.
+ *: * 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
+ *: 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
+ *: 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)
+ *: 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
+ *: POSSIBILITY OF SUCH DAMAGE.
+ *:*/
+
+#ifndef TOOLS_H
+#define TOOLS_H
+
+#include "../fype.h"
+
+void tool_skip_block(ListIterator *p_iter, int i_offset);
+
+#endif /* TOOLS_H */
diff --git a/src/core/variable.c b/src/core/variable.c
new file mode 100644
index 0000000..2b924a5
--- /dev/null
+++ b/src/core/variable.c
@@ -0,0 +1,59 @@
+/*:*
+ *: File: ./src/core/variable.c
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
+ *: 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
+ *: notice, this list of conditions and the following disclaimer.
+ *: * 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
+ *: 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
+ *: 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)
+ *: 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
+ *: POSSIBILITY OF SUCH DAMAGE.
+ *:*/
+
+#include "variable.h"
+#include "token.h"
+
+Variable*
+variable_new(char *c_name, Token *p_token,Frame *p_frame) {
+ Variable *p_variable = malloc(sizeof(Variable));
+
+ p_variable->c_name = c_name;
+ p_variable->p_token = p_token;
+ p_variable->p_frame = p_frame;
+
+ return (p_variable);
+}
+
+void
+variable_delete(Variable *p_variable) {
+ free(p_variable);
+}
+
+void
+variable_print(Variable *p_variable) {
+ printf("+ST_VARIABLE(name=%s,value=%s)\n",
+ p_variable->c_name,
+ p_variable->p_token->c_val);
+}
diff --git a/src/core/variable.h b/src/core/variable.h
new file mode 100644
index 0000000..7a7d27c
--- /dev/null
+++ b/src/core/variable.h
@@ -0,0 +1,52 @@
+/*:*
+ *: File: ./src/core/variable.h
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
+ *: 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
+ *: notice, this list of conditions and the following disclaimer.
+ *: * 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
+ *: 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
+ *: 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)
+ *: 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
+ *: POSSIBILITY OF SUCH DAMAGE.
+ *:*/
+
+#ifndef VARIABLE_H
+#define VARIABLE_H
+
+#include "../defines.h"
+#include "frame.h"
+#include "token.h"
+
+typedef struct _Variable {
+ char *c_name;
+ Token *p_token;
+ Frame *p_frame;
+} Variable;
+
+Variable* variable_new(char *c_name, Token *p_token,Frame *p_frame);
+void variable_delete(Variable *p_variable);
+void variable_print(Variable *p_variable);
+
+#endif
diff --git a/src/data/array.c b/src/data/array.c
index fbb4590..f50e998 100644
--- a/src/data/array.c
+++ b/src/data/array.c
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/data/array.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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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/data/array.h b/src/data/array.h
index 21c23d3..6800061 100644
--- a/src/data/array.h
+++ b/src/data/array.h
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/data/array.h
- *: 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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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/data/cons.c b/src/data/cons.c
new file mode 100644
index 0000000..7331167
--- /dev/null
+++ b/src/data/cons.c
@@ -0,0 +1,88 @@
+/*:*
+ *: File: ./src/data/cons.c
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
+ *: 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
+ *: notice, this list of conditions and the following disclaimer.
+ *: * 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
+ *: 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
+ *: 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)
+ *: 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
+ *: POSSIBILITY OF SUCH DAMAGE.
+ *:*/
+
+#include "cons.h"
+
+Cons*
+cons_new(void *p_val) {
+ Cons *p_cons = malloc(sizeof(Cons));
+
+ p_cons->p_val = p_val;
+ p_cons->p_succ = NULL;
+
+ return (p_cons);
+}
+
+void
+cons_delete(Cons *p_cons) {
+ free(p_cons);
+}
+
+void
+cons_delete_cb(void *p_cons) {
+ cons_delete(p_cons);
+}
+
+void
+cons_iterate(Cons *p_cons, void (*func)(void *)) {
+ if (p_cons != NULL && p_cons->p_val != NULL) {
+ (*func) (p_cons->p_val);
+ cons_iterate(p_cons->p_succ, func);
+ }
+}
+
+void*
+cons_car(Cons *p_cons) {
+ return (p_cons->p_val);
+}
+
+Cons*
+cons_cdr(Cons *p_cons) {
+ return (p_cons->p_succ);
+}
+
+Cons*
+cons_cons(Cons *p_cons, void *p_val) {
+ if (p_cons->p_val == NULL) {
+ p_cons->p_val = p_val;
+ return (p_cons);
+
+ } else if (p_val == NULL) {
+ return (p_cons);
+ }
+
+ Cons *p_new = cons_new(p_val);
+ p_new->p_succ = p_cons;
+ return (p_new);
+}
diff --git a/src/data/cons.h b/src/data/cons.h
new file mode 100644
index 0000000..130415b
--- /dev/null
+++ b/src/data/cons.h
@@ -0,0 +1,55 @@
+/*:*
+ *: File: ./src/data/cons.h
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
+ *: 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
+ *: notice, this list of conditions and the following disclaimer.
+ *: * 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
+ *: 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
+ *: 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)
+ *: 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
+ *: POSSIBILITY OF SUCH DAMAGE.
+ *:*/
+
+#ifndef CONS_H
+#define CONS_H
+
+#include <stdlib.h>
+
+#include "../defines.h"
+
+typedef struct Cons_ {
+ void *p_val;
+ struct Cons_ *p_succ;
+} Cons;
+
+Cons *cons_new(void *p_val);
+void cons_delete(Cons *p_cons);
+void cons_delete_cb(void *p_cons);
+void cons_iterate(Cons *p_cons, void (*func)(void *));
+void *cons_car(Cons *p_cons);
+Cons *cons_cdr(Cons *p_cons);
+Cons *cons_cons(Cons *p_cons, void *p_val);
+
+#endif
diff --git a/src/data/dat.c b/src/data/dat.c
index edd861f..b448cdc 100644
--- a/src/data/dat.c
+++ b/src/data/dat.c
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/data/dat.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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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/data/dat.h b/src/data/dat.h
index 6e638cb..dcc7928 100644
--- a/src/data/dat.h
+++ b/src/data/dat.h
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/data/dat.h
- *: 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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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/data/hash.c b/src/data/hash.c
index c892f2c..e196840 100644
--- a/src/data/hash.c
+++ b/src/data/hash.c
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/data/hash.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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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.
*:*/
@@ -297,3 +296,11 @@ hash_iterate_key(Hash *p_hash, void (*func)(void *, char *)) {
if (p_hash->p_elems[i].flag == 'o')
(*func) (p_hash->p_elems[i].p_val, p_hash->p_elems[i].c_key);
}
+
+_Bool
+hash_key_exists(Hash *p_hash, char *c_key) {
+ if (hash_get(p_hash, c_key))
+ return (true);
+
+ return (false);
+}
diff --git a/src/data/hash.h b/src/data/hash.h
index 13dd742..8bf0a49 100644
--- a/src/data/hash.h
+++ b/src/data/hash.h
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/data/hash.h
- *: 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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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.
*:*/
@@ -61,10 +60,10 @@ Hash*hash_new(unsigned i_size);
void hash_delete(Hash *p_hash);
RETCODE hash_insert(Hash *p_hash, char *c_key, void *p_val);
RETCODE hash_insert_ht(Hash *p_hash, char *c_key, void *p_val, TYPE type);
-void*hash_get(Hash *p_hash, char *c_key);
-void*hash_get_ht(Hash *p_hash, char *c_key, TYPE *p_type);
-void*hash_get_ht_addr(Hash *p_hash, char *c_key, TYPE *p_type, int *p_addr);
-void*hash_remove(Hash *p_hash, char *c_key);
+void* hash_get(Hash *p_hash, char *c_key);
+void* hash_get_ht(Hash *p_hash, char *c_key, TYPE *p_type);
+void* hash_get_ht_addr(Hash *p_hash, char *c_key, TYPE *p_type, int *p_addr);
+void* hash_remove(Hash *p_hash, char *c_key);
void hash_print(Hash *p_hash);
void hash_print_addrval(Hash *p_hash, int i_addr);
RETCODE hash_size(Hash *p_hash, int i_size);
@@ -77,6 +76,7 @@ int hash_nextaddr(Hash *p_hash, int i_max_tries,
HASH_OP OP);
void hash_iterate(Hash *p_hash, void (*func)(void *));
void hash_iterate_key(Hash *p_hash, void (*func)(void *, char *));
+_Bool hash_key_exists(Hash *p_hash, char *c_key);
#define hash_get_cur_size(hash) hash->i_cur_size
#define hash_get_size(hash) hash->i_size
diff --git a/src/data/list.c b/src/data/list.c
index f751fa0..e641133 100644
--- a/src/data/list.c
+++ b/src/data/list.c
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/data/list.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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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.
*:*/
@@ -343,6 +342,32 @@ listiterator_new(List *p_list) {
}
ListIterator*
+listiterator_new_from_elem(ListElem *p_listelem) {
+ if (!p_listelem)
+ return (NULL);
+
+ ListIterator *p_iter = malloc(sizeof(ListIterator));
+
+ p_iter->p_cur = p_listelem;
+ p_iter->b_reverse = false;
+ p_iter->func = NULL;
+
+ return (p_iter);
+}
+
+ListIterator*
+listiterator_new_from_elem_reverse(ListElem *p_listelem) {
+ ListIterator *p_iter = listiterator_new_from_elem(p_listelem);
+
+ if (!p_iter)
+ return (NULL);
+
+ p_iter->b_reverse = true;
+
+ return (p_iter);
+}
+
+ListIterator*
listiterator_new_reverse(List *p_list) {
if (!p_list)
return (NULL);
@@ -411,6 +436,27 @@ listiterator_current(ListIterator *p_iter) {
return (NULL);
}
+ListElem*
+listiterator_current_elem(ListIterator *p_iter) {
+ if (p_iter->p_cur)
+ return (p_iter->p_cur);
+
+ return (NULL);
+}
+
+ListElem*
+listiterator_prev_elem(ListIterator *p_iter) {
+ if (p_iter->p_cur) {
+ if (!p_iter->b_reverse)
+ return (p_iter->p_cur->p_prev);
+
+ else
+ return (p_iter->p_cur->p_next);
+ }
+
+ return (NULL);
+}
+
void*
listiterator_end(ListIterator *p_iter) {
void *p_ret = NULL;
@@ -421,6 +467,28 @@ listiterator_end(ListIterator *p_iter) {
return (p_ret);
}
+_Bool
+listiterator_current_elem_equals(ListIterator *p_iter, ListElem *p_listelem) {
+ if (!p_iter || !p_listelem)
+ return (false);
+
+ ListElem *p_listelem_current = listiterator_current_elem(p_iter);
+
+ if (!p_listelem_current)
+ return (false);
+
+ else if (p_listelem_current->p_next != p_listelem->p_next)
+ return (false);
+
+ else if (p_listelem_current->p_prev != p_listelem->p_prev)
+ return (false);
+
+ else if (p_listelem_current->p_val != p_listelem->p_val)
+ return (false);
+
+ return (true);
+}
+
ListElem*
listiterator_next_elem(ListIterator *p_iter) {
if (p_iter->p_cur) {
diff --git a/src/data/list.h b/src/data/list.h
index 1295485..fb6a9b8 100644
--- a/src/data/list.h
+++ b/src/data/list.h
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/data/list.h
- *: 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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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.
*:*/
@@ -97,14 +96,19 @@ void list_iterate3(List *p_list,
void list_iterate3_ptr(List *p_list,
void (*func)(void *, void *, void *),
void *p_void1, void *p_void2);
-ListIterator *listiterator_new(List *p_list);
-ListIterator *listiterator_new_reverse(List *p_list);
+ListIterator* listiterator_new(List *p_list);
+ListIterator* listiterator_new_from_elem(ListElem *p_listelem);
+ListIterator* listiterator_new_from_elem_reverse(ListElem *p_listelem);
+ListIterator* listiterator_new_reverse(List *p_list);
void listiterator_delete(ListIterator *p_iter);
-void *listiterator_next(ListIterator *p_iter);
-void *listiterator_prev(ListIterator *p_iter);
-void *listiterator_current(ListIterator *p_iter);
-void *listiterator_end(ListIterator *p_iter);
+void* listiterator_next(ListIterator *p_iter);
+void* listiterator_prev(ListIterator *p_iter);
+void* listiterator_current(ListIterator *p_iter);
+ListElem* listiterator_current_elem(ListIterator *p_iter);
+ListElem* listiterator_prev_elem(ListIterator *p_iter);
+void* listiterator_end(ListIterator *p_iter);
_Bool listiterator_has_next(ListIterator *p_iter);
+_Bool listiterator_current_elem_equals(ListIterator *p_iter, ListElem *p_listelem);
ListElem* listiterator_next_elem(ListIterator *p_iter);
void list_remove_elem(List *p_list, ListElem *p_elem_remove);
ListIteratorState* listiterator_get_state(ListIterator *p_iter);
diff --git a/src/data/map.c b/src/data/map.c
index 2437385..3c95dc2 100644
--- a/src/data/map.c
+++ b/src/data/map.c
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/data/map.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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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/data/map.h b/src/data/map.h
index c457529..c01dbe1 100644
--- a/src/data/map.h
+++ b/src/data/map.h
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/data/map.h
- *: 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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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/data/queue.c b/src/data/queue.c
index e6e6d7b..63987a0 100644
--- a/src/data/queue.c
+++ b/src/data/queue.c
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/data/queue.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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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/data/queue.h b/src/data/queue.h
index 5e24fce..227ce29 100644
--- a/src/data/queue.h
+++ b/src/data/queue.h
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/data/queue.h
- *: 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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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/data/stack.c b/src/data/stack.c
index 7e30f32..e6a60a4 100644
--- a/src/data/stack.c
+++ b/src/data/stack.c
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/data/stack.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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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/data/stack.h b/src/data/stack.h
index a54a894..395dd32 100644
--- a/src/data/stack.h
+++ b/src/data/stack.h
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/data/stack.h
- *: 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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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/data/tree.c b/src/data/tree.c
index 67f0b15..c55dcf1 100644
--- a/src/data/tree.c
+++ b/src/data/tree.c
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/data/tree.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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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.
*:*/
@@ -76,56 +75,19 @@ _tree_print_cb(void *p_void, void *p_indent) {
TreeNode *ptn = p_void;
_indent((int) p_indent);
-#ifdef FYPE
- TokenType tt = (TokenType) treenode_get_val(ptn);
-
- if (IS_NOT_TERMINAL(tt))
- goto no_token_val;
-
- Token *p_token = treenode_get_val2(ptn);
-
- if (!p_token)
- goto no_token_val;
-
- char *c_token_val = token_get_val(p_token);
- TokenType tt_token = token_get_tt(p_token);
-
- if (!c_token_val)
- c_token_val = "";
-
- printf(" %s=%s", tt_get_name(tt_token), c_token_val);
- return;
-
-no_token_val:
- printf(" %s", tt_get_name(tt));
-
-#else
printf(" %d", (int) treenode_get_val(ptn));
-#endif
}
void
_tree_print(TreeNode *p_treenode, int i_indent) {
- TokenType tt = (TokenType)treenode_get_val(p_treenode);
-
-#ifdef FYPE
- _Bool b_print_nl = false;
- if (IS_NOT_TERMINAL(tt)) {
- _indent(i_indent);
- printf("%s:", tt_get_name(tt));
- b_print_nl = true;
- }
-#else
- _indent(i_indent);
- printf("%s:", tt_get_name(tt));
-#endif
+ //TokenType tt = (TokenType)treenode_get_val(p_treenode);
+
+ //_indent(i_indent);
+ //printf("%s:", tt_get_name(tt));
array_iterate2(p_treenode->p_array_childs, _tree_print_cb, (void*) 0);
-#ifdef FYPE
- if (b_print_nl)
-#endif
- printf("\nTree ");
+ printf("\nTree ");
array_iterate2(p_treenode->p_array_childs,
_tree_print_cb2,
diff --git a/src/data/tree.h b/src/data/tree.h
index 6dc7d4b..ce9ecc4 100644
--- a/src/data/tree.h
+++ b/src/data/tree.h
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/data/tree.h
- *: 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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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,7 +39,7 @@
#include "array.h"
#include "stack.h"
-#ifdef FYPE
+#ifdef PBSC
#include "../core/token.h"
#endif
diff --git a/src/data/tupel.c b/src/data/tupel.c
index 1294fbf..68c0247 100644
--- a/src/data/tupel.c
+++ b/src/data/tupel.c
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/data/tupel.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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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/data/tupel.h b/src/data/tupel.h
index 35ad6d0..e5d0fe7 100644
--- a/src/data/tupel.h
+++ b/src/data/tupel.h
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/data/tupel.h
- *: 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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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/data/types.h b/src/data/types.h
index 3fbab40..2899dfe 100644
--- a/src/data/types.h
+++ b/src/data/types.h
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/data/types.h
- *: 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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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/defines.h b/src/defines.h
index 6721a47..9484784 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/defines.h
- *: 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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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.
*:*/
@@ -43,22 +42,19 @@
#include "build.h"
-#define COPYRIGHT "(c) Paul C. Buetow (2005 - 2008) <fype@dev.buetow.org>"
+#define COPYRIGHT "(c) Paul C. Buetow (2005 - 2010) <fype@dev.buetow.org>"
#define FYPE
#define GRAMMAR_MAP_SIZES 128
#define ARRAY_SIZE 16
#define HASH_MAXOCC 5
#define HASH_MKEYLEN 32
#define HASH_SCALE 10
-#define NAME "Fype0"
-#define ASSEMBLER "yasm"
+#define NAME "Fype2"
#define LINKER "cc"
#define SCANNER_BUFSIZE 512
-#define URL "<http://fype0.buetow.org>"
+#define URL "<http://fype.buetow.org>"
#define VERSION "Alpha Build"
-
-
#ifndef false
#define false (_Bool)0
#endif
@@ -98,4 +94,15 @@
#define STR_RESIZE(str, len) (char *) realloc(str, len *sizeof(char))
#define STRLST(str) str[strlen(str)-1]
+#define ERROR_INTERPRET(m,t) \
+ ERROR(\
+ "%s: Interpret error in %s line %d pos %d near '%s'", m, \
+ t->c_filename, \
+ t->i_line_nr, \
+ t->i_pos_nr, \
+ t->c_val \
+ )
+#define ERROR_EOB ERROR_INTERPRET("Unexpected end of block", p_token)
+
+
#endif
diff --git a/src/fype.c b/src/fype.c
index 23f017f..cc22c03 100644
--- a/src/fype.c
+++ b/src/fype.c
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/fype.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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,74 +15,66 @@
*: * 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 buetow.org 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 C. 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 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)
*: 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 "fype.h"
#include "argv.h"
-#include "core/garbage.h"
-#include "core/interpret.h"
#include "core/scanner.h"
-#include "core/symbol.h"
+#include "core/token.h"
+#include "core/interpret.h"
-Fype*
+PBSc*
fype_new() {
- Fype *p_fype = malloc(sizeof(Fype));
+ PBSc *p_fype = malloc(sizeof(PBSc));
p_fype->p_hash_syms = hash_new(512);
p_fype->p_list_token = list_new();
p_fype->p_tupel_argv = tupel_new();
p_fype->c_basename = NULL;
- garbage_init();
-
return (p_fype);
}
void
-fype_delete(Fype *p_fype) {
+fype_delete(PBSc *p_fype) {
argv_tupel_delete(p_fype->p_tupel_argv);
- hash_iterate(p_fype->p_hash_syms, symbol_cleanup_hash_syms_cb);
hash_delete(p_fype->p_hash_syms);
- //list_iterate(p_fype->p_list_token, token_print_cb);
- list_iterate(p_fype->p_list_token, token_ref_down_cb);
- //list_iterate(p_fype->p_list_token, token_print_cb);
+ list_iterate(p_fype->p_list_token, token_delete_cb);
list_delete(p_fype->p_list_token);
if (p_fype->c_basename)
free(p_fype->c_basename);
-
- garbage_destroy();
}
int
fype_run(int i_argc, char **pc_argv) {
- Fype *p_fype = fype_new();
+ PBSc *p_fype = fype_new();
// argv: Maintains command line options
argv_run(p_fype, i_argc, pc_argv);
- // scanner: Creates a list of token
+ // scanner: Fills the list of tokens
scanner_run(p_fype);
- // interpret: Interpret the list of token
+ // interpret: Interprets the list of tokens
interpret_run(p_fype);
fype_delete(p_fype);
diff --git a/src/fype.h b/src/fype.h
index a8bd2b2..9f5b432 100644
--- a/src/fype.h
+++ b/src/fype.h
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/fype.h
- *: 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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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.
*:*/
@@ -46,13 +45,13 @@
typedef struct {
Tupel *p_tupel_argv; // Contains command line options
- List *p_list_token; // Initial list of token
+ List *p_list_token; // Initial list of tokens
Hash *p_hash_syms; // Symbol table
char *c_basename;
-} Fype;
+} PBSc;
-Fype *fype_new();
-void fype_delete(Fype *p_fype);
+PBSc *fype_new();
+void fype_delete(PBSc *p_fype);
int fype_run(int i_argc, char **pc_argv);
#endif /* FYPE_H */
diff --git a/src/main.c b/src/main.c
index c01a9f3..ac48bd1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,14 +1,13 @@
/*:*
*: File: ./src/main.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
- *: All rights reserved.
- *:
+ *: A simple Fype interpreter
+ *:
+ *: WWW: http://fype.buetow.org
+ *: AUTHOR: http://paul.buetow.org
+ *: E-Mail: fype at dev.buetow.org
+ *:
+ *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *:
*: 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,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 buetow.org nor the names of its contributors may
- *: be used to endorse or promote products derived from this software
+ *: * Neither the name of buetow.org 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 C. 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 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)
*: 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.
*:*/