|
1 /* |
|
2 * libtu/parser.h |
|
3 * |
|
4 * Copyright (c) Tuomo Valkonen 1999-2000. |
|
5 * |
|
6 * This file is distributed under the terms of the "Artistic License". |
|
7 * See the included file LICENSE for details. |
|
8 */ |
|
9 |
|
10 #ifndef __LIBTU_PARSER_H |
|
11 #define __LIBTU_PARSER_H |
|
12 |
|
13 #include "tokenizer.h" |
|
14 |
|
15 /* |
|
16 * format: |
|
17 * l = long |
|
18 * d = double |
|
19 * i = identifier |
|
20 * s = string |
|
21 * c = char |
|
22 * . = 1 times any ("l.d") |
|
23 * * = 0 or more times any (must be the last, "sd*") |
|
24 * ? = optional ("?c") |
|
25 * : = conditional (":c:s") |
|
26 * + = 1 or more times last (most be the last, "l+") |
|
27 * special entries: |
|
28 * |
|
29 * "#end" call this handler at the end of section. |
|
30 * "#cancel" call this handler when recovering from error |
|
31 */ |
|
32 |
|
33 typedef struct _ConfOpt{ |
|
34 const char *optname; |
|
35 const char *argfmt; |
|
36 bool (*fn)(Tokenizer *tokz, int n, Token *toks); |
|
37 struct _ConfOpt *opts; |
|
38 } ConfOpt; |
|
39 |
|
40 |
|
41 extern bool parse_config_tokz(Tokenizer *tokz, const ConfOpt *options); |
|
42 extern bool parse_config(const char *fname, const ConfOpt *options, int flags); |
|
43 extern bool parse_config_file(FILE *file, const ConfOpt *options, int flags); |
|
44 |
|
45 #endif /* __LIBTU_PARSER_H */ |