Eleminate unnecessary variables
[pspp-builds.git] / src / language / stats / npar.c
1 /* PSPP - a program for statistical analysis. -*-c-*-
2    Copyright (C) 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
16
17 #include <config.h>
18
19 #include <language/stats/npar.h>
20 #include "npar-summary.h"
21
22 #include <stdlib.h>
23 #include <math.h>
24
25 #include "xalloc.h"
26 #include <data/case.h>
27 #include <data/casegrouper.h>
28 #include <data/casereader.h>
29 #include <data/dictionary.h>
30 #include <data/procedure.h>
31 #include <data/settings.h>
32 #include <data/variable.h>
33 #include <language/command.h>
34 #include <language/lexer/lexer.h>
35 #include <language/lexer/variable-parser.h>
36 #include <language/stats/binomial.h>
37 #include <language/stats/chisquare.h>
38 #include <language/stats/wilcoxon.h>
39 #include <language/stats/sign.h>
40 #include <libpspp/assertion.h>
41 #include <libpspp/cast.h>
42 #include <libpspp/hash.h>
43 #include <libpspp/message.h>
44 #include <libpspp/pool.h>
45 #include <libpspp/str.h>
46 #include <libpspp/taint.h>
47 #include <math/moments.h>
48
49 #include "gettext.h"
50 #define _(msgid) gettext (msgid)
51
52 /* Settings for subcommand specifiers. */
53 enum missing_type
54   {
55     MISS_ANALYSIS,
56     MISS_LISTWISE,
57   };
58
59 /* Array indices for STATISTICS subcommand. */
60 enum
61   {
62     NPAR_ST_DESCRIPTIVES = 0,
63     NPAR_ST_QUARTILES = 1,
64     NPAR_ST_ALL = 2,
65     NPAR_ST_count
66   };
67
68 /* NPAR TESTS structure. */
69 struct cmd_npar_tests
70   {
71     /* CHISQUARE subcommand. */
72     int chisquare;
73
74     /* BINOMIAL subcommand. */
75     int binomial;
76
77     /* WILCOXON subcommand. */
78     int wilcoxon;
79
80     /* SIGN subcommand. */
81     int sign;
82
83     /* MISSING subcommand. */
84     int missing;
85     long miss;
86
87     /* METHOD subcommand. */
88     int method;
89
90     /* STATISTICS subcommand. */
91     int statistics;
92     int a_statistics[NPAR_ST_count];
93   };
94
95
96 struct npar_specs
97 {
98   struct pool *pool;
99   struct npar_test **test;
100   size_t n_tests;
101
102   const struct variable **vv; /* Compendium of all variables
103                                   (those mentioned on ANY subcommand */
104   int n_vars; /* Number of variables in vv */
105
106   enum mv_class filter;    /* Missing values to filter. */
107
108   bool descriptives;       /* Descriptive statistics should be calculated */
109   bool quartiles;          /* Quartiles should be calculated */
110
111   bool exact;  /* Whether exact calculations have been requested */
112   double timer;   /* Maximum time (in minutes) to wait for exact calculations */
113 };
114
115
116 /* Prototype for custom subcommands of NPAR TESTS. */
117 static int npar_chisquare (struct lexer *, struct dataset *, struct npar_specs *);
118 static int npar_binomial (struct lexer *, struct dataset *,  struct npar_specs *);
119 static int npar_wilcoxon (struct lexer *, struct dataset *, struct npar_specs *);
120 static int npar_sign (struct lexer *, struct dataset *, struct npar_specs *);
121 static int npar_method (struct lexer *, struct npar_specs *);
122
123 /* Command parsing functions. */
124 static int parse_npar_tests (struct lexer *lexer, struct dataset *ds, struct cmd_npar_tests *p,
125                              struct npar_specs *npar_specs );
126
127 static int
128 parse_npar_tests (struct lexer *lexer, struct dataset *ds, struct cmd_npar_tests *npt,
129                   struct npar_specs *nps)
130 {
131   npt->chisquare = 0;
132   npt->binomial = 0;
133   npt->wilcoxon = 0;
134   npt->sign = 0;
135   npt->missing = 0;
136   npt->miss = MISS_ANALYSIS;
137   npt->method = 0;
138   npt->statistics = 0;
139   memset (npt->a_statistics, 0, sizeof npt->a_statistics);
140   for (;;)
141     {
142       if (lex_match_hyphenated_word (lexer, "CHISQUARE"))
143         {
144           lex_match (lexer, '=');
145           npt->chisquare++;
146           switch (npar_chisquare (lexer, ds, nps))
147             {
148             case 0:
149               goto lossage;
150             case 1:
151               break;
152             case 2:
153               lex_error (lexer, NULL);
154               goto lossage;
155             default:
156               NOT_REACHED ();
157             }
158         }
159       else if (lex_match_hyphenated_word (lexer, "BINOMIAL"))
160         {
161           lex_match (lexer, '=');
162           npt->binomial++;
163           switch (npar_binomial (lexer, ds, nps))
164             {
165             case 0:
166               goto lossage;
167             case 1:
168               break;
169             case 2:
170               lex_error (lexer, NULL);
171               goto lossage;
172             default:
173               NOT_REACHED ();
174             }
175         }
176       else if (lex_match_hyphenated_word (lexer, "WILCOXON"))
177         {
178           lex_match (lexer, '=');
179           npt->wilcoxon++;
180           switch (npar_wilcoxon (lexer, ds, nps))
181             {
182             case 0:
183               goto lossage;
184             case 1:
185               break;
186             case 2:
187               lex_error (lexer, NULL);
188               goto lossage;
189             default:
190               NOT_REACHED ();
191             }
192         }
193       else if (lex_match_hyphenated_word (lexer, "SIGN"))
194         {
195           lex_match (lexer, '=');
196           npt->sign++;
197           switch (npar_sign (lexer, ds, nps))
198             {
199             case 0:
200               goto lossage;
201             case 1:
202               break;
203             case 2:
204               lex_error (lexer, NULL);
205               goto lossage;
206             default:
207               NOT_REACHED ();
208             }
209         }
210       else if (lex_match_hyphenated_word (lexer, "MISSING"))
211         {
212           lex_match (lexer, '=');
213           npt->missing++;
214           if (npt->missing > 1)
215             {
216               msg (SE, _ ("The %s subcommand may be given only once."), "MISSING");
217               goto lossage;
218             }
219           while (lex_token (lexer) != '/' && lex_token (lexer) != '.')
220             {
221               if (lex_match_hyphenated_word (lexer, "ANALYSIS"))
222                 npt->miss = MISS_ANALYSIS;
223               else if (lex_match_hyphenated_word (lexer, "LISTWISE"))
224                 npt->miss = MISS_LISTWISE;
225               else if (lex_match_hyphenated_word (lexer, "INCLUDE"))
226                 nps->filter = MV_SYSTEM;
227               else if (lex_match_hyphenated_word (lexer, "EXCLUDE"))
228                 nps->filter = MV_ANY;
229               else
230                 {
231                   lex_error (lexer, NULL);
232                   goto lossage;
233                 }
234               lex_match (lexer, ',');
235             }
236         }
237       else if (lex_match_hyphenated_word (lexer, "METHOD"))
238         {
239           lex_match (lexer, '=');
240           npt->method++;
241           if (npt->method > 1)
242             {
243               msg (SE, _ ("The %s subcommand may be given only once."), "METHOD");
244               goto lossage;
245             }
246           switch (npar_method (lexer, nps))
247             {
248             case 0:
249               goto lossage;
250             case 1:
251               break;
252             case 2:
253               lex_error (lexer, NULL);
254               goto lossage;
255             default:
256               NOT_REACHED ();
257             }
258         }
259       else if (lex_match_hyphenated_word (lexer, "STATISTICS"))
260         {
261           lex_match (lexer, '=');
262           npt->statistics++;
263           while (lex_token (lexer) != '/' && lex_token (lexer) != '.')
264             {
265               if (lex_match_hyphenated_word (lexer, "DESCRIPTIVES"))
266                 npt->a_statistics[NPAR_ST_DESCRIPTIVES] = 1;
267               else if (lex_match_hyphenated_word (lexer, "QUARTILES"))
268                 npt->a_statistics[NPAR_ST_QUARTILES] = 1;
269               else if (lex_match (lexer, T_ALL))
270                 npt->a_statistics[NPAR_ST_ALL] = 1;
271               else
272                 {
273                   lex_error (lexer, NULL);
274                   goto lossage;
275                 }
276               lex_match (lexer, ',');
277             }
278         }
279       else if ( settings_get_syntax () != COMPATIBLE && lex_match_id (lexer, "ALGORITHM"))
280         {
281           lex_match (lexer, '=');
282           if (lex_match_id (lexer, "COMPATIBLE"))
283             settings_set_cmd_algorithm (COMPATIBLE);
284           else if (lex_match_id (lexer, "ENHANCED"))
285             settings_set_cmd_algorithm (ENHANCED);
286           }
287         if (!lex_match (lexer, '/'))
288           break;
289       }
290
291     if (lex_token (lexer) != '.')
292       {
293         lex_error (lexer, _ ("expecting end of command"));
294         goto lossage;
295       }
296
297   return true;
298
299 lossage:
300   return false;
301 }
302
303
304
305
306 static void one_sample_insert_variables (const struct npar_test *test,
307                                          struct const_hsh_table *variables);
308
309 static void two_sample_insert_variables (const struct npar_test *test,
310                                          struct const_hsh_table *variables);
311
312
313 static void
314 npar_execute (struct casereader *input,
315              const struct npar_specs *specs,
316              const struct dataset *ds)
317 {
318   int t;
319   struct descriptives *summary_descriptives = NULL;
320
321   for ( t = 0 ; t < specs->n_tests; ++t )
322     {
323       const struct npar_test *test = specs->test[t];
324       if ( NULL == test->execute )
325         {
326           msg (SW, _ ("NPAR subcommand not currently implemented."));
327           continue;
328         }
329       test->execute (ds, casereader_clone (input), specs->filter, test, specs->exact, specs->timer);
330     }
331
332   if ( specs->descriptives )
333     {
334       summary_descriptives = xnmalloc (sizeof (*summary_descriptives),
335                                        specs->n_vars);
336
337       npar_summary_calc_descriptives (summary_descriptives,
338                                       casereader_clone (input),
339                                       dataset_dict (ds),
340                                       specs->vv, specs->n_vars,
341                                       specs->filter);
342     }
343
344   if ( (specs->descriptives || specs->quartiles)
345        && !taint_has_tainted_successor (casereader_get_taint (input)) )
346     do_summary_box (summary_descriptives, specs->vv, specs->n_vars );
347
348   free (summary_descriptives);
349   casereader_destroy (input);
350 }
351
352
353 int
354 cmd_npar_tests (struct lexer *lexer, struct dataset *ds)
355 {
356   struct cmd_npar_tests cmd;
357   bool ok;
358   int i;
359   struct npar_specs npar_specs = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
360   struct const_hsh_table *var_hash;
361   struct casegrouper *grouper;
362   struct casereader *input, *group;
363
364   npar_specs.pool = pool_create ();
365   npar_specs.filter = MV_ANY;
366
367   var_hash = const_hsh_create_pool (npar_specs.pool, 0,
368                                     compare_vars_by_name, hash_var_by_name,
369                                     NULL, NULL);
370
371   if ( ! parse_npar_tests (lexer, ds, &cmd, &npar_specs) )
372     {
373       pool_destroy (npar_specs.pool);
374       return CMD_FAILURE;
375     }
376
377   for (i = 0; i < npar_specs.n_tests; ++i )
378     {
379       const struct npar_test *test = npar_specs.test[i];
380       test->insert_variables (test, var_hash);
381     }
382
383   npar_specs.vv = (const struct variable **) const_hsh_sort (var_hash);
384   npar_specs.n_vars = const_hsh_count (var_hash);
385
386   if ( cmd.statistics )
387     {
388       int i;
389
390       for ( i = 0 ; i < NPAR_ST_count; ++i )
391         {
392           if ( cmd.a_statistics[i] )
393             {
394               switch ( i )
395                 {
396                 case NPAR_ST_DESCRIPTIVES:
397                   npar_specs.descriptives = true;
398                   break;
399                 case NPAR_ST_QUARTILES:
400                   npar_specs.quartiles = true;
401                   break;
402                 case NPAR_ST_ALL:
403                   npar_specs.quartiles = true;
404                   npar_specs.descriptives = true;
405                   break;
406                 default:
407                   NOT_REACHED ();
408                 };
409             }
410         }
411     }
412
413   input = proc_open (ds);
414   if ( cmd.miss == MISS_LISTWISE )
415     {
416       input = casereader_create_filter_missing (input,
417                                                 npar_specs.vv,
418                                                 npar_specs.n_vars,
419                                                 npar_specs.filter,
420                                                 NULL, NULL);
421     }
422
423
424   grouper = casegrouper_create_splits (input, dataset_dict (ds));
425   while (casegrouper_get_next_group (grouper, &group))
426     npar_execute (group, &npar_specs, ds);
427   ok = casegrouper_destroy (grouper);
428   ok = proc_commit (ds) && ok;
429
430   const_hsh_destroy (var_hash);
431
432   pool_destroy (npar_specs.pool);
433
434   return ok ? CMD_SUCCESS : CMD_CASCADING_FAILURE;
435 }
436
437 static int
438 npar_chisquare (struct lexer *lexer, struct dataset *ds,
439                 struct npar_specs *specs)
440 {
441   struct chisquare_test *cstp = pool_alloc (specs->pool, sizeof (*cstp));
442   struct one_sample_test *tp = &cstp->parent;
443   struct npar_test *nt = &tp->parent;
444
445   nt->execute = chisquare_execute;
446   nt->insert_variables = one_sample_insert_variables;
447
448   if (!parse_variables_const_pool (lexer, specs->pool, dataset_dict (ds),
449                                    &tp->vars, &tp->n_vars,
450                                    PV_NO_SCRATCH | PV_NO_DUPLICATE))
451     {
452       return 2;
453     }
454
455   cstp->ranged = false;
456
457   if ( lex_match (lexer, '('))
458     {
459       cstp->ranged = true;
460       if ( ! lex_force_num (lexer)) return 0;
461       cstp->lo = lex_integer (lexer);
462       lex_get (lexer);
463       lex_force_match (lexer, ',');
464       if (! lex_force_num (lexer) ) return 0;
465       cstp->hi = lex_integer (lexer);
466       if ( cstp->lo >= cstp->hi )
467         {
468           msg (ME,
469               _ ("The specified value of HI (%d) is "
470                 "lower than the specified value of LO (%d)"),
471               cstp->hi, cstp->lo);
472           return 0;
473         }
474       lex_get (lexer);
475       if (! lex_force_match (lexer, ')')) return 0;
476     }
477
478   cstp->n_expected = 0;
479   cstp->expected = NULL;
480   if ( lex_match (lexer, '/') )
481     {
482       if ( lex_match_id (lexer, "EXPECTED") )
483         {
484           lex_force_match (lexer, '=');
485           if ( ! lex_match_id (lexer, "EQUAL") )
486             {
487               double f;
488               int n;
489               while ( lex_is_number (lexer) )
490                 {
491                   int i;
492                   n = 1;
493                   f = lex_number (lexer);
494                   lex_get (lexer);
495                   if ( lex_match (lexer, '*'))
496                     {
497                       n = f;
498                       f = lex_number (lexer);
499                       lex_get (lexer);
500                     }
501                   lex_match (lexer, ',');
502
503                   cstp->n_expected += n;
504                   cstp->expected = pool_realloc (specs->pool,
505                                                  cstp->expected,
506                                                  sizeof (double) *
507                                                  cstp->n_expected);
508                   for ( i = cstp->n_expected - n ;
509                         i < cstp->n_expected;
510                         ++i )
511                     cstp->expected[i] = f;
512
513                 }
514             }
515         }
516       else
517         lex_put_back (lexer, '/');
518     }
519
520   if ( cstp->ranged && cstp->n_expected > 0 &&
521        cstp->n_expected != cstp->hi - cstp->lo + 1 )
522     {
523       msg (ME,
524           _ ("%d expected values were given, but the specified "
525             "range (%d-%d) requires exactly %d values."),
526           cstp->n_expected, cstp->lo, cstp->hi,
527           cstp->hi - cstp->lo +1);
528       return 0;
529     }
530
531   specs->n_tests++;
532   specs->test = pool_realloc (specs->pool,
533                               specs->test,
534                               sizeof (*specs->test) * specs->n_tests);
535
536   specs->test[specs->n_tests - 1] = nt;
537
538   return 1;
539 }
540
541
542 static int
543 npar_binomial (struct lexer *lexer, struct dataset *ds,
544                struct npar_specs *specs)
545 {
546   struct binomial_test *btp = pool_alloc (specs->pool, sizeof (*btp));
547   struct one_sample_test *tp = &btp->parent;
548   struct npar_test *nt = &tp->parent;
549
550   nt->execute = binomial_execute;
551   nt->insert_variables = one_sample_insert_variables;
552
553   btp->category1 = btp->category2 = btp->cutpoint = SYSMIS;
554
555   btp->p = 0.5;
556
557   if ( lex_match (lexer, '(') )
558     {
559       if ( lex_force_num (lexer) )
560         {
561           btp->p = lex_number (lexer);
562           lex_get (lexer);
563           lex_force_match (lexer, ')');
564         }
565       else
566         return 0;
567     }
568   else
569     /* Kludge: q2c swallows the '=' so put it back here  */
570      lex_put_back (lexer, '=');
571
572   if (lex_match (lexer, '=') )
573     {
574       if (parse_variables_const_pool (lexer, specs->pool, dataset_dict (ds),
575                                       &tp->vars, &tp->n_vars,
576                                       PV_NUMERIC | PV_NO_SCRATCH | PV_NO_DUPLICATE) )
577         {
578           if (lex_match (lexer, '('))
579             {
580               lex_force_num (lexer);
581               btp->category1 = lex_number (lexer);
582               lex_get (lexer);
583               if ( lex_match (lexer, ','))
584                 {
585                   if ( ! lex_force_num (lexer) ) return 2;
586                   btp->category2 = lex_number (lexer);
587                   lex_get (lexer);
588                 }
589               else
590                 {
591                   btp->cutpoint = btp->category1;
592                 }
593
594               lex_force_match (lexer, ')');
595             }
596         }
597       else
598         return 2;
599
600     }
601
602   specs->n_tests++;
603   specs->test = pool_realloc (specs->pool,
604                               specs->test,
605                               sizeof (*specs->test) * specs->n_tests);
606
607   specs->test[specs->n_tests - 1] = nt;
608
609   return 1;
610 }
611
612
613 static bool
614 parse_two_sample_related_test (struct lexer *lexer,
615                                     const struct dictionary *dict,
616                                     struct two_sample_test *test_parameters,
617                                     struct pool *pool
618                                     );
619
620
621 static bool
622 parse_two_sample_related_test (struct lexer *lexer,
623                                const struct dictionary *dict,
624                                struct two_sample_test *test_parameters,
625                                struct pool *pool
626                                )
627 {
628   int n = 0;
629   bool paired = false;
630   bool with = false;
631   const struct variable **vlist1;
632   size_t n_vlist1;
633
634   const struct variable **vlist2;
635   size_t n_vlist2;
636
637   test_parameters->parent.insert_variables = two_sample_insert_variables;
638
639   if (!parse_variables_const_pool (lexer, pool,
640                                    dict,
641                                    &vlist1, &n_vlist1,
642                                    PV_NUMERIC | PV_NO_SCRATCH | PV_NO_DUPLICATE) )
643     return false;
644
645   if ( lex_match (lexer, T_WITH))
646     {
647       with = true;
648       if ( !parse_variables_const_pool (lexer, pool, dict,
649                                         &vlist2, &n_vlist2,
650                                         PV_NUMERIC | PV_NO_SCRATCH | PV_NO_DUPLICATE) )
651         return false;
652
653       paired = (lex_match (lexer, '(') &&
654                 lex_match_id (lexer, "PAIRED") && lex_match (lexer, ')'));
655     }
656
657
658   if ( with )
659     {
660       if (paired)
661         {
662           if ( n_vlist1 != n_vlist2)
663             msg (SE, _ ("PAIRED was specified but the number of variables "
664                        "preceding WITH (%zu) did not match the number "
665                        "following (%zu)."), n_vlist1, n_vlist2);
666
667           test_parameters->n_pairs = n_vlist1 ;
668         }
669       else
670         {
671           test_parameters->n_pairs = n_vlist1 * n_vlist2;
672         }
673     }
674   else
675     {
676       test_parameters->n_pairs = (n_vlist1 * (n_vlist1 - 1)) / 2 ;
677     }
678
679   test_parameters->pairs =
680     pool_alloc (pool, sizeof ( variable_pair) * test_parameters->n_pairs);
681
682   if ( with )
683     {
684       if (paired)
685         {
686           int i;
687           assert (n_vlist1 == n_vlist2);
688           for ( i = 0 ; i < n_vlist1; ++i )
689             {
690               test_parameters->pairs[n][1] = vlist1[i];
691               test_parameters->pairs[n][0] = vlist2[i];
692               n++;
693             }
694         }
695       else
696         {
697           int i,j;
698           for ( i = 0 ; i < n_vlist1; ++i )
699             {
700               for ( j = 0 ; j < n_vlist2; ++j )
701                 {
702                   test_parameters->pairs[n][1] = vlist1[i];
703                   test_parameters->pairs[n][0] = vlist2[j];
704                   n++;
705                 }
706             }
707         }
708     }
709   else
710     {
711       int i,j;
712       for ( i = 0 ; i < n_vlist1 - 1; ++i )
713         {
714           for ( j = i + 1 ; j < n_vlist1; ++j )
715             {
716               assert ( n < test_parameters->n_pairs);
717               test_parameters->pairs[n][1] = vlist1[i];
718               test_parameters->pairs[n][0] = vlist1[j];
719               n++;
720             }
721         }
722     }
723
724   assert ( n == test_parameters->n_pairs);
725
726   return true;
727 }
728
729 static int
730 npar_wilcoxon (struct lexer *lexer,
731                struct dataset *ds,
732                struct npar_specs *specs )
733 {
734
735
736   struct two_sample_test *tp = pool_alloc (specs->pool, sizeof (*tp));
737   struct npar_test *nt = &tp->parent;
738   nt->execute = wilcoxon_execute;
739
740   if (!parse_two_sample_related_test (lexer, dataset_dict (ds),
741                                       tp, specs->pool) )
742     return 0;
743
744   specs->n_tests++;
745   specs->test = pool_realloc (specs->pool,
746                               specs->test,
747                               sizeof (*specs->test) * specs->n_tests);
748   specs->test[specs->n_tests - 1] = nt;
749
750   return 1;
751 }
752
753 static int
754 npar_sign (struct lexer *lexer, struct dataset *ds,
755            struct npar_specs *specs)
756 {
757   struct two_sample_test *tp = pool_alloc (specs->pool, sizeof (*tp));
758   struct npar_test *nt = &tp->parent;
759
760   nt->execute = sign_execute;
761
762   if (!parse_two_sample_related_test (lexer, dataset_dict (ds),
763                                       tp, specs->pool) )
764     return 0;
765
766   specs->n_tests++;
767   specs->test = pool_realloc (specs->pool,
768                               specs->test,
769                               sizeof (*specs->test) * specs->n_tests);
770   specs->test[specs->n_tests - 1] = nt;
771
772   return 1;
773 }
774
775 /* Insert the variables for TEST into VAR_HASH */
776 static void
777 one_sample_insert_variables (const struct npar_test *test,
778                              struct const_hsh_table *var_hash)
779 {
780   int i;
781   struct one_sample_test *ost = UP_CAST (test, struct one_sample_test, parent);
782
783   for ( i = 0 ; i < ost->n_vars ; ++i )
784     const_hsh_insert (var_hash, ost->vars[i]);
785 }
786
787 static void
788 two_sample_insert_variables (const struct npar_test *test,
789                              struct const_hsh_table *var_hash)
790 {
791   int i;
792
793   const struct two_sample_test *tst = (const struct two_sample_test *) test;
794
795   for ( i = 0 ; i < tst->n_pairs ; ++i )
796     {
797       variable_pair *pair = &tst->pairs[i];
798
799       const_hsh_insert (var_hash, (*pair)[0]);
800       const_hsh_insert (var_hash, (*pair)[1]);
801     }
802 }
803
804 static int
805 npar_method (struct lexer *lexer,  struct npar_specs *specs)
806 {
807   if ( lex_match_id (lexer, "EXACT") )
808     {
809       specs->exact = true;
810       specs->timer = 0.0;
811       if (lex_match_id (lexer, "TIMER"))
812         {
813           specs->timer = 5.0;
814
815           if ( lex_match (lexer, '('))
816             {
817               if ( lex_force_num (lexer) )
818                 {
819                   specs->timer = lex_number (lexer);
820                   lex_get (lexer);
821                 }
822               lex_force_match (lexer, ')');
823             }
824         }
825     }
826
827   return 1;
828 }