diff --git a/README.md b/README.md index 8db7611..749ad37 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/smoke.c b/smoke.c index 8accfe6..86d6dff 100644 --- a/smoke.c +++ b/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}, diff --git a/tinyexpr.c b/tinyexpr.c index 4c0971e..05774ff 100755 --- a/tinyexpr.c +++ b/tinyexpr.c @@ -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++;