X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/blobdiff_plain/b9b5dfbb48617d5ae852b3bc11f7be3552d7ae38..e7b2e067cd007f12227af623649a8e9204a352b1:/src/cdecl.h diff --git a/src/cdecl.h b/src/cdecl.h index ffc01e3..a8e9946 100644 --- a/src/cdecl.h +++ b/src/cdecl.h @@ -41,6 +41,7 @@ enum { CDECL_TYPE_UNSIGNED, CDECL_TYPE_BOOL, CDECL_TYPE_COMPLEX, + CDECL_TYPE_IMAGINARY, CDECL_TYPE_STRUCT, CDECL_TYPE_UNION, CDECL_TYPE_ENUM, @@ -62,6 +63,7 @@ enum { CDECL_DECL_IDENT, CDECL_DECL_POINTER, CDECL_DECL_ARRAY, + CDECL_DECL_FUNCTION, }; struct cdecl { @@ -85,18 +87,37 @@ struct cdecl { char *vla; uintmax_t length; } array; + struct cdecl_function { + struct cdecl *parameters; + _Bool variadic; + } function; } u; } *declarators; }; struct cdecl *cdecl_parse_decl(const char *declstr); +struct cdecl *cdecl_parse_english(const char *english); void cdecl_free(struct cdecl *decl); size_t cdecl_explain(char *buf, size_t n, struct cdecl *decl); +size_t cdecl_declare(char *buf, size_t n, struct cdecl *decl); static inline int cdecl_spec_kind(struct cdecl_declspec *spec) { return spec->type & ~0xffu; } +/* Error handling. */ +enum { + CDECL_ENOMEM, + CDECL_ENOPARSE, +}; + +struct cdecl_error { + unsigned code; + const char *str; +}; + +const struct cdecl_error *cdecl_get_error(void); + #endif