2019-07-22 20:32:33 +00:00
|
|
|
#ifndef FUNC_H
|
|
|
|
#define FUNC_H
|
|
|
|
|
2019-09-03 08:41:37 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
Streamline internals of teapot
The primary change is to add a “funcall” token, so that an entire expression
can be encapsulated as a single token. This change is used to allow a cell to
include simply a selection of appropriate semantic tokens. I.e., the content
and iterative content are now each a single token like the value and the
result value. Token vectors are used only as intermediate results in scanning
and parsing.
Not this means the cells are now in effect storing parse trees, so
computation should be slightly faster and future extensions (like #56) should
be facilitated.
This commit also takes the opportunity while internals are being altered to
add another token to a cell for future use for computed attributes, cf #22,
and to change the internal numerical values from double and ints to long
doubles and long longs. However, the change attempts to encapsulate that
choice so it would be easy to change back or change to another representation.
Note that these changes break savexdr(), as the internal binary format of
a cell is now different. Rather than reimplement it, it is deprecated as
the world does not need another binary spreadsheet format. Hence, the
ascii format for teapot spreadsheets becomes the primary file format.
Loading of old xdr files is still supported for backward compatibility.
Closes #59.
Also along the way, various other slight fixes and enhancements crept in,
a partial but probably not exhaustive list of which follows:
Fixes #31.
Further revisions and improvements to documentation.
Make the approximate comparison of floating point values scale more
accurately with the size of the doubles being compared.
Further extensions of absolute and relative cell addressing.
Addition of (circle constant) tau function/constant.
Modified string conversion to simply use internal printing routines, and
to take "scientific" and "decimal" keywords.
Allowed n() function to take a list of values, or just a single location
defaulting to the current location.
Added floor, ceil, trunc, and round functions, and allowed them to be
keywords controlling the int() integer conversion function as well.
Allowed substr() to drop its last argument to go to the end of the string.
Provided an enum of built-in functions to preserve legacy function
identifiers, allowing the large table inside func.c to be reorganized
in a clearer fashion.
Added additional annotation of properties of the built-in functions,
including precedence.
All operators are now also accessible as built-in functions.
Made precedence of unary - lower than ^ to match python.
Avoided inadvertently using FLTK @symbol abbreviations for formulas with
"@" in them.
2019-08-23 19:12:06 +00:00
|
|
|
#define MAX_FUNC_NAME_LENGTH 20
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
/* The purpose of this enum is to enforce backward compatibility
|
|
|
|
of numeric function identifiers which may be recorded in old
|
|
|
|
save files. Hence, do NOT change the order of the items in this
|
|
|
|
enum, merely add new identifiers at the end, just before
|
|
|
|
N_FUNCTION_IDENTIFIERS.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
NOT_A_FUNCTION = -1,
|
|
|
|
FIRST_FUNCTION = 0,
|
|
|
|
FUNC_AT_SYMBOL = 0, FUNC_AMPERSAND, FUNC_X, FUNC_Y, FUNC_Z, FUNC_EVAL,
|
|
|
|
FUNC_ERROR, FUNC_STRING, FUNC_SUM, FUNC_N, FUNC_INT, FUNC_FRAC, FUNC_LEN,
|
|
|
|
FUNC_MIN, FUNC_MAX, FUNC_ABS, FUNC_DOLLAR_SIGN, FUNC_FLOAT, FUNC_STRFTIME,
|
|
|
|
FUNC_CLOCK, FUNC_POLY, FUNC_E, FUNC_LOG, FUNC_SIN, FUNC_COS, FUNC_TAN,
|
|
|
|
FUNC_SINH, FUNC_COSH, FUNC_TANH, FUNC_ASIN, FUNC_ACOS, FUNC_ATAN,
|
|
|
|
FUNC_ARSINH, FUNC_ARCOSH, FUNC_ARTANH, FUNC_DEG2RAD, FUNC_RAD2DEG,
|
|
|
|
FUNC_RND, FUNC_SUBSTR, FUNC_STRPTIME, FUNC_TIME, FUNC_BITAND, FUNC_BITOR,
|
|
|
|
FUNC_R, FUNC_D, FUNC_CAP_X, FUNC_X_AMPERSAND, FUNC_NEGATE, FUNC_PLUS_SYMBOL,
|
|
|
|
FUNC_MINUS_SYMBOL, FUNC_ASTERISK, FUNC_SLASH,
|
2019-08-28 06:30:02 +00:00
|
|
|
|
|
|
|
/* Note use of these in the macro below */
|
Streamline internals of teapot
The primary change is to add a “funcall” token, so that an entire expression
can be encapsulated as a single token. This change is used to allow a cell to
include simply a selection of appropriate semantic tokens. I.e., the content
and iterative content are now each a single token like the value and the
result value. Token vectors are used only as intermediate results in scanning
and parsing.
Not this means the cells are now in effect storing parse trees, so
computation should be slightly faster and future extensions (like #56) should
be facilitated.
This commit also takes the opportunity while internals are being altered to
add another token to a cell for future use for computed attributes, cf #22,
and to change the internal numerical values from double and ints to long
doubles and long longs. However, the change attempts to encapsulate that
choice so it would be easy to change back or change to another representation.
Note that these changes break savexdr(), as the internal binary format of
a cell is now different. Rather than reimplement it, it is deprecated as
the world does not need another binary spreadsheet format. Hence, the
ascii format for teapot spreadsheets becomes the primary file format.
Loading of old xdr files is still supported for backward compatibility.
Closes #59.
Also along the way, various other slight fixes and enhancements crept in,
a partial but probably not exhaustive list of which follows:
Fixes #31.
Further revisions and improvements to documentation.
Make the approximate comparison of floating point values scale more
accurately with the size of the doubles being compared.
Further extensions of absolute and relative cell addressing.
Addition of (circle constant) tau function/constant.
Modified string conversion to simply use internal printing routines, and
to take "scientific" and "decimal" keywords.
Allowed n() function to take a list of values, or just a single location
defaulting to the current location.
Added floor, ceil, trunc, and round functions, and allowed them to be
keywords controlling the int() integer conversion function as well.
Allowed substr() to drop its last argument to go to the end of the string.
Provided an enum of built-in functions to preserve legacy function
identifiers, allowing the large table inside func.c to be reorganized
in a clearer fashion.
Added additional annotation of properties of the built-in functions,
including precedence.
All operators are now also accessible as built-in functions.
Made precedence of unary - lower than ^ to match python.
Avoided inadvertently using FLTK @symbol abbreviations for formulas with
"@" in them.
2019-08-23 19:12:06 +00:00
|
|
|
FUNC_LESS_EQUAL, FUNC_GREATER_EQUAL, FUNC_LESS_THAN, FUNC_GREATER_THAN,
|
2019-08-27 06:56:19 +00:00
|
|
|
FUNC_EQUAL_EQUAL, FUNC_TILDE_EQUAL, FUNC_BANG_EQUAL,
|
|
|
|
|
|
|
|
FUNC_CARET,
|
Streamline internals of teapot
The primary change is to add a “funcall” token, so that an entire expression
can be encapsulated as a single token. This change is used to allow a cell to
include simply a selection of appropriate semantic tokens. I.e., the content
and iterative content are now each a single token like the value and the
result value. Token vectors are used only as intermediate results in scanning
and parsing.
Not this means the cells are now in effect storing parse trees, so
computation should be slightly faster and future extensions (like #56) should
be facilitated.
This commit also takes the opportunity while internals are being altered to
add another token to a cell for future use for computed attributes, cf #22,
and to change the internal numerical values from double and ints to long
doubles and long longs. However, the change attempts to encapsulate that
choice so it would be easy to change back or change to another representation.
Note that these changes break savexdr(), as the internal binary format of
a cell is now different. Rather than reimplement it, it is deprecated as
the world does not need another binary spreadsheet format. Hence, the
ascii format for teapot spreadsheets becomes the primary file format.
Loading of old xdr files is still supported for backward compatibility.
Closes #59.
Also along the way, various other slight fixes and enhancements crept in,
a partial but probably not exhaustive list of which follows:
Fixes #31.
Further revisions and improvements to documentation.
Make the approximate comparison of floating point values scale more
accurately with the size of the doubles being compared.
Further extensions of absolute and relative cell addressing.
Addition of (circle constant) tau function/constant.
Modified string conversion to simply use internal printing routines, and
to take "scientific" and "decimal" keywords.
Allowed n() function to take a list of values, or just a single location
defaulting to the current location.
Added floor, ceil, trunc, and round functions, and allowed them to be
keywords controlling the int() integer conversion function as well.
Allowed substr() to drop its last argument to go to the end of the string.
Provided an enum of built-in functions to preserve legacy function
identifiers, allowing the large table inside func.c to be reorganized
in a clearer fashion.
Added additional annotation of properties of the built-in functions,
including precedence.
All operators are now also accessible as built-in functions.
Made precedence of unary - lower than ^ to match python.
Avoided inadvertently using FLTK @symbol abbreviations for formulas with
"@" in them.
2019-08-23 19:12:06 +00:00
|
|
|
FUNC_PER_CENT, FUNC_CONCAT, FUNC_TAU, FUNC_SQRT, FUNC_FLOOR, FUNC_CEIL,
|
Make tpa the default file format for Teapot
There turned out to be one blocking technical issue for full adpotion of
tpa format, and that was the fact that the printed representation of
floating values inside the tpa file might not reproduce the same double
when read. This change therefore introduces the "hexact" floating point
format, based on the the %La format string, which produces a hex
representation with exact round trips. While working on this, it was
convenient to add a new representation "compact" which is basically the
shorter of decimal and scientific representations, without trailing zeros.
This is now the default float format, but of course one can select decimal
or scientific formats to restore prior appearance. However, full-precision
compact format is now the (only) format for editing cell contents, as it
is accurate and efficient. Of course you can enter floating point values
in any format you like when typing in a formula.
The addition of several new floating point options overloaded the menus
in terminal teapot, so this change also revamps those menus slightly,
including eliminating the unused MenuChoice struct, and just specifying menus
with an array of strings.
Closes #63.
2019-08-24 16:58:46 +00:00
|
|
|
FUNC_TRUNC, FUNC_ROUND, FUNC_DECIMAL, FUNC_SCIENTIFIC, FUNC_COMPACT,
|
2019-08-26 06:19:34 +00:00
|
|
|
FUNC_HEXACT, FUNC_RIGHT, FUNC_LEFT, FUNC_DOWN, FUNC_UP, FUNC_BELOW, FUNC_ABOVE,
|
2019-08-27 06:56:19 +00:00
|
|
|
FUNC_TRUE, FUNC_FALSE, FUNC_AND, FUNC_OR,
|
Streamline internals of teapot
The primary change is to add a “funcall” token, so that an entire expression
can be encapsulated as a single token. This change is used to allow a cell to
include simply a selection of appropriate semantic tokens. I.e., the content
and iterative content are now each a single token like the value and the
result value. Token vectors are used only as intermediate results in scanning
and parsing.
Not this means the cells are now in effect storing parse trees, so
computation should be slightly faster and future extensions (like #56) should
be facilitated.
This commit also takes the opportunity while internals are being altered to
add another token to a cell for future use for computed attributes, cf #22,
and to change the internal numerical values from double and ints to long
doubles and long longs. However, the change attempts to encapsulate that
choice so it would be easy to change back or change to another representation.
Note that these changes break savexdr(), as the internal binary format of
a cell is now different. Rather than reimplement it, it is deprecated as
the world does not need another binary spreadsheet format. Hence, the
ascii format for teapot spreadsheets becomes the primary file format.
Loading of old xdr files is still supported for backward compatibility.
Closes #59.
Also along the way, various other slight fixes and enhancements crept in,
a partial but probably not exhaustive list of which follows:
Fixes #31.
Further revisions and improvements to documentation.
Make the approximate comparison of floating point values scale more
accurately with the size of the doubles being compared.
Further extensions of absolute and relative cell addressing.
Addition of (circle constant) tau function/constant.
Modified string conversion to simply use internal printing routines, and
to take "scientific" and "decimal" keywords.
Allowed n() function to take a list of values, or just a single location
defaulting to the current location.
Added floor, ceil, trunc, and round functions, and allowed them to be
keywords controlling the int() integer conversion function as well.
Allowed substr() to drop its last argument to go to the end of the string.
Provided an enum of built-in functions to preserve legacy function
identifiers, allowing the large table inside func.c to be reorganized
in a clearer fashion.
Added additional annotation of properties of the built-in functions,
including precedence.
All operators are now also accessible as built-in functions.
Made precedence of unary - lower than ^ to match python.
Avoided inadvertently using FLTK @symbol abbreviations for formulas with
"@" in them.
2019-08-23 19:12:06 +00:00
|
|
|
|
2019-08-28 06:30:02 +00:00
|
|
|
/* Note use of these in the macro below */
|
|
|
|
FUNC_BOOL, FUNC_EMPTY, FUNC_FIDENT,
|
|
|
|
FUNC_FUNCALL, FUNC_LIDENT, FUNC_LOCATION, FUNC_NUMBER, FUNC_OPERATOR,
|
|
|
|
|
2019-09-03 08:41:37 +00:00
|
|
|
FUNC_IS, FUNC_FIND, FUNC_PRECISION, FUNC_FOREGROUND, FUNC_BACKGROUND,
|
|
|
|
FUNC_JUSTIFY, FUNC_FLOATFMT, FUNC_SHADOWED, FUNC_TRANSPARENT, FUNC_BOLD,
|
2019-09-09 14:33:41 +00:00
|
|
|
FUNC_UNDERLINE, FUNC_CENTER, FUNC_STYLE,
|
|
|
|
|
|
|
|
FUNC_FIX,
|
2019-08-28 06:30:02 +00:00
|
|
|
|
Streamline internals of teapot
The primary change is to add a “funcall” token, so that an entire expression
can be encapsulated as a single token. This change is used to allow a cell to
include simply a selection of appropriate semantic tokens. I.e., the content
and iterative content are now each a single token like the value and the
result value. Token vectors are used only as intermediate results in scanning
and parsing.
Not this means the cells are now in effect storing parse trees, so
computation should be slightly faster and future extensions (like #56) should
be facilitated.
This commit also takes the opportunity while internals are being altered to
add another token to a cell for future use for computed attributes, cf #22,
and to change the internal numerical values from double and ints to long
doubles and long longs. However, the change attempts to encapsulate that
choice so it would be easy to change back or change to another representation.
Note that these changes break savexdr(), as the internal binary format of
a cell is now different. Rather than reimplement it, it is deprecated as
the world does not need another binary spreadsheet format. Hence, the
ascii format for teapot spreadsheets becomes the primary file format.
Loading of old xdr files is still supported for backward compatibility.
Closes #59.
Also along the way, various other slight fixes and enhancements crept in,
a partial but probably not exhaustive list of which follows:
Fixes #31.
Further revisions and improvements to documentation.
Make the approximate comparison of floating point values scale more
accurately with the size of the doubles being compared.
Further extensions of absolute and relative cell addressing.
Addition of (circle constant) tau function/constant.
Modified string conversion to simply use internal printing routines, and
to take "scientific" and "decimal" keywords.
Allowed n() function to take a list of values, or just a single location
defaulting to the current location.
Added floor, ceil, trunc, and round functions, and allowed them to be
keywords controlling the int() integer conversion function as well.
Allowed substr() to drop its last argument to go to the end of the string.
Provided an enum of built-in functions to preserve legacy function
identifiers, allowing the large table inside func.c to be reorganized
in a clearer fashion.
Added additional annotation of properties of the built-in functions,
including precedence.
All operators are now also accessible as built-in functions.
Made precedence of unary - lower than ^ to match python.
Avoided inadvertently using FLTK @symbol abbreviations for formulas with
"@" in them.
2019-08-23 19:12:06 +00:00
|
|
|
N_FUNCTION_IDS
|
|
|
|
} FunctionIdentifier;
|
|
|
|
|
2019-08-27 06:56:19 +00:00
|
|
|
#define IS_RELATION_FUNC(f) (((f) >= FUNC_LESS_EQUAL) && ((f) <= FUNC_BANG_EQUAL))
|
2019-09-09 14:33:41 +00:00
|
|
|
#define IS_TYPE_FUNC(f) (((f) >= FUNC_BOOL && ((f) <= FUNC_OPERATOR)) || (f)==FUNC_ERROR || (f)==FUNC_FLOAT || (f)==FUNC_INT || (f)==FUNC_STRING || (f)==FUNC_STYLE)
|
2019-08-27 06:56:19 +00:00
|
|
|
|
Streamline internals of teapot
The primary change is to add a “funcall” token, so that an entire expression
can be encapsulated as a single token. This change is used to allow a cell to
include simply a selection of appropriate semantic tokens. I.e., the content
and iterative content are now each a single token like the value and the
result value. Token vectors are used only as intermediate results in scanning
and parsing.
Not this means the cells are now in effect storing parse trees, so
computation should be slightly faster and future extensions (like #56) should
be facilitated.
This commit also takes the opportunity while internals are being altered to
add another token to a cell for future use for computed attributes, cf #22,
and to change the internal numerical values from double and ints to long
doubles and long longs. However, the change attempts to encapsulate that
choice so it would be easy to change back or change to another representation.
Note that these changes break savexdr(), as the internal binary format of
a cell is now different. Rather than reimplement it, it is deprecated as
the world does not need another binary spreadsheet format. Hence, the
ascii format for teapot spreadsheets becomes the primary file format.
Loading of old xdr files is still supported for backward compatibility.
Closes #59.
Also along the way, various other slight fixes and enhancements crept in,
a partial but probably not exhaustive list of which follows:
Fixes #31.
Further revisions and improvements to documentation.
Make the approximate comparison of floating point values scale more
accurately with the size of the doubles being compared.
Further extensions of absolute and relative cell addressing.
Addition of (circle constant) tau function/constant.
Modified string conversion to simply use internal printing routines, and
to take "scientific" and "decimal" keywords.
Allowed n() function to take a list of values, or just a single location
defaulting to the current location.
Added floor, ceil, trunc, and round functions, and allowed them to be
keywords controlling the int() integer conversion function as well.
Allowed substr() to drop its last argument to go to the end of the string.
Provided an enum of built-in functions to preserve legacy function
identifiers, allowing the large table inside func.c to be reorganized
in a clearer fashion.
Added additional annotation of properties of the built-in functions,
including precedence.
All operators are now also accessible as built-in functions.
Made precedence of unary - lower than ^ to match python.
Avoided inadvertently using FLTK @symbol abbreviations for formulas with
"@" in them.
2019-08-23 19:12:06 +00:00
|
|
|
/* Forward declaration of Token, since this header is used in scanner.h */
|
|
|
|
typedef struct Token_struc Token;
|
|
|
|
|
|
|
|
typedef enum /* In increasing order of precedence */
|
|
|
|
{
|
2019-08-27 06:56:19 +00:00
|
|
|
NO_PRECEDENCE, INFIX_CONC, INFIX_BOOL, INFIX_REL, INFIX_PLUS, INFIX_MUL,
|
2019-08-24 22:17:35 +00:00
|
|
|
PREFIX_NEG, INFIX_POW, PREFIX_FUNC
|
Streamline internals of teapot
The primary change is to add a “funcall” token, so that an entire expression
can be encapsulated as a single token. This change is used to allow a cell to
include simply a selection of appropriate semantic tokens. I.e., the content
and iterative content are now each a single token like the value and the
result value. Token vectors are used only as intermediate results in scanning
and parsing.
Not this means the cells are now in effect storing parse trees, so
computation should be slightly faster and future extensions (like #56) should
be facilitated.
This commit also takes the opportunity while internals are being altered to
add another token to a cell for future use for computed attributes, cf #22,
and to change the internal numerical values from double and ints to long
doubles and long longs. However, the change attempts to encapsulate that
choice so it would be easy to change back or change to another representation.
Note that these changes break savexdr(), as the internal binary format of
a cell is now different. Rather than reimplement it, it is deprecated as
the world does not need another binary spreadsheet format. Hence, the
ascii format for teapot spreadsheets becomes the primary file format.
Loading of old xdr files is still supported for backward compatibility.
Closes #59.
Also along the way, various other slight fixes and enhancements crept in,
a partial but probably not exhaustive list of which follows:
Fixes #31.
Further revisions and improvements to documentation.
Make the approximate comparison of floating point values scale more
accurately with the size of the doubles being compared.
Further extensions of absolute and relative cell addressing.
Addition of (circle constant) tau function/constant.
Modified string conversion to simply use internal printing routines, and
to take "scientific" and "decimal" keywords.
Allowed n() function to take a list of values, or just a single location
defaulting to the current location.
Added floor, ceil, trunc, and round functions, and allowed them to be
keywords controlling the int() integer conversion function as well.
Allowed substr() to drop its last argument to go to the end of the string.
Provided an enum of built-in functions to preserve legacy function
identifiers, allowing the large table inside func.c to be reorganized
in a clearer fashion.
Added additional annotation of properties of the built-in functions,
including precedence.
All operators are now also accessible as built-in functions.
Made precedence of unary - lower than ^ to match python.
Avoided inadvertently using FLTK @symbol abbreviations for formulas with
"@" in them.
2019-08-23 19:12:06 +00:00
|
|
|
} FunctionPrecedence;
|
|
|
|
|
|
|
|
typedef enum { FUNCT, MACRO } EvaluationStrategy;
|
2019-07-22 20:32:33 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
Streamline internals of teapot
The primary change is to add a “funcall” token, so that an entire expression
can be encapsulated as a single token. This change is used to allow a cell to
include simply a selection of appropriate semantic tokens. I.e., the content
and iterative content are now each a single token like the value and the
result value. Token vectors are used only as intermediate results in scanning
and parsing.
Not this means the cells are now in effect storing parse trees, so
computation should be slightly faster and future extensions (like #56) should
be facilitated.
This commit also takes the opportunity while internals are being altered to
add another token to a cell for future use for computed attributes, cf #22,
and to change the internal numerical values from double and ints to long
doubles and long longs. However, the change attempts to encapsulate that
choice so it would be easy to change back or change to another representation.
Note that these changes break savexdr(), as the internal binary format of
a cell is now different. Rather than reimplement it, it is deprecated as
the world does not need another binary spreadsheet format. Hence, the
ascii format for teapot spreadsheets becomes the primary file format.
Loading of old xdr files is still supported for backward compatibility.
Closes #59.
Also along the way, various other slight fixes and enhancements crept in,
a partial but probably not exhaustive list of which follows:
Fixes #31.
Further revisions and improvements to documentation.
Make the approximate comparison of floating point values scale more
accurately with the size of the doubles being compared.
Further extensions of absolute and relative cell addressing.
Addition of (circle constant) tau function/constant.
Modified string conversion to simply use internal printing routines, and
to take "scientific" and "decimal" keywords.
Allowed n() function to take a list of values, or just a single location
defaulting to the current location.
Added floor, ceil, trunc, and round functions, and allowed them to be
keywords controlling the int() integer conversion function as well.
Allowed substr() to drop its last argument to go to the end of the string.
Provided an enum of built-in functions to preserve legacy function
identifiers, allowing the large table inside func.c to be reorganized
in a clearer fashion.
Added additional annotation of properties of the built-in functions,
including precedence.
All operators are now also accessible as built-in functions.
Made precedence of unary - lower than ^ to match python.
Avoided inadvertently using FLTK @symbol abbreviations for formulas with
"@" in them.
2019-08-23 19:12:06 +00:00
|
|
|
const char name[MAX_FUNC_NAME_LENGTH + 1];
|
2019-08-26 06:19:34 +00:00
|
|
|
Token (*func)(FunctionIdentifier self, int, const Token*);
|
Streamline internals of teapot
The primary change is to add a “funcall” token, so that an entire expression
can be encapsulated as a single token. This change is used to allow a cell to
include simply a selection of appropriate semantic tokens. I.e., the content
and iterative content are now each a single token like the value and the
result value. Token vectors are used only as intermediate results in scanning
and parsing.
Not this means the cells are now in effect storing parse trees, so
computation should be slightly faster and future extensions (like #56) should
be facilitated.
This commit also takes the opportunity while internals are being altered to
add another token to a cell for future use for computed attributes, cf #22,
and to change the internal numerical values from double and ints to long
doubles and long longs. However, the change attempts to encapsulate that
choice so it would be easy to change back or change to another representation.
Note that these changes break savexdr(), as the internal binary format of
a cell is now different. Rather than reimplement it, it is deprecated as
the world does not need another binary spreadsheet format. Hence, the
ascii format for teapot spreadsheets becomes the primary file format.
Loading of old xdr files is still supported for backward compatibility.
Closes #59.
Also along the way, various other slight fixes and enhancements crept in,
a partial but probably not exhaustive list of which follows:
Fixes #31.
Further revisions and improvements to documentation.
Make the approximate comparison of floating point values scale more
accurately with the size of the doubles being compared.
Further extensions of absolute and relative cell addressing.
Addition of (circle constant) tau function/constant.
Modified string conversion to simply use internal printing routines, and
to take "scientific" and "decimal" keywords.
Allowed n() function to take a list of values, or just a single location
defaulting to the current location.
Added floor, ceil, trunc, and round functions, and allowed them to be
keywords controlling the int() integer conversion function as well.
Allowed substr() to drop its last argument to go to the end of the string.
Provided an enum of built-in functions to preserve legacy function
identifiers, allowing the large table inside func.c to be reorganized
in a clearer fashion.
Added additional annotation of properties of the built-in functions,
including precedence.
All operators are now also accessible as built-in functions.
Made precedence of unary - lower than ^ to match python.
Avoided inadvertently using FLTK @symbol abbreviations for formulas with
"@" in them.
2019-08-23 19:12:06 +00:00
|
|
|
FunctionPrecedence precedence;
|
|
|
|
EvaluationStrategy eval_as;
|
|
|
|
const char* display_symbol;
|
2019-07-22 20:32:33 +00:00
|
|
|
} Tfunc;
|
|
|
|
|
Streamline internals of teapot
The primary change is to add a “funcall” token, so that an entire expression
can be encapsulated as a single token. This change is used to allow a cell to
include simply a selection of appropriate semantic tokens. I.e., the content
and iterative content are now each a single token like the value and the
result value. Token vectors are used only as intermediate results in scanning
and parsing.
Not this means the cells are now in effect storing parse trees, so
computation should be slightly faster and future extensions (like #56) should
be facilitated.
This commit also takes the opportunity while internals are being altered to
add another token to a cell for future use for computed attributes, cf #22,
and to change the internal numerical values from double and ints to long
doubles and long longs. However, the change attempts to encapsulate that
choice so it would be easy to change back or change to another representation.
Note that these changes break savexdr(), as the internal binary format of
a cell is now different. Rather than reimplement it, it is deprecated as
the world does not need another binary spreadsheet format. Hence, the
ascii format for teapot spreadsheets becomes the primary file format.
Loading of old xdr files is still supported for backward compatibility.
Closes #59.
Also along the way, various other slight fixes and enhancements crept in,
a partial but probably not exhaustive list of which follows:
Fixes #31.
Further revisions and improvements to documentation.
Make the approximate comparison of floating point values scale more
accurately with the size of the doubles being compared.
Further extensions of absolute and relative cell addressing.
Addition of (circle constant) tau function/constant.
Modified string conversion to simply use internal printing routines, and
to take "scientific" and "decimal" keywords.
Allowed n() function to take a list of values, or just a single location
defaulting to the current location.
Added floor, ceil, trunc, and round functions, and allowed them to be
keywords controlling the int() integer conversion function as well.
Allowed substr() to drop its last argument to go to the end of the string.
Provided an enum of built-in functions to preserve legacy function
identifiers, allowing the large table inside func.c to be reorganized
in a clearer fashion.
Added additional annotation of properties of the built-in functions,
including precedence.
All operators are now also accessible as built-in functions.
Made precedence of unary - lower than ^ to match python.
Avoided inadvertently using FLTK @symbol abbreviations for formulas with
"@" in them.
2019-08-23 19:12:06 +00:00
|
|
|
FunctionIdentifier identcode(const char *s, size_t len);
|
2019-07-22 20:32:33 +00:00
|
|
|
extern Tfunc tfunc[];
|
|
|
|
|
2019-09-03 08:41:37 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-07-22 20:32:33 +00:00
|
|
|
#endif
|