mirror of
https://github.com/eledio-devices/thirdparty-tinyexpr.git
synced 2025-10-30 16:15:41 +01:00
fully allow upper-case letters in variable names
This commit is contained in:
@@ -255,11 +255,10 @@ TinyExpr parses the following grammar:
|
||||
|
||||
In addition, whitespace between tokens is ignored.
|
||||
|
||||
Valid variable names consist of a lower case letter followed by any combination
|
||||
of: lower case letters *a* through *z*, the digits *0* through *9*, and
|
||||
underscore. Constants can be integers, decimal numbers, or in scientific
|
||||
notation (e.g. *1e3* for *1000*). A leading zero is not required (e.g. *.5*
|
||||
for *0.5*)
|
||||
Valid variable names consist of a letter followed by any combination of:
|
||||
letters, the digits *0* through *9*, and underscore. Constants can be integers,
|
||||
decimal numbers, or in scientific notation (e.g. *1e3* for *1000*). A leading
|
||||
zero is not required (e.g. *.5* for *0.5*)
|
||||
|
||||
|
||||
## Functions supported
|
||||
|
||||
5
smoke.c
5
smoke.c
@@ -174,8 +174,9 @@ void test_syntax() {
|
||||
{"1*2(+4", 4},
|
||||
{"1*2(1+4", 4},
|
||||
{"a+5", 1},
|
||||
{"A+5", 1},
|
||||
{"Aa+5", 1},
|
||||
{"!+5", 1},
|
||||
{"_a+5", 1},
|
||||
{"#a+5", 1},
|
||||
{"1^^5", 3},
|
||||
{"1**5", 3},
|
||||
{"sin(cos5", 8},
|
||||
|
||||
@@ -243,7 +243,7 @@ void next_token(state *s) {
|
||||
s->type = TOK_NUMBER;
|
||||
} else {
|
||||
/* Look for a variable or builtin function call. */
|
||||
if (s->next[0] >= 'a' && s->next[0] <= 'z') {
|
||||
if (isalpha(s->next[0])) {
|
||||
const char *start;
|
||||
start = s->next;
|
||||
while (isalpha(s->next[0]) || isdigit(s->next[0]) || (s->next[0] == '_')) s->next++;
|
||||
|
||||
Reference in New Issue
Block a user