# HG changeset patch # User lost # Date 1237744242 0 # Node ID 0d916bcebb908448ca79d5698c7ed9028152cfaa # Parent 716879fc67900f1a4231255b41598780b1788caf First pass at allowing symbols starting with digits but containing $ diff -r 716879fc6790 -r 0d916bcebb90 lwasm/expr.c --- a/lwasm/expr.c Sun Mar 22 17:25:19 2009 +0000 +++ b/lwasm/expr.c Sun Mar 22 17:50:42 2009 +0000 @@ -284,7 +284,7 @@ /* - a symbol will be a string of characters introduced by a letter, ".", - "_" but NOT a number + "_" but NOT a number OR it may start with a digit if it contains a $ - a decimal constant will consist of only digits, optionally prefixed with "&" - a binary constant will consist of only 0s and 1s either prefixed with % @@ -423,32 +423,42 @@ } // symbol or bare decimal or suffix identified constant here - // all numbers will start with a digit at this point - if (**p < '0' || **p > '9') + + // find the end of a potential symbol + do { int l = 0; char *sb; + int havedol = 0; // evaluate a symbol here static const char *symchars = "_.$@?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; while ((*p)[l] && strchr(symchars, (*p)[l])) + { + if ((*p)[l] == '$') + havedol = 1; l++; - + } if (l == 0) return -1; - sb = lwasm_alloc(l + 1); - sb[l] = '\0'; - memcpy(sb, *p, l); - t = lwasm_expr_term_create_sym(sb); - lwasm_expr_stack_push(s, t); - lwasm_expr_term_free(t); - (*p) += l; - debug_message(3, "Symbol: '%s'; (%s)", sb, *p); - lwasm_free(sb); - return 0; - } - + if (havedol || **p < '0' || **p > '9') + { + // have a symbol here + + sb = lwasm_alloc(l + 1); + sb[l] = '\0'; + memcpy(sb, *p, l); + t = lwasm_expr_term_create_sym(sb); + lwasm_expr_stack_push(s, t); + lwasm_expr_term_free(t); + (*p) += l; + debug_message(3, "Symbol: '%s'; (%s)", sb, *p); + lwasm_free(sb); + return 0; + } + } while (0); + if (!**p) return -1;