+ if (!c->n_cats && lex_match_id (lexer, "ORDER"))
+ {
+ lex_match (lexer, T_EQUALS);
+ if (lex_match_id (lexer, "A"))
+ cat.sort_ascending = true;
+ else if (lex_match_id (lexer, "D"))
+ cat.sort_ascending = false;
+ else
+ {
+ lex_error_expecting (lexer, "A", "D");
+ goto error;
+ }
+ }
+ else if (!c->n_cats && lex_match_id (lexer, "KEY"))
+ {
+ int start_ofs = lex_ofs (lexer) - 1;
+ lex_match (lexer, T_EQUALS);
+ if (lex_match_id (lexer, "VALUE"))
+ cat.type = CCT_VALUE;
+ else if (lex_match_id (lexer, "LABEL"))
+ cat.type = CCT_LABEL;
+ else
+ {
+ cat.type = CCT_FUNCTION;
+ if (!parse_ctables_summary_function (lexer, &cat.sort_function,
+ &cat.weighting, &cat.area))
+ goto error;
+
+ if (lex_match (lexer, T_LPAREN))
+ {
+ cat.sort_var = parse_variable (lexer, dict);
+ if (!cat.sort_var)
+ goto error;
+
+ if (cat.sort_function == CTSF_PTILE)
+ {
+ lex_match (lexer, T_COMMA);
+ if (!lex_force_num_range_closed (lexer, "PTILE", 0, 100))
+ goto error;
+ cat.percentile = lex_number (lexer);
+ lex_get (lexer);
+ }
+
+ if (!lex_force_match (lexer, T_RPAREN))
+ goto error;
+ }
+ else if (ctables_function_availability (cat.sort_function)
+ == CTFA_SCALE)
+ {
+ bool UNUSED b = lex_force_match (lexer, T_LPAREN);
+ goto error;
+ }
+
+ lex_ofs_error (lexer, start_ofs, lex_ofs (lexer) - 1,
+ _("Data-dependent sorting is not implemented."));
+ goto error;
+ }
+ }
+ else if (!c->n_cats && lex_match_id (lexer, "MISSING"))
+ {
+ lex_match (lexer, T_EQUALS);
+ if (lex_match_id (lexer, "INCLUDE"))
+ cat.include_missing = true;
+ else if (lex_match_id (lexer, "EXCLUDE"))
+ cat.include_missing = false;
+ else
+ {
+ lex_error_expecting (lexer, "INCLUDE", "EXCLUDE");
+ goto error;
+ }
+ }
+ else if (lex_match_id (lexer, "TOTAL"))
+ {
+ lex_match (lexer, T_EQUALS);
+ if (!parse_bool (lexer, &show_totals))
+ goto error;
+ }
+ else if (lex_match_id (lexer, "LABEL"))
+ {
+ lex_match (lexer, T_EQUALS);
+ if (!lex_force_string (lexer))
+ goto error;
+ free (total_label);
+ total_label = ss_xstrdup (lex_tokss (lexer));
+ lex_get (lexer);
+ }
+ else if (lex_match_id (lexer, "POSITION"))
+ {
+ lex_match (lexer, T_EQUALS);
+ if (lex_match_id (lexer, "BEFORE"))
+ totals_before = true;
+ else if (lex_match_id (lexer, "AFTER"))
+ totals_before = false;
+ else
+ {
+ lex_error_expecting (lexer, "BEFORE", "AFTER");
+ goto error;
+ }
+ }
+ else if (lex_match_id (lexer, "EMPTY"))
+ {
+ lex_match (lexer, T_EQUALS);
+ if (lex_match_id (lexer, "INCLUDE"))
+ c->show_empty = true;
+ else if (lex_match_id (lexer, "EXCLUDE"))
+ c->show_empty = false;
+ else
+ {
+ lex_error_expecting (lexer, "INCLUDE", "EXCLUDE");
+ goto error;
+ }
+ }
+ else
+ {
+ if (!c->n_cats)
+ lex_error_expecting (lexer, "ORDER", "KEY", "MISSING",
+ "TOTAL", "LABEL", "POSITION", "EMPTY");
+ else
+ lex_error_expecting (lexer, "TOTAL", "LABEL", "POSITION", "EMPTY");
+ goto error;