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 /** 35 *@file 36 *The declaration of the #CRTknzr (tokenizer) 37 *class. 38 */ 39 40 #ifndef __CR_TKNZR_H__ 41 #define __CR_TKNZR_H__ 42 43 #include "cr-utils.h" 44 #include "cr-input.h" 45 #include "cr-token.h" 46 47 G_BEGIN_DECLS 48 49 50 typedef struct _CRTknzr CRTknzr ; 51 typedef struct _CRTknzrPriv CRTknzrPriv ; 52 53 /** 54 *The tokenizer is the class that knows 55 *about all the css token. Its main job is 56 *to return the next token found in the character 57 *input stream. 58 */ 59 struct _CRTknzr 60 { 61 /*the private data of the tokenizer.*/ 62 CRTknzrPriv *priv ; 63 } ; 64 65 CRTknzr * cr_tknzr_new (CRInput *a_input) ; 66 67 CRTknzr * cr_tknzr_new_from_uri (const guchar *a_file_uri, 68 enum CREncoding a_enc) ; 69 70 CRTknzr * cr_tknzr_new_from_buf (guchar *a_buf, gulong a_len, 71 enum CREncoding a_enc, 72 gboolean a_free_at_destroy) ; 73 74 gboolean cr_tknzr_unref (CRTknzr *a_this) ; 75 76 void cr_tknzr_ref (CRTknzr *a_this) ; 77 78 enum CRStatus cr_tknzr_read_byte (CRTknzr *a_this, guchar *a_byte) ; 79 80 enum CRStatus cr_tknzr_read_char (CRTknzr *a_this, guint32 *a_char); 81 82 enum CRStatus cr_tknzr_peek_char (CRTknzr *a_this, guint32 *a_char) ; 83 84 enum CRStatus cr_tknzr_peek_byte (CRTknzr *a_this, gulong a_offset, 85 guchar *a_byte) ; 86 87 guchar cr_tknzr_peek_byte2 (CRTknzr *a_this, gulong a_offset, 88 gboolean *a_eof) ; 89 90 enum CRStatus cr_tknzr_set_cur_pos (CRTknzr *a_this, CRInputPos *a_pos) ; 91 92 glong cr_tknzr_get_nb_bytes_left (CRTknzr *a_this) ; 93 94 enum CRStatus cr_tknzr_get_cur_pos (CRTknzr *a_this, CRInputPos *a_pos) ; 95 96 enum CRStatus cr_tknzr_get_parsing_location (CRTknzr *a_this, 97 CRParsingLocation *a_loc) ; 98 99 enum CRStatus cr_tknzr_seek_index (CRTknzr *a_this, 100 enum CRSeekPos a_origin, 101 gint a_pos) ; 102 103 enum CRStatus cr_tknzr_get_cur_byte_addr (CRTknzr *a_this, guchar **a_addr) ; 104 105 106 enum CRStatus cr_tknzr_consume_chars (CRTknzr *a_this, guint32 a_char, 107 glong *a_nb_char) ; 108 109 enum CRStatus cr_tknzr_get_next_token (CRTknzr *a_this, CRToken ** a_tk) ; 110 111 enum CRStatus cr_tknzr_unget_token (CRTknzr *a_this, CRToken *a_token) ; 112 113 114 enum CRStatus cr_tknzr_parse_token (CRTknzr *a_this, enum CRTokenType a_type, 115 enum CRTokenExtraType a_et, gpointer a_res, 116 gpointer a_extra_res) ; 117 enum CRStatus cr_tknzr_set_input (CRTknzr *a_this, CRInput *a_input) ; 118 119 enum CRStatus cr_tknzr_get_input (CRTknzr *a_this, CRInput **a_input) ; 120 121 void cr_tknzr_destroy (CRTknzr *a_this) ; 122 123 G_END_DECLS 124 125 #endif /*__CR_TKZNR_H__*/ 126