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

Diff of /trunk/pg/lib/Parser.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2664 Revision 2673
649 649
650 650
651################################################## 651##################################################
652################################################## 652##################################################
653# 653#
654# Convert a student answer to a formula, with error trapping.
655# If the result is undef, there was an error (message is in Context()->{error} object)
656#
657
658sub Formula {
659 my $f = shift;
660 my $v = eval {Value::Formula->new($f)};
661 $$Value::context->setError($@) unless defined($v) ||
662 $$Value::context->{error}{flag};
663 return $v;
664}
665
666#
667# Evaluate a formula, with error trapping.
668# If the result is undef, there was an error (message is in Context()->{error} object)
669# If the result was a real, make it a fuzzy one.
670#
671sub Evaluate {
672 my $f = shift;
673 return unless defined($f);
674 my $v = eval {$f->eval(@_)};
675 if (defined($v)) {$v = Value::makeValue($v)}
676 else {$f->setError($@) unless $f->{context}{error}{flag}}
677 return $v;
678}
679
680
681##################################################
682##################################################
683#
684# Produce a vector in ijk form 654# Produce a vector in ijk form
685# 655#
686sub ijk { 656sub ijk {
687 my $self = shift; 657 my $self = shift;
688 $self->{tree}->ijk; 658 $self->{tree}->ijk;

Legend:
Removed from v.2664  
changed lines
  Added in v.2673

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9