comparison lwasm/symbol.c @ 193:716879fc6790

Allow $ to be a local symbol and allow symbols with $ to start with a digit
author lost
date Sun, 22 Mar 2009 17:25:19 +0000
parents 563adfccb645
children bae1e3ecdce1
comparison
equal deleted inserted replaced
192:bfd0fb0a85c2 193:716879fc6790
60 // first check if the symbol is valid 60 // first check if the symbol is valid
61 // the following characters are allowed in a symbol: 61 // the following characters are allowed in a symbol:
62 // [a-zA-Z0-9._$?@] and any byte value larger than 0x7F 62 // [a-zA-Z0-9._$?@] and any byte value larger than 0x7F
63 // although symbols should be restricted to the 7 bit range 63 // although symbols should be restricted to the 7 bit range
64 // symbols must start with [a-zA-Z._] 64 // symbols must start with [a-zA-Z._]
65 if (!strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._@?", *sym)) 65 if (!strchr(sym, '$'))
66 { 66 {
67 register_error(as, l, 1, "Bad symbol: %s", sym); 67 if (!strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._@?", *sym))
68 return -1; 68 {
69 } 69 register_error(as, l, 1, "Bad symbol: %s", sym);
70 70 return -1;
71 if (*sym == '@' && isdigit(sym[1])) 71 }
72 { 72
73 register_error(as, l, 1, "Bad symbol: %s", sym); 73 if (*sym == '@' && isdigit(sym[1]))
74 return -1; 74 {
75 register_error(as, l, 1, "Bad symbol: %s", sym);
76 return -1;
77 }
75 } 78 }
76 79
77 for (p = sym; *p; p++) 80 for (p = sym; *p; p++)
78 { 81 {
79 if (!strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._$?@0123456789", *sym)) 82 if (!strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._$?@0123456789", *sym))
80 { 83 {
81 register_error(as, l, 1, "Bad symbol: %s", sym); 84 register_error(as, l, 1, "Bad symbol: %s", sym);
82 return -1; 85 return -1;
83 } 86 }
84 // flag local symbols while we're at it... 87 // flag local symbols while we're at it...
85 if (*p == '?' || *p == '@') 88 if (*p == '?' || *p == '@' || *p == '$')
86 scontext = as -> context; 89 scontext = as -> context;
87 } 90 }
88 91
89 debug_message(3, "lwasm_register_symbol(): registering '%s' (%d) at %04X; flags=%d", sym, scontext, val, flags); 92 debug_message(3, "lwasm_register_symbol(): registering '%s' (%d) at %04X; flags=%d", sym, scontext, val, flags);
90 93