[system] / trunk / pg / lib / Parser / Context Repository: Repository Listing bbplugincoursesdistsnplrochestersystemwww

# Log of /trunk/pg/lib/Parser/Context

 Sticky Revision:

Revision 5472 - Directory Listing
Modified Sat Sep 8 22:24:06 2007 UTC (12 years, 5 months 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 5439 - Directory Listing
Modified Tue Aug 28 21:53:42 2007 UTC (12 years, 5 months 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 5377 - Directory Listing
Modified Sun Aug 19 14:41:26 2007 UTC (12 years, 6 months ago) by dpvc
Make sure clear doesn't remove the special 'start' paren that is
required by the Parser class.


Revision 5237 - Directory Listing
Modified Tue Aug 7 04:30:27 2007 UTC (12 years, 6 months 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 (12 years, 7 months ago) by dpvc
Better control over when extra parentheses are added.


Revision 5130 - Directory Listing
Modified Mon Jul 9 12:45:06 2007 UTC (12 years, 7 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 (12 years, 7 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 (12 years, 7 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 (12 years, 7 months ago) by dpvc
Allow constants to be defined by a hash (like everything else) if desired.


Revision 5116 - Directory Listing
Modified Tue Jul 3 10:44:30 2007 UTC (12 years, 7 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
(like quoted strings, or arbitrary variable names) and about
specifying the order in which they are applied.


Revision 4994 - Directory Listing
Modified Sun Jun 10 01:17:29 2007 UTC (12 years, 8 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 4927 - Directory Listing
Modified Tue Apr 17 00:31:13 2007 UTC (12 years, 10 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 (13 years ago) by gage
Begin pod documentation.


Revision 4729 - Directory Listing
Modified Sat Dec 16 14:10:12 2006 UTC (13 years, 2 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 3913 - Directory Listing
Modified Tue Jan 17 01:56:24 2006 UTC (14 years, 1 month 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 (14 years, 1 month ago) by dpvc
Allow multi-letter variable names and names like x1, x2, etc.


Revision 3762 - Directory Listing
Modified Thu Nov 17 13:20:50 2005 UTC (14 years, 3 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 3703 - Directory Listing
Modified Mon Oct 10 23:47:26 2005 UTC (14 years, 4 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 3591 - Directory Listing
Modified Tue Aug 30 12:21:36 2005 UTC (14 years, 5 months 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 (14 years, 5 months 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 3510 - Directory Listing
Modified Sat Aug 13 17:32:58 2005 UTC (14 years, 6 months 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 3494 - Directory Listing
Modified Fri Aug 12 23:02:11 2005 UTC (14 years, 6 months ago) by dpvc
Made the 'R' constant in Interval context show up as a bold R in TeX
mode.


Revision 3483 - Directory Listing
Modified Fri Aug 12 01:21:48 2005 UTC (14 years, 6 months 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 (14 years, 6 months ago) by dpvc
Fixed bug with missing fields in initialization.


Revision 3477 - Directory Listing
Modified Thu Aug 11 20:57:18 2005 UTC (14 years, 6 months 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 (14 years, 6 months 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 3465 - Directory Listing
Modified Thu Aug 11 00:38:33 2005 UTC (14 years, 6 months ago) by dpvc
Make upper-case alias a hidden one (since it is not needed for the
pattern).


Revision 3370 - Directory Listing
Modified Tue Jul 12 22:29:53 2005 UTC (14 years, 7 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


Revision 3367 - Directory Listing
Modified Tue Jul 12 02:02:46 2005 UTC (14 years, 7 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 3344 - Directory Listing
Modified Mon Jul 4 19:39:37 2005 UTC (14 years, 7 months ago) by dpvc
Fixed problem with sorting (problem with $a,$b, I think).


Revision 3334 - Directory Listing
Modified Sun Jul 3 20:10:37 2005 UTC (14 years, 7 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.:

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


Revision 3332 - Directory Listing
Modified Sun Jul 3 20:05:28 2005 UTC (14 years, 7 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 (14 years, 8 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 3203 - Directory Listing
Modified Mon Mar 28 23:46:06 2005 UTC (14 years, 10 months ago) by dpvc
Handle extra parentheses better.


Revision 2914 - Directory Listing
Modified Wed Oct 13 02:41:33 2004 UTC (15 years, 4 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 (15 years, 4 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 2842 - Directory Listing
Modified Wed Sep 29 15:47:30 2004 UTC (15 years, 4 months ago) by dpvc
Allow string constants to include spaces.


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


Revision 2797 - Directory Listing
Modified Sun Sep 19 01:16:10 2004 UTC (15 years, 5 months 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 (15 years, 5 months 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 2789 - Directory Listing
Modified Thu Sep 16 22:24:32 2004 UTC (15 years, 5 months 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

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


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


Revision 2696 - Directory Listing
Modified Sat Aug 28 12:34:56 2004 UTC (15 years, 5 months 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 (15 years, 5 months 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

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

including the parameters, even though the student can't type it.  Is
this the right behaviour?


Revision 2678 - Directory Listing
Modified Mon Aug 23 23:55:37 2004 UTC (15 years, 6 months 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 2672 - Directory Listing
Modified Sun Aug 22 22:46:14 2004 UTC (15 years, 6 months 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 (15 years, 6 months ago) by dpvc
Fixed some inconsistencies between handing of matrices within the
parser and Value packages.  Added a predefined Matrix context.


Revision 2666 - Directory Listing
Modified Sun Aug 22 00:56:32 2004 UTC (15 years, 6 months 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(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 (15 years, 6 months 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 2658 - Directory Listing
Modified Fri Aug 20 11:17:06 2004 UTC (15 years, 6 months 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 2653 - Directory Listing
Modified Thu Aug 19 17:31:18 2004 UTC (15 years, 6 months 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 2643 - Directory Listing
Modified Thu Aug 19 11:55:56 2004 UTC (15 years, 6 months 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 (15 years, 6 months 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 2622 - Directory Listing
Modified Sun Aug 15 22:46:57 2004 UTC (15 years, 6 months 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 2609 - Directory Listing
Modified Sat Aug 14 13:54:52 2004 UTC (15 years, 6 months 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
in type mismatch error messages.


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


Revision 2605 - Directory Listing
Modified Sat Aug 14 02:50:18 2004 UTC (15 years, 6 months 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.

messages produces by type mismatches in the answer checkers and
elsewhere.


Revision 2597 - Directory Listing
Modified Fri Aug 13 11:38:22 2004 UTC (15 years, 6 months 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 (15 years, 6 months ago) by dpvc
Have parser handle infinities better.


Revision 2594 - Directory Listing
Modified Thu Aug 12 20:17:18 2004 UTC (15 years, 6 months 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 (15 years, 6 months 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
intervals when the coordinates are formulas.


Revision 2579 - Directory Listing
Modified Mon Aug 9 21:38:01 2004 UTC (15 years, 6 months 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 2558 - Directory Listing
Added Wed Jul 28 20:32:33 2004 UTC (15 years, 6 months ago) by sh002i
merged changes from rel-2-1-a1 -- stop using that branch.


Sort log by: