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

Log of /trunk/pg/lib/Parser

View Directory Listing Directory Listing


Sticky Revision:

Revision 2938 - Directory Listing
Modified Tue Oct 19 00:24:47 2004 UTC (15 years, 3 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 (15 years, 3 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 (15 years, 3 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, 3 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 (15 years, 3 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 (15 years, 3 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 (15 years, 3 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, 4 months 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 (15 years, 4 months 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 (15 years, 4 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, 4 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 2795 - Directory Listing
Modified Sat Sep 18 23:16:37 2004 UTC (15 years, 4 months ago) by dpvc
Fixed typo in addParens method name.

Revision 2789 - Directory Listing
Modified Thu Sep 16 22:24:32 2004 UTC (15 years, 4 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
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 (15 years, 4 months 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 (15 years, 4 months 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 (15 years, 4 months 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 (15 years, 4 months 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 (15 years, 4 months 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 (15 years, 4 months ago) by dpvc
Two more minor TeX improvements.

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

       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 (15 years, 5 months 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 (15 years, 5 months 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 (15 years, 5 months 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 (15 years, 5 months 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 (15 years, 5 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 2675 - Directory Listing
Modified Mon Aug 23 04:59:05 2004 UTC (15 years, 5 months 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 (15 years, 5 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, 5 months 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 (15 years, 5 months 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 (15 years, 5 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(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 (15 years, 5 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 2664 - Directory Listing
Modified Sat Aug 21 22:02:14 2004 UTC (15 years, 5 months 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 (15 years, 5 months 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 (15 years, 5 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 2655 - Directory Listing
Modified Fri Aug 20 02:11:50 2004 UTC (15 years, 5 months ago) by dpvc
Fixed typo.

Revision 2653 - Directory Listing
Modified Thu Aug 19 17:31:18 2004 UTC (15 years, 5 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 2650 - Directory Listing
Modified Thu Aug 19 14:23:00 2004 UTC (15 years, 5 months 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 (15 years, 5 months 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 (15 years, 5 months 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 (15 years, 5 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, 5 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 2628 - Directory Listing
Modified Mon Aug 16 21:41:05 2004 UTC (15 years, 5 months 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 (15 years, 5 months 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 (15 years, 5 months 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 (15 years, 5 months 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 (15 years, 5 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 2621 - Directory Listing
Modified Sun Aug 15 17:05:41 2004 UTC (15 years, 5 months 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 (15 years, 5 months 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 (15 years, 5 months 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 (15 years, 5 months 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 (15 years, 5 months ago) by dpvc
*** empty log message ***

Revision 2612 - Directory Listing
Modified Sat Aug 14 19:29:42 2004 UTC (15 years, 5 months 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 (15 years, 5 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
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 (15 years, 5 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, 5 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.

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 (15 years, 5 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, 5 months ago) by dpvc
Have parser handle infinities better.

Revision 2594 - Directory Listing
Modified Thu Aug 12 20:17:18 2004 UTC (15 years, 5 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, 5 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
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 (15 years, 5 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 2576 - Directory Listing
Modified Wed Aug 4 20:52:28 2004 UTC (15 years, 5 months 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 (15 years, 5 months 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