Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
gscanner.h
Go to the documentation of this file.
1/* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20/*
21 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GLib Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GLib at ftp://ftp.gtk.org/pub/gtk/.
25 */
26
27#ifndef __G_SCANNER_H__
28#define __G_SCANNER_H__
29
30#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
31#error "Only <glib.h> can be included directly."
32#endif
33
34#include <glib/gdataset.h>
35#include <glib/ghash.h>
36
38
39typedef struct _GScanner GScanner;
42
43typedef void (*GScannerMsgFunc) (GScanner *scanner,
44 gchar *message,
46
47/* GScanner: Flexible lexical scanner for general purpose.
48 */
49
50/* Character sets */
51#define G_CSET_A_2_Z "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
52#define G_CSET_a_2_z "abcdefghijklmnopqrstuvwxyz"
53#define G_CSET_DIGITS "0123456789"
54#define G_CSET_LATINC "\300\301\302\303\304\305\306"\
55 "\307\310\311\312\313\314\315\316\317\320"\
56 "\321\322\323\324\325\326"\
57 "\330\331\332\333\334\335\336"
58#define G_CSET_LATINS "\337\340\341\342\343\344\345\346"\
59 "\347\350\351\352\353\354\355\356\357\360"\
60 "\361\362\363\364\365\366"\
61 "\370\371\372\373\374\375\376\377"
62
63/* Error types */
75
76/* Token types */
112
128
130{
131 /* Character sets
132 */
133 gchar *cset_skip_characters; /* default: " \t\n" */
136 gchar *cpair_comment_single; /* default: "#\n" */
137
138 /* Should symbol lookup work case sensitive?
139 */
141
142 /* Boolean values to be adjusted "on the fly"
143 * to configure scanning behaviour.
144 */
145 guint skip_comment_multi : 1; /* C like comment */
146 guint skip_comment_single : 1; /* single line comment */
147 guint scan_comment_multi : 1; /* scan multi line comments? */
155 guint scan_hex : 1; /* '0x0ff0' */
156 guint scan_hex_dollar : 1; /* '$0ff0' */
157 guint scan_string_sq : 1; /* string: 'anything' */
158 guint scan_string_dq : 1; /* string: "\\-escapes!\n" */
159 guint numbers_2_int : 1; /* bin, octal, hex => int */
160 guint int_2_float : 1; /* int => G_TOKEN_FLOAT? */
162 guint char_2_token : 1; /* return G_TOKEN_CHAR? */
164 guint scope_0_fallback : 1; /* try scope 0 on lookups? */
165 guint store_int64 : 1; /* use value.v_int64 rather than v_int */
166
167 /*< private >*/
169};
170
172{
173 /* unused fields */
176
177 /* g_scanner_error() increments this field */
179
180 /* name of input stream, featured by the default message handler */
182
183 /* quarked data */
185
186 /* link into the scanner configuration */
188
189 /* fields filled in after g_scanner_get_next_token() */
194
195 /* fields filled in after g_scanner_peek_next_token() */
200
201 /*< private >*/
202 /* to be considered private */
205 const gchar *text;
209
210 /*< public >*/
211 /* handler function for _warn and _error */
213};
214
216GScanner* g_scanner_new (const GScannerConfig *config_templ);
221 gint input_fd);
226 const gchar *text,
227 guint text_len);
244 guint scope_id);
247 guint scope_id,
248 const gchar *symbol,
252 guint scope_id,
253 const gchar *symbol);
256 guint scope_id,
257 const gchar *symbol);
260 guint scope_id,
261 GHFunc func,
262 gpointer user_data);
265 const gchar *symbol);
268 GTokenType expected_token,
269 const gchar *identifier_spec,
270 const gchar *symbol_spec,
271 const gchar *symbol_name,
272 const gchar *message,
273 gint is_error);
276 const gchar *format,
277 ...) G_GNUC_PRINTF (2,3);
280 const gchar *format,
281 ...) G_GNUC_PRINTF (2,3);
282
283/* keep downward source compatibility */
284#define g_scanner_add_symbol( scanner, symbol, value ) G_STMT_START { \
285 g_scanner_scope_add_symbol ((scanner), 0, (symbol), (value)); \
286} G_STMT_END GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_scanner_scope_add_symbol)
287#define g_scanner_remove_symbol( scanner, symbol ) G_STMT_START { \
288 g_scanner_scope_remove_symbol ((scanner), 0, (symbol)); \
289} G_STMT_END GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_scanner_scope_remove_symbol)
290#define g_scanner_foreach_symbol( scanner, func, data ) G_STMT_START { \
291 g_scanner_scope_foreach_symbol ((scanner), 0, (func), (data)); \
292} G_STMT_END GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_scanner_scope_foreach_symbol)
293
294/* The following two functions are deprecated and will be removed in
295 * the next major release. They do no good. */
296#define g_scanner_freeze_symbol_table(scanner) ((void)0) GLIB_DEPRECATED_MACRO_IN_2_26
297#define g_scanner_thaw_symbol_table(scanner) ((void)0) GLIB_DEPRECATED_MACRO_IN_2_26
298
300
301#endif /* __G_SCANNER_H__ */
typedefG_BEGIN_DECLS struct _GData GData
Definition gdataset.h:38
typedefG_BEGIN_DECLS struct _GHashTable GHashTable
Definition ghash.h:40
#define GLIB_AVAILABLE_IN_ALL
unsigned long guint64
Definition glibconfig.h:67
#define G_END_DECLS
Definition gmacros.h:910
#define G_GNUC_PRINTF(format_idx, arg_idx)
Definition gmacros.h:608
#define G_BEGIN_DECLS
Definition gmacros.h:909
GLIB_AVAILABLE_IN_ALL gboolean g_scanner_eof(GScanner *scanner)
GLIB_AVAILABLE_IN_ALL void g_scanner_scope_add_symbol(GScanner *scanner, guint scope_id, const gchar *symbol, gpointer value)
GLIB_AVAILABLE_IN_ALL guint g_scanner_set_scope(GScanner *scanner, guint scope_id)
GLIB_AVAILABLE_IN_ALL void GLIB_AVAILABLE_IN_ALL void g_scanner_warn(GScanner *scanner, const gchar *format,...) G_GNUC_PRINTF(2
GLIB_AVAILABLE_IN_ALL void g_scanner_input_file(GScanner *scanner, gint input_fd)
GLIB_AVAILABLE_IN_ALL void g_scanner_error(GScanner *scanner, const gchar *format,...) G_GNUC_PRINTF(2
typedefG_BEGIN_DECLS struct _GScanner GScanner
Definition gscanner.h:39
GLIB_AVAILABLE_IN_ALL GTokenType g_scanner_get_next_token(GScanner *scanner)
GLIB_AVAILABLE_IN_ALL GTokenType g_scanner_peek_next_token(GScanner *scanner)
GLIB_AVAILABLE_IN_ALL GScanner * g_scanner_new(const GScannerConfig *config_templ)
GLIB_AVAILABLE_IN_ALL void g_scanner_destroy(GScanner *scanner)
GLIB_AVAILABLE_IN_ALL GTokenType g_scanner_cur_token(GScanner *scanner)
GLIB_AVAILABLE_IN_ALL void g_scanner_scope_remove_symbol(GScanner *scanner, guint scope_id, const gchar *symbol)
GLIB_AVAILABLE_IN_ALL guint g_scanner_cur_line(GScanner *scanner)
GLIB_AVAILABLE_IN_ALL void g_scanner_unexp_token(GScanner *scanner, GTokenType expected_token, const gchar *identifier_spec, const gchar *symbol_spec, const gchar *symbol_name, const gchar *message, gint is_error)
GLIB_AVAILABLE_IN_ALL gpointer g_scanner_scope_lookup_symbol(GScanner *scanner, guint scope_id, const gchar *symbol)
GLIB_AVAILABLE_IN_ALL void g_scanner_sync_file_offset(GScanner *scanner)
GLIB_AVAILABLE_IN_ALL gpointer g_scanner_lookup_symbol(GScanner *scanner, const gchar *symbol)
GLIB_AVAILABLE_IN_ALL guint g_scanner_cur_position(GScanner *scanner)
GLIB_AVAILABLE_IN_ALL GTokenValue g_scanner_cur_value(GScanner *scanner)
GLIB_AVAILABLE_IN_ALL void g_scanner_scope_foreach_symbol(GScanner *scanner, guint scope_id, GHFunc func, gpointer user_data)
void(* GScannerMsgFunc)(GScanner *scanner, gchar *message, gboolean error)
Definition gscanner.h:43
GLIB_AVAILABLE_IN_ALL void g_scanner_input_text(GScanner *scanner, const gchar *text, guint text_len)
GTokenType
Definition gscanner.h:78
@ G_TOKEN_EQUAL_SIGN
Definition gscanner.h:87
@ G_TOKEN_ERROR
Definition gscanner.h:92
@ G_TOKEN_COMMENT_SINGLE
Definition gscanner.h:106
@ G_TOKEN_INT
Definition gscanner.h:97
@ G_TOKEN_LEFT_CURLY
Definition gscanner.h:83
@ G_TOKEN_EOF
Definition gscanner.h:79
@ G_TOKEN_LEFT_PAREN
Definition gscanner.h:81
@ G_TOKEN_RIGHT_CURLY
Definition gscanner.h:84
@ G_TOKEN_COMMA
Definition gscanner.h:88
@ G_TOKEN_CHAR
Definition gscanner.h:94
@ G_TOKEN_IDENTIFIER
Definition gscanner.h:103
@ G_TOKEN_HEX
Definition gscanner.h:98
@ G_TOKEN_NONE
Definition gscanner.h:90
@ G_TOKEN_LEFT_BRACE
Definition gscanner.h:85
@ G_TOKEN_STRING
Definition gscanner.h:100
@ G_TOKEN_OCTAL
Definition gscanner.h:96
@ G_TOKEN_IDENTIFIER_NULL
Definition gscanner.h:104
@ G_TOKEN_RIGHT_PAREN
Definition gscanner.h:82
@ G_TOKEN_BINARY
Definition gscanner.h:95
@ G_TOKEN_RIGHT_BRACE
Definition gscanner.h:86
@ G_TOKEN_SYMBOL
Definition gscanner.h:102
@ G_TOKEN_LAST
Definition gscanner.h:110
@ G_TOKEN_COMMENT_MULTI
Definition gscanner.h:107
@ G_TOKEN_FLOAT
Definition gscanner.h:99
GErrorType
Definition gscanner.h:65
@ G_ERR_UNEXP_EOF_IN_STRING
Definition gscanner.h:68
@ G_ERR_DIGIT_RADIX
Definition gscanner.h:71
@ G_ERR_UNKNOWN
Definition gscanner.h:66
@ G_ERR_UNEXP_EOF_IN_COMMENT
Definition gscanner.h:69
@ G_ERR_FLOAT_MALFORMED
Definition gscanner.h:73
@ G_ERR_FLOAT_RADIX
Definition gscanner.h:72
@ G_ERR_NON_DIGIT_IN_CONST
Definition gscanner.h:70
@ G_ERR_UNEXP_EOF
Definition gscanner.h:67
gint gboolean
Definition gtypes.h:56
unsigned long gulong
Definition gtypes.h:60
unsigned char guchar
Definition gtypes.h:58
G_BEGIN_DECLS typedef char gchar
Definition gtypes.h:52
void * gpointer
Definition gtypes.h:109
int gint
Definition gtypes.h:55
void(* GHFunc)(gpointer key, gpointer value, gpointer user_data)
Definition gtypes.h:144
double gdouble
Definition gtypes.h:64
unsigned int guint
Definition gtypes.h:61
json_t format(printf, 1, 2)))
int value
Definition lsqlite3.c:2155
static void error(LoadState *S, const char *why)
guint symbol_2_token
Definition gscanner.h:163
guint store_int64
Definition gscanner.h:165
guint padding_dummy
Definition gscanner.h:168
guint skip_comment_single
Definition gscanner.h:146
guint case_sensitive
Definition gscanner.h:140
guint scope_0_fallback
Definition gscanner.h:164
guint scan_identifier
Definition gscanner.h:148
guint numbers_2_int
Definition gscanner.h:159
gchar * cset_skip_characters
Definition gscanner.h:133
guint skip_comment_multi
Definition gscanner.h:145
guint scan_comment_multi
Definition gscanner.h:147
guint scan_identifier_NULL
Definition gscanner.h:150
gchar * cpair_comment_single
Definition gscanner.h:136
guint scan_binary
Definition gscanner.h:152
gchar * cset_identifier_nth
Definition gscanner.h:135
guint scan_string_dq
Definition gscanner.h:158
guint identifier_2_string
Definition gscanner.h:161
guint scan_identifier_1char
Definition gscanner.h:149
guint scan_string_sq
Definition gscanner.h:157
guint int_2_float
Definition gscanner.h:160
guint scan_symbols
Definition gscanner.h:151
gchar * cset_identifier_first
Definition gscanner.h:134
guint char_2_token
Definition gscanner.h:162
guint scan_hex_dollar
Definition gscanner.h:156
GTokenValue value
Definition gscanner.h:191
gpointer user_data
Definition gscanner.h:174
guint scope_id
Definition gscanner.h:208
GData * qdata
Definition gscanner.h:184
const gchar * text
Definition gscanner.h:205
guint max_parse_errors
Definition gscanner.h:175
GHashTable * symbol_table
Definition gscanner.h:203
const gchar * text_end
Definition gscanner.h:206
GTokenType next_token
Definition gscanner.h:196
guint next_position
Definition gscanner.h:199
gchar * buffer
Definition gscanner.h:207
const gchar * input_name
Definition gscanner.h:181
guint parse_errors
Definition gscanner.h:178
guint line
Definition gscanner.h:192
GTokenType token
Definition gscanner.h:190
GScannerConfig * config
Definition gscanner.h:187
gint input_fd
Definition gscanner.h:204
GScannerMsgFunc msg_handler
Definition gscanner.h:212
guint next_line
Definition gscanner.h:198
GTokenValue next_value
Definition gscanner.h:197
guint position
Definition gscanner.h:193
gulong v_octal
Definition gscanner.h:118
gdouble v_float
Definition gscanner.h:121
guchar v_char
Definition gscanner.h:125
guint v_error
Definition gscanner.h:126
gchar * v_comment
Definition gscanner.h:124
gulong v_hex
Definition gscanner.h:122
gchar * v_string
Definition gscanner.h:123
guint64 v_int64
Definition gscanner.h:120
gchar * v_identifier
Definition gscanner.h:116
gulong v_int
Definition gscanner.h:119
gulong v_binary
Definition gscanner.h:117
gpointer v_symbol
Definition gscanner.h:115