1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2021 Free Software Foundation, Inc.
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/>. */
19 #include "data/dataset.h"
20 #include "language/data-io/file-handle.h"
21 #include "language/lexer/lexer.h"
22 #include "language/command.h"
25 #define _(msgid) gettext (msgid)
28 cmd_mconvert (struct lexer *lexer, struct dataset *ds)
31 struct file_handle *in = NULL;
32 struct file_handle *out = NULL;
33 while (lex_token (lexer) != T_ENDCMD)
35 if (lex_match_id (lexer, "APPEND"))
37 else if (lex_match_id (lexer, "REPLACE"))
41 if (lex_match_id (lexer, "MATRIX"))
42 lex_match (lexer, T_EQUALS);
44 struct file_handle **fhp = (lex_match_id (lexer, "IN") ? &in
45 : lex_match_id (lexer, "OUT") ? &out
49 lex_error_expecting (lexer, "IN", "OUT", "APPEND", "REPLACE");
52 if (!lex_force_match (lexer, T_LPAREN))
56 if (lex_match (lexer, T_ASTERISK))
60 *fhp = fh_parse (lexer, FH_REF_FILE, dataset_session (ds));
65 if (!lex_force_match (lexer, T_RPAREN))
69 lex_match (lexer, T_SLASH);
72 if (!in && !dataset_has_source (ds))
74 msg (SE, _("No active file is defined and no external file is "
75 "specified on MATRIX=IN."));