Mercurial > hg-old > index.cgi
comparison src/symbol.c @ 40:d2cee0c335e7
adjusted symbol rules to accept symbols starting with @ but not @<digit>
author | lost |
---|---|
date | Sat, 03 Jan 2009 19:41:39 +0000 |
parents | 538e15927776 |
children | b9856da2674a |
comparison
equal
deleted
inserted
replaced
39:efa19ec69df9 | 40:d2cee0c335e7 |
---|---|
27 #include <string.h> | 27 #include <string.h> |
28 | 28 |
29 #include "lwasm.h" | 29 #include "lwasm.h" |
30 #include "util.h" | 30 #include "util.h" |
31 | 31 |
32 /* | |
33 Note that this function may accept symbols that the expression evaluator doesn't | |
34 recognize because the expression evaluator must avoid all ambiguity in order | |
35 to achieve predictable results. The checks here are simply a fuzz check. | |
36 */ | |
32 int lwasm_register_symbol(asmstate_t *as, lwasm_line_t *l, char *sym, int val) | 37 int lwasm_register_symbol(asmstate_t *as, lwasm_line_t *l, char *sym, int val) |
33 { | 38 { |
34 lwasm_symbol_ent_t *se, *se2; | 39 lwasm_symbol_ent_t *se, *se2; |
35 char *p; | 40 char *p; |
36 | 41 |
40 // the following characters are allowed in a symbol: | 45 // the following characters are allowed in a symbol: |
41 // [a-zA-Z0-9._$?@] and any byte value larger than 0x7F | 46 // [a-zA-Z0-9._$?@] and any byte value larger than 0x7F |
42 // although symbols should be restricted to the 7 bit range | 47 // although symbols should be restricted to the 7 bit range |
43 // symbols must start with [a-zA-Z._] | 48 // symbols must start with [a-zA-Z._] |
44 if (!strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._@?", *sym)) | 49 if (!strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._@?", *sym)) |
50 { | |
51 register_error(as, l, 1, "Bad symbol: %s", sym); | |
52 return -1; | |
53 } | |
54 | |
55 if (*sym == '@' && isdigit(sym[1])) | |
45 { | 56 { |
46 register_error(as, l, 1, "Bad symbol: %s", sym); | 57 register_error(as, l, 1, "Bad symbol: %s", sym); |
47 return -1; | 58 return -1; |
48 } | 59 } |
49 | 60 |