From f2d1017b9869432b3863dce6e759148e3a4e9e16 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Mon, 4 Aug 2008 19:17:27 +0000 Subject: Stub out at-rule handling svn path=/trunk/libcss/; revision=4899 --- src/lex/lex.h | 1 + src/parse/css21.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/lex/lex.h b/src/lex/lex.h index 2cdf7f1..97a4a17 100644 --- a/src/lex/lex.h +++ b/src/lex/lex.h @@ -8,6 +8,7 @@ #ifndef css_lex_lex_h_ #define css_lex_lex_h_ +#include #include #include diff --git a/src/parse/css21.c b/src/parse/css21.c index 323c515..d480b82 100644 --- a/src/parse/css21.c +++ b/src/parse/css21.c @@ -6,9 +6,11 @@ */ #include +#include #include +#include "lex/lex.h" #include "parse/css21.h" #include "parse/parse.h" @@ -252,7 +254,50 @@ css_error handleStartAtRule(css_css21 *c, const parserutils_vector *vector) return css_error_from_parserutils_error(perror); } - /** \todo handle tokens */ + /* vector contains: ATKEYWORD ws any0 */ + const css_token *token = NULL; + const css_token *atkeyword = NULL; + int32_t any = 0; + int32_t ctx = 0; + + do { + any = ctx; + + token = parserutils_vector_iterate(vector, &ctx); + if (token == NULL) + break; + + if (atkeyword == NULL) + atkeyword = token; + else if (token->type != CSS_TOKEN_S) + break; + } while (token != NULL); + + /* We now have an ATKEYWORD and the context for the start of any0, if + * there is one */ + assert(atkeyword != NULL && atkeyword->type == CSS_TOKEN_ATKEYWORD); + + /** \todo Erm. Strings are interned now. Stop looking at their data */ + if (atkeyword->data.len == SLEN("charset") && + strncasecmp((const char *) atkeyword->data.ptr, + "charset", SLEN("charset")) == 0) { + /** \todo any0 = STRING */ + } else if (atkeyword->data.len == SLEN("import") && + strncasecmp((const char *) atkeyword->data.ptr, + "import", SLEN("import")) == 0) { + /** \todo any0 = (STRING | URI) ws + * (IDENT ws (',' ws IDENT ws)* )? */ + } else if (atkeyword->data.len == SLEN("media") && + strncasecmp((const char *) atkeyword->data.ptr, + "media", SLEN("media")) == 0) { + /** \todo any0 = IDENT ws (',' ws IDENT ws)* */ + } else if (atkeyword->data.len == SLEN("page") && + strncasecmp((const char *) atkeyword->data.ptr, + "page", SLEN("page")) == 0) { + /** \todo any0 = (':' IDENT)? ws */ + } else { + return CSS_INVALID; + } return CSS_OK; } -- cgit v1.2.3