2 * Copyright © 2011 Nick Bowler
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 /* Declaration specifier kinds. */
27 CDECL_SPEC_STOR = 256,
28 CDECL_SPEC_QUAL = 512,
29 CDECL_SPEC_FUNC = 1024,
33 CDECL_TYPE_VOID = CDECL_SPEC_TYPE,
48 CDECL_STOR_TYPEDEF = CDECL_SPEC_STOR,
53 CDECL_QUAL_RESTRICT = CDECL_SPEC_QUAL,
56 CDECL_FUNC_INLINE = CDECL_SPEC_FUNC,
59 /* Declarator types. */
71 struct cdecl_declspec {
72 struct cdecl_declspec *next;
77 struct cdecl_declarator {
78 struct cdecl_declarator *child;
82 struct cdecl_pointer {
83 struct cdecl_declspec *qualifiers;
89 struct cdecl_function {
90 struct cdecl *parameters;
97 struct cdecl *cdecl_parse_decl(const char *declstr);
98 void cdecl_free(struct cdecl *decl);
100 size_t cdecl_explain(char *buf, size_t n, struct cdecl *decl);
102 static inline int cdecl_spec_kind(struct cdecl_declspec *spec)
104 return spec->type & ~0xffu;