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);
+}