summaryrefslogtreecommitdiff
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
parent337c1c8abbe199670259bb043b95b541945427f4 (diff)
parenta90467d4be3bcf91cab299b4521bf5f762abb1d5 (diff)
Merge remote-tracking branch 'remotes/github/build-010388-scheme' into build-010388-schemebuild-010388-scheme
-rw-r--r--COPYING35
-rw-r--r--INSTALL2
-rw-r--r--Makefile25
-rw-r--r--docs/header.txt11
-rw-r--r--docs/help.txt4
-rw-r--r--docs/pbsc.txt43
-rw-r--r--docs/stats.txt8
-rw-r--r--docs/version.txt2
-rw-r--r--examples/netsted.fype11
-rw-r--r--examples/reverse.fype7
-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
-rw-r--r--tags166
-rw-r--r--test.fype13
-rw-r--r--test.out208
57 files changed, 2201 insertions, 2489 deletions
diff --git a/COPYING b/COPYING
index e7642a4..d911f4d 100644
--- a/COPYING
+++ b/COPYING
@@ -1,22 +1,27 @@
-Fype (http://fype.buetow.org) is ...
-... Copyright (c) 2005 2006 2007 2008 by Dipl.-Inf. (FH) Paul C. Buetow
-All rights reserved.
+File: ./COPYING
+A simple Fype interpreter
-Redistribution and use in source and binary forms, with or without
-modification, 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.
+WWW: http://fype.buetow.org
+AUTHOR: http://paul.buetow.org
+E-Mail: fype at dev.buetow.org
-THIS SOFTWARE IS PROVIDED BY Paul Buetow ``AS IS'' AND ANY EXPRESS OR
+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 Buetow BE LIABLE FOR ANY DIRECT,
+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)
diff --git a/INSTALL b/INSTALL
index 669dabf..a8b38a4 100644
--- a/INSTALL
+++ b/INSTALL
@@ -6,6 +6,6 @@ How to install fype:
How to read the docu:
- man fype
+ man pbsc
Examples can be found in the ./examples directory.
diff --git a/Makefile b/Makefile
index a9b6b31..37568aa 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,6 @@ OSYSTEM!=uname
PREFIX=/usr/local
all: build $(OBJS) newline stats-tofile
@$(CC) -lm -o $(BIN) $(OBJS) $(LDADD)
- @if test -z '$(DEBUG)'; then strip $(BIN) ; fi
@awk '$$2 == "BUILDNR" { printf("===> Fype build number % 13s :% 6s%d\n", \
"", "", $$3); exit(0); }' src/build.h
@echo "===> Fype binary size : `du -hs $(BIN)`"
@@ -41,7 +40,7 @@ printbuild:
@awk '$$2 == "BUILDNR" { printf("%d\n", \
$$3); exit(0); }' src/build.h
ctags:
- @# Generating Source-Tags for Vim
+ # Generating Source-Tags for Vim
ctags `find . -name '*.c'`
style: astyle check
astyle:
@@ -59,30 +58,31 @@ stats:
grep -E \"\\.(c|h)$$\" | wc -l`"; \
echo "===> Num of C source lines : `echo \"$$wc\" | \
tail -n 1 | sed s/total//`"'
- @sh -c 'wc=`find ./examples -name "*.fy" | xargs wc -l`; \
+ @sh -c 'wc=`find ./examples -name "*.fype" | xargs wc -l`; \
echo "===> Num of Fype source examples : `echo \"$$wc\" | \
- grep -E \"\\.fy$$\" | wc -l`"; \
+ grep -E \"\\.fype$$\" | wc -l`"; \
echo "===> Num of Fype source lines : `echo \"$$wc\" | \
tail -n 1 | sed s/total//`"'
stats-tofile:
make stats | tee ./docs/stats.txt
testrun:
- cat ./test.fy > ./test.out
- ./$(BIN) -V ./test.fy | tee -a ./test.out
+ cat ./test.fype > ./test.out
+ ./$(BIN) -V ./test.fype | tee -a ./test.out
tr: testrun
test: all testrun
t: test
run:
- ./$(BIN) ./test.fy
+ ./$(BIN) ./test.fype
core:
- gdb $(BIN) $(BIN).core
+ #gdb $(BIN) $(BIN).core
+ gdb $(BIN) core
gdb:
- gdb --args $(BIN) .//test.fy
+ gdb --args $(BIN) .//
newline:
@echo
examples: all
echo > ./examples/all-examples.txt
- for i in ./examples/*.fy; do \
+ for i in ./examples/*.fype; do \
echo "===> Running $$i"; \
./$(BIN) $$i; \
cat $$i >> ./examples/all-examples.txt; \
@@ -94,6 +94,10 @@ replace:
headers:
@find ./src -name '*.[ch]' -exec sh -c 'export FILE={}; \
make header' \;
+ @sh -c '> ./COPYING;export FILE=./COPYING; make header'
+ @# BSD sed does not support the -i (inplace) switch
+ @sed -n '1d;$$d;s/....//; w .tmp' ./COPYING && mv .tmp ./COPYING
+
header:
@echo "===> Processing $(FILE)"
@sed -n '/*:/d; w .tmp' $(FILE)
@@ -112,4 +116,3 @@ deinstall:
uninstall: deinstall
pod:
@cd ./docs/pod; make clean all
- @cp ./docs/pod/fype.pod README.pod
diff --git a/docs/header.txt b/docs/header.txt
index 88c96c2..83638b8 100644
--- a/docs/header.txt
+++ b/docs/header.txt
@@ -1,12 +1,11 @@
File: ${FILE}
-A simple interpreter
+A simple Fype interpreter
-WWW : http://fype.buetow.org
-AUTHOR : http://paul.buetow.org
-E-Mail : fype at dev.buetow.org
+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.
+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:
diff --git a/docs/help.txt b/docs/help.txt
index 545eda4..0033293 100644
--- a/docs/help.txt
+++ b/docs/help.txt
@@ -1,5 +1,5 @@
-Fype0 Alpha Build 9669
-(c) Paul C. Buetow (2005 - 2008) <fype@dev.buetow.org>
+Fype2 Alpha Build 10387
+(c) Paul C. Buetow (2005 - 2010) <fype@dev.buetow.org>
-e Executes given code string (see synopses)
-h Prints this help
-s Prints the synopsis
diff --git a/docs/pbsc.txt b/docs/pbsc.txt
new file mode 100644
index 0000000..3a2726c
--- /dev/null
+++ b/docs/pbsc.txt
@@ -0,0 +1,43 @@
+Global Frame
+
+v?: Variables
+p?: Parameters
+b?: Boolean expression (Returns #t or #f)
+t?: Term
+f: Function
+l?: List
+
+(f p1 p2 ...)
+
+(define v1 t1)
+
+(lambda (v1 v2 ...) t1)
+
+(define foo (lambda (v1 v2 ...) t1))
+(define (foo (v1 v2 ...) t1))
+
+(if b1 t1 t2)
+(unless b1 t1 t2)
+(eq? t1 t2)
+(neq? t1 t2)
+(and b1 b2)
+(or b1 b2)
+(xor b1 b2)
+(not b1)
+
+(cond ((b1 t1)
+ (b2 t2)
+ ...
+ (else tn)))
+
+(let ((v1 t1)
+ (v2 t2)
+ ...)
+ t3)
+
+(cons t1 l1)
+(car l1)
+(cdr l1)
+(set-car l1 t1)
+(set-cdr l1 t1)
+(list p1 p2 ...)
diff --git a/docs/stats.txt b/docs/stats.txt
index b44c232..50cbda1 100644
--- a/docs/stats.txt
+++ b/docs/stats.txt
@@ -1,4 +1,4 @@
-===> Num of C source files : 46
-===> Num of C source lines : 8227
-===> Num of Fype source examples : 15
-===> Num of Fype source lines : 376
+===> Num of C source files : 44
+===> Num of C source lines : 5740
+===> Num of Fype source examples : 2
+===> Num of Fype source lines : 18
diff --git a/docs/version.txt b/docs/version.txt
index dd836b0..d2c768b 100644
--- a/docs/version.txt
+++ b/docs/version.txt
@@ -1 +1 @@
-Fype0 Alpha Build 9669
+Fype2 Alpha Build 10387
diff --git a/examples/netsted.fype b/examples/netsted.fype
new file mode 100644
index 0000000..2ddf89f
--- /dev/null
+++ b/examples/netsted.fype
@@ -0,0 +1,11 @@
+(def (test)
+ (say "This is test")
+ (def (test2)
+ (say "I am in test2" "And test3 will be defined next!")
+ (def (test3)
+ (say "Displaying all frames now:")
+ (show-frames))
+ (test3))
+ (test2))
+(test)
+
diff --git a/examples/reverse.fype b/examples/reverse.fype
new file mode 100644
index 0000000..a4384b6
--- /dev/null
+++ b/examples/reverse.fype
@@ -0,0 +1,7 @@
+(def (reverse x)
+ (def (my-reverse x y)
+ (if (null? x)
+ y
+ (my-reverse (cdr x) (cons (car x) y))))
+ (my-reverse x '()))
+(reverse (list 1 2 3))
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.
*:*/
diff --git a/tags b/tags
index 0e894d3..6a1e484 100644
--- a/tags
+++ b/tags
@@ -4,66 +4,38 @@
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.7 //
-ARGV_OSLEN ./src/argv.c 45;" d file:
+ARGV_OSLEN ./src/argv.c 44;" d file:
BINARY ./src/argv.c /^char *BINARY;$/;" v
-CASE ./src/core/token.c 99;" d file:
-CHECK ./src/core/token.c 40;" d file:
-LIST_GARBAGE ./src/core/garbage.c /^List *LIST_GARBAGE = NULL;$/;" v
+CASE ./src/core/token.c 38;" d file:
+CHECK ./src/core/token.c 37;" d file:
TOKEN_ID_COUNTER ./src/core/token.c /^long TOKEN_ID_COUNTER = 0;$/;" v
-_ADD_SEMICOLON_INDEX ./src/core/scanner.c 42;" d file:
-_CHECK ./src/core/interpret.c 52;" d file:
_CODESTR_INDEX ./src/core/scanner.c /^int _CODESTR_INDEX = 0;$/;" v
-_FUNCTIONS_ERROR ./src/core/functions.c 46;" d file:
-_GARBAGE_ERROR ./src/core/garbage.c 38;" d file:
-_Garbage ./src/core/garbage.c /^} _Garbage;$/;" t typeref:struct:__anon1 file:
-_HAS_NEXT ./src/core/interpret.c 53;" d file:
-_INTERPRET_ERROR ./src/core/interpret.c 43;" d file:
-_NEXT ./src/core/interpret.c 55;" d file:
-_NEXT2 ./src/core/interpret.c 56;" d file:
-_NEXT_ORG ./src/core/interpret.c 54;" d file:
-_NEXT_TT ./src/core/interpret.c 57;" d file:
-_SKIP ./src/core/interpret.c 58;" d file:
-_TOKENENDS ./src/core/scanner.c /^const char _TOKENENDS[] = "}])+-*\/={([<>;:,.!";$/;" v
-_add_semicolon_to_list ./src/core/scanner.c /^_add_semicolon_to_list(Scanner *p_scanner) {$/;" f
-_block ./src/core/interpret.c /^_block(Interpret *p_interpret) {$/;" f
-_block_get ./src/core/interpret.c /^_block_get(Interpret *p_interpret, List *p_list_block) {$/;" f
-_block_skip ./src/core/interpret.c /^_block_skip(Interpret *p_interpret) {$/;" f
-_compare ./src/core/interpret.c /^_compare(Interpret *p_interpret) {$/;" f
-_control ./src/core/interpret.c /^_control(Interpret *p_interpret) {$/;" f
-_expression ./src/core/interpret.c /^_expression(Interpret *p_interpret) {$/;" f
-_expression_ ./src/core/interpret.c /^_expression_(Interpret *p_interpret) {$/;" f
-_expression_get ./src/core/interpret.c /^_expression_get(Interpret *p_interpret, List *p_list_expression) {$/;" f
-_func_decl ./src/core/interpret.c /^_func_decl(Interpret *p_interpret) {$/;" f
+_ERROR ./src/core/promise.c 37;" d file:
+_I_FRAME_ID_COUNT ./src/core/frame.c /^unsigned _I_FRAME_ID_COUNT = 0;$/;" v
+_TOKEN_ENDS ./src/core/scanner.c /^const char _TOKEN_ENDS[] = "()";$/;" v
+_def ./src/core/interpret.c /^_def(Interpret *p_inter, Token *p_token, ListIterator *p_iter) {$/;" f
+_eval ./src/core/interpret.c /^_eval(Interpret *p_inter) {$/;" f
+_eval_lambda ./src/core/interpret.c /^_eval_lambda(Interpret *p_inter, Lambda *p_lambda, ListIterator *p_iter) {$/;" f
+_eval_symbol ./src/core/interpret.c /^_eval_symbol(Interpret *p_inter, Symbol *p_symbol, ListIterator *p_iter) {$/;" f
+_frame_print ./src/core/frame.c /^_frame_print(Frame *p_frame, int i_frame_nr) {$/;" f
_indent ./src/data/tree.c /^void _indent(int i_indent) {$/;" f
_list_copy_cb ./src/data/list.c /^_list_copy_cb(void *p_void1, void *p_cpy) {$/;" f
-_next ./src/core/interpret.c /^_next(Interpret *p_interpret) {$/;" f
-_next_tt ./src/core/interpret.c /^_next_tt(Interpret *p_interpret) {$/;" f
-_print_lookahead ./src/core/interpret.c /^_print_lookahead(Interpret *p_interpret) {$/;" f
-_proc_decl ./src/core/interpret.c /^_proc_decl(Interpret *p_interpret) {$/;" f
-_process ./src/core/functions.c /^_process(Interpret *p_interpret, Token *p_token_store, Token *p_token_op,$/;" f
-_product ./src/core/interpret.c /^_product(Interpret *p_interpret) {$/;" f
-_product2 ./src/core/interpret.c /^_product2(Interpret *p_interpret) {$/;" f
-_program ./src/core/interpret.c /^_program(Interpret *p_interpret) {$/;" f
+_parant ./src/core/interpret.c /^_parant(Interpret *p_inter, Token *p_token) {$/;" f
+_run_func ./src/core/interpret.c /^_run_func(Interpret *p_inter, Token *p_token, ListIterator *p_iter) {$/;" f
+_say ./src/core/interpret.c /^_say(Interpret *p_inter, Token *p_token, ListIterator *p_iter) {$/;" f
_scanner_get_next_char ./src/core/scanner.c /^_scanner_get_next_char(Scanner *p_scanner) {$/;" f
_scanner_has_next_char ./src/core/scanner.c /^_scanner_has_next_char(Scanner *p_scanner) {$/;" f
-_scope_get_hash ./src/core/scope.c /^_scope_get_hash(Scope *p_scope, char *c_key) {$/;" f file:
-_scope_print_cb ./src/core/scope.c /^_scope_print_cb(void *p_void, int i_level) {$/;" f
-_statement ./src/core/interpret.c /^_statement(Interpret *p_interpret) {$/;" f
-_sum ./src/core/interpret.c /^_sum(Interpret *p_interpret) {$/;" f
-_term ./src/core/interpret.c /^_term(Interpret *p_interpret) {$/;" f
+_symbol_print_cb ./src/core/frame.c /^_symbol_print_cb(void *p_val, char *c_name) {$/;" f
_tree_print ./src/data/tree.c /^_tree_print(TreeNode *p_treenode, int i_indent) {$/;" f
_tree_print_cb ./src/data/tree.c /^_tree_print_cb(void *p_void, void *p_indent) {$/;" f
_tree_print_cb2 ./src/data/tree.c /^_tree_print_cb2(void *p_void, void *p_indent) {$/;" f
_unshift_cb ./src/data/array.c /^_unshift_cb(void *p_array, void *p_void) {$/;" f
-_var_assign ./src/core/interpret.c /^_var_assign(Interpret *p_interpret) {$/;" f
-_var_decl ./src/core/interpret.c /^_var_decl(Interpret *p_interpret) {$/;" f
-_var_list ./src/core/interpret.c /^_var_list(Interpret *p_interpret) {$/;" f
argv_addopt ./src/argv.c /^argv_addopt(char c_opt, Tupel *p_tupel_argv) {$/;" f
argv_check_argc ./src/argv.c /^argv_check_argc(int i_required, unsigned i_argc_left, Tupel *p_tupel_argv) {$/;" f
argv_checkopt ./src/argv.c /^argv_checkopt(char c_opt, Tupel *p_tupel_argv) {$/;" f
argv_checkopts ./src/argv.c /^argv_checkopts(char *c_opts, Tupel *p_tupel_argv) {$/;" f
argv_help ./src/argv.c /^argv_help() {$/;" f
-argv_run ./src/argv.c /^argv_run(Fype *p_fype, int i_argc, char **pc_argv) {$/;" f
+argv_run ./src/argv.c /^argv_run(PBSc *p_fype, int i_argc, char **pc_argv) {$/;" f
argv_switch ./src/argv.c /^argv_switch(char c_arg, Tupel *p_tupel_argv, unsigned i_argc_left) {$/;" f
argv_synopsis ./src/argv.c /^argv_synopsis(Tupel *p_tupel_argv) {$/;" f
argv_tupel_delete ./src/argv.c /^argv_tupel_delete(Tupel *p_tupel_argv) {$/;" f
@@ -92,14 +64,13 @@ arrayiterator_delete ./src/data/array.c /^arrayiterator_delete(ArrayIterator *p_
arrayiterator_has_next ./src/data/array.c /^arrayiterator_has_next(ArrayIterator *p_arrayiterator) {$/;" f
arrayiterator_new ./src/data/array.c /^arrayiterator_new(Array *p_array) {$/;" f
arrayiterator_next ./src/data/array.c /^arrayiterator_next(ArrayIterator *p_arrayiterator) {$/;" f
-convert_function_arg_types_to_highest ./src/core/convert.c /^convert_function_arg_types_to_highest(Stack *p_stack_args, int i_args) {$/;" f
-convert_to_array ./src/core/convert.c /^convert_to_array(Token *p_token) {$/;" f
-convert_to_double ./src/core/convert.c /^convert_to_double(Token *p_token) {$/;" f
-convert_to_highest ./src/core/convert.c /^convert_to_highest(Token *p_token1, Token *p_token2) {$/;" f
-convert_to_integer ./src/core/convert.c /^convert_to_integer(Token *p_token) {$/;" f
-convert_to_integer_get ./src/core/convert.c /^convert_to_integer_get(Token *p_token) {$/;" f
-convert_to_string ./src/core/convert.c /^convert_to_string(Token *p_token) {$/;" f
-convert_to_tt ./src/core/convert.c /^convert_to_tt(Token *p_token, TokenType tt) {$/;" f
+cons_car ./src/data/cons.c /^cons_car(Cons *p_cons) {$/;" f
+cons_cdr ./src/data/cons.c /^cons_cdr(Cons *p_cons) {$/;" f
+cons_cons ./src/data/cons.c /^cons_cons(Cons *p_cons, void *p_val) {$/;" f
+cons_delete ./src/data/cons.c /^cons_delete(Cons *p_cons) {$/;" f
+cons_delete_cb ./src/data/cons.c /^cons_delete_cb(void *p_cons) {$/;" f
+cons_iterate ./src/data/cons.c /^cons_iterate(Cons *p_cons, void (*func)(void *)) {$/;" f
+cons_new ./src/data/cons.c /^cons_new(void *p_val) {$/;" f
dat_clear ./src/data/dat.c /^dat_clear(Dat *p_dat) {$/;" f
dat_delete ./src/data/dat.c /^dat_delete(Dat *p_dat) {$/;" f
dat_empty ./src/data/dat.c /^dat_empty(Dat *p_dat) {$/;" f
@@ -127,26 +98,14 @@ datiter_new ./src/data/dat.c /^datiter_new(Dat *p_dat) {$/;" f
datiter_next ./src/data/dat.c /^datiter_next(DatIter *p_iter) {$/;" f
datiter_next_t ./src/data/dat.c /^datiter_next_t(DatIter *p_iter, TYPE *p_type) {$/;" f
datiter_skip ./src/data/dat.c /^datiter_skip(DatIter *p_iter, unsigned i_num) {$/;" f
-function_delete ./src/core/function.c /^function_delete(Function *p_function) {$/;" f
-function_is_buildin ./src/core/functions.c /^function_is_buildin(Token *p_token_ident) {$/;" f
-function_is_self_defined ./src/core/functions.c /^function_is_self_defined(Interpret *p_interpret) {$/;" f
-function_new ./src/core/function.c /^function_new() {$/;" f
-function_process ./src/core/functions.c /^function_process(Interpret *p_interpret, Token *p_token_op,$/;" f
-function_process_buildin ./src/core/functions.c /^function_process_buildin(Interpret *p_interpret, Token *p_token_ident,$/;" f
-function_process_self_defined ./src/core/functions.c /^function_process_self_defined(Interpret *p_interpret, Token *p_token_ident) {$/;" f
-functions_delete ./src/core/functions.c /^functions_delete(Functions *p_functions) {$/;" f
-functions_init ./src/core/functions.c /^functions_init(Functions *p_functions) {$/;" f
-functions_new ./src/core/functions.c /^functions_new() {$/;" f
-fype_delete ./src/fype.c /^fype_delete(Fype *p_fype) {$/;" f
+frame_add_symbol ./src/core/frame.c /^frame_add_symbol(Frame *p_frame, char *c_name, SymbolType st, void *p_val) {$/;" f
+frame_delete ./src/core/frame.c /^frame_delete(Frame *p_frame) {$/;" f
+frame_get_symbol ./src/core/frame.c /^frame_get_symbol(Frame *p_frame, char *c_name) {$/;" f
+frame_new ./src/core/frame.c /^frame_new(Frame *p_parent_frame) {$/;" f
+frame_print ./src/core/frame.c /^frame_print(Frame *p_frame) {$/;" f
+fype_delete ./src/fype.c /^fype_delete(PBSc *p_fype) {$/;" f
fype_new ./src/fype.c /^fype_new() {$/;" f
fype_run ./src/fype.c /^fype_run(int i_argc, char **pc_argv) {$/;" f
-garbage_add ./src/core/garbage.c /^garbage_add(void *p, GarbageType type) {$/;" f
-garbage_add2 ./src/core/garbage.c /^garbage_add2(void *p,$/;" f
-garbage_add3 ./src/core/garbage.c /^garbage_add3(void *p,$/;" f
-garbage_add_token ./src/core/garbage.c /^garbage_add_token(Token *p_token) {$/;" f
-garbage_collect ./src/core/garbage.c /^garbage_collect() {$/;" f
-garbage_destroy ./src/core/garbage.c /^garbage_destroy() {$/;" f
-garbage_init ./src/core/garbage.c /^garbage_init() {$/;" f
get_tt ./src/core/token.c /^get_tt(char *c_token) {$/;" f
hash_addrisfree ./src/data/hash.c /^hash_addrisfree(Hash *p_hash, int i_addr) {$/;" f
hash_addrisocc ./src/data/hash.c /^hash_addrisocc(Hash *p_hash, int i_addr, char *c_key) {$/;" f
@@ -159,17 +118,20 @@ hash_insert ./src/data/hash.c /^hash_insert(Hash *p_hash, char *c_key, void *p_v
hash_insert_ht ./src/data/hash.c /^hash_insert_ht(Hash *p_hash, char *c_key, void *p_val, TYPE type) {$/;" f
hash_iterate ./src/data/hash.c /^hash_iterate(Hash *p_hash, void (*func)(void *)) {$/;" f
hash_iterate_key ./src/data/hash.c /^hash_iterate_key(Hash *p_hash, void (*func)(void *, char *)) {$/;" f
+hash_key_exists ./src/data/hash.c /^hash_key_exists(Hash *p_hash, char *c_key) {$/;" f
hash_new ./src/data/hash.c /^hash_new(unsigned i_size) {$/;" f
hash_nextaddr ./src/data/hash.c /^hash_nextaddr(Hash *p_hash, int i_max_tries, char *c_key, int i_addr,$/;" f
hash_print ./src/data/hash.c /^hash_print(Hash *p_hash) {$/;" f
hash_print_addrval ./src/data/hash.c /^hash_print_addrval(Hash *p_hash, int i_addr) {$/;" f
hash_remove ./src/data/hash.c /^hash_remove(Hash *p_hash, char *c_key) {$/;" f
hash_size ./src/data/hash.c /^hash_size(Hash *p_hash, int i_size) {$/;" f
-interpret_delete ./src/core/interpret.c /^interpret_delete(Interpret *p_interpret) {$/;" f
-interpret_new ./src/core/interpret.c /^interpret_new(List *p_list_token, Hash *p_hash_syms) {$/;" f
-interpret_process ./src/core/interpret.c /^interpret_process(Interpret *p_interpret) {$/;" f
-interpret_run ./src/core/interpret.c /^interpret_run(Fype *p_fype) {$/;" f
-interpret_subprocess ./src/core/interpret.c /^interpret_subprocess(Interpret *p_interpret, List *p_list_token) {$/;" f
+interpret_delete ./src/core/interpret.c /^interpret_delete(Interpret *p_inter) {$/;" f
+interpret_new ./src/core/interpret.c /^interpret_new(List *p_list_token) {$/;" f
+interpret_new_lambda ./src/core/interpret.c /^interpret_new_lambda(Interpret *p_inter, Lambda *p_lambda) {$/;" f
+interpret_run ./src/core/interpret.c /^interpret_run(PBSc *p_fype) {$/;" f
+lambda_delete ./src/core/lambda.c /^lambda_delete(Lambda *p_lambda) {$/;" f
+lambda_new ./src/core/lambda.c /^lambda_new(char *c_name, List *p_list_args, ListElem *p_listelem, ListElem *p_listelem_end, Frame *p_frame) {$/;" f
+lambda_print ./src/core/lambda.c /^lambda_print(Lambda *p_lambda) {$/;" f
list_add_back ./src/data/list.c /^list_add_back(List *p_list, void *p_val) {$/;" f
list_add_front ./src/data/list.c /^list_add_front(List *p_list, void *p_val) {$/;" f
list_clear ./src/data/list.c /^list_clear(List *p_list) {$/;" f
@@ -194,15 +156,20 @@ list_remove_front ./src/data/list.c /^list_remove_front(List *p_list) {$/;" f
list_size ./src/data/list.c /^list_size(List *p_list) {$/;" f
listelem_new ./src/data/list.c /^listelem_new() {$/;" f
listiterator_current ./src/data/list.c /^listiterator_current(ListIterator *p_iter) {$/;" f
+listiterator_current_elem ./src/data/list.c /^listiterator_current_elem(ListIterator *p_iter) {$/;" f
+listiterator_current_elem_equals ./src/data/list.c /^listiterator_current_elem_equals(ListIterator *p_iter, ListElem *p_listelem) {$/;" f
listiterator_delete ./src/data/list.c /^listiterator_delete(ListIterator *p_iter) {$/;" f
listiterator_end ./src/data/list.c /^listiterator_end(ListIterator *p_iter) {$/;" f
listiterator_get_state ./src/data/list.c /^listiterator_get_state(ListIterator *p_iter) {$/;" f
listiterator_has_next ./src/data/list.c /^listiterator_has_next(ListIterator *p_iter) {$/;" f
listiterator_new ./src/data/list.c /^listiterator_new(List *p_list) {$/;" f
+listiterator_new_from_elem ./src/data/list.c /^listiterator_new_from_elem(ListElem *p_listelem) {$/;" f
+listiterator_new_from_elem_reverse ./src/data/list.c /^listiterator_new_from_elem_reverse(ListElem *p_listelem) {$/;" f
listiterator_new_reverse ./src/data/list.c /^listiterator_new_reverse(List *p_list) {$/;" f
listiterator_next ./src/data/list.c /^listiterator_next(ListIterator *p_iter) {$/;" f
listiterator_next_elem ./src/data/list.c /^listiterator_next_elem(ListIterator *p_iter) {$/;" f
listiterator_prev ./src/data/list.c /^listiterator_prev(ListIterator *p_iter) {$/;" f
+listiterator_prev_elem ./src/data/list.c /^listiterator_prev_elem(ListIterator *p_iter) {$/;" f
listiterator_set_state ./src/data/list.c /^listiterator_set_state(ListIterator *p_iter, ListIteratorState *p_state) {$/;" f
listiteratorstate_delete ./src/data/list.c /^listiteratorstate_delete(ListIteratorState *p_state) {$/;" f
main ./src/main.c /^main(int i_argc, char **pc_argv) {$/;" f
@@ -232,10 +199,8 @@ map_new_named ./src/data/map.c /^map_new_named(int i_max_size, char *c_name) {$/
map_next_free_addr ./src/data/map.c /^map_next_free_addr(Map *p_map) {$/;" f
map_print ./src/data/map.c /^map_print(Map *p_map) {$/;" f
map_remove ./src/data/map.c /^map_remove(Map *p_map, char *c_key) {$/;" f
-p_2free ./src/core/garbage.c /^ void *p_2free;$/;" m struct:__anon1 file:
-p_func ./src/core/garbage.c /^ void (*p_func)(void*);$/;" m struct:__anon1 file:
-p_print ./src/core/garbage.c /^ void (*p_print)(void*);$/;" m struct:__anon1 file:
-p_ref_count ./src/core/garbage.c /^ int *p_ref_count;$/;" m struct:__anon1 file:
+promise_delete ./src/core/promise.c /^promise_delete(Promise *p_promise) {$/;" f
+promise_new ./src/core/promise.c /^promise_new(Token *p_token_lambda, ListElem *p_elem_start) {$/;" f
queue_clear ./src/data/queue.c /^queue_clear(Queue *p_queue) {$/;" f
queue_delete ./src/data/queue.c /^queue_delete(Queue *p_queue) {$/;" f
queue_empty ./src/data/queue.c /^queue_empty(Queue *p_queue) {$/;" f
@@ -256,26 +221,12 @@ queueiter_new ./src/data/queue.c /^queueiter_new(Queue *p_queue) {$/;" f
queueiter_next ./src/data/queue.c /^queueiter_next(QueueIter *p_iter) {$/;" f
queueiter_next_t ./src/data/queue.c /^queueiter_next_t(QueueIter *p_iter, TYPE *p_type) {$/;" f
queueiter_queue ./src/data/queue.c /^queueiter_queue(QueueIter *p_iter) {$/;" f
-reference_delete ./src/core/reference.c /^reference_delete(Reference *p_reference) {$/;" f
-reference_delete_cb ./src/core/reference.c /^reference_delete_cb(void *p_void) {$/;" f
-reference_new ./src/core/reference.c /^reference_new(Symbol *p_symbol) {$/;" f
scanner_add_token ./src/core/scanner.c /^scanner_add_token(Scanner *p_scanner, char **cc_token, int *p_token_len,$/;" f
scanner_cleanup_list_token_cb ./src/core/scanner.c /^scanner_cleanup_list_token_cb(void *p_void) {$/;" f
scanner_delete ./src/core/scanner.c /^scanner_delete(Scanner *p_scanner) {$/;" f
scanner_get_tt_cur ./src/core/scanner.c /^scanner_get_tt_cur(char *c_token) {$/;" f
scanner_new ./src/core/scanner.c /^scanner_new(List *p_list_token, Tupel *p_tupel_argv) {$/;" f
-scanner_post_task ./src/core/scanner.c /^scanner_post_task(Scanner *p_scanner) {$/;" f
-scanner_run ./src/core/scanner.c /^scanner_run(Fype *p_fype) {$/;" f
-scope_delete ./src/core/scope.c /^scope_delete(Scope *p_scope) {$/;" f
-scope_down ./src/core/scope.c /^scope_down(Scope *p_scope) {$/;" f
-scope_exists ./src/core/scope.c /^scope_exists(Scope *p_scope, char *c_key) {$/;" f
-scope_get ./src/core/scope.c /^scope_get(Scope *p_scope, char *c_key) {$/;" f
-scope_new ./src/core/scope.c /^scope_new(Hash *p_hash_syms) {$/;" f
-scope_newset ./src/core/scope.c /^scope_newset(Scope *p_scope, char *c_key, Symbol *p_symbol) {$/;" f
-scope_print ./src/core/scope.c /^scope_print(Scope *p_scope) {$/;" f
-scope_remove ./src/core/scope.c /^scope_remove(Scope *p_scope, char *c_key) {$/;" f
-scope_reset ./src/core/scope.c /^scope_reset(Scope *p_scope, char *c_key, Symbol *p_symbol) {$/;" f
-scope_up ./src/core/scope.c /^scope_up(Scope *p_scope) {$/;" f
+scanner_run ./src/core/scanner.c /^scanner_run(PBSc *p_fype) {$/;" f
stack_clear ./src/data/stack.c /^stack_clear(Stack *p_stack) {$/;" f
stack_concat ./src/data/stack.c /^stack_concat(Stack *p_stack, Stack *p_stack_concat) {$/;" f
stack_delete ./src/data/stack.c /^stack_delete(Stack *p_stack) {$/;" f
@@ -296,28 +247,19 @@ stackiterator_has_next ./src/data/stack.c /^stackiterator_has_next(StackIterator
stackiterator_new ./src/data/stack.c /^stackiterator_new(Stack *p_stack) {$/;" f
stackiterator_next ./src/data/stack.c /^stackiterator_next(StackIterator *p_iter) {$/;" f
stackiterator_remove_prev ./src/data/stack.c /^stackiterator_remove_prev(StackIterator *p_iter) {$/;" f
-sym_get_name ./src/core/symbol.c /^sym_get_name(SymbolType sym) {$/;" f
-symbol_cleanup_hash_syms_cb ./src/core/symbol.c /^symbol_cleanup_hash_syms_cb(void *p_void) {$/;" f
-symbol_delete ./src/core/symbol.c /^symbol_delete(Symbol *p_symbol) {$/;" f
-symbol_new ./src/core/symbol.c /^symbol_new(SymbolType sym, void *p_val) {$/;" f
-symbol_print ./src/core/symbol.c /^symbol_print(Symbol *p_symbol, char *c_key) {$/;" f
-symbol_print_cb ./src/core/symbol.c /^symbol_print_cb(void *p_void, char *c_key) {$/;" f
-token_copy_cb ./src/core/token.c /^token_copy_cb(void *p_void) {$/;" f
-token_copy_vals ./src/core/token.c /^void token_copy_vals(Token *p_token_to, Token *p_token_from) {$/;" f
+symbol_delete ./src/core/frame.c /^symbol_delete(Symbol *p_symbol) {$/;" f
+symbol_delete_cb ./src/core/frame.c /^symbol_delete_cb(void *p_symbol) {$/;" f
+symbol_get_type_name ./src/core/frame.c /^symbol_get_type_name(Symbol *p_symbol) {$/;" f
+symbol_new ./src/core/frame.c /^symbol_new(SymbolType st, void *p_val) {$/;" f
token_delete ./src/core/token.c /^token_delete(Token *p_token) {$/;" f
token_delete_cb ./src/core/token.c /^token_delete_cb(void *p_void) {$/;" f
+token_is ./src/core/token.c /^token_is(Token *p_token, char *c_str) {$/;" f
token_new ./src/core/token.c /^token_new(char *c_val, TokenType tt_cur, int i_line_nr,$/;" f
-token_new_ ./src/core/token.c /^token_new_(char *c_val, TokenType tt_cur, char *c_filename) {$/;" f
-token_new_array ./src/core/token.c /^token_new_array(int i_size) {$/;" f
-token_new_copy ./src/core/token.c /^token_new_copy(Token *p_token) {$/;" f
-token_new_double ./src/core/token.c /^token_new_double(double d_val) {$/;" f
token_new_dummy ./src/core/token.c /^token_new_dummy() {$/;" f
-token_new_integer ./src/core/token.c /^token_new_integer(int i_val) {$/;" f
-token_new_string ./src/core/token.c /^token_new_string(char *c_val) {$/;" f
token_print ./src/core/token.c /^token_print(Token *p_token) {$/;" f
token_print_cb ./src/core/token.c /^token_print_cb(void *p_void) {$/;" f
-token_print_val ./src/core/token.c /^token_print_val(Token *p_token) {$/;" f
-token_ref_down_cb ./src/core/token.c /^token_ref_down_cb(void *p_void) {$/;" f
+token_print_ln ./src/core/token.c /^token_print_ln(Token *p_token) {$/;" f
+tool_skip_block ./src/core/tools.c /^tool_skip_block(ListIterator *p_iter, int i_offset) {$/;" f
tree_delete ./src/data/tree.c /^tree_delete(Tree *p_tree) {$/;" f
tree_new ./src/data/tree.c /^tree_new() {$/;" f
tree_print ./src/data/tree.c /^tree_print(Tree *p_tree) {$/;" f
@@ -335,4 +277,6 @@ treenode_new2 ./src/data/tree.c /^treenode_new2(void *p_val, void *p_val2) {$/;"
tt_get_name ./src/core/token.c /^tt_get_name(TokenType tt_cur) {$/;" f
tupel_delete ./src/data/tupel.c /^tupel_delete(Tupel *p_tupel) {$/;" f
tupel_new ./src/data/tupel.c /^tupel_new() {$/;" f
-type ./src/core/garbage.c /^ GarbageType type;$/;" m struct:__anon1 file:
+variable_delete ./src/core/variable.c /^variable_delete(Variable *p_variable) {$/;" f
+variable_new ./src/core/variable.c /^variable_new(char *c_name, Token *p_token,Frame *p_frame) {$/;" f
+variable_print ./src/core/variable.c /^variable_print(Variable *p_variable) {$/;" f
diff --git a/test.fype b/test.fype
new file mode 100644
index 0000000..e5fb86c
--- /dev/null
+++ b/test.fype
@@ -0,0 +1,13 @@
+(def (test a)
+ (def (test2 a2)
+ (def (test3 a3)
+ (BEEP))
+ (test3 a2))
+ (def foo bar)
+ (def (barrr) foo)
+ (def (barr) (foo baz))
+ (def (bar x) (foo baz))
+ (test2 a))
+(test (foo bar baz))
+(say "hello world" 1.2)
+
diff --git a/test.out b/test.out
index 31bac64..2576315 100644
--- a/test.out
+++ b/test.out
@@ -1,94 +1,116 @@
-#*
- * Examples of how to use arrays
- *#
+(def (test a)
+ (def (test2 a2)
+ (def (test3 a3)
+ (BEEP))
+ (test3 a2))
+ (def foo bar)
+ (def (barrr) foo)
+ (def (barr) (foo baz))
+ (def (bar x) (foo baz))
+ (test2 a))
+(test (foo bar baz))
+(say "hello world" 1.2)
-# Create a function bar, returns 0 by default
-func bar { say "bar" }
-
-# Create a multi dimensional array foo
-my foo = [bar, 1, 4/2, double "3", ["A", ["BA", "BB"]]];
-
-# Run on each element of foo recursive 'say'
-say foo;
-
-# Print the length of the array
-assert 5 == say len foo;
-
-# Print the last index of the array
-assert 4 == say ind foo;
-
-# Print the 3rd element of the array
-say foo[3];
-
-#say "bla";
-Token (id=00000, line=00006, pos=0005, type=TT_FUNC, val=func, ival=0, dval=0.000000, refs=1)
-Token (id=00001, line=00006, pos=0009, type=TT_IDENT, val=bar, ival=0, dval=0.000000, refs=1)
-Token (id=00002, line=00006, pos=0011, type=TT_PARANT_CL, val={, ival=0, dval=0.000000, refs=1)
-Token (id=00003, line=00006, pos=0015, type=TT_IDENT, val=say, ival=0, dval=0.000000, refs=1)
-Token (id=00004, line=00006, pos=0016, type=TT_STRING, val=bar, ival=0, dval=0.000000, refs=1)
-Token (id=00005, line=00006, pos=0019, type=TT_PARANT_CR, val=}, ival=0, dval=0.000000, refs=1)
-Token (id=00006, line=00009, pos=0003, type=TT_MY, val=my, ival=0, dval=0.000000, refs=1)
-Token (id=00007, line=00009, pos=0007, type=TT_IDENT, val=foo, ival=0, dval=0.000000, refs=1)
-Token (id=00008, line=00009, pos=0009, type=TT_ASSIGN, val==, ival=0, dval=0.000000, refs=1)
-Token (id=00009, line=00009, pos=0011, type=TT_PARANT_AL, val=[, ival=0, dval=0.000000, refs=1)
-Token (id=00010, line=00009, pos=0014, type=TT_IDENT, val=bar, ival=0, dval=0.000000, refs=1)
-Token (id=00011, line=00009, pos=0015, type=TT_COMMA, val=,, ival=0, dval=0.000000, refs=1)
-Token (id=00012, line=00009, pos=0017, type=TT_INTEGER, val=1, ival=1, dval=0.000000, refs=1)
-Token (id=00013, line=00009, pos=0018, type=TT_COMMA, val=,, ival=0, dval=0.000000, refs=1)
-Token (id=00014, line=00009, pos=0020, type=TT_INTEGER, val=4, ival=4, dval=0.000000, refs=1)
-Token (id=00015, line=00009, pos=0021, type=TT_DIV, val=/, ival=0, dval=0.000000, refs=1)
-Token (id=00016, line=00009, pos=0022, type=TT_INTEGER, val=2, ival=2, dval=0.000000, refs=1)
-Token (id=00017, line=00009, pos=0023, type=TT_COMMA, val=,, ival=0, dval=0.000000, refs=1)
-Token (id=00018, line=00009, pos=0030, type=TT_IDENT, val=double, ival=0, dval=0.000000, refs=1)
-Token (id=00019, line=00009, pos=0031, type=TT_STRING, val=3, ival=0, dval=0.000000, refs=1)
-Token (id=00020, line=00009, pos=0033, type=TT_COMMA, val=,, ival=0, dval=0.000000, refs=1)
-Token (id=00021, line=00009, pos=0035, type=TT_PARANT_AL, val=[, ival=0, dval=0.000000, refs=1)
-Token (id=00022, line=00009, pos=0035, type=TT_STRING, val=A, ival=0, dval=0.000000, refs=1)
-Token (id=00023, line=00009, pos=0037, type=TT_COMMA, val=,, ival=0, dval=0.000000, refs=1)
-Token (id=00024, line=00009, pos=0039, type=TT_PARANT_AL, val=[, ival=0, dval=0.000000, refs=1)
-Token (id=00025, line=00009, pos=0039, type=TT_STRING, val=BA, ival=0, dval=0.000000, refs=1)
-Token (id=00026, line=00009, pos=0041, type=TT_COMMA, val=,, ival=0, dval=0.000000, refs=1)
-Token (id=00027, line=00009, pos=0042, type=TT_STRING, val=BB, ival=0, dval=0.000000, refs=1)
-Token (id=00028, line=00009, pos=0044, type=TT_PARANT_AR, val=], ival=0, dval=0.000000, refs=1)
-Token (id=00029, line=00009, pos=0044, type=TT_SEMICOLON, val=;, ival=0, dval=0.000000, refs=1)
-Token (id=00030, line=00009, pos=0045, type=TT_PARANT_AR, val=], ival=0, dval=0.000000, refs=1)
-Token (id=00031, line=00009, pos=0045, type=TT_SEMICOLON, val=;, ival=0, dval=0.000000, refs=1)
-Token (id=00032, line=00009, pos=0046, type=TT_PARANT_AR, val=], ival=0, dval=0.000000, refs=1)
-Token (id=00033, line=00009, pos=0047, type=TT_SEMICOLON, val=;, ival=0, dval=0.000000, refs=1)
-Token (id=00034, line=00012, pos=0004, type=TT_IDENT, val=say, ival=0, dval=0.000000, refs=1)
-Token (id=00035, line=00012, pos=0008, type=TT_IDENT, val=foo, ival=0, dval=0.000000, refs=1)
-Token (id=00036, line=00012, pos=0009, type=TT_SEMICOLON, val=;, ival=0, dval=0.000000, refs=1)
-Token (id=00037, line=00015, pos=0007, type=TT_IDENT, val=assert, ival=0, dval=0.000000, refs=1)
-Token (id=00038, line=00015, pos=0009, type=TT_INTEGER, val=5, ival=5, dval=0.000000, refs=1)
-Token (id=00039, line=00015, pos=0011, type=TT_ASSIGN, val==, ival=0, dval=0.000000, refs=1)
-Token (id=00040, line=00015, pos=0012, type=TT_ASSIGN, val==, ival=0, dval=0.000000, refs=1)
-Token (id=00041, line=00015, pos=0016, type=TT_IDENT, val=say, ival=0, dval=0.000000, refs=1)
-Token (id=00042, line=00015, pos=0020, type=TT_IDENT, val=len, ival=0, dval=0.000000, refs=1)
-Token (id=00043, line=00015, pos=0024, type=TT_IDENT, val=foo, ival=0, dval=0.000000, refs=1)
-Token (id=00044, line=00015, pos=0025, type=TT_SEMICOLON, val=;, ival=0, dval=0.000000, refs=1)
-Token (id=00045, line=00018, pos=0007, type=TT_IDENT, val=assert, ival=0, dval=0.000000, refs=1)
-Token (id=00046, line=00018, pos=0009, type=TT_INTEGER, val=4, ival=4, dval=0.000000, refs=1)
-Token (id=00047, line=00018, pos=0011, type=TT_ASSIGN, val==, ival=0, dval=0.000000, refs=1)
-Token (id=00048, line=00018, pos=0012, type=TT_ASSIGN, val==, ival=0, dval=0.000000, refs=1)
-Token (id=00049, line=00018, pos=0016, type=TT_IDENT, val=say, ival=0, dval=0.000000, refs=1)
-Token (id=00050, line=00018, pos=0020, type=TT_IDENT, val=ind, ival=0, dval=0.000000, refs=1)
-Token (id=00051, line=00018, pos=0024, type=TT_IDENT, val=foo, ival=0, dval=0.000000, refs=1)
-Token (id=00052, line=00018, pos=0025, type=TT_SEMICOLON, val=;, ival=0, dval=0.000000, refs=1)
-Token (id=00053, line=00021, pos=0004, type=TT_IDENT, val=say, ival=0, dval=0.000000, refs=1)
-Token (id=00054, line=00021, pos=0008, type=TT_IDENT, val=foo, ival=0, dval=0.000000, refs=1)
-Token (id=00055, line=00021, pos=0009, type=TT_PARANT_AL, val=[, ival=0, dval=0.000000, refs=1)
-Token (id=00056, line=00021, pos=0010, type=TT_INTEGER, val=3, ival=3, dval=0.000000, refs=1)
-Token (id=00057, line=00021, pos=0010, type=TT_SEMICOLON, val=;, ival=0, dval=0.000000, refs=1)
-Token (id=00058, line=00021, pos=0011, type=TT_PARANT_AR, val=], ival=0, dval=0.000000, refs=1)
-Token (id=00059, line=00021, pos=0012, type=TT_SEMICOLON, val=;, ival=0, dval=0.000000, refs=1)
-bar
-0
-1
-2
-3.000000
-A
-BA
-BB
-5
-4
-3.000000
+Token (id=00000, line=00001, pos=0001, type=TT_PARANT_L, val=()
+Token (id=00001, line=00001, pos=0005, type=TT_IDENT, val=def)
+Token (id=00002, line=00001, pos=0006, type=TT_PARANT_L, val=()
+Token (id=00003, line=00001, pos=0011, type=TT_IDENT, val=test)
+Token (id=00004, line=00001, pos=0013, type=TT_IDENT, val=a)
+Token (id=00005, line=00001, pos=0014, type=TT_PARANT_R, val=))
+Token (id=00006, line=00002, pos=0004, type=TT_PARANT_L, val=()
+Token (id=00007, line=00002, pos=0008, type=TT_IDENT, val=def)
+Token (id=00008, line=00002, pos=0009, type=TT_PARANT_L, val=()
+Token (id=00009, line=00002, pos=0015, type=TT_IDENT, val=test2)
+Token (id=00010, line=00002, pos=0018, type=TT_IDENT, val=a2)
+Token (id=00011, line=00002, pos=0019, type=TT_PARANT_R, val=))
+Token (id=00012, line=00003, pos=0007, type=TT_PARANT_L, val=()
+Token (id=00013, line=00003, pos=0011, type=TT_IDENT, val=def)
+Token (id=00014, line=00003, pos=0012, type=TT_PARANT_L, val=()
+Token (id=00015, line=00003, pos=0018, type=TT_IDENT, val=test3)
+Token (id=00016, line=00003, pos=0021, type=TT_IDENT, val=a3)
+Token (id=00017, line=00003, pos=0022, type=TT_PARANT_R, val=))
+Token (id=00018, line=00004, pos=0010, type=TT_PARANT_L, val=()
+Token (id=00019, line=00004, pos=0015, type=TT_IDENT, val=BEEP)
+Token (id=00020, line=00004, pos=0016, type=TT_PARANT_R, val=))
+Token (id=00021, line=00004, pos=0017, type=TT_PARANT_R, val=))
+Token (id=00022, line=00005, pos=0007, type=TT_PARANT_L, val=()
+Token (id=00023, line=00005, pos=0013, type=TT_IDENT, val=test3)
+Token (id=00024, line=00005, pos=0016, type=TT_IDENT, val=a2)
+Token (id=00025, line=00005, pos=0017, type=TT_PARANT_R, val=))
+Token (id=00026, line=00005, pos=0018, type=TT_PARANT_R, val=))
+Token (id=00027, line=00006, pos=0004, type=TT_PARANT_L, val=()
+Token (id=00028, line=00006, pos=0008, type=TT_IDENT, val=def)
+Token (id=00029, line=00006, pos=0012, type=TT_IDENT, val=foo)
+Token (id=00030, line=00006, pos=0016, type=TT_IDENT, val=bar)
+Token (id=00031, line=00006, pos=0017, type=TT_PARANT_R, val=))
+Token (id=00032, line=00007, pos=0004, type=TT_PARANT_L, val=()
+Token (id=00033, line=00007, pos=0008, type=TT_IDENT, val=def)
+Token (id=00034, line=00007, pos=0009, type=TT_PARANT_L, val=()
+Token (id=00035, line=00007, pos=0015, type=TT_IDENT, val=barrr)
+Token (id=00036, line=00007, pos=0016, type=TT_PARANT_R, val=))
+Token (id=00037, line=00007, pos=0020, type=TT_IDENT, val=foo)
+Token (id=00038, line=00007, pos=0021, type=TT_PARANT_R, val=))
+Token (id=00039, line=00008, pos=0004, type=TT_PARANT_L, val=()
+Token (id=00040, line=00008, pos=0008, type=TT_IDENT, val=def)
+Token (id=00041, line=00008, pos=0009, type=TT_PARANT_L, val=()
+Token (id=00042, line=00008, pos=0014, type=TT_IDENT, val=barr)
+Token (id=00043, line=00008, pos=0015, type=TT_PARANT_R, val=))
+Token (id=00044, line=00008, pos=0016, type=TT_PARANT_L, val=()
+Token (id=00045, line=00008, pos=0020, type=TT_IDENT, val=foo)
+Token (id=00046, line=00008, pos=0024, type=TT_IDENT, val=baz)
+Token (id=00047, line=00008, pos=0025, type=TT_PARANT_R, val=))
+Token (id=00048, line=00008, pos=0026, type=TT_PARANT_R, val=))
+Token (id=00049, line=00009, pos=0004, type=TT_PARANT_L, val=()
+Token (id=00050, line=00009, pos=0008, type=TT_IDENT, val=def)
+Token (id=00051, line=00009, pos=0009, type=TT_PARANT_L, val=()
+Token (id=00052, line=00009, pos=0013, type=TT_IDENT, val=bar)
+Token (id=00053, line=00009, pos=0015, type=TT_IDENT, val=x)
+Token (id=00054, line=00009, pos=0016, type=TT_PARANT_R, val=))
+Token (id=00055, line=00009, pos=0017, type=TT_PARANT_L, val=()
+Token (id=00056, line=00009, pos=0021, type=TT_IDENT, val=foo)
+Token (id=00057, line=00009, pos=0025, type=TT_IDENT, val=baz)
+Token (id=00058, line=00009, pos=0026, type=TT_PARANT_R, val=))
+Token (id=00059, line=00009, pos=0027, type=TT_PARANT_R, val=))
+Token (id=00060, line=00010, pos=0004, type=TT_PARANT_L, val=()
+Token (id=00061, line=00010, pos=0010, type=TT_IDENT, val=test2)
+Token (id=00062, line=00010, pos=0012, type=TT_IDENT, val=a)
+Token (id=00063, line=00010, pos=0013, type=TT_PARANT_R, val=))
+Token (id=00064, line=00010, pos=0014, type=TT_PARANT_R, val=))
+Token (id=00065, line=00011, pos=0001, type=TT_PARANT_L, val=()
+Token (id=00066, line=00011, pos=0006, type=TT_IDENT, val=test)
+Token (id=00067, line=00011, pos=0007, type=TT_PARANT_L, val=()
+Token (id=00068, line=00011, pos=0011, type=TT_IDENT, val=foo)
+Token (id=00069, line=00011, pos=0015, type=TT_IDENT, val=bar)
+Token (id=00070, line=00011, pos=0019, type=TT_IDENT, val=baz)
+Token (id=00071, line=00011, pos=0020, type=TT_PARANT_R, val=))
+Token (id=00072, line=00011, pos=0021, type=TT_PARANT_R, val=))
+Token (id=00073, line=00012, pos=0001, type=TT_PARANT_L, val=()
+Token (id=00074, line=00012, pos=0005, type=TT_IDENT, val=say)
+Token (id=00075, line=00012, pos=0006, type=TT_STRING, val=hello world)
+Token (id=00076, line=00012, pos=0009, type=TT_INTEGER, val=1)
+Token (id=00077, line=00012, pos=0009, type=TT_DOT, val=.)
+Token (id=00078, line=00012, pos=0011, type=TT_INTEGER, val=2)
+Token (id=00079, line=00012, pos=0012, type=TT_PARANT_R, val=))
+No symbol 'BEEP' defined @ any frame:
+FRAME(id=3) 0:
++ST_VARIABLE(name=a3,value=a2)
+FRAME(id=2) 1:
++ST_VARIABLE(name=a2,value=a)
++ST_LAMBDA(name=test3;args=a3)
+( ( BEEP ) )
+FRAME(id=1) 2:
++ST_LAMBDA(name=a;args=)
+( ( foo bar baz )
++ST_LAMBDA(name=test2;args=a2)
+( ( def ( test3 a3 ) ( BEEP ) ) ( test3 a2 ) )
++ST_LAMBDA(name=barrr;args=)
+( foo )
++ST_LAMBDA(name=barr;args=)
+( ( foo baz ) )
++ST_LAMBDA(name=bar;args=x)
+( ( foo baz ) )
++ST_VARIABLE(name=foo,value=bar)
+FRAME(id=0) 3:
++ST_LAMBDA(name=test;args=a)
+( ( def ( test2 a2 ) ( def ( test3 a3 ) ( BEEP ) ) ( test3 a2 ) ) ( def foo bar ) ( def ( barrr ) foo ) ( def ( barr ) ( foo baz ) ) ( def ( bar x ) ( foo baz ) ) ( test2 a ) )
+Error.: Interpret error in ./test.fype line 4 pos 15 near 'BEEP' (Fype2 @ ./src/core/interpret.c line 342)