libcss
Loading...
Searching...
No Matches
language.h
Go to the documentation of this file.
1/*
2 * This file is part of LibCSS.
3 * Licensed under the MIT License,
4 * http://www.opensource.org/licenses/mit-license.php
5 * Copyright 2008 John-Mark Bell <jmb@netsurf-browser.org>
6 */
7
8#ifndef css_css__parse_language_h_
9#define css_css__parse_language_h_
10
11#include <parserutils/utils/stack.h>
12#include <parserutils/utils/vector.h>
13
14#include <libcss/functypes.h>
15#include <libcss/types.h>
16
17#include "lex/lex.h"
18#include "parse/parse.h"
19#include "parse/propstrings.h"
20
24typedef struct css_namespace {
25 lwc_string *prefix;
26 lwc_string *uri;
28
52
54 void **language);
56
57/******************************************************************************
58 * Helper functions *
59 ******************************************************************************/
60
67static inline void consumeWhitespace(const parserutils_vector *vector, int32_t *ctx)
68{
69 const css_token *token = NULL;
70
71 while ((token = parserutils_vector_peek(vector, *ctx)) != NULL &&
72 token->type == CSS_TOKEN_S)
73 parserutils_vector_iterate(vector, ctx);
74}
75
83static inline bool tokenIsChar(const css_token *token, uint8_t c)
84{
85 bool result = false;
86
87 if (token != NULL && token->type == CSS_TOKEN_CHAR &&
88 lwc_string_length(token->idata) == 1) {
89 char d = lwc_string_data(token->idata)[0];
90
91 /* Ensure lowercase comparison */
92 if ('A' <= d && d <= 'Z')
93 d += 'a' - 'A';
94
95 result = (d == c);
96 }
97
98 return result;
99}
100
101#endif
102
css_error
Definition errors.h:18
css_error css__language_destroy(css_language *language)
Definition language.c:165
css_error css__language_create(css_stylesheet *sheet, css_parser *parser, void **language)
Definition language.c:116
@ CSS_TOKEN_S
Definition lex.h:47
@ CSS_TOKEN_CHAR
Definition lex.h:41
Definition language.h:32
parserutils_stack * context
Definition language.h:36
css_namespace * namespaces
Definition language.h:49
lwc_string * default_namespace
Definition language.h:48
css_stylesheet * sheet
Definition language.h:33
lwc_string ** strings
Definition language.h:46
uint32_t num_namespaces
Definition language.h:50
enum css_language::@10 state
@ NAMESPACE_PERMITTED
Definition language.h:41
@ CHARSET_PERMITTED
Definition language.h:39
@ HAD_RULE
Definition language.h:42
@ IMPORT_PERMITTED
Definition language.h:40
Definition language.h:24
lwc_string * uri
Definition language.h:26
lwc_string * prefix
Definition language.h:25
Definition parse.c:87
Definition stylesheet.h:170
Definition lex.h:55
lwc_string * idata
Definition lex.h:63
css_token_type type
Definition lex.h:56