parser.h

Wed, 10 Mar 2004 17:46:49 +0100

author
tuomov
date
Wed, 10 Mar 2004 17:46:49 +0100
changeset 67
b53529762874
parent 62
aae5facf9fc5
permissions
-rw-r--r--

trunk: changeset 1370
- Added red-black tree routines for direct pointer comparison.

- Made keys to red-black tree routines const.

58
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
1 /*
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
2 * libtu/parser.h
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
3 *
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
4 * Copyright (c) Tuomo Valkonen 1999-2002.
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
5 *
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
6 * You may distribute and modify this library under the terms of either
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
7 * the Clarified Artistic License or the GNU LGPL, version 2.1 or later.
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
8 */
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
9
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
10 #ifndef LIBTU_PARSER_H
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
11 #define LIBTU_PARSER_H
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
12
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
13 #include "tokenizer.h"
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
14
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
15 /*
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
16 * format:
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
17 * l = long
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
18 * d = double
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
19 * i = identifier
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
20 * s = string
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
21 * c = char
58
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
22 * . = 1 times any ("l.d")
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
23 * * = 0 or more times any (must be the last, "sd*")
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
24 * ? = optional ("?c")
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
25 * : = conditional (":c:s")
58
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
26 * + = 1 or more times last (most be the last, "l+")
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
27 * special entries:
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
28 *
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
29 * "#end" call this handler at the end of section.
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
30 * "#cancel" call this handler when recovering from error
58
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
31 */
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
32
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
33 #define END_CONFOPTS {NULL, NULL, NULL, NULL}
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
34
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
35 typedef struct _ConfOpt{
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
36 const char *optname;
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
37 const char *argfmt;
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
38 bool (*fn)(Tokenizer *tokz, int n, Token *toks);
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
39 struct _ConfOpt *opts;
58
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
40 } ConfOpt;
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
41
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
42 #define CONFOPTS_NOT_SET libtu_dummy_confopts
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
43 extern ConfOpt libtu_dummy_confopts[];
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
44
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
45 extern bool parse_config_tokz(Tokenizer *tokz, const ConfOpt *options);
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
46 extern bool parse_config_tokz_skip_section(Tokenizer *tokz);
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
47 extern bool parse_config(const char *fname, const ConfOpt *options, int flags);
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
48 extern bool parse_config_file(FILE *file, const ConfOpt *options, int flags);
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
49 extern bool check_args(const Tokenizer *tokz, Token *tokens, int ntokens,
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
50 const char *fmt);
58
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
51 extern bool check_args_loose(const Tokenizer *tokz, Token *tokens, int ntokens,
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
52 const char *fmt);
58
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
53
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
54 #endif /* LIBTU_PARSER_H */

mercurial