Skip to content

Commit 61af1dd

Browse files
committed
fully allow upper-case letters in variable names
1 parent 8d7ebbb commit 61af1dd

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,10 @@ TinyExpr parses the following grammar:
255255

256256
In addition, whitespace between tokens is ignored.
257257

258-
Valid variable names consist of a lower case letter followed by any combination
259-
of: lower case letters *a* through *z*, the digits *0* through *9*, and
260-
underscore. Constants can be integers, decimal numbers, or in scientific
261-
notation (e.g. *1e3* for *1000*). A leading zero is not required (e.g. *.5*
262-
for *0.5*)
258+
Valid variable names consist of a letter followed by any combination of:
259+
letters, the digits *0* through *9*, and underscore. Constants can be integers,
260+
decimal numbers, or in scientific notation (e.g. *1e3* for *1000*). A leading
261+
zero is not required (e.g. *.5* for *0.5*)
263262

264263

265264
## Functions supported

smoke.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,9 @@ void test_syntax() {
174174
{"1*2(+4", 4},
175175
{"1*2(1+4", 4},
176176
{"a+5", 1},
177-
{"A+5", 1},
178-
{"Aa+5", 1},
177+
{"!+5", 1},
178+
{"_a+5", 1},
179+
{"#a+5", 1},
179180
{"1^^5", 3},
180181
{"1**5", 3},
181182
{"sin(cos5", 8},

tinyexpr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ void next_token(state *s) {
243243
s->type = TOK_NUMBER;
244244
} else {
245245
/* Look for a variable or builtin function call. */
246-
if (s->next[0] >= 'a' && s->next[0] <= 'z') {
246+
if (isalpha(s->next[0])) {
247247
const char *start;
248248
start = s->next;
249249
while (isalpha(s->next[0]) || isdigit(s->next[0]) || (s->next[0] == '_')) s->next++;

0 commit comments

Comments
 (0)