135 #define PRIVATE(obj) ((obj)->priv)
137 #define CHARS_TAB_SIZE 12
139 #define RECURSIVE_CALLERS_LIMIT 100
146 #define IS_NUM(a_char) (((a_char) >= '0' && (a_char) <= '9')?TRUE:FALSE)
157 #define CHECK_PARSING_STATUS(status, is_exception) \
158 if ((status) != CR_OK) \
160 if (is_exception == FALSE) \
162 status = CR_PARSING_ERROR ; \
181 #define CHECK_PARSING_STATUS_ERR(a_this, a_status, a_is_exception,\
182 a_err_msg, a_err_status) \
183 if ((a_status) != CR_OK) \
185 if (a_is_exception == FALSE) a_status = CR_PARSING_ERROR ; \
186 cr_parser_push_error (a_this, a_err_msg, a_err_status) ; \
200 #define PEEK_NEXT_CHAR(a_this, a_to_char) \
202 enum CRStatus pnc_status ; \
203 pnc_status = cr_tknzr_peek_char (PRIVATE (a_this)->tknzr, a_to_char) ; \
204 CHECK_PARSING_STATUS (pnc_status, TRUE) \
215 #define READ_NEXT_CHAR(a_this, a_to_char) \
216 status = cr_tknzr_read_char (PRIVATE (a_this)->tknzr, a_to_char) ; \
217 CHECK_PARSING_STATUS (status, TRUE)
229 #define RECORD_INITIAL_POS(a_this, a_pos) \
230 status = cr_tknzr_get_cur_pos (PRIVATE \
231 (a_this)->tknzr, a_pos) ; \
232 g_return_val_if_fail (status == CR_OK, status)
241 #define RECORD_CUR_BYTE_ADDR(a_this, a_addr) \
242 status = cr_tknzr_get_cur_byte_addr \
243 (PRIVATE (a_this)->tknzr, a_addr) ; \
244 CHECK_PARSING_STATUS (status, TRUE)
257 #define PEEK_BYTE(a_parser, a_offset, a_byte_ptr) \
258 status = cr_tknzr_peek_byte (PRIVATE (a_this)->tknzr, \
261 CHECK_PARSING_STATUS (status, TRUE) ;
263 #define BYTE(a_parser, a_offset, a_eof) \
264 cr_tknzr_peek_byte2 (PRIVATE (a_this)->tknzr, a_offset, a_eof)
273 #define READ_NEXT_BYTE(a_this, a_byte_ptr) \
274 status = cr_tknzr_read_byte (PRIVATE (a_this)->tknzr, a_byte_ptr) ; \
275 CHECK_PARSING_STATUS (status, TRUE) ;
285 #define SKIP_BYTES(a_this, a_nb_bytes) \
286 status = cr_tknzr_seek_index (PRIVATE (a_this)->tknzr, \
287 CR_SEEK_CUR, a_nb_bytes) ; \
288 CHECK_PARSING_STATUS (status, TRUE) ;
297 #define SKIP_CHARS(a_parser, a_nb_chars) \
299 glong nb_chars = a_nb_chars ; \
300 status = cr_tknzr_consume_chars \
301 (PRIVATE (a_parser)->tknzr,0, &nb_chars) ; \
302 CHECK_PARSING_STATUS (status, TRUE) ; \
311 #define ENSURE_PARSING_COND(condition) \
312 if (! (condition)) {status = CR_PARSING_ERROR; goto error ;}
314 #define ENSURE_PARSING_COND_ERR(a_this, a_condition, \
315 a_err_msg, a_err_status) \
316 if (! (a_condition)) \
318 status = CR_PARSING_ERROR; \
319 cr_parser_push_error (a_this, a_err_msg, a_err_status) ; \
323 #define GET_NEXT_TOKEN(a_this, a_token_ptr) \
324 status = cr_tknzr_get_next_token (PRIVATE (a_this)->tknzr, \
326 ENSURE_PARSING_COND (status == CR_OK) ;
328 #ifdef WITH_UNICODE_ESCAPE_AND_RANGE
330 guint32 * a_unicode);
332 guint32 * a_esc_code);
381 static CRParserError *cr_parser_error_new (
const guchar * a_msg,
385 const guchar * a_msg);
389 static void cr_parser_error_set_status (
CRParserError * a_this,
394 glong a_column, glong a_byte_num);
399 const guchar * a_msg,
403 gboolean a_clear_errs);
405 cr_parser_clear_errors (
CRParser * a_this);
418 cr_parser_error_new (
const guchar * a_msg,
enum CRStatus a_status)
424 if (result == NULL) {
431 cr_parser_error_set_msg (result, a_msg);
432 cr_parser_error_set_status (result, a_status);
443 cr_parser_error_set_msg (
CRParserError * a_this,
const guchar * a_msg)
445 g_return_if_fail (a_this);
448 g_free (a_this->
msg);
451 a_this->
msg = (guchar *) g_strdup ((
const gchar *) a_msg);
463 g_return_if_fail (a_this);
465 a_this->
status = a_status;
477 glong a_line, glong a_column, glong a_byte_num)
479 g_return_if_fail (a_this);
481 a_this->
line = a_line;
482 a_this->
column = a_column;
489 g_return_if_fail (a_this);
491 g_printerr (
"parsing error: %ld:%ld:", a_this->
line, a_this->
column);
493 g_printerr (
"%s\n", a_this->
msg);
503 g_return_if_fail (a_this);
506 g_free (a_this->
msg);
521 cr_parser_push_error (
CRParser * a_this,
522 const guchar * a_msg,
enum CRStatus a_status)
529 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
532 error = cr_parser_error_new (a_msg, a_status);
534 g_return_val_if_fail (error,
CR_ERROR);
538 cr_parser_error_set_pos
542 g_list_prepend (
PRIVATE (a_this)->err_stack, error);
544 if (
PRIVATE (a_this)->err_stack == NULL)
552 cr_parser_error_destroy (error);
568 cr_parser_dump_err_stack (
CRParser * a_this, gboolean a_clear_errs)
574 if (
PRIVATE (a_this)->err_stack == NULL)
577 for (cur =
PRIVATE (a_this)->err_stack; cur; cur = cur->next) {
581 if (a_clear_errs == TRUE) {
582 cr_parser_clear_errors (a_this);
594 cr_parser_clear_errors (
CRParser * a_this)
600 for (cur =
PRIVATE (a_this)->err_stack; cur; cur = cur->next) {
607 if (
PRIVATE (a_this)->err_stack) {
608 g_list_free (
PRIVATE (a_this)->err_stack);
609 PRIVATE (a_this)->err_stack = NULL;
630 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
643 while ((token != NULL)
681 cr_parser_parse_stylesheet_core (
CRParser * a_this)
703 }
else if (status !=
CR_OK) {
707 switch (token->
type) {
711 goto continue_parsing;
719 cr_parser_clear_errors (a_this);
720 if (status ==
CR_OK) {
721 goto continue_parsing;
735 cr_parser_clear_errors (a_this);
740 (a_this, (
const guchar *)
"could not recognize next production",
CR_ERROR);
742 cr_parser_dump_err_stack (a_this, TRUE);
763 cr_parser_parse_atrule_core (
CRParser * a_this)
791 status = cr_parser_parse_any_core (a_this, 0);
792 }
while (status ==
CR_OK);
802 status = cr_parser_parse_block_core (a_this, 0);
838 cr_parser_parse_ruleset_core (
CRParser * a_this)
847 status = cr_parser_parse_selector_core (a_this);
860 status = cr_parser_parse_declaration_core (a_this);
862 parse_declaration_list:
880 status = cr_parser_parse_declaration_core (a_this);
881 cr_parser_clear_errors (a_this);
894 goto parse_declaration_list;
903 if (status ==
CR_OK) {
927 cr_parser_parse_selector_core (
CRParser * a_this)
937 status = cr_parser_parse_any_core (a_this, 0);
941 status = cr_parser_parse_any_core (a_this, 0);
943 }
while (status ==
CR_OK);
967 cr_parser_parse_block_core (
CRParser * a_this,
1001 goto parse_block_content;
1004 goto parse_block_content;
1008 status = cr_parser_parse_block_core (a_this, n_calls + 1);
1010 goto parse_block_content;
1014 status = cr_parser_parse_any_core (a_this, n_calls + 1);
1016 goto parse_block_content;
1025 if (status ==
CR_OK)
1040 cr_parser_parse_declaration_core (
CRParser * a_this)
1051 status = cr_parser_parse_property (a_this, &prop);
1053 cr_parser_clear_errors (a_this);
1066 status = cr_parser_parse_value_core (a_this);
1096 cr_parser_parse_value_core (
CRParser * a_this)
1116 switch (token->
type) {
1121 status = cr_parser_parse_block_core (a_this, 0);
1124 goto continue_parsing;
1129 goto continue_parsing;
1135 status = cr_parser_parse_any_core (a_this, 0);
1136 if (status ==
CR_OK) {
1138 goto continue_parsing;
1153 if (status ==
CR_OK && ref)
1178 cr_parser_parse_any_core (
CRParser * a_this,
1197 switch (token1->
type) {
1229 status = cr_parser_parse_any_core (a_this, n_calls + 1);
1230 }
while (status ==
CR_OK);
1236 && token2 && token2->type ==
PC_TK);
1243 if (token2->type ==
PC_TK) {
1249 (
PRIVATE (a_this)->tknzr, token2);
1254 status = cr_parser_parse_any_core (a_this, n_calls + 1);
1255 }
while (status ==
CR_OK);
1262 && token2 && token2->type ==
PC_TK);
1271 if (token2->type ==
BC_TK) {
1277 (
PRIVATE (a_this)->tknzr, token2);
1282 status = cr_parser_parse_any_core (a_this, n_calls + 1);
1283 }
while (status ==
CR_OK);
1290 && token2 && token2->type ==
BC_TK);
1339 cr_parser_parse_attribute_selector (
CRParser * a_this,
1375 token->
u.
str = NULL;
1386 goto parse_right_part;
1389 goto parse_right_part;
1392 goto parse_right_part;
1412 token->
u.
str = NULL;
1415 token->
u.
str = NULL;
1445 cr_parser_clear_errors (a_this);
1479 cr_parser_parse_property (
CRParser * a_this,
1485 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
1492 status = cr_parser_parse_ident (a_this, a_property);
1497 cr_parser_clear_errors (a_this);
1539 if (status !=
CR_OK || !token)
1550 if (status !=
CR_OK || !token)
1559 if (status !=
CR_OK || !token)
1573 token->
u.
num = NULL;
1579 status = cr_parser_parse_function (a_this, &func_name,
1582 if (status ==
CR_OK) {
1592 token->
u.
str = NULL;
1596 token->
u.
str = NULL;
1600 token->
u.
str = NULL;
1604 token->
u.
rgb = NULL;
1611 token->
u.
str = NULL;
1616 if (status !=
CR_OK) {
1632 cr_parser_clear_errors (a_this);
1683 gboolean found_sel = FALSE;
1684 guint32 cur_char = 0;
1691 if (status !=
CR_OK)
1709 token->
u.
str = NULL;
1734 if (status !=
CR_OK)
1745 token->
u.
str = NULL;
1752 (add_sel_list, add_sel);
1760 (
PRIVATE (a_this)->tknzr, &token);
1761 if (status !=
CR_OK)
1771 token->
u.
str = NULL;
1775 (add_sel_list, add_sel);
1785 }
else if (token && token->
type ==
BO_TK) {
1790 (
PRIVATE (a_this)->tknzr, token);
1791 if (status !=
CR_OK)
1795 status = cr_parser_parse_attribute_selector
1796 (a_this, &attr_sel);
1808 (add_sel_list, add_sel);
1827 (
PRIVATE (a_this)->tknzr, &token);
1837 token->
u.
str = NULL;
1841 token->
u.
str = NULL;
1844 status = cr_parser_parse_ident
1845 (a_this, &pseudo->
extra);
1857 if (status ==
CR_OK) {
1869 (add_sel_list, add_sel);
1874 (
PRIVATE (a_this)->tknzr, token);
1880 if (status ==
CR_OK && found_sel == TRUE) {
1884 add_sel_list = NULL;
1886 if (*a_sel == NULL) {
1899 cr_parser_clear_errors (a_this);
1914 add_sel_list = NULL;
1943 cr_parser_parse_simple_sels (
CRParser * a_this,
1949 guint32 cur_char = 0;
1951 g_return_val_if_fail (a_this
1958 status = cr_parser_parse_simple_selector (a_this, &sel);
1964 guint32 next_char = 0;
1971 if (next_char ==
'+') {
1975 }
else if (next_char ==
'>') {
1983 status = cr_parser_parse_simple_selector (a_this, &sel);
1984 if (status !=
CR_OK)
1996 cr_parser_clear_errors (a_this);
2018 cr_parser_parse_selector (
CRParser * a_this,
2023 guint32 cur_char = 0,
2032 status = cr_parser_parse_simple_sels (a_this, &simple_sels);
2037 (selector, simple_sels);
2040 (&selector->location,
2051 if (status !=
CR_OK) {
2060 if (next_char ==
',') {
2066 if (status !=
CR_OK) {
2075 if (next_char !=
',')
2083 status = cr_parser_parse_simple_sels
2084 (a_this, &simple_sels);
2091 (selector, simple_sels);
2102 *a_selector = selector;
2141 cr_parser_parse_function (
CRParser * a_this,
2150 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
2157 if (status !=
CR_OK)
2161 *a_func_name = token->
u.
str;
2162 token->
u.
str = NULL;
2177 if (status !=
CR_OK)
2190 cr_parser_clear_errors (a_this);
2197 *a_func_name = NULL;
2232 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
2262 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
2290 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
2318 cr_parser_parse_stylesheet (
CRParser * a_this)
2325 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
2332 if (
PRIVATE (a_this)->sac_handler
2333 &&
PRIVATE (a_this)->sac_handler->start_document) {
2334 PRIVATE (a_this)->sac_handler->start_document
2335 (
PRIVATE (a_this)->sac_handler);
2356 if (status ==
CR_OK && charset) {
2357 if (
PRIVATE (a_this)->sac_handler
2358 &&
PRIVATE (a_this)->sac_handler->charset) {
2359 PRIVATE (a_this)->sac_handler->charset
2360 (
PRIVATE (a_this)->sac_handler,
2361 charset, &location);
2364 status = cr_parser_parse_atrule_core (a_this);
2381 goto parse_charset ;
2397 (
PRIVATE (a_this)->tknzr, &token);
2414 (
PRIVATE (a_this)->tknzr, &token);
2420 GList *media_list = NULL;
2425 (
PRIVATE (a_this)->tknzr, token);
2433 if (status ==
CR_OK) {
2435 &&
PRIVATE (a_this)->sac_handler
2436 &&
PRIVATE (a_this)->sac_handler->import_style) {
2437 PRIVATE (a_this)->sac_handler->import_style
2438 (
PRIVATE(a_this)->sac_handler,
2443 if ((
PRIVATE (a_this)->sac_handler->resolve_import == TRUE)) {
2450 if ((
PRIVATE (a_this)->sac_handler->import_style_result)) {
2451 PRIVATE (a_this)->sac_handler->import_style_result
2452 (
PRIVATE (a_this)->sac_handler,
2453 media_list, import_string,
2458 if (
PRIVATE (a_this)->sac_handler
2459 &&
PRIVATE (a_this)->sac_handler->error) {
2460 PRIVATE (a_this)->sac_handler->error
2461 (
PRIVATE (a_this)->sac_handler);
2463 status = cr_parser_parse_atrule_core (a_this);
2478 for (cur = media_list; cur; cur = cur->next) {
2484 g_list_free (media_list);
2488 if (import_string) {
2490 import_string = NULL;
2499 (
PRIVATE (a_this)->tknzr, token);
2509 (
PRIVATE (a_this)->tknzr, &token);
2521 (
PRIVATE (a_this)->tknzr, token);
2524 goto parse_ruleset_and_others;
2528 parse_ruleset_and_others:
2534 (
PRIVATE (a_this)->tknzr, &token);
2543 (
PRIVATE (a_this)->tknzr, token);
2555 (
PRIVATE (a_this)->tknzr, &token);
2563 (
PRIVATE (a_this)->tknzr, token);
2582 (
PRIVATE (a_this)->tknzr, token);
2588 if (status ==
CR_OK) {
2591 if (
PRIVATE (a_this)->sac_handler
2592 &&
PRIVATE (a_this)->sac_handler->error) {
2593 PRIVATE (a_this)->sac_handler->
2599 status = cr_parser_parse_ruleset_core
2602 if (status ==
CR_OK) {
2610 (
PRIVATE (a_this)->tknzr, token);
2615 if (status ==
CR_OK) {
2618 if (
PRIVATE (a_this)->sac_handler
2619 &&
PRIVATE (a_this)->sac_handler->error) {
2620 PRIVATE (a_this)->sac_handler->
2626 status = cr_parser_parse_atrule_core (a_this);
2628 if (status ==
CR_OK) {
2637 (
PRIVATE (a_this)->tknzr, token);
2642 if (status ==
CR_OK) {
2645 if (
PRIVATE (a_this)->sac_handler
2646 &&
PRIVATE (a_this)->sac_handler->error) {
2647 PRIVATE (a_this)->sac_handler->
2653 status = cr_parser_parse_atrule_core (a_this);
2655 if (status ==
CR_OK) {
2663 (
PRIVATE (a_this)->tknzr, token);
2668 if (status ==
CR_OK) {
2671 if (
PRIVATE (a_this)->sac_handler
2672 &&
PRIVATE (a_this)->sac_handler->error) {
2673 PRIVATE (a_this)->sac_handler->
2679 status = cr_parser_parse_atrule_core (a_this);
2681 if (status ==
CR_OK) {
2689 (
PRIVATE (a_this)->tknzr, token);
2694 if (status ==
CR_OK) {
2710 if (
PRIVATE (a_this)->sac_handler
2711 &&
PRIVATE (a_this)->sac_handler->end_document) {
2712 PRIVATE (a_this)->sac_handler->end_document
2713 (
PRIVATE (a_this)->sac_handler);
2719 cr_parser_push_error
2720 (a_this, (
const guchar *)
"could not recognize next production",
CR_ERROR);
2722 if (
PRIVATE (a_this)->sac_handler
2723 &&
PRIVATE (a_this)->sac_handler->unrecoverable_error) {
2724 PRIVATE (a_this)->sac_handler->
2725 unrecoverable_error (
PRIVATE (a_this)->sac_handler);
2728 cr_parser_dump_err_stack (a_this, TRUE);
2739 if (
PRIVATE (a_this)->sac_handler
2740 &&
PRIVATE (a_this)->sac_handler->unrecoverable_error) {
2741 PRIVATE (a_this)->sac_handler->
2742 unrecoverable_error (
PRIVATE (a_this)->sac_handler);
2770 result = g_malloc0 (
sizeof (
CRParser));
2778 g_return_val_if_fail (status ==
CR_OK, NULL);
2801 gboolean a_free_buf)
2806 g_return_val_if_fail (a_buf && a_len, NULL);
2809 g_return_val_if_fail (input, NULL);
2834 g_return_val_if_fail (tokenizer, NULL);
2838 g_return_val_if_fail (result, NULL);
2863 g_return_val_if_fail (result, NULL);
2881 if (
PRIVATE (a_this)->sac_handler) {
2885 PRIVATE (a_this)->sac_handler = a_handler;
2907 *a_handler =
PRIVATE (a_this)->sac_handler;
2935 if (status !=
CR_OK) {
2937 default_sac_handler = NULL;
2952 gboolean a_use_core_grammar)
2956 PRIVATE (a_this)->use_core_grammar = a_use_core_grammar;
2970 gboolean * a_use_core_grammar)
2974 *a_use_core_grammar =
PRIVATE (a_this)->use_core_grammar;
2992 const guchar * a_file_uri,
enum CREncoding a_enc)
2997 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
3002 g_return_val_if_fail (tknzr != NULL,
CR_ERROR);
3031 guchar next_byte = 0;
3032 gulong nb_terms = 0;
3034 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
3044 guchar
operator = 0;
3048 if (status !=
CR_OK) {
3063 if (next_byte ==
'/' || next_byte ==
',') {
3071 if (status !=
CR_OK || expr2 == NULL) {
3078 expr2->the_operator =
DIVIDE;
3081 expr2->the_operator =
COMMA;
3093 if (status ==
CR_OK) {
3097 cr_parser_clear_errors (a_this);
3138 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
3185 CRTerm ** a_expr, gboolean * a_important)
3189 guint32 cur_char = 0;
3193 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
3194 && a_property && a_expr
3199 status = cr_parser_parse_property (a_this, a_property);
3205 (a_this, status, FALSE,
3206 (
const guchar *)
"while parsing declaration: next property is malformed",
3211 if (cur_char !=
':') {
3213 cr_parser_push_error
3215 (
const guchar *)
"while parsing declaration: this char must be ':'",
3225 (a_this, status, FALSE,
3226 (
const guchar *)
"while parsing declaration: next expression is malformed",
3234 *a_important = TRUE;
3236 *a_important = FALSE;
3246 cr_parser_clear_errors (a_this);
3291 switch (token->
type) {
3300 status = cr_parser_parse_atrule_core (a_this);
3307 status = cr_parser_parse_ruleset_core (a_this);
3308 cr_parser_clear_errors (a_this);
3345 guint32 cur_char = 0,
3351 gboolean start_selector = FALSE,
3352 is_important = FALSE;
3359 status = cr_parser_parse_selector (a_this, &selector);
3365 (a_this, cur_char ==
'{',
3366 (
const guchar *)
"while parsing rulset: current char should be '{'",
3369 if (
PRIVATE (a_this)->sac_handler
3370 &&
PRIVATE (a_this)->sac_handler->start_selector) {
3379 PRIVATE (a_this)->sac_handler->start_selector
3380 (
PRIVATE (a_this)->sac_handler, selector);
3381 start_selector = TRUE;
3395 &&
PRIVATE (a_this)->sac_handler
3396 &&
PRIVATE (a_this)->sac_handler->property) {
3397 PRIVATE (a_this)->sac_handler->property
3398 (
PRIVATE (a_this)->sac_handler, property, expr,
3401 if (status ==
CR_OK) {
3423 if (status ==
CR_OK && c ==
'}') {
3425 goto end_of_ruleset ;
3429 (a_this, status, FALSE,
3430 (
const guchar *)
"while parsing ruleset: next construction should be a declaration",
3435 if (next_char !=
';')
3444 &expr, &is_important);
3450 &&
PRIVATE (a_this)->sac_handler
3451 &&
PRIVATE (a_this)->sac_handler->property) {
3452 PRIVATE (a_this)->sac_handler->property
3453 (
PRIVATE (a_this)->sac_handler,
3454 property, expr, is_important);
3471 (a_this, cur_char ==
'}',
3472 (
const guchar *)
"while parsing rulset: current char must be a '}'",
3475 selector->location = end_parsing_location;
3476 if (
PRIVATE (a_this)->sac_handler
3477 &&
PRIVATE (a_this)->sac_handler->end_selector) {
3478 PRIVATE (a_this)->sac_handler->end_selector
3479 (
PRIVATE (a_this)->sac_handler, selector);
3480 start_selector = FALSE;
3498 cr_parser_clear_errors (a_this);
3504 if (start_selector == TRUE
3505 &&
PRIVATE (a_this)->sac_handler
3506 &&
PRIVATE (a_this)->sac_handler->error) {
3507 PRIVATE (a_this)->sac_handler->error
3508 (
PRIVATE (a_this)->sac_handler);
3558 GList ** a_media_list,
3564 guint32 cur_char = 0,
3568 g_return_val_if_fail (a_this
3570 && (*a_import_string == NULL),
3575 if (
BYTE (a_this, 1, NULL) ==
'@'
3576 &&
BYTE (a_this, 2, NULL) ==
'i'
3577 &&
BYTE (a_this, 3, NULL) ==
'm'
3578 &&
BYTE (a_this, 4, NULL) ==
'p'
3579 &&
BYTE (a_this, 5, NULL) ==
'o'
3580 &&
BYTE (a_this, 6, NULL) ==
'r'
3581 &&
BYTE (a_this, 7, NULL) ==
't') {
3585 (a_this, a_location) ;
3600 if (next_char ==
'"' || next_char ==
'\'') {
3601 status = cr_parser_parse_string (a_this, a_import_string);
3605 status = cr_parser_parse_uri (a_this, a_import_string);
3612 status = cr_parser_parse_ident (a_this, &medium);
3614 if (status ==
CR_OK && medium) {
3615 *a_media_list = g_list_append (*a_media_list, medium);
3621 for (; status ==
CR_OK;) {
3623 &next_char)) !=
CR_OK) {
3631 if (next_char ==
',') {
3639 status = cr_parser_parse_ident (a_this, &medium);
3643 if ((status ==
CR_OK) && medium) {
3644 *a_media_list = g_list_append (*a_media_list, medium);
3657 cr_parser_clear_errors (a_this);
3664 if (*a_media_list) {
3677 for (cur = *a_media_list; cur; cur = cur->next) {
3683 g_list_free (*a_media_list);
3684 *a_media_list = NULL;
3687 if (*a_import_string) {
3689 *a_import_string = NULL;
3723 guint32 next_char = 0,
3726 GList *media_list = NULL;
3729 g_return_val_if_fail (a_this
3750 medium = token->
u.
str;
3751 token->
u.
str = NULL;
3756 media_list = g_list_append (media_list, medium);
3760 for (; status ==
CR_OK;) {
3764 if (next_char ==
',') {
3772 status = cr_parser_parse_ident (a_this, &medium);
3777 media_list = g_list_append (media_list, medium);
3789 if (
PRIVATE (a_this)->sac_handler
3790 &&
PRIVATE (a_this)->sac_handler->start_media) {
3791 PRIVATE (a_this)->sac_handler->start_media
3792 (
PRIVATE (a_this)->sac_handler, media_list,
3800 for (; status ==
CR_OK;) {
3812 if (
PRIVATE (a_this)->sac_handler
3813 &&
PRIVATE (a_this)->sac_handler->end_media) {
3814 PRIVATE (a_this)->sac_handler->end_media
3815 (
PRIVATE (a_this)->sac_handler, media_list);
3832 for (cur = media_list; cur; cur = cur->next) {
3836 g_list_free (media_list);
3840 cr_parser_clear_errors (a_this);
3860 for (cur = media_list; cur; cur = cur->next) {
3864 g_list_free (media_list);
3893 CRTerm *css_expression = NULL;
3895 *page_pseudo_class = NULL,
3897 gboolean important = TRUE;
3920 page_selector = token->
u.
str;
3921 token->
u.
str = NULL;
3939 status = cr_parser_parse_ident (a_this, &page_pseudo_class);
3963 if (
PRIVATE (a_this)->sac_handler
3964 &&
PRIVATE (a_this)->sac_handler->start_page) {
3965 PRIVATE (a_this)->sac_handler->start_page
3966 (
PRIVATE (a_this)->sac_handler,
3967 page_selector, page_pseudo_class,
3982 if (
PRIVATE (a_this)->sac_handler
3983 &&
PRIVATE (a_this)->sac_handler->property) {
3987 PRIVATE (a_this)->sac_handler->property
3988 (
PRIVATE (a_this)->sac_handler,
3989 property, css_expression, important);
3999 if (css_expression) {
4001 css_expression = NULL;
4011 (
PRIVATE (a_this)->tknzr, &token);
4030 if (status !=
CR_OK)
4036 if (
PRIVATE (a_this)->sac_handler
4037 &&
PRIVATE (a_this)->sac_handler->property) {
4039 PRIVATE (a_this)->sac_handler->property
4040 (
PRIVATE (a_this)->sac_handler,
4041 property, css_expression, important);
4051 if (css_expression) {
4053 css_expression = NULL;
4064 (
PRIVATE (a_this)->tknzr, &token);
4073 if (
PRIVATE (a_this)->sac_handler
4074 &&
PRIVATE (a_this)->sac_handler->end_page) {
4075 PRIVATE (a_this)->sac_handler->end_page
4076 (
PRIVATE (a_this)->sac_handler,
4077 page_selector, page_pseudo_class);
4080 if (page_selector) {
4082 page_selector = NULL;
4085 if (page_pseudo_class) {
4087 page_pseudo_class = NULL;
4094 cr_parser_clear_errors (a_this);
4104 if (page_selector) {
4106 page_selector = NULL;
4108 if (page_pseudo_class) {
4110 page_pseudo_class = NULL;
4116 if (css_expression) {
4118 css_expression = NULL;
4147 g_return_val_if_fail (a_this && a_value
4148 && (*a_value == NULL),
4157 if (a_charset_sym_location) {
4171 charset_str = token->
u.
str;
4172 token->
u.
str = NULL;
4186 *a_value = charset_str;
4235 CRTerm *css_expression = NULL;
4237 gboolean important = FALSE;
4238 guint32 next_char = 0,
4269 if (
PRIVATE (a_this)->sac_handler
4270 &&
PRIVATE (a_this)->sac_handler->start_font_face) {
4271 PRIVATE (a_this)->sac_handler->start_font_face
4272 (
PRIVATE (a_this)->sac_handler, &location);
4280 &css_expression, &important);
4281 if (status ==
CR_OK) {
4286 if (
PRIVATE (a_this)->sac_handler &&
4287 PRIVATE (a_this)->sac_handler->property) {
4288 PRIVATE (a_this)->sac_handler->property
4289 (
PRIVATE (a_this)->sac_handler,
4290 property, css_expression, important);
4299 if (css_expression) {
4301 css_expression = NULL;
4305 if (next_char ==
';') {
4315 if (status !=
CR_OK)
4321 if (
PRIVATE (a_this)->sac_handler->property) {
4322 PRIVATE (a_this)->sac_handler->property
4323 (
PRIVATE (a_this)->sac_handler,
4324 property, css_expression, important);
4334 if (css_expression) {
4336 css_expression = NULL;
4345 if (
PRIVATE (a_this)->sac_handler->end_font_face) {
4346 PRIVATE (a_this)->sac_handler->end_font_face
4347 (
PRIVATE (a_this)->sac_handler);
4355 cr_parser_clear_errors (a_this);
4368 if (css_expression) {
4370 css_expression = NULL;
4391 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
4394 if (
PRIVATE (a_this)->use_core_grammar == FALSE) {
4395 status = cr_parser_parse_stylesheet (a_this);
4397 status = cr_parser_parse_stylesheet_core (a_this);
4415 if (
PRIVATE (a_this)->tknzr) {
4419 PRIVATE (a_this)->tknzr = a_tknzr;
4440 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
4443 *a_tknzr =
PRIVATE (a_this)->tknzr;
4461 g_return_val_if_fail (a_this
4466 (
PRIVATE (a_this)->tknzr, a_loc) ;
4482 const guchar * a_buf,
4488 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
4493 g_return_val_if_fail (tknzr != NULL,
CR_ERROR);
4514 g_return_if_fail (a_this &&
PRIVATE (a_this));
4516 if (
PRIVATE (a_this)->tknzr) {
4518 PRIVATE (a_this)->tknzr = NULL;
4521 if (
PRIVATE (a_this)->sac_handler) {
4523 PRIVATE (a_this)->sac_handler = NULL;
4526 if (
PRIVATE (a_this)->err_stack) {
4527 cr_parser_clear_errors (a_this);
4528 PRIVATE (a_this)->err_stack = NULL;
CRAdditionalSel * cr_additional_sel_append(CRAdditionalSel *a_this, CRAdditionalSel *a_sel)
cr_additional_sel_append: @a_this: the "this pointer" of the current instance of CRAdditionalSel .
CRAdditionalSel * cr_additional_sel_new_with_type(enum AddSelectorType a_sel_type)
cr_additional_sel_new_with_type: @a_sel_type: the type of the newly built instance of CRAdditionalSel...
void cr_additional_sel_destroy(CRAdditionalSel *a_this)
cr_additional_sel_destroy: @a_this: the "this pointer" of the current instance of CRAdditionalSel .
@ PSEUDO_CLASS_ADD_SELECTOR
enum CRStatus cr_attr_sel_append_attr_sel(CRAttrSel *a_this, CRAttrSel *a_attr_sel)
cr_attr_sel_append_attr_sel: @a_this: the this pointer of the current instance of CRAttrSel.
CRAttrSel * cr_attr_sel_new(void)
CRAttrSel:
void cr_attr_sel_destroy(CRAttrSel *a_this)
cr_attr_sel_destroy: @a_this: the "this pointer" of the current instance of CRAttrSel.
void cr_doc_handler_ref(CRDocHandler *a_this)
cr_doc_handler_ref: @a_this: the current instance of CRDocHandler.
CRDocHandler * cr_doc_handler_new(void)
cr_doc_handler_new: Constructor of CRDocHandler.
gboolean cr_doc_handler_unref(CRDocHandler *a_this)
cr_doc_handler_unref: @a_this: the currrent instance of CRDocHandler.
enum CRStatus cr_doc_handler_set_default_sac_handler(CRDocHandler *a_this)
cr_doc_handler_set_default_sac_handler: @a_this: a pointer to the current instance of CRDocHandler.
void cr_doc_handler_destroy(CRDocHandler *a_this)
cr_doc_handler_destroy: @a_this: the instance of CRDocHandler to destroy.
typedefG_BEGIN_DECLS struct _CRDocHandler CRDocHandler
The declaration of the CRNum class.
#define CHECK_PARSING_STATUS(status, is_exception)
Checks if 'status' equals CR_OK.
enum CRStatus cr_parser_parse_ruleset(CRParser *a_this)
cr_parser_parse_ruleset: @a_this: the "this pointer" of the current instance of CRParser.
enum CRStatus cr_parser_get_tknzr(CRParser *a_this, CRTknzr **a_tknzr)
cr_parser_get_tknzr: @a_this: the current instance of CRParser @a_tknzr: out parameter.
#define RECORD_INITIAL_POS(a_this, a_pos)
Gets information about the current position in the input of the parser.
#define PEEK_NEXT_CHAR(a_this, a_to_char)
Peeks the next char from the input stream of the current parser by invoking cr_tknzr_input_peek_char(...
enum CRStatus cr_parser_parse_font_face(CRParser *a_this)
cr_parser_parse_font_face: @a_this: the current instance of CRParser.
#define ENSURE_PARSING_COND(condition)
Tests the condition and if it is false, sets status to "CR_PARSING_ERROR" and goto the 'error' label.
enum CRStatus cr_parser_set_use_core_grammar(CRParser *a_this, gboolean a_use_core_grammar)
cr_parser_set_use_core_grammar: @a_this: the current instance of CRParser.
enum CRStatus cr_parser_get_use_core_grammar(CRParser const *a_this, gboolean *a_use_core_grammar)
cr_parser_get_use_core_grammar: @a_this: the current instance of CRParser.
enum CRStatus cr_parser_get_parsing_location(CRParser const *a_this, CRParsingLocation *a_loc)
cr_parser_get_parsing_location: @a_this: the current instance of CRParser @a_loc: the parsing locatio...
enum CRStatus cr_parser_parse_file(CRParser *a_this, const guchar *a_file_uri, enum CREncoding a_enc)
cr_parser_parse_file: @a_this: a pointer to the current instance of CRParser.
CRParser * cr_parser_new_from_input(CRInput *a_input)
cr_parser_new_from_input: @a_input: the parser input stream to use.
#define READ_NEXT_CHAR(a_this, a_to_char)
Reads the next char from the input stream of the current parser.
enum CRStatus cr_parser_parse_statement_core(CRParser *a_this)
cr_parser_parse_statement_core: @a_this: the current instance of CRParser.
#define CHECK_PARSING_STATUS_ERR(a_this, a_status, a_is_exception, a_err_msg, a_err_status)
CHECK_PARSING_STATUS_ERR: @a_this: the current instance of CRParser .
enum CRStatus cr_parser_parse_buf(CRParser *a_this, const guchar *a_buf, gulong a_len, enum CREncoding a_enc)
cr_parser_parse_buf: @a_this: the current instance of #CRparser @a_buf: the input buffer @a_len: the ...
void cr_parser_destroy(CRParser *a_this)
cr_parser_destroy: @a_this: the current instance of CRParser to destroy.
#define BYTE(a_parser, a_offset, a_eof)
enum CRStatus cr_parser_parse_prio(CRParser *a_this, CRString **a_prio)
cr_parser_parse_prio: @a_this: the current instance of CRParser.
#define READ_NEXT_BYTE(a_this, a_byte_ptr)
Reads a byte from the topmost parser input steam.
enum CRStatus cr_parser_parse_charset(CRParser *a_this, CRString **a_value, CRParsingLocation *a_charset_sym_location)
cr_parser_parse_charset: @a_this: the "this pointer" of the current instance of CRParser.
enum CRStatus cr_parser_parse(CRParser *a_this)
cr_parser_parse: @a_this: the current instance of CRParser.
CRParser * cr_parser_new_from_file(const guchar *a_file_uri, enum CREncoding a_enc)
cr_parser_new_from_file: @a_file_uri: the uri of the file to parse.
enum CRStatus cr_parser_get_sac_handler(CRParser *a_this, CRDocHandler **a_handler)
cr_parser_get_sac_handler: @a_this: the "this pointer" of the current instance of CRParser.
enum CRStatus cr_parser_try_to_skip_spaces_and_comments(CRParser *a_this)
cr_parser_try_to_skip_spaces_and_comments: @a_this: the current instance of CRParser.
enum CRStatus cr_parser_parse_media(CRParser *a_this)
cr_parser_parse_media: @a_this: the "this pointer" of the current instance of CRParser.
enum CRStatus cr_parser_parse_import(CRParser *a_this, GList **a_media_list, CRString **a_import_string, CRParsingLocation *a_location)
cr_parser_parse_import: @a_this: the "this pointer" of the current instance of CRParser.
#define RECURSIVE_CALLERS_LIMIT
CRParser * cr_parser_new_from_buf(guchar *a_buf, gulong a_len, enum CREncoding a_enc, gboolean a_free_buf)
cr_parser_new_from_buf: @a_buf: the buffer to parse.
#define SKIP_CHARS(a_parser, a_nb_chars)
Skip utf8 encoded characters.
enum CRStatus cr_parser_set_sac_handler(CRParser *a_this, CRDocHandler *a_handler)
cr_parser_set_sac_handler: @a_this: the "this pointer" of the current instance of CRParser.
enum CRStatus cr_parser_parse_expr(CRParser *a_this, CRTerm **a_expr)
cr_parser_parse_expr: @a_this: the current instance of CRParser.
CRParser * cr_parser_new(CRTknzr *a_tknzr)
cr_parser_new: @a_tknzr: the tokenizer to use for the parsing.
enum CRStatus cr_parser_set_tknzr(CRParser *a_this, CRTknzr *a_tknzr)
cr_parser_set_tknzr: @a_this: the current instance of CRParser; @a_tknzr: the new tokenizer.
#define ENSURE_PARSING_COND_ERR(a_this, a_condition, a_err_msg, a_err_status)
enum CRStatus cr_parser_parse_declaration(CRParser *a_this, CRString **a_property, CRTerm **a_expr, gboolean *a_important)
cr_parser_parse_declaration: @a_this: the "this pointer" of the current instance of CRParser.
enum CRStatus cr_parser_parse_page(CRParser *a_this)
cr_parser_parse_page: @a_this: the "this pointer" of the current instance of CRParser.
enum CRStatus cr_parser_parse_term(CRParser *a_this, CRTerm **a_term)
cr_parser_parse_term: @a_term: out parameter.
enum CRStatus cr_parser_set_default_sac_handler(CRParser *a_this)
cr_parser_set_default_sac_handler: @a_this: a pointer to the current instance of CRParser.
@ TRY_PARSE_RULESET_STATE
@ TRY_PARSE_FONT_FACE_STATE
@ TRY_PARSE_CHARSET_STATE
The declaration file of the CRParser class.
enum CRStatus cr_parsing_location_copy(CRParsingLocation *a_to, CRParsingLocation const *a_from)
cr_parsing_location_copy: @a_to: the destination of the copy.
CRPseudo * cr_pseudo_new(void)
@CRPseudo: The definition of the CRPseudo class.
gboolean cr_selector_unref(CRSelector *a_this)
cr_selector_unref:
CRSelector * cr_selector_append_simple_sel(CRSelector *a_this, CRSimpleSel *a_simple_sel)
cr_selector_append_simple_sel:
CRSelector * cr_selector_append(CRSelector *a_this, CRSelector *a_new)
cr_selector_append:
void cr_selector_ref(CRSelector *a_this)
cr_selector_ref:
typedefG_BEGIN_DECLS struct _CRSelector CRSelector
void cr_simple_sel_destroy(CRSimpleSel *a_this)
cr_simple_sel_destroy:
CRSimpleSel * cr_simple_sel_append_simple_sel(CRSimpleSel *a_this, CRSimpleSel *a_sel)
cr_simple_sel_append_simple_sel:
CRSimpleSel * cr_simple_sel_new(void)
cr_simple_sel_new:
the declaration of the CRSimpleSel class.
CRString * cr_string_new_from_string(const gchar *a_string)
Instanciate a string and initialise it to a_string.
void cr_string_destroy(CRString *a_this)
typedefG_BEGIN_DECLS struct _CRString CRString
enum CRStatus cr_term_set_number(CRTerm *a_this, CRNum *a_num)
enum CRStatus cr_term_set_uri(CRTerm *a_this, CRString *a_str)
enum CRStatus cr_term_set_ident(CRTerm *a_this, CRString *a_str)
enum CRStatus cr_term_set_hash(CRTerm *a_this, CRString *a_str)
enum CRStatus cr_term_set_string(CRTerm *a_this, CRString *a_str)
void cr_term_destroy(CRTerm *a_this)
The destructor of the the CRTerm class.
void cr_term_ref(CRTerm *a_this)
Increments the reference counter of the current instance of CRTerm.
CRTerm * cr_term_new(void)
Instanciate a CRTerm.
enum CRStatus cr_term_set_function(CRTerm *a_this, CRString *a_func_name, CRTerm *a_func_param)
enum CRStatus cr_term_set_rgb(CRTerm *a_this, CRRgb *a_rgb)
CRTerm * cr_term_append_term(CRTerm *a_this, CRTerm *a_new_term)
Appends a new term to the current list of CRTerm.
gboolean cr_term_unref(CRTerm *a_this)
Decrements the ref count of the current instance of CRTerm.
Declaration of the #CRTem class.
void cr_tknzr_ref(CRTknzr *a_this)
gboolean cr_tknzr_unref(CRTknzr *a_this)
enum CRStatus cr_tknzr_unget_token(CRTknzr *a_this, CRToken *a_token)
enum CRStatus cr_tknzr_peek_byte(CRTknzr *a_this, gulong a_offset, guchar *a_byte)
Peeks a byte ahead at a given postion in the parser input stream.
enum CRStatus cr_tknzr_get_next_token(CRTknzr *a_this, CRToken **a_tk)
Returns the next token of the input stream.
CRTknzr * cr_tknzr_new(CRInput *a_input)
CRTknzr * cr_tknzr_new_from_buf(guchar *a_buf, gulong a_len, enum CREncoding a_enc, gboolean a_free_at_destroy)
enum CRStatus cr_tknzr_set_cur_pos(CRTknzr *a_this, CRInputPos *a_pos)
enum CRStatus cr_tknzr_peek_char(CRTknzr *a_this, guint32 *a_char)
Peeks a char from the parser input stream.
enum CRStatus cr_tknzr_get_parsing_location(CRTknzr *a_this, CRParsingLocation *a_loc)
CRTknzr * cr_tknzr_new_from_uri(const guchar *a_file_uri, enum CREncoding a_enc)
enum CRStatus cr_tknzr_parse_token(CRTknzr *a_this, enum CRTokenType a_type, enum CRTokenExtraType a_et, gpointer a_res, gpointer a_extra_res)
typedefG_BEGIN_DECLS struct _CRTknzr CRTknzr
void cr_token_destroy(CRToken *a_this)
The destructor of the CRToken class.
#define cr_utils_trace_info(a_msg)
Traces an info message.
CRStatus
The status type returned by the methods of the croco library.
CREncoding
Encoding values.
CRParsingLocation location
union CRAdditionalSelectorContent content
CRParsingLocation location
enum AttrMatchWay match_way
An abstraction of an error reported by by the parsing routines.
The private attributes of CRParser.
CRDocHandler * sac_handler
The sac handlers to call to notify the parsing of the css2 constructions.
GList * err_stack
A stack of errors reported by the parsing routines.
gboolean is_case_sensitive
gboolean use_core_grammar
CRTknzr * tknzr
The tokenizer.
The implementation of the SAC parser.
CRParsingLocation location
The abstraction of a css2 simple selection list as defined by the right part of the "selector" produc...
CRParsingLocation location
CRAdditionalSel * add_sel
The additional selector list of the current simple selector.
enum Combinator combinator
The combinator that separates this simple selector from the previous one.
enum SimpleSelectorType type_mask
An abstraction of a css2 term as defined in the CSS2 spec in appendix D.1: term ::= [ NUMBER S* | PER...
enum UnaryOperator unary_op
The unary operator associated to the current term.
CRParsingLocation location
enum CRTermType type
The type of the term.
This class abstracts a css2 token.
CRParsingLocation location