summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-08-04 19:17:27 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-08-04 19:17:27 +0000
commitf2d1017b9869432b3863dce6e759148e3a4e9e16 (patch)
treee95c8351239cd56237c0024a792f353d97468d28 /src
parent22f18932fb790295e6047ca1301687ade5546e94 (diff)
downloadlibcss-f2d1017b9869432b3863dce6e759148e3a4e9e16.tar.gz
libcss-f2d1017b9869432b3863dce6e759148e3a4e9e16.tar.bz2
Stub out at-rule handling
svn path=/trunk/libcss/; revision=4899
Diffstat (limited to 'src')
-rw-r--r--src/lex/lex.h1
-rw-r--r--src/parse/css21.c47
2 files changed, 47 insertions, 1 deletions
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 <libcss/errors.h>
#include <libcss/functypes.h>
#include <libcss/types.h>
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 <assert.h>
+#include <string.h>
#include <parserutils/utils/stack.h>
+#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;
}