[system] / trunk / pg / lib / Parser Repository:
ViewVC logotype

Log of /trunk/pg/lib/Parser

View Directory Listing Directory Listing


Sticky Revision:

Revision 6171 - Directory Listing
Modified Sat Dec 5 19:37:13 2009 UTC (8 years, 9 months ago) by dpvc
Added missing comma

Revision 6170 - Directory Listing
Modified Sat Dec 5 19:33:57 2009 UTC (8 years, 9 months ago) by dpvc
Correct output for j vector in Vector2D context (obsolete)

Revision 6136 - Directory Listing
Modified Sat Oct 3 16:40:47 2009 UTC (8 years, 11 months ago) by dpvc
Handle formula 'constants' properly

Revision 6135 - Directory Listing
Modified Sat Oct 3 16:40:09 2009 UTC (8 years, 11 months ago) by dpvc
Handle variables in formula 'constants' properly

Revision 6126 - Directory Listing
Modified Thu Oct 1 22:06:11 2009 UTC (8 years, 11 months ago) by dpvc
Handle arbitrary variable names

Revision 6118 - Directory Listing
Modified Thu Oct 1 14:10:02 2009 UTC (8 years, 11 months ago) by dpvc
Fix error message for powers of negatives

Revision 6058 - Directory Listing
Modified Thu Jun 25 23:28:44 2009 UTC (9 years, 3 months ago) by gage
syncing pg HEAD with pg2.4.7 on 6/25/2009

Revision 5992 - Directory Listing
Modified Thu Feb 5 15:01:44 2009 UTC (9 years, 7 months ago) by dpvc
Removed unused variable

Revision 5977 - Directory Listing
Modified Tue Jan 20 18:54:56 2009 UTC (9 years, 8 months ago) by dpvc
Fixed incorrect parentheses being added when $showparens eq "same"

Revision 5949 - Directory Listing
Modified Tue Dec 30 00:41:40 2008 UTC (9 years, 8 months ago) by dpvc
Fixed the name stored in the StrictFraction context (removed the
trailling s).

Revision 5697 - Directory Listing
Modified Sat Jun 14 22:51:04 2008 UTC (10 years, 3 months ago) by dpvc
Fix typo in changes for "no strict refs".

Revision 5696 - Directory Listing
Modified Sat Jun 14 12:14:21 2008 UTC (10 years, 3 months ago) by dpvc
Added

	 no strict "refs"

to try to avoid new error checking in Perl 5.10.

Revision 5695 - Directory Listing
Modified Sat Jun 14 11:56:02 2008 UTC (10 years, 3 months ago) by dpvc
Fix typo in comments

Revision 5607 - Directory Listing
Modified Thu Jan 31 14:26:45 2008 UTC (10 years, 7 months ago) by dpvc
Fixed differentiation of log() function (it used to give an error
about undefined function D_ln).

Revision 5581 - Directory Listing
Modified Tue Nov 6 16:23:33 2007 UTC (10 years, 10 months ago) by dpvc
When (-x)*y or x*(-y) reductions are performed, don't print extra
parentheses in string and TeX version.  I.e., display as -xy not
-(xy).  This makes reduction with polynomials work better.

Revision 5520 - Directory Listing
Modified Mon Sep 24 22:33:16 2007 UTC (11 years ago) by dpvc
Update the List() object to not add "(" and ")" around the list unless
they are explicitly entered by the author.  This prevents extraneous
parentheses from being introduced into the problem text that the
author hadn't expected.

Parentheses now are added only for nested lists, as in
List(1,List(2,3)), which will display as "1, (2, 3)", not "1, 2, 3".

Revision 5511 - Directory Listing
Modified Sat Sep 15 14:45:22 2007 UTC (11 years ago) by dpvc
Cosmetic changes.

Revision 5510 - Directory Listing
Modified Sat Sep 15 14:44:03 2007 UTC (11 years ago) by dpvc
Reduce -0 to 0.

Revision 5509 - Directory Listing
Modified Sat Sep 15 00:56:51 2007 UTC (11 years ago) by dpvc
Formula objects and Context objects contain reference loops, which
prevent them from being freed properly by perl when they are no longer
needed.  This is a source of an important memory leak in WeBWorK.  The
problem has been fixed by using Scalar::Util::weaken for these
recursive references, so these objects can be freed properly when they
go out of scope.  This should cause an improvement in the memory usage
of the httpd child processes.

Revision 5485 - Directory Listing
Modified Tue Sep 11 14:07:51 2007 UTC (11 years ago) by dpvc
A couple of syntax issues.

