#ifndef CDECL_H_
-#define CEDCL_H_
+#define CDECL_H_
+
+#include <stddef.h>
+#include <stdint.h>
/* Declaration specifier kinds. */
enum {
/* Declarator types. */
enum {
CDECL_DECL_IDENT,
+ CDECL_DECL_POINTER,
+ CDECL_DECL_ARRAY,
};
struct cdecl {
} *specifiers;
struct cdecl_declarator {
- struct cdecl_declarator *next;
+ struct cdecl_declarator *next, *child;
unsigned type;
- char *ident;
+ union {
+ char *ident;
+ struct cdecl_pointer {
+ struct cdecl_declspec *qualifiers;
+ } pointer;
+ struct cdecl_array {
+ char *vla;
+ uintmax_t length;
+ } array;
+ } u;
} *declarators;
};
struct cdecl *cdecl_parse_decl(const char *declstr);
void cdecl_free(struct cdecl *decl);
+size_t cdecl_explain(char *buf, size_t n, struct cdecl *decl);
+
static inline int cdecl_spec_kind(struct cdecl_declspec *spec)
{
return spec->type & ~0xffu;