{
case CMD_STATE_INITIAL:
case CMD_STATE_DATA:
- switch ((int) command->states)
+ switch ((int) command->states
+ & (S_INITIAL | S_DATA | S_INPUT_PROGRAM | S_FILE_TYPE))
{
/* One allowed state. */
case S_INITIAL:
DEF_CMD (S_DATA, 0, "TEMPORARY", cmd_temporary)
DEF_CMD (S_DATA, 0, "USE", cmd_use)
-/* Commands valid only with INPUT PROGRAM. */
+/* Commands valid only inside INPUT PROGRAM. */
DEF_CMD (S_INPUT_PROGRAM | S_NESTED_INPUT_PROGRAM, 0, "END CASE", cmd_end_case)
DEF_CMD (S_INPUT_PROGRAM | S_NESTED_INPUT_PROGRAM, 0, "END FILE", cmd_end_file)
DEF_CMD (S_INPUT_PROGRAM | S_NESTED_INPUT_PROGRAM, 0, "REREAD", cmd_reread)
+/* Not really commands, but part of LOOP and DO IF syntax. */
+DEF_CMD (S_ANY, 0, "ELSE IF", cmd_inside_do_if)
+DEF_CMD (S_ANY, 0, "ELSE", cmd_inside_do_if)
+DEF_CMD (S_ANY, 0, "END IF", cmd_inside_do_if)
+DEF_CMD (S_ANY, 0, "END LOOP", cmd_inside_loop)
+
/* Commands for testing PSPP. */
DEF_CMD (S_ANY, F_TESTING, "DEBUG EXPAND", cmd_debug_expand)
DEF_CMD (S_ANY, F_TESTING, "DEBUG EVALUATE", cmd_debug_evaluate)
return ok ? CMD_SUCCESS : CMD_CASCADING_FAILURE;
}
+int
+cmd_inside_do_if (struct lexer *lexer UNUSED, struct dataset *ds UNUSED)
+{
+ msg (SE, _("This command cannot appear outside DO IF...END IF."));
+ return CMD_FAILURE;
+}
+
static const struct trns_chain *
do_if_find_clause (const struct do_if_trns *do_if,
struct ccase *c, casenumber case_num)
return ok ? CMD_SUCCESS : CMD_CASCADING_FAILURE;
}
+int
+cmd_inside_loop (struct lexer *lexer UNUSED, struct dataset *ds UNUSED)
+{
+ msg (SE, _("This command cannot appear outside LOOP...END LOOP."));
+ return CMD_FAILURE;
+}
+
static enum trns_result
break_trns_proc (void *aux UNUSED, struct ccase **c UNUSED,
casenumber case_num UNUSED)
/* Parses BREAK. */
int
-cmd_break (struct lexer *lexer UNUSED, struct dataset *ds)
+cmd_break (struct lexer *lexer, struct dataset *ds)
{
if (!in_loop)
{
- msg (SE, _("BREAK cannot appear outside LOOP...END LOOP."));
+ cmd_inside_loop (lexer, ds);
return CMD_FAILURE;
}
fh_unref (fh);
free (encoding);
+ data_list_seen ();
+
return CMD_SUCCESS;
error:
return inside_input_program;
}
+void
+data_list_seen (void)
+{
+ saw_DATA_LIST = true;
+}
+
/* Emits an END CASE transformation for INP. */
static void
emit_END_CASE (struct dataset *ds)
#include <stdbool.h>
bool in_input_program (void);
-void cancel_input_program (void);
+
+void data_list_seen (void);
#endif /* inpt-pgm.h */
{
struct compute_trns *compute = compute_;
- printf ("compute\n");
if (compute->test == NULL
|| expr_evaluate_num (compute->test, *c, case_num) == 1.0)
{
])
AT_CHECK([pspp -O format=csv do-if.sps], [1], [dnl
do-if.sps:7: error: ELSE: This command cannot appear outside DO IF...END IF.
-
-do-if.sps:9: error: Stopping syntax file processing here to avoid a cascade of dependent command failures.
])
AT_CLEANUP