return ret;
}
+static int cmd_declare(const char *cmd, const char *arg)
+{
+ struct cdecl *decl;
+ const char *str;
+ int ret = -1;
+
+ /* The name of the command is significant here. */
+ decl = cdecl_parse_english(cmd);
+ if (!decl)
+ goto out;
+
+ /*
+ * English parses have at most one full declarator, so no loop is
+ * needed here.
+ */
+ str = do_format(cdecl_declare, decl);
+ if (!str)
+ goto out;
+
+ printf("%s\n", str);
+ ret = 1;
+out:
+ cdecl_free(decl);
+ return ret;
+}
+
static int cmd_quit(const char *cmd, const char *arg)
{
return 0;
} commands[] = {
{ "explain", cmd_explain, "Explain a C declaration." },
{ "simplify", cmd_simplify, "Simplify a C declaration." },
+ { "declare", cmd_declare, "Construct a C declaration." },
+ { "type", cmd_declare, "Construct a C type name." },
{ "help", cmd_help, "Print this list of commands." },
{ "quit", cmd_quit, "Quit the program." },
{ "exit", cmd_quit, NULL }