summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2010-05-12 20:28:06 +0000
committerPaul Buetow <paul@buetow.org>2010-05-12 20:28:06 +0000
commit3e452b027838fb8114c226667dcab04c9121f61b (patch)
treed9fc06ec69b3a5b02b1261971698547a109356f0
parente3414345f18156200a2ac8ee055aacff7909e2ce (diff)
parent0b7e31f8586a8237297f29793169b3eb27842f46 (diff)
lambda is the new trunk
-rw-r--r--COPYING35
-rw-r--r--Makefile24
-rw-r--r--NEW6
-rw-r--r--README435
-rw-r--r--Session.vim133
-rw-r--r--TODO11
-rw-r--r--docs/fype.txt13
-rw-r--r--docs/header.txt11
-rw-r--r--docs/help.txt4
-rw-r--r--docs/pod/Makefile20
-rw-r--r--docs/pod/fype.1.gzbin6545 -> 0 bytes
-rw-r--r--docs/pod/fype.html629
-rw-r--r--docs/pod/fype.man625
-rw-r--r--docs/pod/fype.pod495
-rw-r--r--docs/pod/fype.tex569
-rw-r--r--docs/pod/fype.txt435
-rw-r--r--docs/stats.txt8
-rw-r--r--docs/version.txt2
-rw-r--r--examples/all-examples.txt377
-rw-r--r--examples/assert.fy14
-rw-r--r--examples/bitwise.fy32
-rw-r--r--examples/comments.fy21
-rw-r--r--examples/conditionals.fy41
-rw-r--r--examples/control.fy32
-rw-r--r--examples/expressions.fy31
-rw-r--r--examples/fork.fy14
-rw-r--r--examples/functions.fy25
-rw-r--r--examples/inlinefunctions.fy20
-rw-r--r--examples/io.fy13
-rw-r--r--examples/procedures.fy30
-rw-r--r--examples/scopeing.fy31
-rw-r--r--examples/synonyms.fy37
-rw-r--r--examples/types.fy14
-rw-r--r--examples/variables.fy21
-rwxr-xr-xfypebin702117 -> 0 bytes
-rw-r--r--src/argv.c11
-rw-r--r--src/argv.h11
-rw-r--r--src/build.h13
-rw-r--r--src/core/convert.c216
-rw-r--r--src/core/frame.c152
-rw-r--r--src/core/frame.h (renamed from src/core/scope.h)64
-rw-r--r--src/core/functions.c985
-rw-r--r--src/core/functions.h64
-rw-r--r--src/core/garbage.c144
-rw-r--r--src/core/interpret.c1227
-rw-r--r--src/core/interpret.h52
-rw-r--r--src/core/lambda.c98
-rw-r--r--src/core/lambda.h (renamed from src/core/convert.h)42
-rw-r--r--src/core/promise.c60
-rw-r--r--src/core/promise.h (renamed from src/core/function.c)36
-rw-r--r--src/core/scanner.c139
-rw-r--r--src/core/scanner.h14
-rw-r--r--src/core/scope.c169
-rw-r--r--src/core/symbol.c122
-rw-r--r--src/core/symbol.h71
-rw-r--r--src/core/token.c341
-rw-r--r--src/core/token.h144
-rw-r--r--src/core/tools.c (renamed from src/core/garbage.h)64
-rw-r--r--src/core/tools.h (renamed from src/core/function.h)26
-rw-r--r--src/core/variable.c59
-rw-r--r--src/core/variable.h (renamed from src/core/reference.h)38
-rw-r--r--src/data/array.c11
-rw-r--r--src/data/array.h11
-rw-r--r--src/data/cons.c88
-rw-r--r--src/data/cons.h (renamed from src/core/reference.c)46
-rw-r--r--src/data/dat.c11
-rw-r--r--src/data/dat.h11
-rw-r--r--src/data/hash.c19
-rw-r--r--src/data/hash.h20
-rw-r--r--src/data/list.c80
-rw-r--r--src/data/list.h28
-rw-r--r--src/data/map.c11
-rw-r--r--src/data/map.h11
-rw-r--r--src/data/queue.c11
-rw-r--r--src/data/queue.h11
-rw-r--r--src/data/stack.c11
-rw-r--r--src/data/stack.h11
-rw-r--r--src/data/tree.c58
-rw-r--r--src/data/tree.h11
-rw-r--r--src/data/tupel.c11
-rw-r--r--src/data/tupel.h11
-rw-r--r--src/data/types.h11
-rw-r--r--src/defines.h31
-rw-r--r--src/fype.c29
-rw-r--r--src/fype.h13
-rw-r--r--src/main.c11
-rw-r--r--tags158
-rw-r--r--test.fy23
-rw-r--r--test.fype0
-rw-r--r--test.out208
90 files changed, 1451 insertions, 8085 deletions
diff --git a/COPYING b/COPYING
index e7642a4..e8eb069 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 Paul 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/Makefile b/Makefile
index f9d8ce4..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)
diff --git a/NEW b/NEW
deleted file mode 100644
index b0dbb82..0000000
--- a/NEW
+++ /dev/null
@@ -1,6 +0,0 @@
-keywords:
- refs
-
-functions:
- ind
- len
diff --git a/README b/README
deleted file mode 100644
index a6be7b8..0000000
--- a/README
+++ /dev/null
@@ -1,435 +0,0 @@
-NAME
- Fype is For Your Program Execution
-
- Fype is Free Yak Programed for ELF
-
- It's not a hype - it's Fype!
-
-SYNOPSES
- fype [-[hsvTV]] file.fy
- fype -e "fype code string;"
-
-ABOUT
- Fype is not yet released! Lots of basic stuff is still missing! See the
- TODO file of the source distribution of Fype!
-
- Fype is a 32 bit scripting language created for fun. You can use it and
- comment on it if you like. You could also write patches and mail them to
- fype at dev dot buetow dot org! Or go visit the IRC channel #coding at
- irc.german-elite.net and ask rantanplan.
-
- Fype is developed under the BSD license. See the COPYING file which is
- included in the source tree.
-
- Fype should be "at least as good as AWK". This does not mean it will be
- a replacement for AWK but it should support functions, loops and arrays
- like AWK does but with a different syntax. It should also get extension
- support like AWK has. I am not talking about GNU AWK but about New AWK,
- which is included in the *BSD distributions! Fype already has a few
- features which are not available in AWK. However, AWK has still many
- features which are not available in Fype as well ;)
-
- Fancy stuff like OOP or unicode or threading is not yet planed. But
- fancy stuff like function pointers and closures may be considered for
- one of the first releases of Fype :)
-
-PARSING / CODE GENERATION
- The Fype syntax is very simple and is using a maximum look ahead of 1
- and a very easy top down parsing. Fype is parsing and interpreting its
- code simultaneous. This means, that syntax errors are only detected
- during program runtime.
-
-REQUIREMENTS
- Fype only has been tested on FreeBSD 7.0. Linux may work too. Windows
- support is not planned. But may work using Cygwin or SFU. Linux users
- have to install pmake before compiling Fype!
-
- You will need:
-
- GNU GCC C Compiler (gcc.gnu.org)
- NetBSD Make aka pmake (GNU Make will not work)
-
- NetBSD Make is included in any *BSD and can be run with just make.
-
-GETTING STARTED
- On Linux: Extract, compile and install Fype:
-
- tar xvjf fype.tar.bz2
- cd fype
- pmake
- sudo pmake install
- pmake clean
-
- On FreeBSD: Extract, compile and install Fype:
-
- tar xvjf fype.tar.bz2
- cd fype
- make
- sudo make install
- make clean
-
- Run a .fy file:
-
- fype test.fy
-
- See the ./examples subdir of the Fype source distribution for examples!
- See also fype -h for a list of all options.
-
-DATA TYPES
- Fype uses auto type conversion. However, if you want to know what's
- going on you may take a look at the provided basic datatypes.
-
- The basic data types
- *integer*
- Specifies an integer number
-
- *double*
- Specifies a double number
-
- *string*
- Specifies a string
-
- *number*
- May be an integer or a double number
-
- *any*
- May be of any type above
-
- *void*
- No type
-
- *identifier*
- It's a variable name or a procedure name or a function name
-
- Explicit type conversions
- (*integer*) integer *any*
- Converts any type to an integer
-
- (*double*) double *any*
- Converts any type to a double
-
- (*string*) string *any*
- Converts any type to a string
-
-SYNTAX
- Comments
- Text from a # character until the end of the current line is considered
- being a comment. Multi line comments may start with an #* and and with
- an *# anywhere. Exceptions are if those signs are inside of strings.
-
- Statements
- A Fype program is a list of statements. Each keyword, expression or
- function call is part of a statement. Each statement is ended with a
- semicolon. Example:
-
- my bar = 3, foo = 1 + 2;
- say foo;
- exit foo - bar;
-
- Paranthesis
- All paranthesis of function calls are optional. They help to make the
- code better readable. They also help to force precedences of
- expressions.
-
- Scopeing
- A new scope starts with an { and ends with an }. An exception is a
- procedure, which does not use its own scope (see later in this manual).
- Control statements and functions support scopeings. The scope function
- will print out all available symbols at the current position. Here is a
- small example of how to use scopes:
-
- my foo = 1;
-
- {
- # Prints out 1
- put defined foo;
- {
- my bar = 2;
-
- # Prints out 1
- put defined bar;
-
- # Prints out all available symbols at this
- # point to stdout. Those are: bar and foo
- scope;
- }
-
- # Prints out 0
- put defined bar;
-
- my baz = 3;
- }
-
- # Prints out 0
- say defined bar;
-
- Control statements
- Fype knows the following control statements:
-
- if *<expression*> { *<statements*> }
- Runs the statements if the expression evaluates to a true value.
-
- ifnot *<expression*> { *<statements*> }
- Runs the statements if the expression evaluates to a false value.
-
- while *<expression*> { *<statements*> }
- Runs the statements as long as the the expression evaluates to a
- true value.
-
- until *<expression*> { *<statements*> }
- Runs the statements as long as the the expression evaluates to a
- false value.
-
-VARIABLES
- Variables can be defined with the my keyword. If you don't assign a
- value during declaration, then it's using the default integer value 0.
- Variables may be changed during program runtime. Variables may be
- deleted using the undef keyword! Example of defining variables:
-
- my foo = 1 + 2;
- say foo;
-
- my bar = 12, baz = foo;
- say 1 + bar;
- say bar;
-
- my baz;
- say baz; # Will print out 0
-
- You may use the defined keyword to check if an identifier has been
- defined or not.
-
- ifnot defined foo {
- say "No foo yet defined";
- }
-
- my foo = 1;
-
- if defined foo {
- put "foo is defined and has the value ";
- say foo;
- }
-
-SYNONYMS
- Each variable can have as many synonyms as wished. A synonym is another
- name to access the content of a specific variable. Here is an example of
- how to use synomyms:
-
- my foo = "foo";
- my bar = \foo;
- foo = "bar";
-
- # The synonym variable should now also set to "bar"
- assert "bar" == bar;
-
- Synonyms can be used for all kind of identifiers. It's not limited to
- normal variables but can be also used for function and procedure names
- etc.
-
- # Create a new procedure baz
- proc baz { say "I am baz"; }
-
- # Make a synonym baz, and undefine baz
- my bay = \baz;
-
- undef baz;
-
- # bay still has a reference of the original procedure baz
- bay; # this prints aut "I am baz"
-
- The syms keyword gives you the total number of synonyms pointing to a
- specific value:
-
- my foo = 1;
- say syms foo; # Prints 1
-
- my baz = \foo;
- say syms foo; # Prints 2
- say syms baz; # Prints 2
-
- undef baz;
- say syms foo; # Prints 1
-
-BUILT IN FUNCTIONS
- In Fype, operators are built in functions as well. The difference is,
- that they may be written in infix notation instead in front of the
- arguments. The types inside the () specify the return types.
-
- Math
- (*any*) *any* + *an