Improve the way we handle the various parsing "states". Until now
[pspp-builds.git] / src / language / command.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
3    Written by Ben Pfaff <blp@gnu.org>.
4
5    This program is free software; you can redistribute it and/or
6    modify it under the terms of the GNU General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18    02110-1301, USA. */
19
20 #ifndef COMMAND_H
21 #define COMMAND_H 1
22
23 #include <stdbool.h>
24
25 /* Command return values. */
26 enum cmd_result
27   {
28     /* Successful return values. */
29     CMD_SUCCESS = 1,            /* Successfully parsed and executed. */
30     CMD_EOF,                    /* No commands left. */
31     CMD_QUIT,                   /* Requested exit. */
32     CMD_END_SUBLOOP,            /* End of INPUT PROGRAM or FILE TYPE. */
33
34     /* Various kinds of failures. */
35     CMD_FAILURE,                /* Not executed at all. */
36     CMD_NOT_IMPLEMENTED,        /* Command not implemented. */
37     CMD_CASCADING_FAILURE       /* Serious error: don't continue. */
38   };
39
40 bool cmd_result_is_success (enum cmd_result);
41 bool cmd_result_is_failure (enum cmd_result);
42
43 /* Command processing state. */
44 enum cmd_state
45   {
46     CMD_STATE_INITIAL,          /* No active file yet defined. */
47     CMD_STATE_DATA,             /* Active file has been defined. */
48     CMD_STATE_INPUT_PROGRAM,    /* Inside INPUT PROGRAM. */
49     CMD_STATE_FILE_TYPE         /* Inside FILE TYPE. */
50   };
51
52 #if HAVE_READLINE
53 char **pspp_attempted_completion_function (const char *, int start, int end);
54 #endif
55
56 enum cmd_result cmd_parse (enum cmd_state);
57
58 /* Prototype all the command functions. */
59 #define DEF_CMD(STATES, FLAGS, NAME, FUNCTION) int FUNCTION (void);
60 #define UNIMPL_CMD(NAME, DESCRIPTION)
61 #include "command.def"
62 #undef DEF_CMD
63 #undef UNIMPL_CMD
64
65 #endif /* command.h */