Ejemplo n.º 1
0
	inline bool isIdent(TToken &tk)
	{
		return matchIdent(tk);
	}
Ejemplo n.º 2
0
DFArray *CSSParserContent(CSSParser *p)
{
    DFArray *result = DFArrayNew((DFCopyFunction)ContentPartRetain,(DFFreeFunction)ContentPartRelease);
    matchWhitespace(p);
    while (p->pos < p->length) {
        size_t start = p->pos;
        switch (p->chars[p->pos]) {
            case '"':
            case '\'': {
                int invalid = 0;
                if (!matchString(p,&invalid))
                    return result;
                char *quotedValue = trimmedSubstring(p,start,p->pos);
                char *unquotedValue = DFUnquote(quotedValue);
                ContentPart *part = ContentPartNew(ContentPartString,unquotedValue,NULL);
                DFArrayAppend(result,part);
                ContentPartRelease(part);
                free(quotedValue);
                free(unquotedValue);
                if ((p->pos < p->length) && !matchWhitespace(p))
                    return result;
                break;
            }
            case 'C':
            case 'c': {
                if (matchSpecific(p,"counters(")) {
                    // Not yet supported
                    return result;
                }
                else if (matchSpecific(p,"counter(")) {
                    size_t nameStart = p->pos;
                    if (!matchIdent(p))
                        return result;
                    char *name = DFSubstring(p->chars,nameStart,p->pos);

                    char *type = NULL;
                    if (match(p,',')) {
                        size_t typeStart = p->pos;
                        if (!matchIdent(p)) {
                            free(name);
                            free(type);
                            return result;
                        }
                        type = DFSubstring(p->chars,typeStart,p->pos);
                    }

                    ContentPart *part = ContentPartNew(ContentPartCounter,name,type);
                    DFArrayAppend(result,part);
                    ContentPartRelease(part);

                    if (!match(p,')')) {
                        free(name);
                        free(type);
                        return result;
                    }

                    if ((p->pos < p->length) && !matchWhitespace(p)) {
                        free(name);
                        free(type);
                        return result;
                    }

                    free(name);
                    free(type);
                }
                else {
                    return result;
                }
                break;
            }
            default:
                return result;
        }
    }
    return result;
}