From cb1450b796eff3c8830616e2e9a3d83d4dfb4900 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 18 Oct 2008 22:47:31 +0000 Subject: backdowngrade --- Makefile | 2 +- README | 392 ++++++++++++++++++++++------------------------ docs/header.txt | 2 +- docs/help.txt | 2 +- docs/pod/fype.1.gz | Bin 6302 -> 6105 bytes docs/pod/fype.html | 191 ++++++++++------------ docs/pod/fype.man | 157 ++++++++----------- docs/pod/fype.pod | 142 +++++++---------- docs/pod/fype.tex | 154 ++++++++---------- docs/pod/fype.txt | 392 ++++++++++++++++++++++------------------------ docs/stats.txt | 4 +- docs/version.txt | 2 +- examples/all-examples.txt | 335 +++++++++++++++++++++++++++++++++++++++ examples/conditionals.fy | 2 + examples/types.fy | 4 - fype | Bin 0 -> 47628 bytes src/build.h | 2 +- src/core/convert.c | 23 --- src/core/function.c | 97 ++++-------- src/core/garbage.c | 15 +- src/core/interpret.c | 84 +++------- src/core/scanner.c | 12 +- src/core/scanner.h | 1 + src/core/scope.c | 33 +--- src/core/symbol.c | 14 -- src/core/token.c | 133 ++++------------ src/core/token.h | 13 +- src/data/array.c | 50 ++---- src/data/array.h | 2 - src/data/hash.c | 4 +- src/data/stack.c | 17 +- src/data/stack.h | 3 +- src/defines.h | 5 +- src/fype.c | 4 +- tags | 289 ++++++++++++++++++++++++++++++++++ tmp/test.fy | 25 +-- tmp/test.out | 113 +------------ 37 files changed, 1404 insertions(+), 1316 deletions(-) create mode 100644 examples/all-examples.txt create mode 100755 fype create mode 100644 tags diff --git a/Makefile b/Makefile index 719200c..5624b2e 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ SRCS!=find ./src -name '*.c' OBJS=$(SRCS:.c=.o) CC?=cc #CC=mingw32-gcc -DEBUG=-g3 -ggdb3 +#DEBUG=-g3 -ggdb3 CFLAGS+=-c -Wall -std=c99 -pedantic $(DEBUG) LDADD+= HEADER?=docs/header.txt diff --git a/README b/README index b6f6969..66a9695 100644 --- a/README +++ b/README @@ -75,6 +75,42 @@ GETTING STARTED 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 @@ -90,8 +126,8 @@ SYNTAX say foo; exit foo - bar; - Parenthesis - All parenthesis of function calls are optional. They help to make the + Paranthesis + All paranthesis of function calls are optional. They help to make the code better readable. They also help to force precedences of expressions. @@ -139,270 +175,216 @@ SYNTAX Runs the statements as long as the the expression evaluates to a false value. -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* - (Internal name TT_INTEGER) - - *double* - (Internal name TT_DOUBLE) - - *string* - (Internal name TT_STRING) - - *array* - (Internal name TT_ARRAY) - - *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 - The data types inside the brackets are only showing the return types of - each function. - - (*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. - - (*array*) array *any* - Converts any type to an array. This function is not yet implemented. - - More functions for data types - (*string*) type *any* - Returns the name of the current type. Examples: - - my foo = 1; - put type foo; # Prints "TT_INTEGER" - put type 1.2; # Prints "TT_DOUBLE" - 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: + 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 foo = 1 + 2; + say foo; - my bar = 12, baz = foo; - say 1 + bar; - say bar; + my bar = 12, baz = foo; + say 1 + bar; + say bar; - my baz; - say baz; # Will print out 0 + my baz; + say baz; # Will print out 0 - You may use the defined keyword to check if an identifier has been - defined or not. + You may use the defined keyword to check if an identifier has been + defined or not. - ifnot defined foo { - say "No foo yet defined"; - } + ifnot defined foo { + say "No foo yet defined"; + } - my foo = 1; + my foo = 1; - if defined foo { - put "foo is defined and has the value "; - say foo; - } + if defined foo { + put "foo is defined and has the value "; + say foo; + } 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. + 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* + *any* - Special string behavior: A string will get auto convertet into - an *integer*. + (*any*) *any* + *any* + Special string behavior: A string will get auto convertet into an + *integer*. - (*any*) *any* - *any* - Special string behavior: A string will get auto convertet into - an *integer*. + (*any*) *any* - *any* + Special string behavior: A string will get auto convertet into an + *integer*. - (*any*) *any* * *any* - Special string behavior: A string will get auto convertet into - an *integer*. + (*any*) *any* * *any* + Special string behavior: A string will get auto convertet into an + *integer*. - (*any*) *any* / *any* - Special string behavior: A string will get auto convertet into - an *integer*. + (*any*) *any* / *any* + Special string behavior: A string will get auto convertet into an + *integer*. Conditional - (*integer*) *any* == *any* - (*integer*) *any* != *any* - (*integer*) *any* <= *any* - (*integer*) *any* >= *any* - (*integer*) *any* < *any* - (*integer*) *any* > *any* - (*integer*) not *any* + (*integer*) *any* == *any* + (*integer*) *any* != *any* + (*integer*) *any* <= *any* + (*integer*) *any* >= *any* + (*integer*) *any* < *any* + (*integer*) *any* > *any* + (*integer*) not *any* Definedness - (*integer*) defined *identifier* - Returns 1 if *identifier* has been defined. Returns 0 else. + (*integer*) defined *identifier* + Returns 1 if *identifier* has been defined. Returns 0 else. - (*integer*) undef *identifier* - Tries to undefine/delete the *identifier*. Returns 1 if success, - otherwise 0 is returned. + (*integer*) undef *identifier* + Tries to undefine/delete the *identifier*. Returns 1 if success, + otherwise 0 is returned. Bitwise - (*integer*) *any* :< *any* - (*integer*) *any* :> *any* - (*integer*) *any* and *any* - (*integer*) *any* or *any* - (*integer*) *any* xor *any* + (*integer*) *any* :< *any* + (*integer*) *any* :> *any* + (*integer*) *any* and *any* + (*integer*) *any* or *any* + (*integer*) *any* xor *any* Numeric - (*number*) neg *number* - This function returns the negative value of *any* + (*number*) neg *number* + This function returns the negative value of *any* - (*integer*) no [*integer*] - This function returns 1 if the argument is 0, otherwise it will - return 0! If no argument is given, then 0 is returned! + (*integer*) no [*integer*] + This function returns 1 if the argument is 0, otherwise it will + return 0! If no argument is given, then 0 is returned! - (*integer*) yes [*integer*] - This function always returns 1. The parameter is optional. + (*integer*) yes [*integer*] + This function always returns 1. The parameter is optional. - # Prints out 1, because foo is not defined - if yes { say no defined foo; } + # Prints out 1, because foo is not defined + if yes { say no defined foo; } System - (*void*) end - Exits the program with the exit status of 0 + (*void*) end + Exits the program with the exit status of 0 - (*void*) exit *integer* - Exits the program with the specified exit status + (*void*) exit *integer* + Exits the program with the specified exit status - (*integer*) fork - Fork forks a subprocess. It returns 0 for the child process and - the pid of the child process otherwise! Example: + (*integer*) fork + Fork forks a subprocess. It returns 0 for the child process and the + pid of the child process otherwise! Example: - my pid = fork; + my pid = fork; - if pid { - put "I am the parent process; child has the pid "; - say pid; + if pid { + put "I am the parent process; child has the pid "; + say pid; - } ifnot pid { - say "I am the child process"; - } + } ifnot pid { + say "I am the child process"; + } - (*integer*) gc - Executes the garbage collector and returns the number of items - freed! You may wonder why most of the time it will return a - value of 0! Fype tries to free not needed memory asap. This may - change in future versions in order to gain faster execution of - scripts! + (*integer*) gc + Executes the garbage collector and returns the number of items + freed! You may wonder why most of the time it will return a value of + 0! Fype tries to free not needed memory asap. This may change in + future versions in order to gain faster execution of scripts! I/O - (*any*) put *any* - Prints out the argument + (*any*) put *any* + Prints out the argument - (*any*) say *any* - Same as put, but also includes an ending newline + (*any*) say *any* + Same as put, but also includes an ending newline - (*void*) ln - Just prints a newline + (*void*) ln + Just prints a newline SELF DEFINING PROCEDURES AND FUNCTIONS Procedures - A procedure can be defined with the proc keyword and deleted with - the undef keyword. A procedure does not return any value and does - not support parameter passing. It's using already defined variables - (e.g. global variables). A procedure does not have its own - namespace. It's using the calling namespace. It is possible to - define new variabes inside of a procedure in the current namespace. - - proc foo { - say 1 + a * 3 + b; - my c = 6; - } + A procedure can be defined with the proc keyword and deleted with the + undef keyword. A procedure does not return any value and does not + support parameter passing. It's using already defined variables (e.g. + global variables). A procedure does not have its own namespace. It's + using the calling namespace. It is possible to define new variabes + inside of a procedure in the current namespace. + + proc foo { + say 1 + a * 3 + b; + my c = 6; + } - my a = 2, b = 4; + my a = 2, b = 4; - foo; # Run the procedure. Print out "11\n" - say c; # Print out "6\n"; + foo; # Run the procedure. Print out "11\n" + say c; # Print out "6\n"; Nested procedures - It's possible to define procedures inside of procedures. Since - procedures don't have its own scope, nested procedures will be - available to the current scope as soon as the main procedure has run - the first time. You may use the defined keyword in order to check if - a procedure has been defined or not. - - proc foo { - say "I am foo"; - - undef bar; - proc bar { - say "I am bar"; - } - } + It's possible to define procedures inside of procedures. Since + procedures don't have its own scope, nested procedures will be available + to the current scope as soon as the main procedure has run the first + time. You may use the defined keyword in order to check if a procedure + has been defined or not. + + proc foo { + say "I am foo"; + + undef bar; + proc bar { + say "I am bar"; + } + } - # Here bar would produce an error because - # the proc is not yet defined! - # bar; + # Here bar would produce an error because + # the proc is not yet defined! + # bar; - foo; # Here the procedure foo will define the procedure bar! - bar; # Now the procedure bar is defined! - foo; # Here the procedure foo will redefine bar again! + foo; # Here the procedure foo will define the procedure bar! + bar; # Now the procedure bar is defined! + foo; # Here the procedure foo will redefine bar again! Functions - A function should be defined with the func keyword and deleted with - the undef keyword. Function not yet return values (will be changed - in future versions) and supports not yet parameter passing (will be - changed in future versions). It's using local (lexical scoped) - variables. If a certain variable does not exist It's using already - defined variables (e.g. one scope above). - - func foo { - say 1 + a * 3 + b; - my c = 6; - } + A function should be defined with the func keyword and deleted with the + undef keyword. Function not yet return values (will be changed in future + versions) and supports not yet parameter passing (will be changed in + future versions). It's using local (lexical scoped) variables. If a + certain variable does not exist It's using already defined variables + (e.g. one scope above). + + func foo { + say 1 + a * 3 + b; + my c = 6; + } - my a = 2, b = 4; + my a = 2, b = 4; - foo; # Run the procedure. Print out "11\n" - say c; # Will produce an error, because c is out of scoped! + foo; # Run the procedure. Print out "11\n" + say c; # Will produce an error, because c is out of scoped! Nested functions - Nested functions work the same way the nested procedures work, with - the exception that nested functions will not be available any more - after the function has been left! + Nested functions work the same way the nested procedures work, with the + exception that nested functions will not be available any more after the + function has been left! - func foo { - func bar { - say "Hello i am nested"; - } + func foo { + func bar { + say "Hello i am nested"; + } - bar; # Calling nested - } + bar; # Calling nested + } - foo; - bar; # Will produce an error, because bar is out of scope! + foo; + bar; # Will produce an error, because bar is out of scope! AUTHOR - Paul C. Buetow (http://paul.buetow.org) + Paul C. Buetow (http://paul.buetow.org) WEBSITE - The Fype Language (http://fype.buetow.org) + The Fype Language (http://fype.buetow.org) SEE ALSO - awk(1) cc(1) + awk(1) cc(1) make(1) diff --git a/docs/header.txt b/docs/header.txt index 651e6e9..d673a17 100644 --- a/docs/header.txt +++ b/docs/header.txt @@ -1,5 +1,5 @@ File: ${FILE} -A simple interpreter +A simple interpreter WWW : http://fype.buetow.org E-Mail : fype@dev.buetow.org diff --git a/docs/help.txt b/docs/help.txt index 66881ef..b99470f 100644 --- a/docs/help.txt +++ b/docs/help.txt @@ -1,4 +1,4 @@ -Fype v0.1-devel Build 9640 +Fype v0.1-devel Build 9213 Copyright by Paul C. Buetow (2005 - 2008) -e Executes given code string (see synopses) -h Prints this help diff --git a/docs/pod/fype.1.gz b/docs/pod/fype.1.gz index 29ae39d..e05d4c5 100644 Binary files a/docs/pod/fype.1.gz and b/docs/pod/fype.1.gz differ diff --git a/docs/pod/fype.html b/docs/pod/fype.html index 47397a4..b88a1b4 100644 --- a/docs/pod/fype.html +++ b/docs/pod/fype.html @@ -20,24 +20,23 @@
  • PARSING / CODE GENERATION
  • REQUIREMENTS
  • GETTING STARTED
  • +
  • DATA TYPES
  • + +
  • SYNTAX
  • -
  • DATA TYPES
  • - -
  • VARIABLES
  • BUILT IN FUNCTIONS