ExpressionVector* ExpressionParser::Parse(const wchar_t *input) { if (!input || wcslen(input) == 0) return NULL; ExpressionVector* ret = new ExpressionVector; Entity en = EN_UNDEFINED; uint32 i, j; for (i = 0; i < wcslen(input); ) { // try to determine, if it's an operator or parenthesis en = charEntity(input[i]); if (en != EN_UNDEFINED) { ret->push(en); i++; continue; } // it's a value for (j = i; j < wcslen(input); j++) { en = charEntity(input[j]); if (en != EN_UNDEFINED || j == wcslen(input)-1) { if (j == wcslen(input)-1) { wchar_t* val = new wchar_t[j-i+2]; wcsncpy(val, &(input[i]), j-i+1); val[j-i+1] = '\0'; ret->push(EN_VALUE, val); i = j+1; } else { wchar_t* val = new wchar_t[j-i+1]; wcsncpy(val, &(input[i]), j-i); val[j-i] = '\0'; ret->push(EN_VALUE, val); i = j; goto continue_label; } } } continue_label:; } return ret; }
void Html::extractCode(OutBuffer *buf) { //printf("Html::extractCode()\n"); dbuf = buf; // save for other routines buf->reserve(end - p); inCode = 0; while (1) { //printf("p = %p, *p = x%x\n", p, *p); switch (*p) { #if 0 // strings are not recognized outside of tags case '"': case '\'': skipString(); continue; #endif case '<': if (p[1] == '!' && isCommentStart()) { // Comments start with <!-- scanComment(); } else if(p[1] == '!' && isCDATAStart()) { scanCDATA(); } else if (p[1] == '/' && istagstart(*skipWhite(p + 2))) skipTag(); else if (istagstart(*skipWhite(p + 1))) skipTag(); else goto Ldefault; continue; case 0: case 0x1a: break; // end of file case '&': if (inCode) { // Translate character entity into ascii for D parser int c; c = charEntity(); buf->writeUTF8(c); } else p++; continue; case '\r': if (p[1] == '\n') goto Ldefault; case '\n': linnum++; // Always extract new lines, so that D lexer counts the // lines right. buf->writeByte(*p); p++; continue; default: Ldefault: if (inCode) buf->writeByte(*p); p++; continue; } break; } buf->writeByte(0); // ending sentinel //printf("D code is: '%s'\n", (char *)buf->data); }