--- /dev/null
+/* PSPP - a program for statistical analysis.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include "data/dataset.h"
+#include "language/data-io/file-handle.h"
+#include "language/lexer/lexer.h"
+#include "language/command.h"
+
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
+int
+cmd_mconvert (struct lexer *lexer, struct dataset *ds)
+{
+ bool append = false;
+ struct file_handle *in = NULL;
+ struct file_handle *out = NULL;
+ while (lex_token (lexer) != T_ENDCMD)
+ {
+ if (lex_match_id (lexer, "APPEND"))
+ append = true;
+ else if (lex_match_id (lexer, "REPLACE"))
+ append = false;
+ else
+ {
+ if (lex_match_id (lexer, "MATRIX"))
+ lex_match (lexer, T_EQUALS);
+
+ struct file_handle **fhp = (lex_match_id (lexer, "IN") ? &in
+ : lex_match_id (lexer, "OUT") ? &out
+ : NULL);
+ if (!fhp)
+ {
+ lex_error_expecting (lexer, "IN", "OUT", "APPEND", "REPLACE");
+ goto error;
+ }
+ if (!lex_force_match (lexer, T_LPAREN))
+ goto error;
+
+ fh_unref (*fhp);
+ if (lex_match (lexer, T_ASTERISK))
+ *fhp = NULL;
+ else
+ {
+ *fhp = fh_parse (lexer, FH_REF_FILE, dataset_session (ds));
+ if (!*fhp)
+ goto error;
+ }
+
+ if (!lex_force_match (lexer, T_RPAREN))
+ goto error;
+ }
+
+ lex_match (lexer, T_SLASH);
+ }
+
+ if (!in && !dataset_has_source (ds))
+ {
+ msg (SE, _("No active file is defined and no external file is "
+ "specified on MATRIX=IN."));
+ goto error;
+ }
+
+ /* XXX */
+
+error:
+ fh_unref (in);
+ fh_unref (out);
+ return CMD_FAILURE;
+}
+