1 /* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset: 8-*- */
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 Lesser 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 Lesser 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 */
24 /**
25 *@file
26 *The declaration of the #CRTknzr (tokenizer)
27 *class.
28 */
30 #ifndef __CR_TKNZR_H__
31 #define __CR_TKNZR_H__
33 #include "cr-utils.h"
34 #include "cr-input.h"
35 #include "cr-token.h"
37 G_BEGIN_DECLS
40 typedef struct _CRTknzr CRTknzr ;
41 typedef struct _CRTknzrPriv CRTknzrPriv ;
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 */
49 struct _CRTknzr
50 {
51 /*the private data of the tokenizer.*/
52 CRTknzrPriv *priv ;
53 } ;
55 CRTknzr * cr_tknzr_new (CRInput *a_input) ;
57 CRTknzr * cr_tknzr_new_from_uri (const guchar *a_file_uri,
58 enum CREncoding a_enc) ;
60 CRTknzr * cr_tknzr_new_from_buf (guchar *a_buf, gulong a_len,
61 enum CREncoding a_enc,
62 gboolean a_free_at_destroy) ;
64 gboolean cr_tknzr_unref (CRTknzr *a_this) ;
66 void cr_tknzr_ref (CRTknzr *a_this) ;
68 enum CRStatus cr_tknzr_read_byte (CRTknzr *a_this, guchar *a_byte) ;
70 enum CRStatus cr_tknzr_read_char (CRTknzr *a_this, guint32 *a_char);
72 enum CRStatus cr_tknzr_peek_char (CRTknzr *a_this, guint32 *a_char) ;
74 enum CRStatus cr_tknzr_peek_byte (CRTknzr *a_this, gulong a_offset,
75 guchar *a_byte) ;
77 guchar cr_tknzr_peek_byte2 (CRTknzr *a_this, gulong a_offset,
78 gboolean *a_eof) ;
80 enum CRStatus cr_tknzr_set_cur_pos (CRTknzr *a_this, CRInputPos *a_pos) ;
82 glong cr_tknzr_get_nb_bytes_left (CRTknzr *a_this) ;
84 enum CRStatus cr_tknzr_get_cur_pos (CRTknzr *a_this, CRInputPos *a_pos) ;
86 enum CRStatus cr_tknzr_get_parsing_location (CRTknzr *a_this,
87 CRParsingLocation *a_loc) ;
89 enum CRStatus cr_tknzr_seek_index (CRTknzr *a_this,
90 enum CRSeekPos a_origin,
91 gint a_pos) ;
93 enum CRStatus cr_tknzr_get_cur_byte_addr (CRTknzr *a_this, guchar **a_addr) ;
96 enum CRStatus cr_tknzr_consume_chars (CRTknzr *a_this, guint32 a_char,
97 glong *a_nb_char) ;
99 enum CRStatus cr_tknzr_get_next_token (CRTknzr *a_this, CRToken ** a_tk) ;
101 enum CRStatus cr_tknzr_unget_token (CRTknzr *a_this, CRToken *a_token) ;
104 enum 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) ;
107 enum CRStatus cr_tknzr_set_input (CRTknzr *a_this, CRInput *a_input) ;
109 enum CRStatus cr_tknzr_get_input (CRTknzr *a_this, CRInput **a_input) ;
111 void cr_tknzr_destroy (CRTknzr *a_this) ;
113 G_END_DECLS
115 #endif /*__CR_TKZNR_H__*/