msgstr ""
"Project-Id-Version: PSPP 0.3.1\n"
"Report-Msgid-Bugs-To: pspp-dev@gnu.org\n"
-"POT-Creation-Date: 2005-03-03 06:08+0800\n"
+"POT-Creation-Date: 2005-03-06 10:44-0800\n"
"PO-Revision-Date: 2004-01-23 13:04+0800\n"
"Last-Translator: John Darrington <john@darrington.wattle.id.au>\n"
"Language-Team: John Darrington <john@darrington.wattle.id.au>\n"
msgid "installation error"
msgstr ""
-#: src/filename.c:221
-#, c-format
-msgid "Searching for `%s'..."
-msgstr ""
-
-#: src/filename.c:229 src/filename.c:261
-msgid "Search unsuccessful!"
-msgstr ""
-
-#: src/filename.c:254
-#, c-format
-msgid "Found `%s'."
-msgstr ""
-
-#: src/filename.c:686
-#, c-format
-msgid "Not opening pipe file `%s' because SAFER option set."
-msgstr ""
-
#: src/file-type.c:129
msgid "MIXED, GROUPED, or NESTED expected."
msgstr ""
msgid "Unknown record type %g."
msgstr ""
+#: src/filename.c:221
+#, c-format
+msgid "Searching for `%s'..."
+msgstr ""
+
+#: src/filename.c:229 src/filename.c:261
+msgid "Search unsuccessful!"
+msgstr ""
+
+#: src/filename.c:254
+#, c-format
+msgid "Found `%s'."
+msgstr ""
+
+#: src/filename.c:686
+#, c-format
+msgid "Not opening pipe file `%s' because SAFER option set."
+msgstr ""
+
#: src/flip.c:81
msgid ""
"FLIP ignores TEMPORARY. Temporary transformations will be made permanent."
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: pspp-dev@gnu.org\n"
-"POT-Creation-Date: 2005-03-03 06:08+0800\n"
+"POT-Creation-Date: 2005-03-06 10:44-0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
msgid "installation error"
msgstr ""
-#: src/filename.c:221
-#, c-format
-msgid "Searching for `%s'..."
-msgstr ""
-
-#: src/filename.c:229 src/filename.c:261
-msgid "Search unsuccessful!"
-msgstr ""
-
-#: src/filename.c:254
-#, c-format
-msgid "Found `%s'."
-msgstr ""
-
-#: src/filename.c:686
-#, c-format
-msgid "Not opening pipe file `%s' because SAFER option set."
-msgstr ""
-
#: src/file-type.c:129
msgid "MIXED, GROUPED, or NESTED expected."
msgstr ""
msgid "Unknown record type %g."
msgstr ""
+#: src/filename.c:221
+#, c-format
+msgid "Searching for `%s'..."
+msgstr ""
+
+#: src/filename.c:229 src/filename.c:261
+msgid "Search unsuccessful!"
+msgstr ""
+
+#: src/filename.c:254
+#, c-format
+msgid "Found `%s'."
+msgstr ""
+
+#: src/filename.c:686
+#, c-format
+msgid "Not opening pipe file `%s' because SAFER option set."
+msgstr ""
+
#: src/flip.c:81
msgid ""
"FLIP ignores TEMPORARY. Temporary transformations will be made permanent."
--- /dev/null
+Makefile
+Makefile.in
+evaluate.h
+evaluate.inc
+operations.h
+optimize.inc
+parse.inc
+Sun Mar 6 10:47:13 2005 Ben Pfaff <blp@gnu.org>
+
+ * operations.def: Add VALUE function.
+
+ * parse.c: (parse_function) Need an unary composite node for
+ variables in A TO B, not a variable node. Use
+ allocate_unary_variable().
+ (parse_primary) Use allocate_unary_variable().
+ (allocate_unary_variable) New function.
+
Thu Mar 3 23:53:32 2005 Ben Pfaff <blp@gnu.org>
* PSPP_expressions.pm: Renamed it back to generate.pl but fixed
{
return case_num (c, v->fv) == SYSMIS;
}
+no_opt boolean function VALUE (num_var v)
+ case c;
+{
+ return case_num (c, v->fv);
+}
no_opt operator VEC_ELEM_NUM (idx)
vector v;
struct expression *);
static bool type_check (struct expression *, union any_node **,
enum expr_type expected_type);
+static union any_node *allocate_unary_variable (struct expression *,
+ struct variable *);
\f
/* Public functions. */
atom_type required_type, union any_node **node,
const char *operator_name)
{
- return type_coercion_core (e, required_type, node, operator_name, 1);
+ return type_coercion_core (e, required_type, node, operator_name, true);
}
/* Coerces *NODE to type REQUIRED_TYPE.
type_coercion_assert (struct expression *e,
atom_type required_type, union any_node **node)
{
- int success = type_coercion_core (e, required_type, node, NULL, 1);
+ int success = type_coercion_core (e, required_type, node, NULL, true);
assert (success);
}
is_coercible (atom_type required_type, union any_node *const *node)
{
return type_coercion_core (NULL, required_type,
- (union any_node **) node, NULL, 0);
+ (union any_node **) node, NULL, false);
}
/* How to parse an operator. */
/* It looks like a user variable.
(It could be a format specifier, but we'll assume
it's a variable unless proven otherwise. */
- struct variable *v = parse_dict_variable (e->dict);
- assert (v != NULL);
- return expr_allocate_unary (e,
- (v->type == NUMERIC
- ? OP_NUM_VAR : OP_STR_VAR),
- expr_allocate_variable (e, v));
+ return allocate_unary_variable (e, parse_dict_variable (e->dict));
}
else
{
goto fail;
for (i = 0; i < var_cnt; i++)
add_arg (&args, &arg_cnt, &arg_cap,
- expr_allocate_variable (e, vars[i]));
+ allocate_unary_variable (e, vars[i]));
free (vars);
}
else
n->format.f = *format;
return n;
}
+
+/* Allocates a unary composite node that represents the value of
+ variable V in expression E. */
+static union any_node *
+allocate_unary_variable (struct expression *e, struct variable *v)
+{
+ assert (v != NULL);
+ return expr_allocate_unary (e, v->type == NUMERIC ? OP_NUM_VAR : OP_STR_VAR,
+ expr_allocate_variable (e, v));
+}
+Sun Mar 6 11:03:58 2005 Ben Pfaff <blp@gnu.org>
+
+ * Makefile.am: Add expressions/variables.sh. Remove expr.stat.
+
+ * expr.stat: Removed.
+
'Mon Feb 28 23:31:16 2005 Ben Pfaff <blp@gnu.org>
* Makefile.am: Removed xforms/expressions.sh. Added
stats/percentiles-enhanced.sh \
expressions/expressions.sh \
expressions/epoch.sh \
- expressions/randist.sh
+ expressions/randist.sh \
+ expressions/variables.sh
noinst_PROGRAMS = gengarbage
+++ /dev/null
-title 'Test optimization of constant expressions'.
-
-remark EOF
-----------------------------------------------------------------------
-Testing ability of stat to optimize constant expressions.
-stat must have been compiled with debugging enabled in order to
-run these tests.
-----------------------------------------------------------------------
-EOF
-eval 1+2+3+(4*5).
-eval (4-2+6.323)*(0/4-1)*(1-3+abs(-9.78)).
-eval 3**(2**(8/2*3/4)).
-
-* Truth tables.
-eval 0 and 0.
-eval 0 and 1.
-eval 1 and 0.
-eval 1 and 1.
-
-eval 0 or 0.
-eval 0 or 1.
-eval 1 or 0.
-eval 1 or 1.
-
-eval not 0.
-eval not 1.
-
-eval (1 gt 2) and (2 gt 1).
-eval (7/8+1 lt 2) or (2-1/6 lt 1).
-eval not (7 ne 6).
-
-eval -(7/8).
-eval abs(-6.5).
-eval arcos(1.0).
-eval arcos(sqrt(2)/2).
-eval arsin(sqrt(2)/2).
-eval artan(0).
-eval artan(1.0).
-eval cos(3.141592654/4).
-eval cos(3.141592654/6).
-eval exp(1).
-eval exp(-1).
-eval lg10(10).
-eval lg10(128.910).
-eval ln(2.71828182846).
-eval ln(50).
-eval mod10(128.910).
-eval rnd(128.9).
-eval rnd(-128.9).
-eval rnd(128.1).
-eval rnd(-128.1).
-eval rnd(128).
-eval rnd(-128).
-eval rnd(128.5).
-eval rnd(-128.5).
-eval sin(2*3.141592654).
-eval sin(3.141592654/6).
-eval tan(0).
-eval tan(3.141592654/8).
-eval trunc(3.141592654).
-eval trunc(-9.99).
-
-eval 'x'.
-eval concat('x','y').
-
--- /dev/null
+#!/bin/sh
+
+# This program tests use of variables in expressions.
+
+TEMPDIR=/tmp/pspp-tst-$$
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+
+cleanup()
+{
+ rm -rf $TEMPDIR
+}
+
+
+fail()
+{
+ echo $activity
+ echo FAILED
+ cleanup;
+ exit 1;
+}
+
+
+no_result()
+{
+ echo $activity
+ echo NO RESULT;
+ cleanup;
+ exit 2;
+}
+
+pass()
+{
+ cleanup;
+ exit 0;
+}
+
+mkdir -p $TEMPDIR
+
+cd $TEMPDIR
+
+activity="create program"
+cat > $TEMPDIR/variables.stat <<EOF
+SET MXERR 1000.
+SET MXWARN 1000.
+
+DATA LIST /N1 TO N5 1-5.
+MISSING VALUES N1 TO N5 (3 THRU 5, 1).
+BEGIN DATA.
+12345
+6789
+END DATA.
+
+COMPUTE P1=N1.
+COMPUTE P2=N2.
+COMPUTE P3=N3.
+COMPUTE P4=N4.
+COMPUTE P5=N5.
+
+COMPUTE MC=NMISS(N1 TO N5).
+COMPUTE VC=NVALID(N1 TO N5).
+
+COMPUTE S1=SYSMIS(N1).
+COMPUTE S2=SYSMIS(N2).
+COMPUTE S3=SYSMIS(N3).
+COMPUTE S4=SYSMIS(N4).
+COMPUTE S5=SYSMIS(N5).
+
+COMPUTE M1=MISSING(N1).
+COMPUTE M2=MISSING(N2).
+COMPUTE M3=MISSING(N3).
+COMPUTE M4=MISSING(N4).
+COMPUTE M5=MISSING(N5).
+
+COMPUTE V1=VALUE(N1).
+COMPUTE V2=VALUE(N2).
+COMPUTE V3=VALUE(N3).
+COMPUTE V4=VALUE(N4).
+COMPUTE V5=VALUE(N5).
+
+FORMATS ALL (F1).
+
+LIST.
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="run program"
+$SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/variables.stat > $TEMPDIR/variables.err 2> $TEMPDIR/variables.out
+if [ $? -ne 0 ] ; then fail ; fi
+
+activity="compare results"
+diff -b -B $TEMPDIR/pspp.list - <<EOF
+1.1 DATA LIST. Reading 1 record from the command file.
++--------+------+-------+------+
+|Variable|Record|Columns|Format|
+#========#======#=======#======#
+|N1 | 1| 1- 1|F1.0 |
+|N2 | 1| 2- 2|F1.0 |
+|N3 | 1| 3- 3|F1.0 |
+|N4 | 1| 4- 4|F1.0 |
+|N5 | 1| 5- 5|F1.0 |
++--------+------+-------+------+
+
+N1 N2 N3 N4 N5 P1 P2 P3 P4 P5 MC VC S1 S2 S3 S4 S5 M1 M2 M3 M4 M5 V1 V2 V3 V4 V5
+-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+ 1 2 3 4 5 . 2 . . . 4 1 0 0 0 0 0 1 0 1 1 1 1 2 3 4 5
+ 6 7 8 9 . 6 7 8 9 . 1 4 0 0 0 0 1 0 0 0 0 1 6 7 8 9 .
+EOF
+
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+if [ $? -ne 0 ] ; then fail ; fi
+
+
+
+pass;