Revision 5472 - Directory Listing
Modified Sat Sep 8 22:24:06 2007 UTC (11 years ago) by dpvc
Make vectors that are creates using ijk notation remain in ijk
notation when displayed.  (This is easy now that objects produced by
combining others inherit the parent objects' flags.)

Added another context flag (ijkAnyDimension) that controls whether
vectors in ijk notation will conform to whatever dimension is used by
the vector they are being compared to.  When set, i+2*j will equal
<1,2> even though i and j are vectors in 3-space.  The value of
ijkAnyDimension is 1 by default.

This eliminates the need for the Vector2D context.

Revision 5471 - Directory Listing
Modified Sat Sep 8 21:46:52 2007 UTC (11 years ago) by dpvc
Make copies of the components rather than just copying the pointers.

Revision 5464 - Directory Listing
Modified Fri Sep 7 14:18:30 2007 UTC (11 years ago) by dpvc
Derivatives of absolute values were leaving out the chain rule when
written as |...| (but not as abs(...)).  The chain rule is built into
the derivatives of function objects automatically, but not of lists,
which is how |...| is implemented (a special form of parentheses), and
so I missed it when adding the derivative in this form.  Argh!

Revision 5439 - Directory Listing
Modified Tue Aug 28 21:53:42 2007 UTC (11 years ago) by dpvc
Updated contexts to include a "name" field that at least tracks what
context you started with (though it can be modified and no longer be
the same as the original context).

Remove the individual named variables in the Default.pm file; they are
now available only through the %Parser::Context::Default::context
hash.

Remove the >< and . operators, the <...> parentheses, the norm and
unit functions, and the i, j, and k constants from the Point context.
So the Point context no longer includes vectors and vector
operaterations.

Revision 5432 - Directory Listing
Modified Sun Aug 26 18:53:23 2007 UTC (11 years, 1 month ago) by dpvc
Only try to form intervals from lists that could be intervals when
they are of length 2.

Revision 5408 - Directory Listing
Modified Fri Aug 24 03:02:54 2007 UTC (11 years, 1 month ago) by dpvc
Load the UNIVERSAL package and make it available to Parser Items and Contexts.

Revision 5387 - Directory Listing
Modified Sun Aug 19 21:31:17 2007 UTC (11 years, 1 month ago) by dpvc
Always make units be in \textstyle (in particular, in the preview display).

Revision 5377 - Directory Listing
Modified Sun Aug 19 14:41:26 2007 UTC (11 years, 1 month ago) by dpvc
Make sure clear doesn't remove the special 'start' paren that is
required by the Parser class.

Revision 5375 - Directory Listing
Modified Sun Aug 19 03:39:10 2007 UTC (11 years, 1 month ago) by dpvc
Improved method of looking up the item class so that it will work with
more deeply nested namespaces.

Revision 5369 - Directory Listing
Modified Sun Aug 19 00:30:41 2007 UTC (11 years, 1 month ago) by dpvc
The "undef" in Parser::Context->getCopy(undef,"NAME") is no longer
needed, and will be ignored if provided, but you can now use

    Parser::Context->getCopy("NAME");

which is more reasonable to read.

Revision 5367 - Directory Listing
Modified Sat Aug 18 23:46:02 2007 UTC (11 years, 1 month ago) by dpvc
Include extra parens when they have been requested.

Revision 5331 - Directory Listing
Modified Wed Aug 15 04:10:41 2007 UTC (11 years, 1 month ago) by dpvc
Added a reduce flag for x^1 processing (it was not able to be
disabled before).

Revision 5323 - Directory Listing
Modified Tue Aug 14 15:57:19 2007 UTC (11 years, 1 month ago) by dpvc
Fixed a problem where Real's were being promoted to NumberWithReals
during the numeric comparison (when units should be ignored).  This
error was a result of the changes made this summer.

[This class should probably be redesigned to implement the overloaded
operators and, in particular, handle the equality check in compare()
rather than an over-ridden cmp_parse.  That would make it possible to
manipulate numbers-with-units via perl code in a natural way, just
like all the other MathObjects.]

Revision 5252 - Directory Listing
Modified Thu Aug 9 06:01:48 2007 UTC (11 years, 1 month ago) by dpvc
Make sure ^ is quoted in character patterns so it doesn't become a
negatted character pattern.

Revision 5238 - Directory Listing
Modified Tue Aug 7 04:30:59 2007 UTC (11 years, 1 month ago) by dpvc
Use getCopy() rather than depricated get() method.

Revision 5237 - Directory Listing
Modified Tue Aug 7 04:30:27 2007 UTC (11 years, 1 month ago) by dpvc
Allow Context()->variables-add(name=>[type,options]) format for
declaring a variable.

Revision 5132 - Directory Listing
Modified Mon Jul 9 19:54:21 2007 UTC (11 years, 2 months ago) by dpvc
Better control over when extra parentheses are added.

Revision 5131 - Directory Listing
Modified Mon Jul 9 19:53:15 2007 UTC (11 years, 2 months ago) by dpvc
Remove the space inserted by \left...\right when it appears in a
multiplication operation (so function calls look better, for example).

Revision 5130 - Directory Listing
Modified Mon Jul 9 12:45:06 2007 UTC (11 years, 2 months ago) by dpvc
Added new flags to error checking of operands and function arguments.
This is so that a context can be developed that is more forgiving
about what can be put next to what.  Such a context can NOT be used
for evaluation or answer checking, but can be used to generate TeX
output in more sophisticated situations.

Revision 5124 - Directory Listing
Modified Wed Jul 4 20:13:03 2007 UTC (11 years, 2 months ago) by dpvc
Make the patterns be pre-compiled patterns for efficiency.

Revision 5123 - Directory Listing
Modified Wed Jul 4 20:11:17 2007 UTC (11 years, 2 months ago) by dpvc
Make sure the caiseInsensitive array is copied when the context is
copied (so that the token list will be maintained correctly).

Revision 5122 - Directory Listing
Modified Wed Jul 4 17:04:51 2007 UTC (11 years, 2 months ago) by dpvc
Allow constants to be defined by a hash (like everything else) if desired.

Revision 5121 - Directory Listing
Modified Wed Jul 4 17:02:26 2007 UTC (11 years, 2 months ago) by dpvc
Cosmetic change.

Revision 5120 - Directory Listing
Modified Wed Jul 4 17:00:18 2007 UTC (11 years, 2 months ago) by dpvc
Allow constants to override their string representations.

Revision 5119 - Directory Listing
Modified Wed Jul 4 01:19:18 2007 UTC (11 years, 2 months ago) by dpvc
Removed some unneeded spaces in the comments.

Revision 5118 - Directory Listing
Modified Wed Jul 4 01:18:52 2007 UTC (11 years, 2 months ago) by dpvc
Make string() method use the separator specified in the List
definition rather than a hard coded comma.

Revision 5116 - Directory Listing
Modified Tue Jul 3 10:44:30 2007 UTC (11 years, 2 months ago) by dpvc
Modified the method used to tokenize a formula to use one large
pattern that includes all the token types rather than individual
patterns for variables, strings, operators, and so on.  This allows
the Parser to handle the situation where a token of one type is a
prefix of a token of another type (e.g., < as a parenthesis but <- as
an operator) without worrying about which one is checked first.  The
new mtheod is also more flexible about having additional patterns
(like quoted strings, or arbitrary variable names) and about
specifying the order in which they are applied.

Revision 5114 - Directory Listing
Modified Mon Jul 2 23:21:06 2007 UTC (11 years, 2 months ago) by dpvc
Fixed error in derivative of quotients introduced by recent bad editing.

Revision 5107 - Directory Listing
Modified Sun Jul 1 18:25:24 2007 UTC (11 years, 2 months ago) by dpvc
Arrange for creation of constant Matrices to produce 1 x n matrices
(rather than vectors) properly.  (This involves including an extra
array reference in List.pm, which must be removed in list types that
don't need them, namely intervals and absolute value.)

Revision 5105 - Directory Listing
Modified Sun Jul 1 11:18:39 2007 UTC (11 years, 2 months ago) by dpvc
Do a better version of promote (get the context right) for these
function calls.

Revision 5082 - Directory Listing
Modified Fri Jun 29 19:08:04 2007 UTC (11 years, 2 months ago) by dpvc
Only promote complex numbers of they aren't already complex (this
prevents changing the context, since Parser::Function->call is called
directly, so $self->context is the current context, not the context of
the argument being passed).

Revision 5067 - Directory Listing
Modified Thu Jun 28 22:33:31 2007 UTC (11 years, 2 months ago) by dpvc
Added perl method so that the result is always a number (not a blank
when it is false).

Revision 5060 - Directory Listing
Modified Thu Jun 28 20:42:53 2007 UTC (11 years, 2 months ago) by dpvc
Use Value->context rather than $$Value::context.

Revision 5026 - Directory Listing
Modified Sat Jun 23 20:08:07 2007 UTC (11 years, 3 months ago) by dpvc
Make the Package method really be a method of the context rather than
the Value objects, and make the Value method call the context one.
This means it is not necessary to pass the context as a parameter any
longer.

Revision 5024 - Directory Listing
Modified Sat Jun 23 19:46:00 2007 UTC (11 years, 3 months ago) by dpvc
Fix typo, and handle case where Allow is called from package.

Revision 5023 - Directory Listing
Modified Sat Jun 23 19:45:17 2007 UTC (11 years, 3 months ago) by dpvc
Make context method work when called from package rather than blessed object.

Revision 5015 - Directory Listing
Modified Fri Jun 22 01:56:06 2007 UTC (11 years, 3 months ago) by dpvc
more fixes to handle the contexts properly.

Revision 5014 - Directory Listing
Modified Fri Jun 22 00:26:47 2007 UTC (11 years, 3 months ago) by dpvc
Fixed context issues and a typo (must have been interrupted when
editing this file earlier).  Also modified the units pattern to allow
trailing spaces.

Revision 5013 - Directory Listing
Modified Thu Jun 21 23:29:10 2007 UTC (11 years, 3 months ago) by dpvc
Don't use \cdot with things like 3i.

Revision 5012 - Directory Listing
Modified Thu Jun 21 23:10:13 2007 UTC (11 years, 3 months ago) by dpvc
Added Package method to the Context object to replace the
Value->Package() calls and simplify the $self->Package calls (don't
have to look up the context again).

Revision 5004 - Directory Listing
Modified Fri Jun 15 03:17:31 2007 UTC (11 years, 3 months ago) by dpvc
Only set the context if the data is a MathObject.

Revision 5001 - Directory Listing
Modified Tue Jun 12 04:05:56 2007 UTC (11 years, 3 months ago) by dpvc
More fixes for creating items in the corret context.  Also added a
method for looking up the package associated with a particular Parser
class (for consistency with the Value->Package call).

Revision 4996 - Directory Listing
Modified Sun Jun 10 11:34:27 2007 UTC (11 years, 3 months ago) by dpvc
Allow promote() to accept a context as the first argument so that the
promoted object can be forced into the given context.

Revision 4994 - Directory Listing
Modified Sun Jun 10 01:17:29 2007 UTC (11 years, 3 months ago) by dpvc
Update to handle the fact that the Value package now includes the
context with all MathObjects.  (This may still need some work.)

Revision 4981 - Directory Listing
Modified Thu Jun 7 12:35:02 2007 UTC (11 years, 3 months ago) by dpvc
Context() now always makes a copy of the context, even if it comes
from the problem's local contxt table.  That way it will work
consistently no matter where the context comes from.  (In the past, if
PGcourse.pl made a local copy of a context that it could modify, for
example, then Context() would not copy it when it was called, and that
means problems that relied on Context(name) resetting the context to
its original values would not work properly.

Revision 4980 - Directory Listing
Modified Thu Jun 7 12:30:28 2007 UTC (11 years, 3 months ago) by dpvc
Updated to include some recent changes in documentation and removal of
old commented-out code.

Revision 4979 - Directory Listing
Modified Thu Jun 7 11:59:05 2007 UTC (11 years, 3 months ago) by dpvc
More updates for marking MathObjects with the context in which they
were created, so they should now work like the Formula objects in that
respect.  As they are combined via overloaded operators, they should
pass on their contexts correctly.

Also normalized the use of getFlag() to obtain flags from the
MathObject's context rather than looking in the context directly.
This allows the math object to override the flag by setting the flag
value in the object's hash (e.g., $f->{tolerance} = .001).  I've also
added the ability to override context flags via the answerHash (e.g.,
$f->cmp(tolerance => .001)), though some filtering may need to be
added to this at some point.  Note that ONLY the context flags can be
overridden, not other parts of the context.

Revision 4975 - Directory Listing
Modified Wed Jun 6 21:44:05 2007 UTC (11 years, 3 months ago) by dpvc
This begins some major updates to the Parser and Value libraries.
This may make the MathObjects unstable as things shake down, but I'll
try to keep that to a minimum.

This update reorganizes how the overloading of operations are
implemented.  The base Value class is now overloaded rather than the
individual Value classes.  This makes it easier to make subclasses
that take advantage of the overloading.

The code that handles promoting one MathObject to another has been
updated as a part of this.  This should also make subclassing the
existing MathObjects more flexible.

In the past, Formula objects included a pointer to the Context in
which the object was created, but other MathObject did not.  This
update is the first round of updates to include the context in the
other MathObjects, but more work needs to be done.

The changes here should not affect existing problems; it is possible
that some macro files will need to be updated, but none of the
standard ones in pg/macros seem to need it at the moment.

Revision 4928 - Directory Listing
Modified Tue Apr 17 00:36:16 2007 UTC (11 years, 5 months ago) by dpvc
Modified the way the Parser-based versions of the traditional answer
checkers get copies of their contexts.  They now use a new method
getCopy to obtain the copy either from the problem's context table or
the default table (rather than only from the default).  That way the
instructor can use parserCustomization.pl to customize the contexts
used by the answer checkers.

Revision 4927 - Directory Listing
Modified Tue Apr 17 00:31:13 2007 UTC (11 years, 5 months ago) by dpvc
Added a Vector2D context that has i and j defined as vectors in
2-space so that they can be used to generate vectors in 2D.  This
avoids students getting the "incorrect number of coordinates" error.

Revision 4765 - Directory Listing
Modified Sat Feb 3 15:23:05 2007 UTC (11 years, 7 months ago) by gage
Begin pod documentation.

Revision 4729 - Directory Listing
Modified Sat Dec 16 14:10:12 2006 UTC (11 years, 9 months ago) by dpvc
Add a new operator // to be the same as / except its TeX form is a/b
rather than \frac{a}{b}.  This makes it possible get horizontal
fractions in exponents, for example, where vertical fractions often
don't look so good.

Revision 4672 - Directory Listing
Modified Mon Nov 27 04:20:40 2006 UTC (11 years, 9 months ago) by dpvc
Abstracted the NumberWithUnits to a more general ObjectWithUnits and
moved the FormulaWithUnits to this file as well, since most of the
code is common.  Although, strictly speaking, FormulaWithUnits is not
legacy code, since the general object-with-units is here, it will be
easier to maintain FormulaWithUnits here as well.  When the Parser
gets a real units class, all of this can be removed.

Also fixed the unit lookup code to use the actual names from the Units
library, so we can now be more accurate about determining the extent
of the units, and can handle things like '5 kg m / s' now.  In the
case of ambiguous formulas with units, e.g., '5m kg' where m is a
variable, use '5*m kg' or '(5m) kg'.

Revision 4669 - Directory Listing
Modified Mon Nov 27 00:00:46 2006 UTC (11 years, 9 months ago) by dpvc
The Units.pm library only accepts one division within the units, and
the Parser wasn't taking that into account, so students could enter
m/s/s and still get credit even if the units were m/s.  This have been
fixed.

Revision 4667 - Directory Listing
Modified Sun Nov 26 21:58:43 2006 UTC (11 years, 9 months ago) by dpvc
Fixed a problem where the TeX version included two copies of the units
(one in TeX mode and one from the string() output).

Revision 4583 - Directory Listing
Modified Mon Oct 23 11:43:40 2006 UTC (11 years, 11 months ago) by dpvc
Make sure \cdot is only used for a numeric right-hand part (finishes
fix of bug 1114).

Revision 4582 - Directory Listing
Modified Mon Oct 23 11:38:14 2006 UTC (11 years, 11 months ago) by dpvc
Use \cdot when a number is followed by a numeric fraction.
(Fixes bug 1114.)

Revision 4546 - Directory Listing
Modified Thu Oct 5 11:10:06 2006 UTC (11 years, 11 months ago) by dpvc
Fixed bad check for if the complex number is 1 (caused reduce to
incorrectly remove the complex number when used in multiplication).

Revision 4528 - Directory Listing
Modified Wed Sep 27 17:15:18 2006 UTC (11 years, 11 months ago) by dpvc
Fixed problem where a zero with units would me marked as "not looking
like anumber with units".

Revision 4511 - Directory Listing
Modified Wed Sep 20 23:38:38 2006 UTC (12 years ago) by dpvc
Make a more sophisticated unit check so that it will handle things
like "3ft / s" (that don't have a space before the units).

Really need to make a units class for the Parser.

Revision 4510 - Directory Listing
Modified Wed Sep 20 21:50:56 2006 UTC (12 years ago) by dpvc
Fixed unit checking so that units can include spaces (like 4 ft /
min).  Also fixed a problem where units were not being reported as
part of the student's entered answer.

Revision 4488 - Directory Listing
Modified Mon Sep 11 22:23:45 2006 UTC (12 years ago) by dpvc
Allow matrices to set their own templates (instead of using "c" for
all columns), and handle missing open and close delimiters better.

Revision 4487 - Directory Listing
Modified Mon Sep 11 22:21:49 2006 UTC (12 years ago) by dpvc
Allow the _check subroutine to affect the {isConstant} field.

Revision 4454 - Directory Listing
Modified Thu Sep 7 01:18:08 2006 UTC (12 years ago) by dpvc
Added ability to overrid TeX and perl versions by specifying a TeX or
perl field in the variable definition.  Also made vector-valued
variables show up in bold.

Revision 4300 - Directory Listing
Modified Wed Jul 26 13:18:25 2006 UTC (12 years, 2 months ago) by dpvc
Fixed a problem with derivatives of constant-valued Matrices (and
vectors and points).  They were incorrectly getting an extra level of
nesting.

Revision 4299 - Directory Listing
Modified Wed Jul 26 12:27:07 2006 UTC (12 years, 2 months ago) by dpvc
Extended the differentiation operator to handle multiple derivatives:

	  $f->D("x","y")    is the same as $f->D("x")->D("y")
	  $f->D(2)          is the same as $f->D->D
	  $f->D(2,"x")      is the same as $f->D("x")->D("x")

and so on.

Revision 4044 - Directory Listing
Modified Thu Apr 6 00:23:59 2006 UTC (12 years, 5 months ago) by dpvc
Fixed a bug that caused can error when a Complex1 object was passed to
the answer checker (rather than a string that needs to be parsed).

Revision 4028 - Directory Listing
Modified Sat Feb 18 22:42:55 2006 UTC (12 years, 7 months ago) by dpvc
Change check for zero from fuzzy check to strict check (when the
problem used absolute tolerances, in particular, this can causebig
problems).

Revision 3915 - Directory Listing
Modified Tue Jan 17 02:20:19 2006 UTC (12 years, 8 months ago) by dpvc
Fixed problem with formula-valued matrices producing an error message
incorrectly.  (Was checking the wrong attribute of the entries.)

Revision 3913 - Directory Listing
Modified Tue Jan 17 01:56:24 2006 UTC (12 years, 8 months ago) by dpvc
Fixed problem with variables that are multiplied with no space between
them (e.g., "ax") that was introduced when I changed the pattern to
allow multi-letter variable names.

The solution is to first check against the defined names before
checking for the more complete name pattern.

Revision 3866 - Directory Listing
Modified Sat Dec 31 01:39:54 2005 UTC (12 years, 8 months ago) by dpvc
Allow multi-letter variable names and names like x1, x2, etc.

Revision 3782 - Directory Listing
Modified Thu Dec 1 13:17:27 2005 UTC (12 years, 9 months ago) by dpvc
Fixed a problem with not including parentheses when a negative number
is the base of a power. (And in general, when a negative is used as an
operand of a higher-precendence operation, but it really only affected
powers.)

Revision 3763 - Directory Listing
Modified Thu Nov 17 13:21:43 2005 UTC (12 years, 10 months ago) by dpvc
Give better error messages when the entries in Points, Vectors and
Matrices are not of the right type.

Revision 3762 - Directory Listing
Modified Thu Nov 17 13:20:50 2005 UTC (12 years, 10 months ago) by dpvc
Adjusted the parentheses slightly so that matrices will only be formed
in Matrix context, not Point or Vector context (this produced
confusing messages for students in some circumstances where they didn't
balence their parentheses correctly).

Revision 3714 - Directory Listing
Modified Sun Oct 16 02:44:34 2005 UTC (12 years, 11 months ago) by dpvc
Modified context data objects to provide a copy method so that the
various types of data can copy themselves (and can provide a more
comprehensive copy if necessary).

Revision 3703 - Directory Listing
Modified Mon Oct 10 23:47:26 2005 UTC (12 years, 11 months ago) by dpvc
Add a new context flag that controls how the student answer should be
displayed.  The formatStudentAnswer flag can be set to 'evaluated'
(the default), which shows the final numeric answer; 'parsed', which
shows the fully parsed version (including extra parentheses for
clarity); or 'reduced', which performs constant operations, but
doesn't perform function evaluations or named-constant substitutions.

For example, if the student answers 1+2+sqrt(3), then 'evaluated' will
produce  4.73205, 'reduced' will show 3+sqrt(3), and 'parsed' will
show 1+2+sqrt(3).

Revision 3702 - Directory Listing
Modified Mon Oct 10 23:41:05 2005 UTC (12 years, 11 months ago) by dpvc
If constant functions are not being reduced, don't mark the function
call as constant (since otherwise it might be evaluated later accidentally).

Revision 3652 - Directory Listing
Modified Sat Sep 24 00:47:30 2005 UTC (13 years ago) by dpvc
Added ability to have answers that are empty strings.  String("") now
will produce a valid string object regardless of the Context's defined
string values.  (You can prevent this using

       Context()->flags->set(allowEmptyStrings=>0);

if you wish).  String("")->cmp will produce an answer checker for an
empty string (it removes the blank checker that WW installs).

Revision 3637 - Directory Listing
Modified Mon Sep 19 00:16:24 2005 UTC (13 years ago) by dpvc
Prevent the empty list from having open and close be set to 'start'
(a value used internally).

Revision 3603 - Directory Listing
Modified Wed Sep 7 01:10:58 2005 UTC (13 years ago) by dpvc
Added support for cplx_cmp() using the Parser.  Move
lib/Parser/Legacy/PGcomplexmacros.pl to the pg/macros directory to use
it.  As with the other legacy macros, $useOldAnswerMacros can be
controlled to determine whether the new or the old macros are used.

There is a new mode 'strict_cartesian' that is parallel to
'strict_polar'.  You must enter a+bi form, but the a and b can have
operations within them.

Revision 3591 - Directory Listing
Modified Tue Aug 30 12:21:36 2005 UTC (13 years ago) by dpvc
The perl method for UOP and BOP now put spaces around the operator, to
prevent Perl from thinking that things like -e is a file test and
*Parser::Function->call is a name reference.  (Some of these had been
done by hand earlier, but now the base BOP and UOP classes handle it,
so we should not have problems in the future).  I removed the ad hoc
fixes from several other locations (Parser/Function.pm,
Parser/Context/Default.pm).

Also extended the operator definitions to allow operators to create
function-call syntax in perl mode (for when the operator doesn't
correspond to a perl operator).

Revision 3587 - Directory Listing
Modified Tue Aug 30 00:36:55 2005 UTC (13 years ago) by dpvc
Added a Point context that is a copy of the Vector context.  This will
allow users to override some settings in Vector context (namely, how
they are entered and displayed) without preventing users from being
able to enter points (in Point context).

Revision 3578 - Directory Listing
Modified Fri Aug 26 14:06:39 2005 UTC (13 years, 1 month ago) by jj
Fix bug where perl functions which may need parentheses by forcing them
when the function starts Parser::Function->.  This seems to work, but
there might be a better way to do it, or need other cleaning up.

Revision 3574 - Directory Listing
Modified Thu Aug 25 18:32:01 2005 UTC (13 years, 1 month ago) by jj
Updated instructions to match changes to global.conf.dist and the move
or PGanswermacros.pl.

Revision 3573 - Directory Listing
Modified Thu Aug 25 18:24:55 2005 UTC (13 years, 1 month ago) by jj
A separate copy of this file is no longer needed.

Revision 3569 - Directory Listing
Modified Thu Aug 25 03:40:44 2005 UTC (13 years, 1 month ago) by dpvc
Fixed problem with Context's not properly initializing themselves with
the WW environment parameters (like zeroLevelTol and useBaseTenLog).
The copy method and the method that did an initialized copy used to be
separate routines, but that turned out to be unnecessary, so they have
now been merged (copy always tries to initialize the WW values when it
can, and when the copied context doesn't already have them).

The reason this is complicated is that a number contexts are set up
before the global.conf data is available, so these can't be
initialized with the WW values.  Also, these default contexts are
stored in the persistant processes, and we don't want to leave
possibly course-specific values lying around in them, so whenever a
context is selected, it is copied from the standard version and the
WW parameters are inserted into it.  The problem author can only
modify the copy, not the original, so this is OK with mod_perl.

The context's copy method now always tries to initialize (we used to
have to call initCoopy to get a copy that has the WW parameters
inserted).  That turned out to cause trouble with code that handled
contexts without the usual Context() command.

Revision 3568 - Directory Listing
Modified Thu Aug 25 03:32:16 2005 UTC (13 years, 1 month ago) by dpvc
Fixed log and log10 perl methods so that log obeys the useBaseTenLog
flag, and log10 doesn't try to call main::log10, which is not
available from within this preloaded package.  The in- and outside
the safe compartment stuff is very confusing, and functions that are
not overloaded native perl functions seem to be not callable from the
Value::Formula package, so the perl method now calls
Parser::Function->call() directly (doesn't look pretty, but I've given
up on that).

Revision 3560 - Directory Listing
Modified Wed Aug 24 11:44:49 2005 UTC (13 years, 1 month ago) by dpvc
Made relative tolerances the default for when the tolType is not one
of 'relative' or 'absolute'.

Revision 3536 - Directory Listing
Modified Sat Aug 20 23:07:13 2005 UTC (13 years, 1 month ago) by dpvc
Added code to handle the case where the professor's answer is in
expondential notation using a little e instead of a big one.  (Perl
will convert .0000001 to 1E-07, for example, before it is passed to
num_cmp.)

Revision 3531 - Directory Listing
Modified Mon Aug 15 22:42:37 2005 UTC (13 years, 1 month ago) by dpvc
Fixed more undefined values

Revision 3529 - Directory Listing
Modified Mon Aug 15 01:50:21 2005 UTC (13 years, 1 month ago) by dpvc
Changed Context() call to direct reference to context, so as not to
leave the wrong content selected as the current one.

Revision 3523 - Directory Listing
Modified Sat Aug 13 22:38:39 2005 UTC (13 years, 1 month ago) by dpvc
Added canBeInUnion and isSetOfReals methods to the Parser package
(similar to the ones in the Value package), replacing the
canBeInterval flag and other ad hoc checks.

Removed ability to form interval like [a] now that we have sets.

Revision 3516 - Directory Listing
Modified Sat Aug 13 20:59:28 2005 UTC (13 years, 1 month ago) by dpvc
Added isSetOfReals and canBeInUnion methods to the Value objects, and
replaced the ad hoc tests for these conditions to call these
routines.

Cleaned up the make() methods for Intervals, Sets and Unions, and
improved the new() methods to handle more cases better.

Fixed Value::makeValue() to handle an array reference correctly.

I don't THINK any of this will break anything.  :-)

Revision 3510 - Directory Listing
Modified Sat Aug 13 17:32:58 2005 UTC (13 years, 1 month ago) by dpvc
Fixed a problem with redefine when used with classes that store their
data in a on-standard form (i.e., by overridding the create()
method).  Now they can define uncreate() to get the original data back
for use with redefine().

Revision 3500 - Directory Listing
Modified Sat Aug 13 01:39:14 2005 UTC (13 years, 1 month ago) by dpvc
Fixed typo in previous update.

Revision 3499 - Directory Listing
Modified Sat Aug 13 00:41:24 2005 UTC (13 years, 1 month ago) by dpvc
Added sets to the differentiation information (no derivatives allowed)

Revision 3497 - Directory Listing
Modified Sat Aug 13 00:25:27 2005 UTC (13 years, 1 month ago) by dpvc
Added ability for Unions and Sets to simplify themselves
(automatically or on demand), and added flags to the Context and
answer checkers to control these features.  The new Context flags
are

    reduceUnions                tells whether unions are automatically
                                reduced when they are created.

    reduceUnionsForComparison   tells whether unions are reduced
                                before comparing them for equality
                                or inequality (etc) if they aren't
                                reduced already.

    reduceSets                  tells whether redundent elements are
                                removed from sets as they are created.

    reduceSetsForComparison     tells whether sets are reduced before
                                comparing them.

All of these default to true.

The Interval, Set, Union, and List answer checkers not have two new
flags for controlling these values:

    studentsMustReduceUnions    tells whether unions and sets will be
                                counted as incorrect when they are not
                                reduced to non-overlapping intervals
                                and at most one set with no repeated
                                entries.

    showUnionReduceWarnings     tells whether an error message will
                                be produced for non-reduced unions and
                                sets, or if they will be marked wrong
                                silently.  (Not available in Lists.)

Both of these are true by default, since most professors probably want
their students to write intervals in reduced form.  (Is this true?)
This corresponds the the current behavior of the interval checkers,
which require the student's answer to be the same set of intervals as
in the professor's, but with the addition of an error message when the
student answer is not reduced.

Revision 3495 - Directory Listing
Modified Fri Aug 12 23:21:52 2005 UTC (13 years, 1 month ago) by dpvc
Fixed use of undefined value for $position in TeX and String methods.

Revision 3494 - Directory Listing
Modified Fri Aug 12 23:02:11 2005 UTC (13 years, 1 month ago) by dpvc
Made the 'R' constant in Interval context show up as a bold R in TeX
mode.

Revision 3491 - Directory Listing
Modified Fri Aug 12 22:54:38 2005 UTC (13 years, 1 month ago) by dpvc
Mark function as constant if it is.

Revision 3483 - Directory Listing
Modified Fri Aug 12 01:21:48 2005 UTC (13 years, 1 month ago) by dpvc
Added redefine() function to complement undefine() for various
Context() values.  For example

      Context()->operators->undefine('+');

makes '+' undefined, but

      Context()->operators->redefine('+');

will put it back.  You can specify a context from which to take the
redefinition, and a name in that context, as in

      Context()->operators->redefine('U',from=>"Interval");
      Context()->operators->redefine('u',from=>"Interval",using=>"U");
      Context()->operators->redefine('U',from=>$content);

where $content is a reference to a Context object.

The undefine() function lets you undefine several items at once, as in

      Context()->operators->undefine('+','-');

For redefine, you must put multiple names in square brackets because
of the optional parmeters:

      Context()->operators->redefine(['+','-']);

Revision 3482 - Directory Listing
Modified Fri Aug 12 01:15:30 2005 UTC (13 years, 1 month ago) by dpvc
Fixed bug with missing fields in initialization.

Revision 3477 - Directory Listing
Modified Thu Aug 11 20:57:18 2005 UTC (13 years, 1 month ago) by dpvc
Added ability to subtract intervals, sets and unions.  Adjusted the
precedence of the union 'U' to be above _ and + so that things like
(1,5) U (7,10) - {8} U (2,3) will do ((1,5) U (7,10)) - ({8} U (2,3))
rather than the previous (1,5) U ((7,10) - {8}) U (2,3).  Finally,
added a constant 'R' to the Interval context that is equivalent to
(-inf,inf), so you can do things like R-{0} now.

Still need to work out reducing unions so that things like (1,3)U(2,4)
can become (1,4).

Revision 3474 - Directory Listing
Modified Thu Aug 11 14:37:18 2005 UTC (13 years, 1 month ago) by dpvc
Changes needed for new Set object, plus for moving string, TeX and
perl into Value.pm.  Also removed unneeded spaces in perl versions of
the constants (these were to fix problems with the minus sign, but
that is now being handled by the minus operators themselves).

Revision 3473 - Directory Listing
Modified Thu Aug 11 14:34:24 2005 UTC (13 years, 1 month ago) by dpvc
Changes needt for Set object, and fixed a bug with unions containing
constant intervals with non-constant ones.

Revision 3466 - Directory Listing
Modified Thu Aug 11 14:19:26 2005 UTC (13 years, 1 month ago) by dpvc
Added new Set object class to the Parser.  It implements a finite set
of real numbers, for use with unions and intervals.  E.g., (1,2) U {3}
or (1,2) U {3,4,5}.  You can created Set objects in your perl code via
the Set() command, e.g, Set(3,4,5) or Set("{1,2,3}").  You should set
the Context to Context("Interval") if you plan to use Set objects, as
this defined the braces to form sets (rather than using them as
parentheses, which is the default WW behavior).  Note that in Interval
context, you can NOT use braces as parentheses.

Current, Set objects are only allowed to be sets of numbers.  It would
be possible to extend that in the future.

Revision 3465 - Directory Listing
Modified Thu Aug 11 00:38:33 2005 UTC (13 years, 1 month ago) by dpvc
Make upper-case alias a hidden one (since it is not needed for the
pattern).

Revision 3464 - Directory Listing
Modified Thu Aug 11 00:37:35 2005 UTC (13 years, 1 month ago) by dpvc
Dereference aliases to aliases properly.

Revision 3458 - Directory Listing
Modified Wed Aug 10 14:28:59 2005 UTC (13 years, 1 month ago) by dpvc
The Parser versions of num_cmp and fun_cmp incorrectly left the
current Context set to the base context used by the answer checker.
The Context is now correctly reset to the one in effect before the
call to num_cmp or fun_cmp.

Also removed some redundant values in if-then checks.

Revision 3446 - Directory Listing
Modified Mon Aug 1 15:14:20 2005 UTC (13 years, 1 month ago) by dpvc
Fixed a bug that would cause step() to produce an error when called on
a constant value.  Also, added fact() function that was defined in
Algparser but not in Parser (which uses x! notation).

Revision 3445 - Directory Listing
Modified Mon Aug 1 14:20:16 2005 UTC (13 years, 1 month ago) by dpvc
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.

Revision 3443 - Directory Listing
Modified Mon Aug 1 12:42:21 2005 UTC (13 years, 1 month ago) by dpvc
Added postfilter to Parser-based implementation of NUM_CMP so that the
student's answer is updated to be the result of evaluating the answer
(when there is no error in evaluating the answer).  This correctly
reflects the behaviour of the original NUM_CMP.

Revision 3441 - Directory Listing
Modified Mon Aug 1 12:04:23 2005 UTC (13 years, 1 month ago) by dpvc
Updates to make mode=>'frac' properly emulate the original num_cmp
behavior (it now allows decimals and fractions instead of requiring a
fraction).  There is also a new LimitedNumeric-StrictFraction context
(not currently used) that disallows decimals and requires fractions.

Revision 3440 - Directory Listing
Modified Mon Aug 1 12:01:39 2005 UTC (13 years, 1 month ago) by dpvc
Folded in Mike's changes for status messages.

Revision 3384 - Directory Listing
Modified Sat Jul 16 19:24:31 2005 UTC (13 years, 2 months ago) by jj
Fixed typo related to useBaseTenLog.

Revision 3370 - Directory Listing
Modified Tue Jul 12 22:29:53 2005 UTC (13 years, 2 months ago) by dpvc
A first pass at making parser error messages localizable.  The
Context()->{error}{msg} hash can be used to specify translations of
the standard messages.  For example,

    Context()->{error}{msg}{'Division by zero'} = "Don't divide by zero, dude!";
    Context()->{error}{msg}{'Function '%s' has too many inputs'} =
        "You passed too many arguments to '%s'";

(I didn't translate into another language, here, but you could do
that, too.)

The msg hash could also be used within answer checkers to make certain
answer messages more appropriate for the given type of expected answer.

Revision 3369 - Directory Listing
Modified Tue Jul 12 21:05:37 2005 UTC (13 years, 2 months ago) by dpvc
Fixed various perl compiler warnings (due to extra "my", and so on).

Revision 3367 - Directory Listing
Modified Tue Jul 12 02:02:46 2005 UTC (13 years, 2 months ago) by dpvc
Fixed problem with minus signs in formulas that are turned into perl
mode.  Perl needs extra spaces to avoid problems with -e type operators.

Revision 3364 - Directory Listing
Modified Fri Jul 8 21:45:14 2005 UTC (13 years, 2 months ago) by jj
Fixed typo in installation instructions.

Revision 3353 - Directory Listing
Modified Tue Jul 5 01:43:30 2005 UTC (13 years, 2 months ago) by dpvc
Don't load Parser.pl (it causes trouble with the Matrix.pm module).
We only needed it because of the calls to Real() that were being used
by Formula objects, so have them call Value::Real directly.

be sure to get the latest versions of Parser and Value (including the
top-level Parser.pm and Value.pm) in order to use this update.

Revision 3352 - Directory Listing
Modified Tue Jul 5 01:38:19 2005 UTC (13 years, 2 months ago) by dpvc
Modified the perl() method to make calles to Value:: directly rather
than to the main:: stubs for creating Value objects.  This will make
it work better from within packages or when Parser.pl hasn't been
loaded.

A few things still won't work in this case; e.g., calls to Closed()
for intervals (these could be handled better using ->with()) and to
functions like Factorial and log10 that are defined in Parser.pl.

Finally, there should be better object-based control over what
routines are called to create these objects, so that subclasses of the
Value objects will be able to be generated correctly.

Revision 3351 - Directory Listing
Modified Tue Jul 5 00:31:57 2005 UTC (13 years, 2 months ago) by gage
Modified formatting

Revision 3350 - Directory Listing
Modified Tue Jul 5 00:08:54 2005 UTC (13 years, 2 months ago) by dpvc
Main file that calls in the legacy modules.

Revision 3348 - Directory Listing
Modified Mon Jul 4 20:18:40 2005 UTC (13 years, 2 months ago) by dpvc
Folded in Mike's changes to checkbox_cmp.

Revision 3347 - Directory Listing
Modified Mon Jul 4 20:12:22 2005 UTC (13 years, 2 months ago) by dpvc
This is an attempt at making the traditional answer checkers call the
new Parser in place of their original ones.  That is, if you follow
the instructions in the README file, then problems that use
std_num_cmp(), fun_cmp(), etc. will really be using the new Parser
instead of the original PGanswermacros.pl versions.

The old answer checkers are still available, and can be switched back
on a site-wide, course-wide, or problem-by-problem basis.  See the
README for details.

Revision 3344 - Directory Listing
Modified Mon Jul 4 19:39:37 2005 UTC (13 years, 2 months ago) by dpvc
Fixed problem with sorting (problem with $a, $b, I think).

Revision 3343 - Directory Listing
Modified Mon Jul 4 16:21:04 2005 UTC (13 years, 2 months ago) by dpvc
Handle TeX versions of variables whose names include underscores
better.

Revision 3335 - Directory Listing
Modified Mon Jul 4 03:28:09 2005 UTC (13 years, 2 months ago) by dpvc
Allow Parser::Number::NoDecimals() to accept a context to be modified
(rather than always changing the curent context).

Revision 3334 - Directory Listing
Modified Sun Jul 3 20:10:37 2005 UTC (13 years, 2 months ago) by dpvc
Updates to allow string matches to be case-insensitive.  This is now
the default, and can be overridden in the Context by setting the
string's "caseSensitive" attribute.  e.g.:

	 Context()->strings->add("FooBar"=>{caseSensitive=>1});

would rewuire "FooBar" to be entered exactly as typed.

Revision 3332 - Directory Listing
Modified Sun Jul 3 20:05:28 2005 UTC (13 years, 2 months ago) by dpvc
Fixed a bug in the enable/disable routines that would cause them to
always work on the current context rather than the one whose
enable/disable method was being called.

Revision 3274 - Directory Listing
Modified Thu Jun 9 11:16:01 2005 UTC (13 years, 3 months ago) by dpvc
Fixed Disable() and Enable() so that they can be called as

    Context()->functions->disable()
and
    Context()->functions->enable()

as well as

    Parser::Context::Functions::Disable()
and
    Parser::Context::Functions::Enable()

The former is the preferred syntax.

Revision 3267 - Directory Listing
Modified Sun Jun 5 23:25:20 2005 UTC (13 years, 3 months ago) by dpvc
Allow for vectors to be marked as Column Vectors.

Revision 3221 - Directory Listing
Modified Mon May 2 00:58:00 2005 UTC (13 years, 4 months ago) by dpvc
During a call(), if the evaluation produced an error message generated
by Value::Error, report it, otherwise report a generic message.

Revision 3219 - Directory Listing
Modified Fri Apr 29 22:30:55 2005 UTC (13 years, 4 months ago) by dpvc
Added derivative of |x| as x/|x|.

Revision 3210 - Directory Listing
Modified Thu Mar 31 19:44:49 2005 UTC (13 years, 5 months ago) by dpvc
Added a check that the coordinates are numeric.  This avoids an error
were <i+j+k> was accepted as OK.

Revision 3204 - Directory Listing
Modified Mon Mar 28 23:47:50 2005 UTC (13 years, 5 months ago) by dpvc
Peroperly negate infinities even when reduceConstants is not in
effect.

Revision 3203 - Directory Listing
Modified Mon Mar 28 23:46:06 2005 UTC (13 years, 5 months ago) by dpvc
Handle extra parentheses better.

Revision 3202 - Directory Listing
Modified Mon Mar 28 23:45:27 2005 UTC (13 years, 5 months ago) by dpvc
Handle log as ln or log properly.

Revision 3194 - Directory Listing
Modified Wed Mar 16 13:35:01 2005 UTC (13 years, 6 months ago) by dpvc
removed a commented-out line that was no longer needed.

Revision 3193 - Directory Listing
Modified Wed Mar 16 13:33:59 2005 UTC (13 years, 6 months ago) by dpvc
Fixed a typo.

Revision 2938 - Directory Listing
Modified Tue Oct 19 00:24:47 2004 UTC (13 years, 11 months ago) by dpvc
Added reduction rules to remove redundent negatives.
Override string and TeX methods that avoid redundent parentheses.

Revision 2915 - Directory Listing
Modified Wed Oct 13 03:31:17 2004 UTC (13 years, 11 months ago) by dpvc
Trap errors in functions that are not native perl functions (like
acos() and csc(), etc.).  In the past, if an error occurred within the
definition of a function, the error message that was reported was the
internal error within the definition of the function.  For example
csc(0) would report "illegal division by zero", while acos(-2) would
report "can't take sqrt of -3".  Now the errors will be "can't take
csc of 0" and "can't take acos of -2".

Revision 2914 - Directory Listing
Modified Wed Oct 13 02:41:33 2004 UTC (13 years, 11 months ago) by dpvc
Added support for useBaseTenLogs to make log() work like ln() or
log10() depending on the value in the course.conf file.

Also fixed a bug that caused the WeBWorK parameters not to be
copied into contexts by initCopy().

Revision 2909 - Directory Listing
Modified Tue Oct 12 20:49:25 2004 UTC (13 years, 11 months ago) by dpvc
In Complex context, make sqrt() and log() of negative numbers return
their complex values.  Also make ^ and ** do the same with negative
bases.  These can be controlled by setting/clearing the
"negativeIsComplex" entry for these functions and operators.

Revision 2908 - Directory Listing
Modified Tue Oct 12 20:46:43 2004 UTC (13 years, 11 months ago) by dpvc
Report errors for powers of negative numbers rather than return 'nan'.
Don't allow 'nan' to be made into a Real object.

Revision 2907 - Directory Listing
Modified Tue Oct 12 20:44:20 2004 UTC (13 years, 11 months ago) by dpvc
In StandardPrecedence mode, make the precedence of function apply
match that in use by that AlgParser.

Revision 2842 - Directory Listing
Modified Wed Sep 29 15:47:30 2004 UTC (13 years, 11 months ago) by dpvc
Allow string constants to include spaces.

Revision 2802 - Directory Listing
Modified Sun Sep 19 14:43:32 2004 UTC (14 years ago) by dpvc
Eliminated unneeded parentheses in TeX output when unary minus and
plus are used with fractions.

Revision 2800 - Directory Listing
Modified Sun Sep 19 14:27:39 2004 UTC (14 years ago) by dpvc
Added isZero and isOne checks for Parser::Value objects (i.e., for
constants within formulas).  These now correctly handle vector and
matrices, in particular.  The isOne and isZero checks are used in the
reduce() method to simplify formulas.

Revision 2797 - Directory Listing
Modified Sun Sep 19 01:16:10 2004 UTC (14 years ago) by dpvc
File needed to reduction flags that was accidentally left out of the
previous commit.  Sorry!

Revision 2796 - Directory Listing
Modified Sun Sep 19 01:15:03 2004 UTC (14 years ago) by dpvc
Added flags that control the reductions performed by
Formula()->reduce.  Each reduction operation can be individually
enabled or disabled in the context, and in the reduce() call itself.

More complex reductions need to be developed.

Revision 2795 - Directory Listing
Modified Sat Sep 18 23:16:37 2004 UTC (14 years ago) by dpvc
Fixed typo in addParens method name.

Revision 2789 - Directory Listing
Modified Thu Sep 16 22:24:32 2004 UTC (14 years ago) by dpvc
Added context flags to control automatic reduction of operations that
involve only constant values.  The default is to combine constants,
but this can now be disabled.

Also added a new flag to control the addition of extra parentheses
that make string values painfully unambiguous (these are for
situations that students tend to get wrong).  By default this is
turned off (so that professor answers won't contain excessive
parentheses), but the answer checker will be made to turn this on for
student answers.

Finally, when extra parens are added to formulas, they alternate
between ( ) and [ ] to make it easier to read.

Revision 2788 - Directory Listing
Modified Thu Sep 16 22:19:59 2004 UTC (14 years ago) by dpvc
Produce an error when attempting to auto-create a formula using a
function that has been removed from the current context.

Revision 2771 - Directory Listing
Modified Sat Sep 11 17:11:29 2004 UTC (14 years ago) by dpvc
Fixed a bug with constants where the values were being cached so that
changes in the context were not being reflected in the formulas that
use them.

Revision 2768 - Directory Listing
Modified Fri Sep 10 23:55:31 2004 UTC (14 years ago) by dpvc
When creating formulas from functions, don't evaluate even if the
formula is constant.  (This makes it possible to create automatically
create formulas even if they only contain constants.)

Revision 2756 - Directory Listing
Modified Fri Sep 10 14:48:35 2004 UTC (14 years ago) by dpvc
Changed the error message produced for functions that have been
removed from the parser.  I hope this will be more appropriate for
students.

Revision 2701 - Directory Listing
Modified Sat Aug 28 15:53:09 2004 UTC (14 years ago) by dpvc
Only convert (f(x))^2 to f^2(x) for specified functions f
(as marked in the Context).

Revision 2697 - Directory Listing
Modified Sat Aug 28 12:43:57 2004 UTC (14 years ago) by dpvc
Two more minor TeX improvements.

Revision 2696 - Directory Listing
Modified Sat Aug 28 12:34:56 2004 UTC (14 years ago) by dpvc
Improved TeX and string output in a number of situations.  Improved
use of parentheses to avoid things like x+-3.  Fixed wrong parentheses
in powers.  Display (sin(x))^2 as sin^2(x) in TeX output.

Revision 2687 - Directory Listing
Modified Fri Aug 27 00:28:27 2004 UTC (14 years, 1 month ago) by dpvc
Added ability to have linear adaptive parameters in the function
answer checker.  It only works for real-valued functions, though.
To use a parameter, use

       Context()->variables->add(a=>'Parameter');

and then use 'a' as a variable within your answer.  The student will
not be allowed to enter the parameter, but the professor will.

Note that the correct answer will show the full professor's answer,
including the parameters, even though the student can't type it.  Is
this the right behaviour?

Revision 2684 - Directory Listing
Modified Tue Aug 24 21:35:21 2004 UTC (14 years, 1 month ago) by dpvc
Added the makeUnion call that was removed earlier.  The AnswerChecker
for formulas sometimes called it (when the student's answer is constant).

Revision 2681 - Directory Listing
Modified Tue Aug 24 03:34:47 2004 UTC (14 years, 1 month ago) by dpvc
TeX mode now adds parentheses around fractions, when needed.

Revision 2680 - Directory Listing
Modified Tue Aug 24 03:33:30 2004 UTC (14 years, 1 month ago) by dpvc
Made string function look for a string field in teh definition of the
function as an override for its name. (This way, you can make asin
appear as arcsin or even sin^(-1) if you want).

Revision 2679 - Directory Listing
Modified Tue Aug 24 03:31:47 2004 UTC (14 years, 1 month ago) by dpvc
Fixed wrong error messages when operators are undefined in a context.

Revision 2678 - Directory Listing
Modified Mon Aug 23 23:55:37 2004 UTC (14 years, 1 month ago) by dpvc
Modified the parser so that the classes for the various object
constructors are stored in the context table rather than hard-coded
into the parser.  That way, you can override the default classes with
your own.  This gives you even more complete control to modify the
parser.  (You had been able to replace the definitions of operators,
functions and list-like objects, but could not override the behaviour
of numbers, strings, variables, and so on.  Now you can.)

This effects most of the files, but only by changing the name of the
calls that create the various objects.

There are also a couple of other minor fixes.

Revision 2675 - Directory Listing
Modified Mon Aug 23 04:59:05 2004 UTC (14 years, 1 month ago) by dpvc
Get the type right when evaluating an AbsoluteValue and obtaining a
Value object.

Revision 2672 - Directory Listing
Modified Sun Aug 22 22:46:14 2004 UTC (14 years, 1 month ago) by dpvc
Added easy calls to disable/enable collections of functions or
individual functions in the current context.  So you can say

	   Parser::Context::Functions::Disable('Trig');

to disallow the use of trig functions, or

	   Parser::Context::Functions::Disable('Trig','Numeric');
	   Parser::Context::Functions::Enable('sqrt');

to disable trig and numeric functions (like log, exp, abs, etc) but
allow sqrt.

Note that disabling sqrt() does not disable x^(1/2) (this must be done
through disabling the ^ and ** operators), and disabling abs() does
not disable |x| (which must be done by removing the '|' definition
from the Context's parens list).

Revision 2671 - Directory Listing
Modified Sun Aug 22 21:18:06 2004 UTC (14 years, 1 month ago) by dpvc
Fixed some inconsistencies between handing of matrices within the
parser and Value packages.  Added a predefined Matrix context.

Revision 2668 - Directory Listing
Modified Sun Aug 22 02:55:38 2004 UTC (14 years, 1 month ago) by dpvc
Fixed TeX output of Matrices to use \array rather than \matrix for
matrices with formulas as entries (this had already been fixed for
constant matrices).  Made intervals produce formulas when of of the
endpoints is a formula.  Removed unneeded comment.

Revision 2666 - Directory Listing
Modified Sun Aug 22 00:56:32 2004 UTC (14 years, 1 month ago) by dpvc
Formulas can now be compared even if their variables are complex
numbers, or even points or vectors!  This makes it possible to ask
students for complex functions like z^2+i and so on.

You can specify limits for variables either via
Context()->variables->set(x=>{limits=>[0,1]})  (for reals) or
Context()->variables->set(z=>{limits=>[[-2,2],[0,1]]}) (for complexes).
Similarly for points and vectors (where the number of sub arrays
depends on the dimension).  You can also give the limits for a
specific formula by assigning to its ->{limits} field:

    $f = Formula("sqrt(x-10)");
    $f->{limits} = [10,12];

There are now named variable types for 'Point2D', 'Point3D',
'Vector2D' and 'Vector3D', in addition to 'Real' and 'Complex'.
You can also specify a variable type by giving an explicit instance of
a value of the given type.  E.g.

    Context()->variables->add(x=>'Real',y=>0);     # two real variables
    Context()->variables->add(z=>'Complex',w=>i);  # two complexes
    Context()->variables->add(r=>Vector(0,0,0));   # a vector in R^3
    Context()->variables->add(X=>'Vector3D');      # a vector in R^3

There still needs to be more error checking in processing
user-supplied limits, but I'm not sure how much overhead is worth it.

Revision 2665 - Directory Listing
Modified Sun Aug 22 00:41:44 2004 UTC (14 years, 1 month ago) by dpvc
Made the default context be Numeric context rather than Full context.
Since there is only one variable in this context, it will speed up
function answer checking.  It will also encourage you to choose the
correct context explicitly.

Also changed Complex context to have z as the only variable.  If you
want x and y as reals, you need to add them in by hand.  Again, this
is for efficiency in answer checking.

Revision 2664 - Directory Listing
Modified Sat Aug 21 22:02:14 2004 UTC (14 years, 1 month ago) by dpvc
Added a file to perform WeBWorK-specific modifications to the
Parser/Value packages.  (I've tried to make these independent of
WeBWorK, so you can use them in other perl code if you want to.)

The parameters for fuzzy reals and some of the other parameters now
are taken from the pg->{ansEvalDefaults} values (as defined in
global.conf or course.conf).  More still needs to be done with this,
however.

Revision 2660 - Directory Listing
Modified Fri Aug 20 15:52:32 2004 UTC (14 years, 1 month ago) by dpvc
A number of adjustments to get negative infinities to work better.
They used to be stored as separate Parser strings, but now they are
flagged versions of a single string.

All of the problems are really due to the fact that there is no
Infinity class in the Parser (only a Value version).  That should be
changed, but will require some work, and can be put off for now.

It would be best if the classes within the two packages would match up
nearly 1-to-1, but for historical reasons, they don't.  Since the
introduction of Real, String and Infinity classes to the Value
package, The Infinity class is the one main difference between the
two, and once that is fixed, everything needs to be looked over to
check for unnecessary complications due to the historical lack of classes
in one or the other package.

Revision 2658 - Directory Listing
Modified Fri Aug 20 11:17:06 2004 UTC (14 years, 1 month ago) by dpvc
Make blank patterns be ^$ (which should never match) rather than empty
(which always matches).  this fixes a problem where if a context has
no functions, for example, the parser would attempt to create function
calls to a function named ''.

Revision 2655 - Directory Listing
Modified Fri Aug 20 02:11:50 2004 UTC (14 years, 1 month ago) by dpvc
Fixed typo.

Revision 2653 - Directory Listing
Modified Thu Aug 19 17:31:18 2004 UTC (14 years, 1 month ago) by dpvc
Fixed error with handling of +infinity and -infinity.
(They had been defined as strings, but now we can let the + and -
operators handle them).

Revision 2650 - Directory Listing
Modified Thu Aug 19 14:23:00 2004 UTC (14 years, 1 month ago) by dpvc
Added Parser::Number::NoDecimals() function that causes the parser to
give an error message when the student types a decimal number.  This
means the student must enter fractions as fractions, or values like
sqrt(2) or pi/4 symbolically not numerically.

Revision 2647 - Directory Listing
Modified Thu Aug 19 12:18:56 2004 UTC (14 years, 1 month ago) by dpvc
Context() now accepts a reference to an actual Context object rather
than a name of a predefined context, and will switch to that.

Revision 2645 - Directory Listing
Modified Thu Aug 19 12:02:15 2004 UTC (14 years, 1 month ago) by dpvc
Make sure equality always returns a defined value, and
put spaces around the equal sign in string output.

Revision 2643 - Directory Listing
Modified Thu Aug 19 11:55:56 2004 UTC (14 years, 1 month ago) by dpvc
Use the standard precedences rather than the experimental ones by
default.  The professor will need to specificaly request the
non-standard ones, for now.

Revision 2629 - Directory Listing
Modified Tue Aug 17 02:01:27 2004 UTC (14 years, 1 month ago) by dpvc
Fixed a number of minor problems with creating perl functions from
formulas (this is done automatically as part of the function answer
checker, so is showing up now that I have that checker in place).

Also improved error messages in the function answer checker, and fixed
a bug when students enter a constant list or union when the answer
checker expects formulas.

Revision 2628 - Directory Listing
Modified Mon Aug 16 21:41:05 2004 UTC (14 years, 1 month ago) by dpvc
Allow parser "constants" to be (in reality) formulas.  That way, for
example, you can defined T, N and B to be the formulas for the unit
tangent, normal and binormal of a space curve (as functions of "t")
and the student can write anwers in terms of T, N and B (without
having to compute them).

You could have created FUNCTIONS T(t), N(t) and B(t), and added them
to the parser to get almost the same effect, but the students would
have had to include the "(t)".  (If you want that, go ahead and do it
that way.)

Revision 2626 - Directory Listing
Modified Mon Aug 16 19:44:26 2004 UTC (14 years, 1 month ago) by dpvc
One more fix for handling intervals properly (I think it's really
right this time).  Also, named constants that end in numbers will
produce TeX output with the number as a subscript (this was already
true for variable names).

Revision 2625 - Directory Listing
Modified Mon Aug 16 18:35:12 2004 UTC (14 years, 1 month ago) by dpvc
Added string comparison to all Value object classes (to compare the
string value of an object to another string).

Overloaded perl '.' operator to do dot product when the operands are
formulas returning vectors.  (Part of the auto-generation of
formulas).

A few improvements to real and complex class output results.

Made Union class slightly more robust and removed need for makeUnion
method other than in the Union itself.

Revision 2624 - Directory Listing
Modified Mon Aug 16 13:44:45 2004 UTC (14 years, 1 month ago) by dpvc
Added support for unorderd list or formulas with partial credit.
Fixed type mismatch reporting in formula answer checker.
Fixed an error with Unions producing incorrect perl versions under
some circumstances.

Revision 2622 - Directory Listing
Modified Sun Aug 15 22:46:57 2004 UTC (14 years, 1 month ago) by dpvc
Created the first draft of the Parser's function answer checker.  Some
work still needs to be done, in particular, type mismatches are not
being reported, and lists are being processed only as ordered lists
with no partial credit.

This doesn't implement everything from fun_cmp.  In particular, there
is no support for parameter matching at the moment.  This will have to
be added, but I'm not quite sure how to do it when the function's
return value is not a real number (e.g., an interval).

On the other hand, this checker is more forgiving about domain errors:
if tries a point where the professor's function is not defined, it
ignores that one and looks for another (until it decides it can't find
one).  Once it has these points, it tries them on the student's
answer, and if the student's function is undefined, then the student
answer is wrong (since it is not defined somewhere that the
professor's funciton is).  This avoids the "Error evaluating student
function at ..." messages, which just confused most students anyway.

Revision 2621 - Directory Listing
Modified Sun Aug 15 17:05:41 2004 UTC (14 years, 1 month ago) by dpvc
Improved error messages, particularly when the student enters a
formula in an answer that should be constant, and also for incorrect
answers in lists of answers.  There are a few other miscellaneous output
improvements as well.

Revision 2620 - Directory Listing
Modified Sun Aug 15 12:02:05 2004 UTC (14 years, 1 month ago) by dpvc
Had to put back the global context variable after all.  :-(
It gets reset in Parser.pl, so it should be OK even with mod_perl.

Revision 2619 - Directory Listing
Modified Sun Aug 15 00:45:46 2004 UTC (14 years, 1 month ago) by dpvc
Modified Context() function so that it no longer uses a global package
variable for storing the user's context table.

Revision 2616 - Directory Listing
Modified Sat Aug 14 21:29:21 2004 UTC (14 years, 1 month ago) by dpvc
Added an equality operator (not active initially) that can be used for
things like equations of planes and so on.  I'm working on the answer
checker for that.

Revision 2615 - Directory Listing
Modified Sat Aug 14 21:27:45 2004 UTC (14 years, 1 month ago) by dpvc
*** empty log message ***

Revision 2612 - Directory Listing
Modified Sat Aug 14 19:29:42 2004 UTC (14 years, 1 month ago) by dpvc
Fixed some bugs in the handle of the context in ->string and ->TeX
methods of Value objects.

Revision 2609 - Directory Listing
Modified Sat Aug 14 13:54:52 2004 UTC (14 years, 1 month ago) by dpvc
Added a String type to the Value package.  Mostly this is to make it
possible to generate an answer checker for it that uses the parser.
It also makes it more consistent for handling things like stringify,
especially when they are recursively called internally.

Added new default strings "NONE" and "DNE", since these get used a
lot.

Modified how the default parameters are set up for the answer
checkers, and how the answer checker reports the expected answer type
in type mismatch error messages.

Revision 2607 - Directory Listing
Modified Sat Aug 14 11:26:49 2004 UTC (14 years, 1 month ago) by dpvc
Allow unary + and - to work on infinities.

Revision 2605 - Directory Listing
Modified Sat Aug 14 02:50:18 2004 UTC (14 years, 1 month ago) by dpvc
Incorporated infinities into Parser package better.  They have been
stored as String objects (with extra data) in the parser, and I've
left it that way, but now they convert to/from Vallue::Infinity
objects correctly, and these are used for generating the output.

Also added the Infinity answer checker, and adjusted the error
messages produces by type mismatches in the answer checkers and
elsewhere.

Revision 2597 - Directory Listing
Modified Fri Aug 13 11:38:22 2004 UTC (14 years, 1 month ago) by dpvc
Added answer checker for parallel vectors.
Added option to number checker to have it not report type mismatches
for the known strings (like 'infinity').  (Really need a class for
infinities, and a Value.pm class for strings.)

Revision 2596 - Directory Listing
Modified Thu Aug 12 23:11:32 2004 UTC (14 years, 1 month ago) by dpvc
Have parser handle infinities better.

Revision 2594 - Directory Listing
Modified Thu Aug 12 20:17:18 2004 UTC (14 years, 1 month ago) by dpvc
Fixes for handling intervals better.  In particular, deal better with
ambiguous situations, like (1,2) that could be a point.

You can use [a,a] to specify the single point a.  I'd like to make {a}
represent this (and maybe even {a,b,c} to form finite sets), but this
would interfere with the use of { and } as alternative parentheses.
(Does anyone really use these?)

Do we need a cross product for intervals (and sets) as a means of
representing regions in R^2 (or higher)?

Revision 2592 - Directory Listing
Modified Thu Aug 12 16:40:47 2004 UTC (14 years, 1 month ago) by dpvc
A number of small fixes.  Most were to fix minor bugs in string and
TeX output, particulary for the various list-based objects (like
vectors, intervals, etc.).  There were also some bug fixes in the
comparison routines.  Some additional checks were added for valid
intervals when the coordinates are formulas.

Revision 2579 - Directory Listing
Modified Mon Aug 9 21:38:01 2004 UTC (14 years, 1 month ago) by dpvc
Significant update to new parser.

New features include:

  Better control over format of vector output (you can now
    specify ijk-format rather than <...> format)

  "Fuzzy" reals, where the relations like == return true when the
    two values are "close enough".  (This is controlable using
    parameters similar to those used in NUM_CMP).

  The fuzzy reals are now used in vectors/points/matrices/complexes/intervals
    and so on so that their relations will also be fuzzy.  E.g.,
    (1E-13,2) == (0,3) will be true, and norm(Vector(0,1E-13)) will
    equal 0.

  The two main portions of the parser (the Parser and Value packages)
    now share a common context object for configuration purposes.

Revision 2576 - Directory Listing
Modified Wed Aug 4 20:52:28 2004 UTC (14 years, 1 month ago) by dpvc
Make Parser work with PGauxiliaryFunctions.pl, and add the macro files
needed to initialize the parser.

Revision 2558 - Directory Listing
Added Wed Jul 28 20:32:33 2004 UTC (14 years, 1 month ago) by sh002i
merged changes from rel-2-1-a1 -- stop using that branch.

Sort log by:

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9