[LON-CAPA-cvs] cvs: modules /TexConvert/algebra AlgParser.pm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 24 Feb 2005 06:21:10 -0000


albertel		Thu Feb 24 01:21:10 2005 EDT

  Modified files:              
    /modules/TexConvert/algebra	AlgParser.pm 
  Log:
  - use strict now works
  
  
Index: modules/TexConvert/algebra/AlgParser.pm
diff -u modules/TexConvert/algebra/AlgParser.pm:1.1 modules/TexConvert/algebra/AlgParser.pm:1.2
--- modules/TexConvert/algebra/AlgParser.pm:1.1	Wed Feb 23 20:21:51 2005
+++ modules/TexConvert/algebra/AlgParser.pm	Thu Feb 24 01:21:10 2005
@@ -6,11 +6,12 @@
 ## Additions and modifications were made by Arnold Pizer, Dept of Math, Univ of Rochester
 
 #use Data::Dumper;
+use strict;
 
 package AlgParser;
 use HTML::Entities;
 
-%close = ();
+my %close = ();
 
 sub new {
   my $package = shift;
@@ -36,30 +37,30 @@
 $close{'['} = ']';
 $close{'('} = ')';
 
-$binoper3 = '(?:\\^|\\*\\*)';
-$binoper2 = '[/*_,]';
-$binoper1 = '[-+=><%!#]';
-$openparen = '[{(\\[]';
-$closeparen = '[})\\]]';
-$varname = '[A-Za-z](?:_[0-9]+)?';
-$specialvalue = '(?:e|pi|da|db|dc|de|df|dg|dh|di|dj|dk|dl|dm|dn|do|dp|dq|dr|ds|dt|du|dv|dw|dx|dy|dz|infty|alpha|bita|gamma|zita|thita|iota|kappa|lambda|mu|nu|xi|rho|sigma|tau|phi|chi|psi|omega|zepslon|zdelta|xeta|zupslon|zeroplace)';
-$numberplain = '(?:\d+(?:\.\d*)?|\.\d+)';
-$numberE = '(?:' . $numberplain . 'E[-+]?\d+)';
-$number = '(?:' . $numberE . '|' . $numberplain . ')';
+my $binoper3 = '(?:\\^|\\*\\*)';
+my $binoper2 = '[/*_,]';
+my $binoper1 = '[-+=><%!#]';
+my $openparen = '[{(\\[]';
+my $closeparen = '[})\\]]';
+my $varname = '[A-Za-z](?:_[0-9]+)?';
+my $specialvalue = '(?:e|pi|da|db|dc|de|df|dg|dh|di|dj|dk|dl|dm|dn|do|dp|dq|dr|ds|dt|du|dv|dw|dx|dy|dz|infty|alpha|bita|gamma|zita|thita|iota|kappa|lambda|mu|nu|xi|rho|sigma|tau|phi|chi|psi|omega|zepslon|zdelta|xeta|zupslon|zeroplace)';
+my $numberplain = '(?:\d+(?:\.\d*)?|\.\d+)';
+my $numberE = '(?:' . $numberplain . 'E[-+]?\d+)';
+my $number = '(?:' . $numberE . '|' . $numberplain . ')';
 #
 #  DPVC -- 2003/03/31
 #       added missing trig and inverse functions
 #
 #$trigfname = '(?:cosh|sinh|tanh|cot|(?:a(?:rc)?)?cos|(?:a(?:rc)?)?sin|' .
 #    '(?:a(?:rc)?)?tan|sech?)';
-$trigfname = '(?:(?:a(?:rc)?)?(?:sin|cos|tan|sec|csc|cot)h?)';
+my $trigfname = '(?:(?:a(?:rc)?)?(?:sin|cos|tan|sec|csc|cot)h?)';
 #
 #  End DPVC
 #
-$otherfunc = '(?:exp|abs|logten|log|ln|sqrt|sgn|step|fact|int|lim|fun[a-zA-Z])';
-$funcname = '(?:' . $otherfunc . '|' . $trigfname . ')';
+my $otherfunc = '(?:exp|abs|logten|log|ln|sqrt|sgn|step|fact|int|lim|fun[a-zA-Z])';
+my $funcname = '(?:' . $otherfunc . '|' . $trigfname . ')';
 
-$tokenregexp = "(?:($binoper3)|($binoper2)|($binoper1)|($openparen)|" .
+my $tokenregexp = "(?:($binoper3)|($binoper2)|($binoper1)|($openparen)|" .
     "($closeparen)|($funcname)|($specialvalue)|($varname)|" .
     "($numberE)|($number))";
 
@@ -95,7 +96,7 @@
   my (@pushback) = ();
 
   my $currentref = \$self->{parseresult}->[1];
-  my $curenttok;
+  my $currenttok;
 
   my $sstring = shift;
   $self->inittokenizer($sstring);
@@ -383,7 +384,9 @@
 }
 
 package AlgParserWithImplicitExpand;
+no strict;
 @ISA=qw(AlgParser);
+use strict;
 
 sub arraytoexpr {
   my ($self) = shift;
@@ -558,6 +561,11 @@
 	return('\frac{' . $args[1]->tolatex() . '}'.
                '{' . $args[2]->tolatex() . '}' ); 
     }
+    elsif ($args[0] eq '*'){
+#	return('\frac{' . $p1 . $args[1]->tolatex() . $p2 . '}'.
+#               '{' . $p3 . $args[2]->tolatex() . $p4 . '}' );
+	return($args[1]->tolatex() . '\cdot ' . $args[2]->tolatex() ); 
+    }
     else{
     return ($p1 . $args[1]->tolatex() . $p2 . $args[0] . $p3 .
             $args[2]->tolatex() . $p4);
@@ -582,7 +590,7 @@
       #       added missing trig functions
       #
       #$specialfunc = '(?:abs|logten|asin|acos|atan|sech|sgn|step|fact)';
-      $specialfunc = '(?:abs|logten|a(?:sin|cos|tan|sec|csc|cot)h?|sgn|step|fact)';
+      my $specialfunc = '(?:abs|logten|a(?:sin|cos|tan|sec|csc|cot)h?|sgn|step|fact)';
       #
       #  End DPVC
       #
@@ -628,8 +636,9 @@
 }
 
 package ExprWithImplicitExpand;
+no strict;
 @ISA=qw(Expr);
-
+use strict;
 
 sub tostring {
 # print STDERR "ExprWIE::tostring\n";