From: Ben Pfaff Date: Wed, 28 Jun 2006 02:21:28 +0000 (+0000) Subject: Add aux data parameter to q2c parse_() and custom parser X-Git-Tag: v0.6.0~801 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp-builds.git;a=commitdiff_plain;h=18f6e8958244f938e9e9a03a4230cacf0d22a470 Add aux data parameter to q2c parse_() and custom parser functions. --- diff --git a/src/language/data-io/file-handle.q b/src/language/data-io/file-handle.q index 5e5ddbad..b3110ac8 100644 --- a/src/language/data-io/file-handle.q +++ b/src/language/data-io/file-handle.q @@ -75,7 +75,7 @@ cmd_file_handle (void) if (!lex_force_match ('/')) return CMD_CASCADING_FAILURE; - if (!parse_file_handle (&cmd)) + if (!parse_file_handle (&cmd, NULL)) return CMD_CASCADING_FAILURE; if (lex_end_of_command () != CMD_SUCCESS) diff --git a/src/language/data-io/list.q b/src/language/data-io/list.q index e377cb41..cd5de5c3 100644 --- a/src/language/data-io/list.q +++ b/src/language/data-io/list.q @@ -134,7 +134,7 @@ cmd_list (void) struct variable casenum_var; bool ok; - if (!parse_list (&cmd)) + if (!parse_list (&cmd, NULL)) return CMD_FAILURE; /* Fill in defaults. */ diff --git a/src/language/lexer/ChangeLog b/src/language/lexer/ChangeLog index 99b6e3e4..3d5768b6 100644 --- a/src/language/lexer/ChangeLog +++ b/src/language/lexer/ChangeLog @@ -1,3 +1,16 @@ +Tue Jun 27 19:15:33 2006 Ben Pfaff + + Add auxiliary data pointer to q2c parse_ function, and + pass it along to the custom parser functions. + + Updated all uses of custom functions in all the existing .q files. + + * q2c.c (dump_declarations): Include auxiliary parameter in + function prototypes. + (dump_subcommand) Include aux arg in calls to custom functions. + (dump_parser) Include aux param in parse_ function + definition. Include aux arg in calls to custom functions. + Tue Jun 27 12:07:34 2006 Ben Pfaff * variable-parser.h: New header. Moved the var_set and variable diff --git a/src/language/lexer/q2c.c b/src/language/lexer/q2c.c index d66dcc01..a62cf917 100644 --- a/src/language/lexer/q2c.c +++ b/src/language/lexer/q2c.c @@ -1177,7 +1177,7 @@ dump_declarations (void) dump (0, "/* Prototype for custom subcommands of %s. */", cmdname); } - dump (0, "static int %scustom_%s (struct cmd_%s *);", + dump (0, "static int %scustom_%s (struct cmd_%s *, void *);", st_lower (prefix), st_lower (sbc->name), make_identifier (cmdname)); } @@ -1189,7 +1189,7 @@ dump_declarations (void) /* Prototypes for parsing and freeing functions. */ { dump (0, "/* Command parsing functions. */"); - dump (0, "static int parse_%s (struct cmd_%s *);", + dump (0, "static int parse_%s (struct cmd_%s *, void *);", make_identifier (cmdname), make_identifier (cmdname)); dump (0, "static void free_%s (struct cmd_%s *);", make_identifier (cmdname), make_identifier (cmdname)); @@ -1696,7 +1696,7 @@ dump_subcommand (const subcommand *sbc) } else if (sbc->type == SBC_CUSTOM) { - dump (1, "switch (%scustom_%s (p))", + dump (1, "switch (%scustom_%s (p, aux))", st_lower (prefix), st_lower (sbc->name)); dump (0, "{"); dump (1, "case 0:"); @@ -1725,7 +1725,8 @@ dump_parser (int persistent) indent = 0; dump (0, "static int"); - dump (0, "parse_%s (struct cmd_%s *p)", make_identifier (cmdname), + dump (0, "parse_%s (struct cmd_%s *p, void *aux UNUSED)", + make_identifier (cmdname), make_identifier (cmdname)); dump (1, "{"); @@ -1761,7 +1762,7 @@ dump_parser (int persistent) } else if (def && def->type == SBC_CUSTOM) { - dump (1, "switch (%scustom_%s (p))", + dump (1, "switch (%scustom_%s (p, aux))", st_lower (prefix), st_lower (def->name)); dump (0, "{"); dump (1, "case 0:"); diff --git a/src/language/stats/correlations.q b/src/language/stats/correlations.q index f998e1df..5ba91e5c 100644 --- a/src/language/stats/correlations.q +++ b/src/language/stats/correlations.q @@ -78,7 +78,7 @@ internal_cmd_correlations (void) cor_list = cor_last = NULL; matrix_file = NULL; - if (!parse_correlations (&cmd)) + if (!parse_correlations (&cmd, NULL)) return CMD_FAILURE; free_correlations (&cmd); @@ -86,7 +86,7 @@ internal_cmd_correlations (void) } static int -cor_custom_variables (struct cmd_correlations *cmd UNUSED) +cor_custom_variables (struct cmd_correlations *cmd UNUSED, void *aux UNUSED) { struct variable **v1, **v2; size_t nv1, nv2; @@ -133,7 +133,7 @@ cor_custom_variables (struct cmd_correlations *cmd UNUSED) } static int -cor_custom_matrix (struct cmd_correlations *cmd UNUSED) +cor_custom_matrix (struct cmd_correlations *cmd UNUSED, void *aux UNUSED) { if (!lex_force_match ('(')) return 0; diff --git a/src/language/stats/crosstabs.q b/src/language/stats/crosstabs.q index c821ce0a..23b12a9d 100644 --- a/src/language/stats/crosstabs.q +++ b/src/language/stats/crosstabs.q @@ -211,7 +211,7 @@ internal_cmd_crosstabs (void) pl_tc = pool_create (); pl_col = pool_create (); - if (!parse_crosstabs (&cmd)) + if (!parse_crosstabs (&cmd, NULL)) return CMD_FAILURE; mode = variables ? INTEGER : GENERAL; @@ -301,7 +301,7 @@ internal_cmd_crosstabs (void) /* Parses the TABLES subcommand. */ static int -crs_custom_tables (struct cmd_crosstabs *cmd UNUSED) +crs_custom_tables (struct cmd_crosstabs *cmd UNUSED, void *aux UNUSED) { struct var_set *var_set; int n_by; @@ -405,7 +405,7 @@ crs_custom_tables (struct cmd_crosstabs *cmd UNUSED) /* Parses the VARIABLES subcommand. */ static int -crs_custom_variables (struct cmd_crosstabs *cmd UNUSED) +crs_custom_variables (struct cmd_crosstabs *cmd UNUSED, void *aux UNUSED) { if (nxtab) { diff --git a/src/language/stats/examine.q b/src/language/stats/examine.q index e2bd897a..44e7125d 100644 --- a/src/language/stats/examine.q +++ b/src/language/stats/examine.q @@ -198,7 +198,7 @@ cmd_examine(void) subc_list_double_create(&percentile_list); percentile_algorithm = PC_HAVERAGE; - if ( !parse_examine(&cmd) ) + if ( !parse_examine(&cmd, NULL) ) return CMD_FAILURE; /* If /MISSING=INCLUDE is set, then user missing values are ignored */ @@ -423,7 +423,7 @@ list_to_ptile_hash(const subc_list_double *l) /* Parse the PERCENTILES subcommand */ static int -xmn_custom_percentiles(struct cmd_examine *p UNUSED) +xmn_custom_percentiles(struct cmd_examine *p UNUSED, void *aux UNUSED) { sbc_percentile = 1; @@ -478,7 +478,7 @@ xmn_custom_percentiles(struct cmd_examine *p UNUSED) /* TOTAL and NOTOTAL are simple, mutually exclusive flags */ static int -xmn_custom_total(struct cmd_examine *p) +xmn_custom_total(struct cmd_examine *p, void *aux UNUSED) { if ( p->sbc_nototal ) { @@ -490,7 +490,7 @@ xmn_custom_total(struct cmd_examine *p) } static int -xmn_custom_nototal(struct cmd_examine *p) +xmn_custom_nototal(struct cmd_examine *p, void *aux UNUSED) { if ( p->sbc_total ) { @@ -506,7 +506,7 @@ xmn_custom_nototal(struct cmd_examine *p) /* Parser for the variables sub command Returns 1 on success */ static int -xmn_custom_variables(struct cmd_examine *cmd ) +xmn_custom_variables(struct cmd_examine *cmd, void *aux UNUSED) { lex_match('='); diff --git a/src/language/stats/frequencies.q b/src/language/stats/frequencies.q index 827f02af..95041d5d 100644 --- a/src/language/stats/frequencies.q +++ b/src/language/stats/frequencies.q @@ -335,7 +335,7 @@ internal_cmd_frequencies (void) n_variables = 0; v_variables = NULL; - if (!parse_frequencies (&cmd)) + if (!parse_frequencies (&cmd, NULL)) return CMD_FAILURE; if (cmd.onepage_limit == NOT_LONG) @@ -791,7 +791,7 @@ cleanup_freq_tab (struct variable *v) /* Parses the VARIABLES subcommand, adding to {n_variables,v_variables}. */ static int -frq_custom_variables (struct cmd_frequencies *cmd UNUSED) +frq_custom_variables (struct cmd_frequencies *cmd UNUSED, void *aux UNUSED) { int mode; int min = 0, max = 0; @@ -879,7 +879,7 @@ frq_custom_variables (struct cmd_frequencies *cmd UNUSED) /* Parses the GROUPED subcommand, setting the n_grouped, grouped fields of specified variables. */ static int -frq_custom_grouped (struct cmd_frequencies *cmd UNUSED) +frq_custom_grouped (struct cmd_frequencies *cmd UNUSED, void *aux UNUSED) { lex_match ('='); if ((token == T_ID && dict_lookup_var (default_dict, tokid) != NULL) diff --git a/src/language/stats/means.q b/src/language/stats/means.q index a1aa7229..fb03f754 100644 --- a/src/language/stats/means.q +++ b/src/language/stats/means.q @@ -72,7 +72,7 @@ cmd_means (void) v_dim = NULL; v_var = NULL; - if (!parse_means (&cmd)) + if (!parse_means (&cmd, NULL)) goto free; if (cmd.sbc_cells) @@ -123,7 +123,7 @@ free: /* Parses the TABLES subcommand. */ static int -mns_custom_tables (struct cmd_means *cmd) +mns_custom_tables (struct cmd_means *cmd, void *aux UNUSED) { struct var_set *var_set; diff --git a/src/language/stats/oneway.q b/src/language/stats/oneway.q index a400c1da..674cf710 100644 --- a/src/language/stats/oneway.q +++ b/src/language/stats/oneway.q @@ -121,7 +121,7 @@ cmd_oneway(void) int i; bool ok; - if ( !parse_oneway(&cmd) ) + if ( !parse_oneway(&cmd, NULL) ) return CMD_FAILURE; /* If /MISSING=INCLUDE is set, then user missing values are ignored */ @@ -223,7 +223,7 @@ output_oneway(void) /* Parser for the variables sub command */ static int -oneway_custom_variables(struct cmd_oneway *cmd UNUSED) +oneway_custom_variables(struct cmd_oneway *cmd UNUSED, void *aux UNUSED) { lex_match('='); diff --git a/src/language/stats/rank.q b/src/language/stats/rank.q index 2022aaaf..7024304d 100644 --- a/src/language/stats/rank.q +++ b/src/language/stats/rank.q @@ -95,7 +95,7 @@ cmd_rank(void) size_t i; n_rank_specs = 0; - if ( !parse_rank(&cmd) ) + if ( !parse_rank(&cmd, NULL) ) return CMD_FAILURE; #if 1 @@ -139,7 +139,7 @@ cmd_rank(void) /* Parser for the variables sub command Returns 1 on success */ static int -rank_custom_variables(struct cmd_rank *cmd UNUSED) +rank_custom_variables(struct cmd_rank *cmd UNUSED, void *aux UNUSED) { static const int terminators[2] = {T_BY, 0}; @@ -298,50 +298,50 @@ parse_rank_function(struct cmd_rank *cmd UNUSED, enum RANK_FUNC f) static int -rank_custom_rank(struct cmd_rank *cmd ) +rank_custom_rank(struct cmd_rank *cmd, void *aux UNUSED ) { return parse_rank_function(cmd, RANK); } static int -rank_custom_normal(struct cmd_rank *cmd ) +rank_custom_normal(struct cmd_rank *cmd, void *aux UNUSED ) { return parse_rank_function(cmd, NORMAL); } static int -rank_custom_percent(struct cmd_rank *cmd ) +rank_custom_percent(struct cmd_rank *cmd, void *aux UNUSED ) { return parse_rank_function(cmd, NORMAL); } static int -rank_custom_rfraction(struct cmd_rank *cmd ) +rank_custom_rfraction(struct cmd_rank *cmd, void *aux UNUSED ) { return parse_rank_function(cmd, RFRACTION); } static int -rank_custom_proportion(struct cmd_rank *cmd ) +rank_custom_proportion(struct cmd_rank *cmd, void *aux UNUSED ) { return parse_rank_function(cmd, PROPORTION); } static int -rank_custom_n(struct cmd_rank *cmd ) +rank_custom_n(struct cmd_rank *cmd, void *aux UNUSED ) { return parse_rank_function(cmd, N); } static int -rank_custom_savage(struct cmd_rank *cmd ) +rank_custom_savage(struct cmd_rank *cmd, void *aux UNUSED ) { return parse_rank_function(cmd, SAVAGE); } static int -rank_custom_ntiles(struct cmd_rank *cmd ) +rank_custom_ntiles(struct cmd_rank *cmd, void *aux UNUSED ) { if ( lex_force_match('(') ) { diff --git a/src/language/stats/regression.q b/src/language/stats/regression.q index 7bb32429..40781568 100644 --- a/src/language/stats/regression.q +++ b/src/language/stats/regression.q @@ -908,7 +908,7 @@ subcommand_export (int export, pspp_linreg_cache * c) } } static int -regression_custom_export (struct cmd_regression *cmd UNUSED) +regression_custom_export (struct cmd_regression *cmd UNUSED, void *aux UNUSED) { /* 0 on failure, 1 on success, 2 on failure that should result in syntax error */ if (!lex_force_match ('(')) @@ -932,7 +932,7 @@ regression_custom_export (struct cmd_regression *cmd UNUSED) int cmd_regression (void) { - if (!parse_regression (&cmd)) + if (!parse_regression (&cmd, NULL)) return CMD_FAILURE; models = xnmalloc (cmd.n_dependent, sizeof *models); @@ -996,7 +996,8 @@ mark_missing_cases (const struct casefile *cf, struct variable *v, /* Parser for the variables sub command */ static int -regression_custom_variables (struct cmd_regression *cmd UNUSED) +regression_custom_variables (struct cmd_regression *cmd UNUSED, + void *aux UNUSED) { lex_match ('='); diff --git a/src/language/stats/t-test.q b/src/language/stats/t-test.q index 7685bd82..5584df7d 100644 --- a/src/language/stats/t-test.q +++ b/src/language/stats/t-test.q @@ -259,7 +259,7 @@ cmd_t_test(void) { bool ok; - if ( !parse_t_test(&cmd) ) + if ( !parse_t_test(&cmd, NULL) ) return CMD_FAILURE; if (! cmd.sbc_criteria) @@ -366,7 +366,7 @@ cmd_t_test(void) } static int -tts_custom_groups (struct cmd_t_test *cmd UNUSED) +tts_custom_groups (struct cmd_t_test *cmd UNUSED, void *aux UNUSED) { int n_group_values=0; @@ -445,7 +445,7 @@ tts_custom_groups (struct cmd_t_test *cmd UNUSED) static int -tts_custom_pairs (struct cmd_t_test *cmd UNUSED) +tts_custom_pairs (struct cmd_t_test *cmd UNUSED, void *aux UNUSED) { struct variable **vars; size_t n_vars; diff --git a/src/language/utilities/set.q b/src/language/utilities/set.q index a230c7d5..b403843a 100644 --- a/src/language/utilities/set.q +++ b/src/language/utilities/set.q @@ -122,7 +122,7 @@ cmd_set (void) struct cmd_set cmd; bool ok = true; - if (!parse_set (&cmd)) + if (!parse_set (&cmd, NULL)) return CMD_FAILURE; if (cmd.sbc_cca) @@ -286,7 +286,7 @@ do_cc (const char *cc_string, int idx) completely blank fields in numeric data imply. X, Wnd: Syntax is SYSMIS or a numeric value. */ static int -stc_custom_blanks (struct cmd_set *cmd UNUSED) +stc_custom_blanks (struct cmd_set *cmd UNUSED, void *aux UNUSED) { lex_match ('='); if ((token == T_ID && lex_id_match ("SYSMIS", tokid))) @@ -307,7 +307,7 @@ stc_custom_blanks (struct cmd_set *cmd UNUSED) /* Parses the EPOCH subcommand, which controls the epoch used for parsing 2-digit years. */ static int -stc_custom_epoch (struct cmd_set *cmd UNUSED) +stc_custom_epoch (struct cmd_set *cmd UNUSED, void *aux UNUSED) { lex_match ('='); if (lex_match_id ("AUTOMATIC")) @@ -333,7 +333,7 @@ stc_custom_epoch (struct cmd_set *cmd UNUSED) } static int -stc_custom_length (struct cmd_set *cmd UNUSED) +stc_custom_length (struct cmd_set *cmd UNUSED, void *aux UNUSED) { int page_length; @@ -360,7 +360,7 @@ stc_custom_length (struct cmd_set *cmd UNUSED) } static int -stc_custom_seed (struct cmd_set *cmd UNUSED) +stc_custom_seed (struct cmd_set *cmd UNUSED, void *aux UNUSED) { lex_match ('='); if (lex_match_id ("RANDOM")) @@ -377,7 +377,7 @@ stc_custom_seed (struct cmd_set *cmd UNUSED) } static int -stc_custom_width (struct cmd_set *cmd UNUSED) +stc_custom_width (struct cmd_set *cmd UNUSED, void *aux UNUSED) { lex_match ('='); if (lex_match_id ("NARROW")) @@ -403,7 +403,7 @@ stc_custom_width (struct cmd_set *cmd UNUSED) /* Parses FORMAT subcommand, which consists of a numeric format specifier. */ static int -stc_custom_format (struct cmd_set *cmd UNUSED) +stc_custom_format (struct cmd_set *cmd UNUSED, void *aux UNUSED) { struct fmt_spec fmt; @@ -423,7 +423,7 @@ stc_custom_format (struct cmd_set *cmd UNUSED) } static int -stc_custom_journal (struct cmd_set *cmd UNUSED) +stc_custom_journal (struct cmd_set *cmd UNUSED, void *aux UNUSED) { lex_match ('='); if (!lex_match_id ("ON") && !lex_match_id ("OFF")) @@ -440,7 +440,7 @@ stc_custom_journal (struct cmd_set *cmd UNUSED) } static int -stc_custom_listing (struct cmd_set *cmd UNUSED) +stc_custom_listing (struct cmd_set *cmd UNUSED, void *aux UNUSED) { bool listing; @@ -460,9 +460,9 @@ stc_custom_listing (struct cmd_set *cmd UNUSED) } static int -stc_custom_disk (struct cmd_set *cmd UNUSED) +stc_custom_disk (struct cmd_set *cmd UNUSED, void *aux) { - return stc_custom_listing (cmd); + return stc_custom_listing (cmd, aux); } static void