[system] / trunk / pg / macros / Parser.pl Repository:
ViewVC logotype

Log of /trunk/pg/macros/Parser.pl

Parent Directory Parent Directory

Links to HEAD: (view) (download) (as text) (annotate)
Sticky Revision:

Revision 5568 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Oct 25 17:11:59 2007 UTC (12 years, 4 months ago) by sh002i
File length: 7701 byte(s)
Diff to previous 5399
new/improved documentation

Revision 5399 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed Aug 22 19:49:36 2007 UTC (12 years, 6 months ago) by dpvc
File length: 6765 byte(s)
Diff to previous 5373
Allow contexts to override the MathObject constructors separately from
the ones generated by the parser.  That way, you can define Real(),
for example, to produce ScientificNotation, without screwing up the
reals used in the parser itself.

Revision 5373 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Aug 19 02:01:57 2007 UTC (12 years, 6 months ago) by dpvc
File length: 6763 byte(s)
Diff to previous 5368
Normalized comments and headers to that they will format their POD
documentation properly.  (I know that the POD processing was supposed
to strip off the initial #, but that doesn't seem to happen, so I've
added a space throughout.)

Revision 5368 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Aug 19 00:21:46 2007 UTC (12 years, 6 months ago) by dpvc
File length: 6730 byte(s)
Diff to previous 5071
Make Compute() retain the original Formula as well as the correct
answer string (for reference if you need it).  Also provide a hook for
subclasses of Parser::Item to force a Formula to be computed as a
Formula-based Value object (e.g., this is needed for
PiecewiseFunctions, which don't compute to constants, but don't want
to be Formula's either).

Revision 5071 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Jun 28 23:19:00 2007 UTC (12 years, 7 months ago) by dpvc
File length: 6404 byte(s)
Diff to previous 4997
Correct and expand some documentation.

Revision 4997 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Jun 11 18:16:40 2007 UTC (12 years, 8 months ago) by gage
File length: 5611 byte(s)
Diff to previous 4990
Fixing docementation so that it can be read from the web.

Revision 4990 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Jun 7 23:48:20 2007 UTC (12 years, 8 months ago) by dpvc
File length: 5480 byte(s)
Diff to previous 4983
More updates to use the new Value->Package() call.  This will make the
standard object-creation functions like Real() and Complex() use the
new lookup method.

Revision 4983 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Jun 7 13:14:52 2007 UTC (12 years, 8 months ago) by dpvc
File length: 5469 byte(s)
Diff to previous 3588
Allow Compute() to create formulas as well as Value objects (with the
correct answer set to the original formula).

Also update some comments and formatting.

Revision 3588 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Aug 30 00:41:34 2005 UTC (14 years, 5 months ago) by dpvc
File length: 5406 byte(s)
Diff to previous 3172
Added a parserCustomization.pl file that is loaded whenever the
Parser.pl file is.  This can be used on a course-by-course basis to
customize features of the Parser.  Some examples are listed in the

You need to be VERY careful when doing this, as this will affect ALL
problems that use the Parser.  Your changes may cause some .pg files
to fail if they rely on the default behavior that you are changing.

If you wish to override settings in one of the predefined contexts
(like "Vector"), then define $context{Vector} as a copy of
$Parser::Context::Default::context{Vector}, as in the commented out
examples.  Then Context("Vector") will use your copy rather than the
original.  If you were to change the version in
Parser::Context::Default, that would change the parser for ALL
courses, not just yours.

Revision 3172 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Feb 15 21:58:54 2005 UTC (15 years ago) by dpvc
File length: 5367 byte(s)
Diff to previous 2666
Updated the answer checkers so that you can more easily specify how
the correct answer shoudl be displayed.  In the past, you could use
something like Real(sqrt(2))->cmp(correct_ans=>"sqrt(2)") to do this,
but that is awkward.  Now the Compute() function (which parses and
then evaluates a string) sets things up so that the original string
will be what is used as the correct answer.  That means
Compute("sqrt(2)")->cmp will have the same result as the example

You can also set the {correct_ans} properly of any Parser object to
have that value used as the correct answer.  For example

     $x = Real(sqrt(2));
     $x->{correct_ans} = "sqrt(2)";

would also produce the same answer checker as the two previous
examples.  All three methods should work.  Use the one that is most
convenient for you.

Revision 2666 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Aug 22 00:56:32 2004 UTC (15 years, 6 months ago) by dpvc
File length: 5306 byte(s)
Diff to previous 2644
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 2644 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Aug 19 12:01:12 2004 UTC (15 years, 6 months ago) by dpvc
File length: 5307 byte(s)
Diff to previous 2602
Make sure loadMacros() doesn't try to load these files more than once.

Revision 2602 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Aug 13 22:57:27 2004 UTC (15 years, 6 months ago) by dpvc
File length: 5248 byte(s)
Diff to previous 2576
Changed the way the parser checks to see if it is loaded.

Revision 2576 - (view) (download) (as text) (annotate) - [select for diffs]
Added Wed Aug 4 20:52:28 2004 UTC (15 years, 6 months ago) by dpvc
File length: 4715 byte(s)
Make Parser work with PGauxiliaryFunctions.pl, and add the macro files
needed to initialize the parser.

This form allows you to request diffs between any two revisions of this file. For each of the two "sides" of the diff, enter a numeric revision.

  Diffs between and
  Type of Diff should be a

Sort log by:

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9