Log Message:
-----------
Added missing "step" function that was defined in the AlgParser but
not in the Parser.
Be sure to copy the updated PGanswermacros.pl to the pg/macros directory.
Modified Files:
--------------
pg/lib/Parser:
Legacy.pm
pg/lib/Parser/Legacy:
PGanswermacros.pl
Added Files:
-----------
pg/lib/Parser/Legacy:
Numeric.pm
Revision Data
-------------
Index: Legacy.pm
===================================================================
RCS file: /webwork/cvs/system/pg/lib/Parser/Legacy.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -Llib/Parser/Legacy.pm -Llib/Parser/Legacy.pm -u -r1.1 -r1.2
--- lib/Parser/Legacy.pm
+++ lib/Parser/Legacy.pm
@@ -4,5 +4,6 @@
use Parser::Legacy::NumberWithUnits;
use Parser::Legacy::LimitedNumeric;
+use Parser::Legacy::Numeric;
1;
Index: PGanswermacros.pl
===================================================================
RCS file: /webwork/cvs/system/pg/lib/Parser/Legacy/PGanswermacros.pl,v
retrieving revision 1.6
retrieving revision 1.7
diff -Llib/Parser/Legacy/PGanswermacros.pl -Llib/Parser/Legacy/PGanswermacros.pl -u -r1.6 -r1.7
--- lib/Parser/Legacy/PGanswermacros.pl
+++ lib/Parser/Legacy/PGanswermacros.pl
@@ -1050,7 +1050,7 @@
last;
};
/^arith$/i and do {
- $context = &$Context("Numeric")->copy;
+ $context = &$Context("LegacyNumeric")->copy;
$context->functions->disable('All');
last;
};
@@ -1060,7 +1060,7 @@
};
# default
- $context = &$Context("Numeric")->copy;
+ $context = &$Context("LegacyNumeric")->copy;
}
$context->{format}{number} = $num_params{'format'};
$context->strings->clear;
@@ -1931,7 +1931,7 @@
#
# Initialize the context for the formula
#
- my $context = &$Context("Numeric")->copy;
+ my $context = &$Context("LegacyNumeric")->copy;
$context->flags->set(
tolerance => $func_params{'tolerance'},
tolType => $func_params{'tolType'},
--- /dev/null
+++ lib/Parser/Legacy/Numeric.pm
@@ -0,0 +1,19 @@
+##########################################################
+#
+# Implements a context in which the "step" function
+# is defined. This was defined in the old AlgParser,
+# but not in the Parser's standard Numeric context.
+#
+# Warning: since step is already defined in PGauxiliarymacros.pl
+# we can't redefine it here, so you can't use step(formula) to
+# automatically generate Formula objects, as you can with
+# all the other functions.
+
+package Parser::Legacy::Numeric;
+our @ISA = qw(Parser::Function::numeric);
+sub step {shift; main::step((shift)->value)}
+
+my $context = $Parser::Context::Default::context{Numeric}->copy;
+$Parser::Context::Default::context{LegacyNumeric} = $context;
+$context->functions->add(step => {class => 'Parser::Legacy::Numeric'});
+
|