#include "language/command.h"
#include "language/lexer/lexer.h"
+#include "libpspp/hmap.h"
#include "libpspp/message.h"
+#include "output/pivot-table.h"
#include "gl/xalloc.h"
enum ctables_postcompute_op
{
/* Terminals. */
- CTPET_CAT_NUMBER,
- CTPET_CAT_STRING,
- CTPET_CAT_RANGE,
- CTPET_CAT_MISSING,
+ CTPO_CAT_NUMBER,
+ CTPO_CAT_STRING,
+ CTPO_CAT_RANGE,
+ CTPO_CAT_MISSING,
/* XXX OTHERNM */
/* XXX SUBTOTAL and HSUBTOTAL */
/* Nonterminals. */
- CTPET_ADD,
- CTPET_SUB,
- CTPET_MUL,
- CTPET_DIV,
- CTPET_POW,
+ CTPO_ADD,
+ CTPO_SUB,
+ CTPO_MUL,
+ CTPO_DIV,
+ CTPO_POW,
}
op;
union
{
- /* CTPET_CAT_NUMBER, CTPET_NUMBER. */
+ /* CTPO_CAT_NUMBER, CTPO_NUMBER. */
double number;
- /* CTPET_CAT_RANGE.
+ /* CTPO_CAT_RANGE.
XXX what about string ranges? */
struct
}
range;
- /* CTPET_ADD, CTPET_SUB, CTPET_MUL, CTPET_DIV, CTPET_POW. */
+ /* CTPO_ADD, CTPO_SUB, CTPO_MUL, CTPO_DIV, CTPO_POW. */
struct ctables_postcompute_expr *subs[2];
};
};
+struct ctables_table
+ {
+ struct ctables_axis *axes[PIVOT_N_AXES];
+
+
+ };
+
+struct ctables_axis
+ {
+ enum ctables_axis_op
+ {
+ /* Terminals. */
+ CTAO_VAR,
+ CTAO_MRSET,
+
+ /* Nonterminals. */
+ CTAO_CONCAT, /* + */
+ CTAO_NEST, /* > */
+ }
+ op;
+
+ union
+ {
+ /* Terminals. */
+ struct
+ {
+ union
+ {
+ struct variable *var;
+ struct mrset *mrset;
+ };
+
+ bool scale;
+ struct ctables_summary *summaries;
+ size_t n_summaries;
+ };
+
+ /* Nonterminals. */
+ struct ctables_axis *subs[2];
+ };
+ };
+
+struct ctables_summary
+ {
+ enum ctables_summary_function
+ {
+ /* All variables. */
+ CTSF_COUNT,
+ CTSF_ECOUNT,
+ CTSF_ROWPCT_COUNT,
+ CTSF_COLPCT_COUNT,
+ CTSF_TABLEPCT_COUNT,
+ CTSF_SUBTABLEPCT_COUNT,
+ CTSF_LAYERPCT_COUNT,
+ CTSF_LAYERROWPCT_COUNT,
+ CTSF_LAYERCOLPCT_COUNT,
+ CTSF_ROWPCT_VALIDN,
+ CTSF_COLPCT_VALIDN,
+ CTSF_TABLEPCT_VALIDN,
+ CTSF_SUBTABLEPCT_VALIDN,
+ CTSF_LAYERPCT_VALIDN,
+ CTSF_LAYERROWPCT_VALIDN,
+ CTSF_LAYERCOLPCT_VALIDN,
+ CTSF_ROWPCT_TOTALN,
+ CTSF_COLPCT_TOTALN,
+ CTSF_TABLEPCT_TOTALN,
+ CTSF_SUBTABLEPCT_TOTALN,
+ CTSF_LAYERPCT_TOTALN,
+ CTSF_LAYERROWPCT_TOTALN,
+ CTSF_LAYERCOLPCT_TOTALN,
+
+ /* Scale variables, totals, and subtotals. */
+ CTSF_MAXIMUM,
+ CTSF_MEAN,
+ CTSF_MEDIAN,
+ CTSF_MINIMUM,
+ CTSF_MISSING,
+ CTSF_MODE,
+ CTSF_PTILE,
+ CTSF_RANGE,
+ CTSF_SEMAN,
+ CTSF_STDDEV,
+ CTSF_SUM,
+ CSTF_TOTALN,
+ CTSF_ETOTALN,
+ CTSF_VALIDN,
+ CTSF_EVALIDN,
+ CTSF_VARIANCE,
+ CTSF_ROWPCT_SUM,
+ CTSF_COLPCT_SUM,
+ CTSF_TABLEPCT_SUM,
+ CTSF_SUBTABLEPCT_SUM,
+ CTSF_LAYERPCT_SUM,
+ CTSF_LAYERROWPCT_SUM,
+ CTSF_LAYERCOLPCT_SUM,
+
+ /* Multiple response sets. */
+ CTSF_ROWPCT_RESPONSES,
+ CTSF_COLPCT_RESPONSES,
+ CTSF_TABLEPCT_RESPONSES,
+ CTSF_SUBTABLEPCT_RESPONSES,
+ CTSF_LAYERPCT_RESPONSES,
+ CTSF_LAYERROWPCT_RESPONSES,
+ CTSF_LAYERCOLPCT_RESPONSES,
+ CTSF_ROWPCT_RESPONSES_COUNT,
+ CTSF_COLPCT_RESPONSES_COUNT,
+ CTSF_TABLEPCT_RESPONSES_COUNT,
+ CTSF_SUBTABLEPCT_RESPONSES_COUNT,
+ CTSF_LAYERPCT_RESPONSES_COUNT,
+ CTSF_LAYERROWPCT_RESPONSES_COUNT,
+ CTSF_LAYERCOLPCT_RESPONSES_COUNT,
+ CTSF_ROWPCT_COUNT_RESPONSES,
+ CTSF_COLPCT_COUNT_RESPONSES,
+ CTSF_TABLEPCT_COUNT_RESPONSES,
+ CTSF_SUBTABLEPCT_COUNT_RESPONSES,
+ CTSF_LAYERPCT_COUNT_RESPONSES,
+ CTSF_LAYERROWPCT_COUNT_RESPONSES,
+ CTSF_LAYERCOLPCT_COUNT_RESPONSES,
+ }
+ function;
+
+ char *label;
+ struct fmt_spec format; /* XXX extra CTABLES formats */
+ };
int
cmd_ctables (struct lexer *lexer, struct dataset *ds)