1 /* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset: 8-*- */ 2 3 /* libcroco - Library for parsing and applying CSS 4 * Copyright (C) 2006-2019 Free Software Foundation, Inc. 5 * 6 * This file is not part of the GNU gettext program, but is used with 7 * GNU gettext. 8 * 9 * The original copyright notice is as follows: 10 */ 11 12 /* 13 * This file is part of The Croco Library 14 * 15 * Copyright (C) 2003-2004 Dodji Seketeli. All Rights Reserved. 16 * 17 * This program is free software; you can redistribute it and/or 18 * modify it under the terms of version 2.1 of the GNU Lesser General Public 19 * License as published by the Free Software Foundation. 20 * 21 * This program is distributed in the hope that it will be useful, 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 * GNU General Public License for more details. 25 * 26 * You should have received a copy of the GNU Lesser General Public License 27 * along with this program; if not, write to the Free Software 28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 29 * USA 30 * 31 * Author: Dodji Seketeli 32 */ 33 34 #ifndef __CR_TOKEN_H__ 35 #define __CR_TOKEN_H__ 36 37 #include "cr-utils.h" 38 #include "cr-input.h" 39 #include "cr-num.h" 40 #include "cr-rgb.h" 41 #include "cr-string.h" 42 #include "cr-parsing-location.h" 43 44 G_BEGIN_DECLS 45 46 enum CRTokenType 47 { 48 NO_TK, 49 S_TK, 50 CDO_TK, 51 CDC_TK, 52 INCLUDES_TK, 53 DASHMATCH_TK, 54 COMMENT_TK, 55 STRING_TK, 56 IDENT_TK, 57 HASH_TK, 58 IMPORT_SYM_TK, 59 PAGE_SYM_TK, 60 MEDIA_SYM_TK, 61 FONT_FACE_SYM_TK, 62 CHARSET_SYM_TK, 63 ATKEYWORD_TK, 64 IMPORTANT_SYM_TK, 65 EMS_TK, 66 EXS_TK, 67 LENGTH_TK, 68 ANGLE_TK, 69 TIME_TK, 70 FREQ_TK, 71 DIMEN_TK, 72 PERCENTAGE_TK, 73 NUMBER_TK, 74 RGB_TK, 75 URI_TK, 76 FUNCTION_TK, 77 UNICODERANGE_TK, 78 SEMICOLON_TK, 79 CBO_TK, /*opening curly bracket*/ 80 CBC_TK, /*closing curly bracket*/ 81 PO_TK, /*opening parenthesis*/ 82 PC_TK, /*closing parenthesis*/ 83 BO_TK, /*opening bracket*/ 84 BC_TK, /*closing bracket*/ 85 DELIM_TK 86 } ; 87 88 enum CRTokenExtraType 89 { 90 NO_ET = 0, 91 LENGTH_PX_ET, 92 LENGTH_CM_ET, 93 LENGTH_MM_ET, 94 LENGTH_IN_ET, 95 LENGTH_PT_ET, 96 LENGTH_PC_ET, 97 ANGLE_DEG_ET, 98 ANGLE_RAD_ET, 99 ANGLE_GRAD_ET, 100 TIME_MS_ET, 101 TIME_S_ET, 102 FREQ_HZ_ET, 103 FREQ_KHZ_ET 104 } ; 105 106 typedef struct _CRToken CRToken ; 107 108 /** 109 *This class abstracts a css2 token. 110 */ 111 struct _CRToken 112 { 113 enum CRTokenType type ; 114 enum CRTokenExtraType extra_type ; 115 CRInputPos pos ; 116 117 union 118 { 119 CRString *str ; 120 CRRgb *rgb ; 121 CRNum *num ; 122 guint32 unichar ; 123 } u ; 124 125 CRString * dimen ; 126 CRParsingLocation location ; 127 } ; 128 129 CRToken* cr_token_new (void) ; 130 131 enum CRStatus cr_token_set_s (CRToken *a_this) ; 132 133 enum CRStatus cr_token_set_cdo (CRToken *a_this) ; 134 135 enum CRStatus cr_token_set_cdc (CRToken *a_this) ; 136 137 enum CRStatus cr_token_set_includes (CRToken *a_this) ; 138 139 enum CRStatus cr_token_set_dashmatch (CRToken *a_this) ; 140 141 enum CRStatus cr_token_set_comment (CRToken *a_this, CRString *a_str) ; 142 143 enum CRStatus cr_token_set_string (CRToken *a_this, CRString *a_str) ; 144 145 enum CRStatus cr_token_set_ident (CRToken *a_this, CRString * a_ident) ; 146 147 enum CRStatus cr_token_set_hash (CRToken *a_this, CRString *a_hash) ; 148 149 enum CRStatus cr_token_set_rgb (CRToken *a_this, CRRgb *a_rgb) ; 150 151 enum CRStatus cr_token_set_import_sym (CRToken *a_this) ; 152 153 enum CRStatus cr_token_set_page_sym (CRToken *a_this) ; 154 155 enum CRStatus cr_token_set_media_sym (CRToken *a_this) ; 156 157 enum CRStatus cr_token_set_font_face_sym (CRToken *a_this) ; 158 159 enum CRStatus cr_token_set_charset_sym (CRToken *a_this) ; 160 161 enum CRStatus cr_token_set_atkeyword (CRToken *a_this, CRString *a_atname) ; 162 163 enum CRStatus cr_token_set_important_sym (CRToken *a_this) ; 164 165 enum CRStatus cr_token_set_ems (CRToken *a_this, CRNum *a_num) ; 166 167 enum CRStatus cr_token_set_exs (CRToken *a_this, CRNum *a_num) ; 168 169 enum CRStatus cr_token_set_length (CRToken *a_this, CRNum *a_num, 170 enum CRTokenExtraType a_et) ; 171 172 enum CRStatus cr_token_set_angle (CRToken *a_this, CRNum *a_num, 173 enum CRTokenExtraType a_et) ; 174 175 enum CRStatus cr_token_set_time (CRToken *a_this, CRNum *a_num, 176 enum CRTokenExtraType a_et) ; 177 178 enum CRStatus cr_token_set_freq (CRToken *a_this, CRNum *a_num, 179 enum CRTokenExtraType a_et) ; 180 181 enum CRStatus cr_token_set_dimen (CRToken *a_this, CRNum *a_num, 182 CRString *a_dim) ; 183 184 enum CRStatus cr_token_set_percentage (CRToken *a_this, CRNum *a_num) ; 185 186 enum CRStatus cr_token_set_number (CRToken *a_this, CRNum *a_num) ; 187 188 enum CRStatus cr_token_set_uri (CRToken *a_this, CRString *a_uri) ; 189 190 enum CRStatus cr_token_set_function (CRToken *a_this, 191 CRString *a_fun_name) ; 192 193 enum CRStatus cr_token_set_bc (CRToken *a_this) ; 194 195 enum CRStatus cr_token_set_bo (CRToken *a_this) ; 196 197 enum CRStatus cr_token_set_po (CRToken *a_this) ; 198 199 enum CRStatus cr_token_set_pc (CRToken *a_this) ; 200 201 enum CRStatus cr_token_set_cbc (CRToken *a_this) ; 202 203 enum CRStatus cr_token_set_cbo (CRToken *a_this) ; 204 205 enum CRStatus cr_token_set_semicolon (CRToken *a_this) ; 206 207 enum CRStatus cr_token_set_delim (CRToken *a_this, guint32 a_char) ; 208 209 210 /* 211 enum CRStatus 212 cr_token_set_unicoderange (CRToken *a_this, 213 CRUnicodeRange *a_range) ; 214 */ 215 216 void 217 cr_token_destroy (CRToken *a_this) ; 218 219 220 G_END_DECLS 221 222 #endif /*__CR_TOKEN_H__*/ 223