[system] / trunk / webwork / system / courseScripts / AlgParser.pm Repository:
ViewVC logotype

Diff of /trunk/webwork/system/courseScripts/AlgParser.pm

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

Revision 3 Revision 4
47$numberplain = '(?:\d+(?:\.\d*)?|\.\d+)'; 47$numberplain = '(?:\d+(?:\.\d*)?|\.\d+)';
48$numberE = '(?:' . $numberplain . 'E[-+]?\d+)'; 48$numberE = '(?:' . $numberplain . 'E[-+]?\d+)';
49$number = '(?:' . $numberE . '|' . $numberplain . ')'; 49$number = '(?:' . $numberE . '|' . $numberplain . ')';
50$trigfname = '(?:cosh|sinh|tanh|cot|(?:a(?:rc)?)?cos|(?:a(?:rc)?)?sin|' . 50$trigfname = '(?:cosh|sinh|tanh|cot|(?:a(?:rc)?)?cos|(?:a(?:rc)?)?sin|' .
51 '(?:a(?:rc)?)?tan|sech?)'; 51 '(?:a(?:rc)?)?tan|sech?)';
52$otherfunc = '(?:exp|abs|logten|log|ln|sqrt|sgn)'; 52$otherfunc = '(?:exp|abs|logten|log|ln|sqrt|sgn|step)';
53$funcname = '(?:' . $otherfunc . '|' . $trigfname . ')'; 53$funcname = '(?:' . $otherfunc . '|' . $trigfname . ')';
54 54
55$tokenregexp = "(?:($binoper3)|($binoper2)|($binoper1)|($openparen)|" . 55$tokenregexp = "(?:($binoper3)|($binoper2)|($binoper1)|($openparen)|" .
56 "($closeparen)|($funcname)|($specialvalue)|($varname)|" . 56 "($closeparen)|($funcname)|($specialvalue)|($varname)|" .
57 "($numberE)|($number))"; 57 "($numberE)|($number))";
540 $args[0] = ' '; 540 $args[0] = ' ';
541 } 541 }
542 } 542 }
543 if ($args[1]->[0] =~ /binop1|numberE/) 543 if ($args[1]->[0] =~ /binop1|numberE/)
544 {($p1,$p2)=qw{ \left( \right) };} 544 {($p1,$p2)=qw{ \left( \right) };}
545 if ($args[2]->[0] =~ /binop[12]|numberE/) 545 # if ($args[2]->[0] =~ /binop[12]|numberE/)
546 if ($args[2]->[0] =~ /binop[12]|numberE|unop1/)
546 {($p3,$p4)=qw{ \left( \right) };} 547 {($p3,$p4)=qw{ \left( \right) };}
547 if ($args[0] eq '/'){ 548 if ($args[0] eq '/'){
548 return('\frac{' . $p1 . $args[1]->tolatex() . $p2 . '}'. 549 return('\frac{' . $p1 . $args[1]->tolatex() . $p2 . '}'.
549 '{' . $p3 . $args[2]->tolatex() . $p4 . '}' ); 550 '{' . $p3 . $args[2]->tolatex() . $p4 . '}' );
550 } 551 }
622 my($type, @args) = @$self; 623 my($type, @args) = @$self;
623 624
624 if (($type eq qq(binop2)) && ($args[0] eq qq(implicit))) { 625 if (($type eq qq(binop2)) && ($args[0] eq qq(implicit))) {
625 my ($p1, $p2, $p3, $p4)=('','','',''); 626 my ($p1, $p2, $p3, $p4)=('','','','');
626 if ($args[1]->head =~ /binop1/) {($p1,$p2)=qw{ ( ) };} 627 if ($args[1]->head =~ /binop1/) {($p1,$p2)=qw{ ( ) };}
627 if ($args[2]->head =~ /binop[12]/) {($p3,$p4)=qw{ ( ) };} 628# if ($args[2]->head =~ /binop[12]/) {($p3,$p4)=qw{ ( ) };}
629 if ($args[2]->head =~ /binop[12]|unop1/) {($p3,$p4)=qw{ ( ) };}
628 return ($p1 . $args[1]->tostring() . $p2 . '*' . $p3 . 630 return ($p1 . $args[1]->tostring() . $p2 . '*' . $p3 .
629 $args[2]->tostring() . $p4); 631 $args[2]->tostring() . $p4);
630 } else { 632 } else {
631 return $self->SUPER::tostring(@_); 633 return $self->SUPER::tostring(@_);
632 } 634 }

Legend:
Removed from v.3  
changed lines
  Added in v.4

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9