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