7ca60dd326501b74ab311d5518919735e509ae39
[platform/upstream/nettle.git] / tools / parse.h
1 /* parse.h
2
3    Copyright (C) 2002, 2003 Niels Möller
4
5    This file is part of GNU Nettle.
6
7    GNU Nettle is free software: you can redistribute it and/or
8    modify it under the terms of either:
9
10      * the GNU Lesser General Public License as published by the Free
11        Software Foundation; either version 3 of the License, or (at your
12        option) any later version.
13
14    or
15
16      * the GNU General Public License as published by the Free
17        Software Foundation; either version 2 of the License, or (at your
18        option) any later version.
19
20    or both in parallel, as here.
21
22    GNU Nettle is distributed in the hope that it will be useful,
23    but WITHOUT ANY WARRANTY; without even the implied warranty of
24    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25    General Public License for more details.
26
27    You should have received copies of the GNU General Public License and
28    the GNU Lesser General Public License along with this program.  If
29    not, see http://www.gnu.org/licenses/.
30 */
31
32 #ifndef NETTLE_TOOLS_PARSE_H_INCLUDED
33 #define NETTLE_TOOLS_PARSE_H_INCLUDED
34
35 #include "misc.h"
36 #include "buffer.h"
37
38 struct sexp_compound_token
39 {
40   enum sexp_token type;
41   struct nettle_buffer display;
42   struct nettle_buffer string;  
43 };
44
45 void
46 sexp_compound_token_init(struct sexp_compound_token *token);
47
48 void
49 sexp_compound_token_clear(struct sexp_compound_token *token);
50
51 struct sexp_parser
52 {
53   struct sexp_input *input;
54   enum sexp_mode mode;
55
56   /* Nesting level of lists. Transport encoding counts as one
57    * level of nesting. */
58   unsigned level;
59
60   /* The nesting level where the transport encoding occured.
61    * Zero if we're not currently using tranport encoding. */
62   unsigned transport;
63 };
64
65 void
66 sexp_parse_init(struct sexp_parser *parser,
67                 struct sexp_input *input,
68                 enum sexp_mode mode);
69
70 void
71 sexp_parse(struct sexp_parser *parser,
72            struct sexp_compound_token *token);
73
74 #endif /* NETTLE_TOOLS_PARSE_H_INCLUDED */