comparison lwasm/parse.c @ 244:c8bcc396ec59 2.x

Allow symbols to appear after whitespace when terminated by :
author lost
date Wed, 16 Sep 2009 00:29:06 +0000
parents a58f49a77441
children 0986834ec7d3
comparison
equal deleted inserted replaced
243:f9f01a499525 244:c8bcc396ec59
68 // if we have C pre-processor directives/output, ignore it 68 // if we have C pre-processor directives/output, ignore it
69 if (*p == '#') 69 if (*p == '#')
70 return; 70 return;
71 71
72 // if we start with a non-space character, it's a symbol 72 // if we start with a non-space character, it's a symbol
73 symbolagain:
73 if (!isspace(*p)) 74 if (!isspace(*p))
74 { 75 {
75 // we have a symbol specified here 76 // we have a symbol specified here
76 // parse it out and record it for later use 77 // parse it out and record it for later use
77 for (p2 = p; *p2 && !isspace(*p2) && *p2 != ':'; p2++) 78 for (p2 = p; *p2 && !isspace(*p2) && *p2 != ':'; p2++)
110 /* do nothing */ ; 111 /* do nothing */ ;
111 112
112 opc = lwasm_alloc((p2 - p) + 1); 113 opc = lwasm_alloc((p2 - p) + 1);
113 memcpy(opc, p, p2 - p); 114 memcpy(opc, p, p2 - p);
114 opc[p2 - p] = '\0'; 115 opc[p2 - p] = '\0';
116
117 if (strchr(opc, ':'))
118 {
119 lwasm_free(opc);
120 goto symbolagain;
121 }
115 122
116 l -> forceglobal = 0; 123 l -> forceglobal = 0;
117 // if the opcode contains an =, treat it as "symbol = expr" 124 // if the opcode contains an =, treat it as "symbol = expr"
118 if (!sym && strchr(opc, '=')) 125 if (!sym && strchr(opc, '='))
119 { 126 {