63 #define PRIVATE(obj) ((obj)->priv) 69 #define IS_NUM(a_char) (((a_char) >= '0' && (a_char) <= '9')?TRUE:FALSE) 80 #define CHECK_PARSING_STATUS(status, is_exception) \ 81 if ((status) != CR_OK) \ 83 if (is_exception == FALSE) \ 85 status = CR_PARSING_ERROR ; \ 99 #define PEEK_NEXT_CHAR(a_tknzr, a_to_char) \ 101 status = cr_tknzr_peek_char (a_tknzr, a_to_char) ; \ 102 CHECK_PARSING_STATUS (status, TRUE) \ 113 #define READ_NEXT_CHAR(a_tknzr, to_char) \ 114 status = cr_tknzr_read_char (a_tknzr, to_char) ;\ 115 CHECK_PARSING_STATUS (status, TRUE) 127 #define RECORD_INITIAL_POS(a_tknzr, a_pos) \ 128 status = cr_input_get_cur_pos (PRIVATE \ 129 (a_tknzr)->input, a_pos) ; \ 130 g_return_val_if_fail (status == CR_OK, status) 139 #define RECORD_CUR_BYTE_ADDR(a_tknzr, a_addr) \ 140 status = cr_input_get_cur_byte_addr \ 141 (PRIVATE (a_tknzr)->input, a_addr) ; \ 142 CHECK_PARSING_STATUS (status, TRUE) 155 #define PEEK_BYTE(a_tknzr, a_offset, a_byte_ptr) \ 156 status = cr_tknzr_peek_byte (a_tknzr, \ 159 CHECK_PARSING_STATUS (status, TRUE) ; 161 #define BYTE(a_input, a_n, a_eof) \ 162 cr_input_peek_byte2 (a_input, a_n, a_eof) 171 #define READ_NEXT_BYTE(a_tknzr, a_byte_ptr) \ 173 cr_input_read_byte (PRIVATE (a_tknzr)->input, a_byte_ptr) ;\ 174 CHECK_PARSING_STATUS (status, TRUE) ; 184 #define SKIP_BYTES(a_tknzr, a_nb_bytes) \ 185 status = cr_input_seek_index (PRIVATE (a_tknzr)->input, \ 186 CR_SEEK_CUR, a_nb_bytes) ; \ 187 CHECK_PARSING_STATUS (status, TRUE) ; 196 #define SKIP_CHARS(a_tknzr, a_nb_chars) \ 198 gulong nb_chars = a_nb_chars ; \ 199 status = cr_input_consume_chars \ 200 (PRIVATE (a_tknzr)->input,0, &nb_chars) ; \ 201 CHECK_PARSING_STATUS (status, TRUE) ; \ 210 #define ENSURE_PARSING_COND(condition) \ 211 if (! (condition)) {status = CR_PARSING_ERROR; goto error ;} 228 guint32 * a_esc_code,
261 cr_tknzr_parse_w (
CRTknzr * a_this,
266 guint32 cur_char = 0;
270 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
294 gboolean is_eof = FALSE;
303 }
else if (status !=
CR_OK) {
335 cr_tknzr_parse_nl (
CRTknzr * a_this,
341 guchar next_chars[2] = { 0 };
344 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
352 if ((next_chars[0] ==
'\r' && next_chars[1] ==
'\n')) {
356 (a_this, a_location) ;
363 }
else if (next_chars[0] ==
'\n' 364 || next_chars[0] ==
'\r' || next_chars[0] ==
'\f') {
368 (a_this, a_location) ;
393 cr_tknzr_try_to_skip_spaces (
CRTknzr * a_this)
396 guint32 cur_char = 0;
398 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
403 if (status !=
CR_OK) {
410 gulong nb_chars = -1;
413 (
PRIVATE (a_this)->input, &nb_chars);
429 cr_tknzr_parse_comment (
CRTknzr * a_this,
434 guint32 cur_char = 0, next_char= 0;
438 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
452 if (next_char ==
'*')
455 g_string_append_unichar (comment->stryng, cur_char);
461 g_string_append_unichar (comment->stryng, cur_char);
463 if (next_char !=
'*')
468 if (next_char ==
'/')
471 g_string_append_unichar (comment->stryng, cur_char);
474 if (next_char ==
'*')
477 g_string_append_unichar (comment->stryng, cur_char);
483 g_string_append_unichar (comment->stryng, cur_char);
485 if (next_char !=
'*')
492 g_string_append_unichar (comment->stryng, cur_char);
494 if (status ==
CR_OK) {
497 *a_comment = comment;
529 cr_tknzr_parse_unicode_escape (
CRTknzr * a_this,
537 guchar *tmp_char_ptr1 = NULL,
538 *tmp_char_ptr2 = NULL;
541 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
549 if (cur_char !=
'\\') {
555 (a_this, a_location) ;
559 for (occur = 0, unicode = 0; ((cur_char >=
'0' && cur_char <=
'9')
560 || (cur_char >=
'a' && cur_char <=
'f')
561 || (cur_char >=
'A' && cur_char <=
'F'))
562 && occur < 6; occur++) {
563 gint cur_char_val = 0;
567 if ((cur_char >=
'0' && cur_char <=
'9')) {
568 cur_char_val = (cur_char -
'0');
569 }
else if ((cur_char >=
'a' && cur_char <=
'f')) {
570 cur_char_val = 10 + (cur_char -
'a');
571 }
else if ((cur_char >=
'A' && cur_char <=
'F')) {
572 cur_char_val = 10 + (cur_char -
'A');
575 unicode = unicode * 16 + cur_char_val;
581 cr_tknzr_parse_w (a_this, &tmp_char_ptr1,
582 &tmp_char_ptr2, NULL);
583 *a_unicode = unicode;
602 cr_tknzr_parse_escape (
CRTknzr * a_this, guint32 * a_esc_code,
606 guint32 cur_char = 0;
608 guchar next_chars[2];
610 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
618 if (next_chars[0] !=
'\\') {
623 if ((next_chars[1] >=
'0' && next_chars[1] <=
'9')
624 || (next_chars[1] >=
'a' && next_chars[1] <=
'f')
625 || (next_chars[1] >=
'A' && next_chars[1] <=
'F')) {
626 status = cr_tknzr_parse_unicode_escape (a_this, a_esc_code,
638 if (cur_char !=
' ' && (cur_char < 200 || cur_char > 4177777)) {
642 *a_esc_code = cur_char;
645 if (status ==
CR_OK) {
671 guint32 cur_char = 0,
677 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
686 else if (cur_char ==
'\'')
695 (a_this, &str->location) ;
698 guchar next_chars[2] = { 0 };
703 if (next_chars[0] ==
'\\') {
704 guchar *tmp_char_ptr1 = NULL,
705 *tmp_char_ptr2 = NULL;
706 guint32 esc_code = 0;
708 if (next_chars[1] ==
'\'' || next_chars[1] ==
'"') {
709 g_string_append_unichar (str->stryng,
714 status = cr_tknzr_parse_escape
715 (a_this, &esc_code, NULL);
717 if (status ==
CR_OK) {
718 g_string_append_unichar
724 if (status !=
CR_OK) {
731 status = cr_tknzr_parse_nl
732 (a_this, &tmp_char_ptr1,
733 &tmp_char_ptr2, NULL);
737 }
else if (strchr (
"\t !#$%&", next_chars[0])
738 || (next_chars[0] >=
'(' && next_chars[0] <=
'~')) {
740 g_string_append_unichar (str->stryng,
747 g_string_append_unichar (str->stryng, cur_char);
748 }
else if (next_chars[0] == delim) {
757 if (status ==
CR_OK) {
758 if (*a_str == NULL) {
762 (*a_str)->stryng = g_string_append_len
795 cr_tknzr_parse_nmstart (
CRTknzr * a_this,
801 guint32 cur_char = 0,
804 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
812 if (next_char ==
'\\') {
813 status = cr_tknzr_parse_escape (a_this, a_char,
820 || ((next_char >=
'a') && (next_char <=
'z'))
821 || ((next_char >=
'A') && (next_char <=
'Z'))
862 cr_tknzr_parse_nmchar (
CRTknzr * a_this, guint32 * a_char,
865 guint32 cur_char = 0,
870 g_return_val_if_fail (a_this &&
PRIVATE (a_this) && a_char,
880 if (next_char ==
'\\') {
881 status = cr_tknzr_parse_escape (a_this, a_char,
888 || ((next_char >=
'a') && (next_char <=
'z'))
889 || ((next_char >=
'A') && (next_char <=
'Z'))
890 || ((next_char >=
'0') && (next_char <=
'9'))
891 || (next_char ==
'-')
892 || (next_char ==
'_')
899 (a_this, a_location) ;
931 guint32 tmp_char = 0;
935 gboolean location_is_set = FALSE ;
937 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
944 g_return_val_if_fail (stringue,
947 if (tmp_char ==
'-') {
950 (a_this, &stringue->location) ;
951 location_is_set = TRUE ;
952 g_string_append_unichar (stringue->stryng,
955 status = cr_tknzr_parse_nmstart (a_this, &tmp_char, NULL);
956 if (status !=
CR_OK) {
960 if (location_is_set == FALSE) {
962 (a_this, &stringue->location) ;
963 location_is_set = TRUE ;
965 g_string_append_unichar (stringue->stryng, tmp_char);
967 status = cr_tknzr_parse_nmchar (a_this,
970 if (status !=
CR_OK) {
974 g_string_append_unichar (stringue->stryng, tmp_char);
976 if (status ==
CR_OK) {
981 g_string_append_len ((*a_str)->stryng,
982 stringue->stryng->str,
983 stringue->stryng->len) ;
995 if (status !=
CR_OK ) {
1016 cr_tknzr_parse_name (
CRTknzr * a_this,
1019 guint32 tmp_char = 0;
1022 gboolean str_needs_free = FALSE,
1023 is_first_nmchar=TRUE ;
1027 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
1034 if (*a_str == NULL) {
1036 str_needs_free = TRUE;
1039 if (is_first_nmchar == TRUE) {
1040 status = cr_tknzr_parse_nmchar
1043 is_first_nmchar = FALSE ;
1045 status = cr_tknzr_parse_nmchar
1046 (a_this, &tmp_char, NULL) ;
1048 if (status !=
CR_OK)
1050 g_string_append_unichar ((*a_str)->stryng,
1055 (&(*a_str)->location, &loc) ;
1058 if (str_needs_free == TRUE && *a_str) {
1073 guint32 cur_char = 0;
1076 gboolean str_needs_free = FALSE;
1079 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
1085 if (cur_char !=
'#') {
1089 if (*a_str == NULL) {
1091 str_needs_free = TRUE;
1095 status = cr_tknzr_parse_name (a_this, a_str);
1097 if (status !=
CR_OK) {
1103 if (str_needs_free == TRUE && *a_str) {
1122 cr_tknzr_parse_uri (
CRTknzr * a_this,
1125 guint32 cur_char = 0;
1128 guchar tab[4] = { 0 }, *tmp_ptr1 = NULL, *tmp_ptr2 = NULL;
1132 g_return_val_if_fail (a_this
1145 if (tab[0] !=
'u' || tab[1] !=
'r' || tab[2] !=
'l' || tab[3] !=
'(') {
1158 cr_tknzr_try_to_skip_spaces (a_this);
1159 status = cr_tknzr_parse_string (a_this, a_str);
1161 if (status ==
CR_OK) {
1162 guint32 next_char = 0;
1163 status = cr_tknzr_parse_w (a_this, &tmp_ptr1,
1165 cr_tknzr_try_to_skip_spaces (a_this);
1167 if (next_char ==
')') {
1174 if (status !=
CR_OK) {
1177 guint32 next_char = 0;
1179 if (strchr (
"!#$%&", next_char)
1180 || (next_char >=
'*' && next_char <=
'~')
1183 g_string_append_unichar
1184 (str->stryng, cur_char);
1187 guint32 esc_code = 0;
1188 status = cr_tknzr_parse_escape
1189 (a_this, &esc_code, NULL);
1190 if (status ==
CR_OK) {
1191 g_string_append_unichar
1200 cr_tknzr_try_to_skip_spaces (a_this);
1202 if (cur_char ==
')') {
1209 if (*a_str == NULL) {
1223 (&(*a_str)->location,
1249 guchar next_bytes[3] = { 0 }, cur_byte = 0;
1254 gboolean is_percentage = FALSE;
1265 if (((next_bytes[0] ==
'r') || (next_bytes[0] ==
'R'))
1266 && ((next_bytes[1] ==
'g') || (next_bytes[1] ==
'G'))
1267 && ((next_bytes[2] ==
'b') || (next_bytes[2] ==
'B'))) {
1278 cr_tknzr_try_to_skip_spaces (a_this);
1279 status = cr_tknzr_parse_num (a_this, &num);
1282 if (num->
val > G_MAXLONG) {
1292 if (next_bytes[0] ==
'%') {
1294 is_percentage = TRUE;
1296 cr_tknzr_try_to_skip_spaces (a_this);
1298 for (i = 0; i < 2; i++) {
1302 cr_tknzr_try_to_skip_spaces (a_this);
1303 status = cr_tknzr_parse_num (a_this, &num);
1306 if (num->
val > G_MAXLONG) {
1312 if (next_bytes[0] ==
'%') {
1319 }
else if (i == 1) {
1327 cr_tknzr_try_to_skip_spaces (a_this);
1331 if (*a_rgb == NULL) {
1335 if (*a_rgb == NULL) {
1341 (*a_rgb)->red = red;
1342 (*a_rgb)->green = green;
1343 (*a_rgb)->blue = blue;
1344 (*a_rgb)->is_percentage = is_percentage;
1349 if (status ==
CR_OK) {
1350 if (a_rgb && *a_rgb) {
1352 (&(*a_rgb)->location,
1384 cr_tknzr_parse_atkeyword (
CRTknzr * a_this,
1387 guint32 cur_char = 0;
1389 gboolean str_needs_free = FALSE;
1392 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
1400 if (cur_char !=
'@') {
1405 if (*a_str == NULL) {
1407 str_needs_free = TRUE;
1409 status = cr_tknzr_parse_ident (a_this, a_str);
1410 if (status !=
CR_OK) {
1416 if (str_needs_free == TRUE && *a_str) {
1425 cr_tknzr_parse_important (
CRTknzr * a_this,
1428 guint32 cur_char = 0;
1432 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
1443 cr_tknzr_try_to_skip_spaces (a_this);
1445 if (
BYTE (
PRIVATE (a_this)->input, 1, NULL) ==
'i' 1453 &&
BYTE (
PRIVATE (a_this)->input, 9, NULL) ==
't') {
1485 cr_tknzr_parse_num (
CRTknzr * a_this,
1490 gboolean parsing_dec,
1493 guint32 cur_char = 0,
1495 gdouble numerator, denominator = 1;
1500 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
1507 if (cur_char ==
'+' || cur_char ==
'-') {
1508 if (cur_char ==
'-') {
1515 numerator = (cur_char -
'0');
1516 parsing_dec = FALSE;
1518 }
else if (cur_char ==
'.') {
1530 if (status !=
CR_OK) {
1535 if (next_char ==
'.') {
1545 }
else if (
IS_NUM (next_char)) {
1549 numerator = numerator * 10 + (cur_char -
'0');
1565 if (status ==
CR_OK) {
1566 gdouble val = (numerator / denominator) * sign;
1567 if (*a_num == NULL) {
1570 if (*a_num == NULL) {
1575 (*a_num)->val = val;
1576 (*a_num)->type = val_type;
1599 result = g_try_malloc (
sizeof (
CRTknzr));
1601 if (result == NULL) {
1606 memset (result, 0,
sizeof (
CRTknzr));
1608 result->priv = g_try_malloc (
sizeof (
CRTknzrPriv));
1610 if (result->priv == NULL) {
1629 gboolean a_free_at_destroy)
1637 g_return_val_if_fail (input != NULL, NULL);
1652 g_return_val_if_fail (input != NULL, NULL);
1662 g_return_if_fail (a_this &&
PRIVATE (a_this));
1664 PRIVATE (a_this)->ref_count++;
1670 g_return_val_if_fail (a_this &&
PRIVATE (a_this), FALSE);
1672 if (
PRIVATE (a_this)->ref_count > 0) {
1673 PRIVATE (a_this)->ref_count--;
1676 if (
PRIVATE (a_this)->ref_count == 0) {
1689 if (
PRIVATE (a_this)->input) {
1693 PRIVATE (a_this)->input = a_input;
1705 *a_input =
PRIVATE (a_this)->input;
1742 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
1746 if (
PRIVATE (a_this)->token_cache) {
1750 PRIVATE (a_this)->token_cache = NULL;
1767 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
1771 if (
PRIVATE (a_this)->token_cache) {
1775 PRIVATE (a_this)->token_cache = NULL;
1793 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
1794 &&
PRIVATE (a_this)->input && a_byte,
1797 if (
PRIVATE (a_this)->token_cache) {
1801 PRIVATE (a_this)->token_cache = NULL;
1821 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
1822 &&
PRIVATE (a_this)->input, 0);
1836 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
1839 if (
PRIVATE (a_this)->token_cache) {
1843 PRIVATE (a_this)->token_cache = NULL;
1852 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
1856 if (
PRIVATE (a_this)->token_cache) {
1860 PRIVATE (a_this)->token_cache = NULL;
1870 g_return_val_if_fail (a_this
1876 (
PRIVATE (a_this)->input, a_loc) ;
1882 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
1884 if (
PRIVATE (a_this)->token_cache) {
1888 PRIVATE (a_this)->token_cache = NULL;
1897 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
1900 if (
PRIVATE (a_this)->token_cache) {
1904 PRIVATE (a_this)->token_cache = NULL;
1913 gulong consumed = *(gulong *) a_nb_char;
1915 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
1918 if (
PRIVATE (a_this)->token_cache) {
1922 PRIVATE (a_this)->token_cache = NULL;
1927 *a_nb_char = (glong) consumed;
1934 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
1937 if (
PRIVATE (a_this)->token_cache) {
1939 PRIVATE (a_this)->token_cache = NULL;
1948 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
1949 &&
PRIVATE (a_this)->token_cache == NULL,
1952 PRIVATE (a_this)->token_cache = a_token;
1974 guint32 next_char = 0;
1975 guchar next_bytes[4] = { 0 };
1976 gboolean reached_eof = FALSE;
1982 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
1983 && a_tk && *a_tk == NULL
1987 if (
PRIVATE (a_this)->token_cache) {
1988 *a_tk =
PRIVATE (a_this)->token_cache;
1989 PRIVATE (a_this)->token_cache = NULL;
1996 (
PRIVATE (a_this)->input, &reached_eof);
1999 if (reached_eof == TRUE) {
2004 input =
PRIVATE (a_this)->input;
2010 switch (next_char) {
2013 if (
BYTE (input, 2, NULL) ==
'f' 2014 &&
BYTE (input, 3, NULL) ==
'o' 2015 &&
BYTE (input, 4, NULL) ==
'n' 2016 &&
BYTE (input, 5, NULL) ==
't' 2017 &&
BYTE (input, 6, NULL) ==
'-' 2018 &&
BYTE (input, 7, NULL) ==
'f' 2019 &&
BYTE (input, 8, NULL) ==
'a' 2020 &&
BYTE (input, 9, NULL) ==
'c' 2021 &&
BYTE (input, 10, NULL) ==
'e') {
2024 (a_this, &location) ;
2033 if (
BYTE (input, 2, NULL) ==
'c' 2034 &&
BYTE (input, 3, NULL) ==
'h' 2035 &&
BYTE (input, 4, NULL) ==
'a' 2036 &&
BYTE (input, 5, NULL) ==
'r' 2037 &&
BYTE (input, 6, NULL) ==
's' 2038 &&
BYTE (input, 7, NULL) ==
'e' 2039 &&
BYTE (input, 8, NULL) ==
't') {
2042 (a_this, &location) ;
2051 if (
BYTE (input, 2, NULL) ==
'i' 2052 &&
BYTE (input, 3, NULL) ==
'm' 2053 &&
BYTE (input, 4, NULL) ==
'p' 2054 &&
BYTE (input, 5, NULL) ==
'o' 2055 &&
BYTE (input, 6, NULL) ==
'r' 2056 &&
BYTE (input, 7, NULL) ==
't') {
2059 (a_this, &location) ;
2068 if (
BYTE (input, 2, NULL) ==
'm' 2069 &&
BYTE (input, 3, NULL) ==
'e' 2070 &&
BYTE (input, 4, NULL) ==
'd' 2071 &&
BYTE (input, 5, NULL) ==
'i' 2072 &&
BYTE (input, 6, NULL) ==
'a') {
2084 if (
BYTE (input, 2, NULL) ==
'p' 2085 &&
BYTE (input, 3, NULL) ==
'a' 2086 &&
BYTE (input, 4, NULL) ==
'g' 2087 &&
BYTE (input, 5, NULL) ==
'e') {
2098 status = cr_tknzr_parse_atkeyword (a_this, &str);
2099 if (status ==
CR_OK) {
2113 if (
BYTE (input, 2, NULL) ==
'r' 2114 &&
BYTE (input, 3, NULL) ==
'l' 2115 &&
BYTE (input, 4, NULL) ==
'(') {
2118 status = cr_tknzr_parse_uri (a_this, &str2);
2119 if (status ==
CR_OK) {
2133 if (
BYTE (input, 2, NULL) ==
'g' 2134 &&
BYTE (input, 3, NULL) ==
'b' 2135 &&
BYTE (input, 4, NULL) ==
'(') {
2136 status = cr_tknzr_parse_rgb (a_this, &rgb);
2137 if (status ==
CR_OK && rgb) {
2153 if (
BYTE (input, 2, NULL) ==
'!' 2154 &&
BYTE (input, 3, NULL) ==
'-' 2155 &&
BYTE (input, 4, NULL) ==
'-') {
2169 if (
BYTE (input, 2, NULL) ==
'-' 2170 &&
BYTE (input, 3, NULL) ==
'>') {
2181 status = cr_tknzr_parse_ident
2183 if (status ==
CR_OK) {
2198 if (
BYTE (input, 2, NULL) ==
'=') {
2212 if (
BYTE (input, 2, NULL) ==
'=') {
2226 if (
BYTE (input, 2, NULL) ==
'*') {
2227 status = cr_tknzr_parse_comment (a_this, &str);
2229 if (status ==
CR_OK) {
2318 guchar *start = NULL,
2321 status = cr_tknzr_parse_w (a_this, &start,
2323 if (status ==
CR_OK) {
2335 status = cr_tknzr_parse_hash (a_this, &str);
2336 if (status ==
CR_OK && str) {
2351 status = cr_tknzr_parse_string (a_this, &str);
2352 if (status ==
CR_OK && str) {
2365 status = cr_tknzr_parse_important (a_this, &location);
2366 if (status ==
CR_OK) {
2392 status = cr_tknzr_parse_num (a_this, &num);
2393 if (status ==
CR_OK && num) {
2394 next_bytes[0] =
BYTE (input, 1, NULL);
2395 next_bytes[1] =
BYTE (input, 2, NULL);
2396 next_bytes[2] =
BYTE (input, 3, NULL);
2397 next_bytes[3] =
BYTE (input, 4, NULL);
2399 if (next_bytes[0] ==
'e' 2400 && next_bytes[1] ==
'm') {
2406 }
else if (next_bytes[0] ==
'e' 2407 && next_bytes[1] ==
'x') {
2413 }
else if (next_bytes[0] ==
'p' 2414 && next_bytes[1] ==
'x') {
2420 }
else if (next_bytes[0] ==
'c' 2421 && next_bytes[1] ==
'm') {
2427 }
else if (next_bytes[0] ==
'm' 2428 && next_bytes[1] ==
'm') {
2434 }
else if (next_bytes[0] ==
'i' 2435 && next_bytes[1] ==
'n') {
2441 }
else if (next_bytes[0] ==
'p' 2442 && next_bytes[1] ==
't') {
2448 }
else if (next_bytes[0] ==
'p' 2449 && next_bytes[1] ==
'c') {
2455 }
else if (next_bytes[0] ==
'd' 2456 && next_bytes[1] ==
'e' 2457 && next_bytes[2] ==
'g') {
2463 }
else if (next_bytes[0] ==
'r' 2464 && next_bytes[1] ==
'a' 2465 && next_bytes[2] ==
'd') {
2471 }
else if (next_bytes[0] ==
'g' 2472 && next_bytes[1] ==
'r' 2473 && next_bytes[2] ==
'a' 2474 && next_bytes[3] ==
'd') {
2480 }
else if (next_bytes[0] ==
'm' 2481 && next_bytes[1] ==
's') {
2487 }
else if (next_bytes[0] ==
's') {
2493 }
else if (next_bytes[0] ==
'H' 2494 && next_bytes[1] ==
'z') {
2500 }
else if (next_bytes[0] ==
'k' 2501 && next_bytes[1] ==
'H' 2502 && next_bytes[2] ==
'z') {
2508 }
else if (next_bytes[0] ==
'%') {
2515 status = cr_tknzr_parse_ident (a_this,
2517 if (status ==
CR_OK && str) {
2533 if (token && token->
u.
num) {
2548 if (next_char ==
'\\' 2550 || ((next_char >=
'a') && (next_char <=
'z'))
2551 || ((next_char >=
'A') && (next_char <=
'Z'))) {
2552 status = cr_tknzr_parse_ident (a_this, &str);
2553 if (status ==
CR_OK && str) {
2557 (
PRIVATE (a_this)->input, &next_c);
2559 if (status ==
CR_OK && next_c ==
'(') {
2603 if (status ==
CR_OK && token) {
2608 memmove (&
PRIVATE (a_this)->prev_pos,
2631 gpointer a_extra_res)
2636 g_return_val_if_fail (a_this &&
PRIVATE (a_this)
2641 if (status !=
CR_OK)
2646 if (token->
type == a_type) {
2671 token->
u.
str = NULL;
2680 token->
u.
num = NULL;
2690 token->
u.
num = NULL;
2697 if (a_extra_res == NULL) {
2703 token->
u.
num = NULL;
2704 token->
dimen = NULL;
2709 *((guint32 *) a_res) = token->
u.
unichar;
2742 g_return_if_fail (a_this);
2747 PRIVATE (a_this)->input = NULL;
2751 if (
PRIVATE (a_this)->token_cache) {
2753 PRIVATE (a_this)->token_cache = NULL;
enum CRStatus cr_tknzr_set_cur_pos(CRTknzr *a_this, CRInputPos *a_pos)
void cr_tknzr_destroy(CRTknzr *a_this)
#define READ_NEXT_BYTE(a_tknzr, a_byte_ptr)
Reads a byte from the topmost parser input steam.
void cr_tknzr_ref(CRTknzr *a_this)
guchar cr_tknzr_peek_byte2(CRTknzr *a_this, gulong a_offset, gboolean *a_eof)
Same as cr_tknzr_peek_byte() but this api returns the byte peeked.
enum CRStatus cr_tknzr_get_next_token(CRTknzr *a_this, CRToken **a_tk)
Returns the next token of the input stream.
CRInputPos prev_pos
The position of the end of the previous token or char fetched.
enum CRStatus cr_token_set_ident(CRToken *a_this, CRString *a_ident)
typedefG_BEGIN_DECLS struct _CRRgb CRRgb
enum CRStatus cr_token_set_important_sym(CRToken *a_this)
glong cr_tknzr_get_nb_bytes_left(CRTknzr *a_this)
Gets the number of bytes left in the topmost input stream associated to this parser.
#define READ_NEXT_CHAR(a_tknzr, to_char)
Reads the next char from the input stream of the current parser.
enum CRStatus cr_tknzr_get_input(CRTknzr *a_this, CRInput **a_input)
enum CRStatus cr_token_set_import_sym(CRToken *a_this)
enum CRStatus cr_tknzr_peek_char(CRTknzr *a_this, guint32 *a_char)
Peeks a char from the parser input stream.
enum CRStatus cr_tknzr_consume_chars(CRTknzr *a_this, guint32 a_char, glong *a_nb_char)
enum CRStatus cr_token_set_bc(CRToken *a_this)
enum CRStatus cr_token_set_exs(CRToken *a_this, CRNum *a_num)
enum CRStatus cr_token_set_semicolon(CRToken *a_this)
enum CRStatus cr_token_set_length(CRToken *a_this, CRNum *a_num, enum CRTokenExtraType a_et)
CRTknzr * cr_tknzr_new_from_uri(const guchar *a_file_uri, enum CREncoding a_enc)
enum CRStatus cr_tknzr_get_parsing_location(CRTknzr *a_this, CRParsingLocation *a_loc)
enum CRStatus cr_tknzr_read_byte(CRTknzr *a_this, guchar *a_byte)
Reads the next byte from the parser input stream.
void cr_string_destroy(CRString *a_this)
CRToken * token_cache
A cache where tknzr_unget_token() puts back the token.
enum CRStatus cr_tknzr_get_cur_pos(CRTknzr *a_this, CRInputPos *a_pos)
#define ENSURE_PARSING_COND(condition)
Tests the condition and if it is false, sets status to "CR_PARSING_ERROR" and goto the 'error' label.
CREncoding
Encoding values.
This class abstracts a css2 token.
void cr_num_destroy(CRNum *a_this)
cr_num_destroy: @a_this: the this pointer of the current instance of CRNum.
enum CRStatus cr_token_set_function(CRToken *a_this, CRString *a_fun_name)
CRStatus
The status type returned by the methods of the croco library.
glong ref_count
The reference count of the current instance of CRTknzr.
enum CRStatus cr_token_set_rgb(CRToken *a_this, CRRgb *a_rgb)
typedefG_BEGIN_DECLS struct _CRDocHandler CRDocHandler
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.
CRString * cr_string_new(void)
Instanciates a CRString.
CRRgb * cr_rgb_new_with_vals(gulong a_red, gulong a_green, gulong a_blue, gboolean a_is_percentage)
cr_rgb_new_with_vals: @a_red: the red component of the color.
enum CRStatus cr_tknzr_get_cur_byte_addr(CRTknzr *a_this, guchar **a_addr)
enum CRStatus cr_tknzr_parse_token(CRTknzr *a_this, enum CRTokenType a_type, enum CRTokenExtraType a_et, gpointer a_res, gpointer a_extra_res)
CRToken * cr_token_new(void)
Default constructor of the CRToken class.
CRSeekPos
Values used by cr_input_seek_position() ;.
#define RECORD_CUR_BYTE_ADDR(a_tknzr, a_addr)
Gets the address of the current byte inside the parser input.
enum CRStatus cr_token_set_includes(CRToken *a_this)
Sets the type of the current instance of CRToken to INCLUDES_TK (INCLUDES as said by the css2 spec).
#define BYTE(a_input, a_n, a_eof)
enum CRStatus cr_token_set_atkeyword(CRToken *a_this, CRString *a_atname)
typedefG_BEGIN_DECLS struct _CRTknzr CRTknzr
enum CRStatus cr_token_set_hash(CRToken *a_this, CRString *a_hash)
enum CRStatus cr_token_set_page_sym(CRToken *a_this)
enum CRStatus cr_tknzr_seek_index(CRTknzr *a_this, enum CRSeekPos a_origin, gint a_pos)
enum CRStatus cr_token_set_freq(CRToken *a_this, CRNum *a_num, enum CRTokenExtraType a_et)
CRTknzr * cr_tknzr_new_from_buf(guchar *a_buf, gulong a_len, enum CREncoding a_enc, gboolean a_free_at_destroy)
typedefG_BEGIN_DECLS struct _CRString CRString
enum CRStatus cr_token_set_time(CRToken *a_this, CRNum *a_num, enum CRTokenExtraType a_et)
#define PEEK_NEXT_CHAR(a_tknzr, a_to_char)
Peeks the next char from the input stream of the current tokenizer.
gboolean cr_utils_is_nonascii(guint32 a_char)
Returns true if the character is a nonascii character (as defined in the css spec chap 4....
#define SKIP_CHARS(a_tknzr, a_nb_chars)
Skip utf8 encoded characters.
The declaration of the #CRDocumentHandler class.
enum CRStatus cr_token_set_s(CRToken *a_this)
Sets the type of curren instance of CRToken to 'S_TK' (S in the css2 spec)
CRParsingLocation location
#define RECORD_INITIAL_POS(a_tknzr, a_pos)
Gets information about the current position in the input of the parser.
enum CRStatus cr_tknzr_unget_token(CRTknzr *a_this, CRToken *a_token)
CRNumType
The different types of numbers.
enum CRStatus cr_token_set_cdc(CRToken *a_this)
Sets the type of the current token to CDC_TK (CDC as said by the css2 spec).
enum CRStatus cr_token_set_cdo(CRToken *a_this)
Sets the type of the current instance of CRToken to 'CDO_TK' (CDO as said by the css2 spec)
enum CRStatus cr_token_set_dashmatch(CRToken *a_this)
Sets the type of the current instance of CRToken to DASHMATCH_TK (DASHMATCH as said by the css2 spec)...
enum CRStatus cr_token_set_cbo(CRToken *a_this)
CRParsingLocation location
enum CRStatus cr_token_set_media_sym(CRToken *a_this)
#define CHECK_PARSING_STATUS(status, is_exception)
Checks if 'status' equals CR_OK.
enum CRStatus cr_token_set_delim(CRToken *a_this, guint32 a_char)
An abstraction of a number (num) as defined in the css2 spec.
CRNum * cr_num_new_with_val(gdouble a_val, enum CRNumType a_type)
cr_num_new_with_val: @a_val: the numerical value of the number.
The declaration of the CRTknzr (tokenizer) class.
enum CRTokenExtraType extra_type
CRTknzr * cr_tknzr_new(CRInput *a_input)
enum CRStatus cr_token_set_string(CRToken *a_this, CRString *a_str)
gboolean cr_tknzr_unref(CRTknzr *a_this)
enum CRStatus cr_token_set_dimen(CRToken *a_this, CRNum *a_num, CRString *a_dim)
enum CRStatus cr_token_set_ems(CRToken *a_this, CRNum *a_num)
#define IS_NUM(a_char)
return TRUE if the character is a number ([0-9]), FALSE otherwise
enum CRStatus cr_tknzr_read_char(CRTknzr *a_this, guint32 *a_char)
Reads the next char from the parser input stream.
enum CRStatus cr_token_set_cbc(CRToken *a_this)
enum CRStatus cr_token_set_charset_sym(CRToken *a_this)
enum CRStatus cr_tknzr_set_input(CRTknzr *a_this, CRInput *a_input)
enum CRStatus cr_token_set_pc(CRToken *a_this)
enum CRStatus cr_token_set_bo(CRToken *a_this)
enum CRStatus cr_token_set_comment(CRToken *a_this, CRString *a_str)
enum CRStatus cr_parsing_location_copy(CRParsingLocation *a_to, CRParsingLocation const *a_from)
cr_parsing_location_copy: @a_to: the destination of the copy.
gboolean cr_utils_is_white_space(guint32 a_char)
Returns TRUE if a_char is a white space as defined in the css spec in chap 4.1.1.
#define PEEK_BYTE(a_tknzr, a_offset, a_byte_ptr)
Peeks a byte from the topmost parser input at a given offset from the current position.
#define SKIP_BYTES(a_tknzr, a_nb_bytes)
Skips a given number of byte in the topmost parser input.
enum CRStatus cr_token_set_font_face_sym(CRToken *a_this)
enum CRStatus cr_token_set_number(CRToken *a_this, CRNum *a_num)
CRDocHandler * sac_handler
void cr_token_destroy(CRToken *a_this)
The destructor of the CRToken class.
CRInput * input
The parser input stream of bytes.
enum CRStatus cr_token_set_angle(CRToken *a_this, CRNum *a_num, enum CRTokenExtraType a_et)
enum CRStatus cr_token_set_percentage(CRToken *a_this, CRNum *a_num)
#define cr_utils_trace_info(a_msg)
Traces an info message.
enum CRStatus cr_token_set_uri(CRToken *a_this, CRString *a_uri)
enum CRStatus cr_token_set_po(CRToken *a_this)