1/* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset: 8-*- */ 2 3/* 4 * This file is part of The Croco Library 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of version 2.1 of the GNU General Public 8 * License as published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 18 * USA 19 * 20 * Author: Dodji Seketeli 21 * See COPYRIGHTS file for coypyright information. 22 */ 23 24/** 25 *@file 26 *The declaration of the #CRTknzr (tokenizer) 27 *class. 28 */ 29 30#ifndef __CR_TKNZR_H__ 31#define __CR_TKNZR_H__ 32 33#include "cr-utils.h" 34#include "cr-input.h" 35#include "cr-token.h" 36 37G_BEGIN_DECLS 38 39 40typedef struct _CRTknzr CRTknzr ; 41typedef struct _CRTknzrPriv CRTknzrPriv ; 42 43/** 44 *The tokenizer is the class that knows 45 *about all the css token. Its main job is 46 *to return the next token found in the character 47 *input stream. 48 */ 49struct _CRTknzr 50{ 51 /*the private data of the tokenizer.*/ 52 CRTknzrPriv *priv ; 53} ; 54 55CRTknzr * cr_tknzr_new (CRInput *a_input) ; 56 57CRTknzr * cr_tknzr_new_from_uri (const guchar *a_file_uri, 58 enum CREncoding a_enc) ; 59 60CRTknzr * cr_tknzr_new_from_buf (guchar *a_buf, gulong a_len, 61 enum CREncoding a_enc, 62 gboolean a_free_at_destroy) ; 63 64gboolean cr_tknzr_unref (CRTknzr *a_this) ; 65 66void cr_tknzr_ref (CRTknzr *a_this) ; 67 68enum CRStatus cr_tknzr_read_byte (CRTknzr *a_this, guchar *a_byte) ; 69 70enum CRStatus cr_tknzr_read_char (CRTknzr *a_this, guint32 *a_char); 71 72enum CRStatus cr_tknzr_peek_char (CRTknzr *a_this, guint32 *a_char) ; 73 74enum CRStatus cr_tknzr_peek_byte (CRTknzr *a_this, gulong a_offset, 75 guchar *a_byte) ; 76 77guchar cr_tknzr_peek_byte2 (CRTknzr *a_this, gulong a_offset, 78 gboolean *a_eof) ; 79 80enum CRStatus cr_tknzr_set_cur_pos (CRTknzr *a_this, CRInputPos *a_pos) ; 81 82glong cr_tknzr_get_nb_bytes_left (CRTknzr *a_this) ; 83 84enum CRStatus cr_tknzr_get_cur_pos (CRTknzr *a_this, CRInputPos *a_pos) ; 85 86enum CRStatus cr_tknzr_get_parsing_location (CRTknzr *a_this, 87 CRParsingLocation *a_loc) ; 88 89enum CRStatus cr_tknzr_seek_index (CRTknzr *a_this, 90 enum CRSeekPos a_origin, 91 gint a_pos) ; 92 93enum CRStatus cr_tknzr_get_cur_byte_addr (CRTknzr *a_this, guchar **a_addr) ; 94 95 96enum CRStatus cr_tknzr_consume_chars (CRTknzr *a_this, guint32 a_char, 97 glong *a_nb_char) ; 98 99enum CRStatus cr_tknzr_get_next_token (CRTknzr *a_this, CRToken ** a_tk) ; 100 101enum CRStatus cr_tknzr_unget_token (CRTknzr *a_this, CRToken *a_token) ; 102 103 104enum CRStatus cr_tknzr_parse_token (CRTknzr *a_this, enum CRTokenType a_type, 105 enum CRTokenExtraType a_et, gpointer a_res, 106 gpointer a_extra_res) ; 107enum CRStatus cr_tknzr_set_input (CRTknzr *a_this, CRInput *a_input) ; 108 109enum CRStatus cr_tknzr_get_input (CRTknzr *a_this, CRInput **a_input) ; 110 111void cr_tknzr_destroy (CRTknzr *a_this) ; 112 113G_END_DECLS 114 115#endif /*__CR_TKZNR_H__*/ 116