return to teapro.com
----------------------------------------------------------------------
C90TEA, How the C90 Teapro Interpreter Works
Copyright (c) 2005-2006 by D La Pierre Ballard
23-OCT-2006
c90tea.com
Email: dlb@teapro.com

In today's world, we need computer software that actually works.
----------------------------------------------------------------------
Please feel free to quote or copy from this webpage. Also, feel free
to link to this webpage.
----------------------------------------------------------------------
There is no warranty of any kind whatsoever on the programming ideas
and examples given on this webpage on c90tea.
----------------------------------------------------------------------
C90tea is the programming methods and constructs used in writing the
Teapro interpreter in C90. C90 is the 1990 standardization of the
programming language C.
----------------------------------------------------------------------
The actual language Teapro will not be covered here. The OpenTea
technology which makes the language Teapro simple and solid will
not be covered here. Both of these topics are covered on other
webpages on teapro.com, opentea.com, c90tea.com and tinytea.com.
----------------------------------------------------------------------
This webpage on c90tea is still in the very earliest stage of being
written. Please check back later for more of it.
----------------------------------------------------------------------
**********************************************************************
CHAPTER: 001: Many of the Standard C Functions were Rewritten
Updated 2006/08/13, 2006/02/18, 2005/11/13
**********************************************************************
----------------------------------------------------------------------
It was decided to rewrite many of the standard C90 functions to
include the lengths of the char arrays. Much tighter control over
the program was gained by doing this. It was felt that the programmer
should know how long these char arrays are.

In teapro.c every string has associated with it a length that is
either an integer or a long.
----------------------------------------------------------------------
**********************************************************************
CHAPTER: 002: Variable Length Strings
Updated 2006/08/13, 2006/02/18, 2005/11/13
**********************************************************************
----------------------------------------------------------------------
The string variables in Teapro can have a length from 0 to 60,000,000
bytes. The C90 command "malloc" is used to create the strings. The
length of each string is stored in a long integer which is associated
with the string by having a very similar name. It was felt that
keeping the length by merely having a zero character at the end of
each was far too prone to problems. Also, it might be desired to have
a zero character somewhere in the middle of the string.

It would be possible to use a structure to hold the long that has the
string length as well as the char pointer to the first byte of the
string. A lot of simplicity would have been given up to move to this
greater level of abstraction. Hence, it was decided not to use
structures for the strings.

The actual Teapro program in teapro.exe is stored using an array of
15,000 or so string pointers and an array of 15,000 or so integers.
The string pointers are for the actual strings of the program lines.
The integers are for the lengths of the program lines.
The fact that the number of maximum possible program lines is set
helps make teapro.exe simple and solid.

String variables are done by having an array of 4000 or so string
pointers with an array of longs. The longs hold the lengths of the
string variables while the array of string pointers has the pointers
to them. Again, the fact that the number, though fairly large, is a
limited number helps make teapro.exe simple and solid.

The maximum length for a string variable in Teapro is 60,000,000
bytes. This is long enough for almost any type of program but is
short enough that having one or two this long will still probably
work.
**********************************************************************
CHAPTER: 003: Variables and Subroutines
Updated 2006/08/13
**********************************************************************
----------------------------------------------------------------------
Variables are allotted to elements on a string array or a double
number array. Right now the string array has 4000 elements, and the
double array has 2000. Global variables are allotted elements with
indices at the beginning. Local variables are allotted elements on
down the arrays. These arrays are commonly called stacks. When a
subroutine is entered the variables for it receive allotted locations
on down the string stack or the double stack depending upon whether
the variable is a string or decimal number. Decimal numbers are stored
in the C data type double.

The local variables inside a subroutines are set to zero length for
strings and zero for doubles when a subroutine ends rather than when
a subroutine begins. This way strings which may be using a lot of
memory are set to zero length as soon as they are not needed at the
end of the subroutine in which they are defined.
----------------------------------------------------------------------
End of Webpage, Program: www.teapro.com/fixran.tea, 23-OCT-2006 19:31:25