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

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

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

Revision 2695 Revision 2696
235# the function call is on the left of the parent operation 235# the function call is on the left of the parent operation
236# and the precedence of the parent is higher than function call 236# and the precedence of the parent is higher than function call
237# (e.g., powers, etc.) 237# (e.g., powers, etc.)
238# 238#
239sub string { 239sub string {
240 my ($self,$precedence,$showparens,$position) = @_; 240 my ($self,$precedence,$showparens,$position,$outerRight,$power) = @_;
241 my $string; my $fn = $self->{equation}{context}{operators}{'fn'}; 241 my $string; my $fn = $self->{equation}{context}{operators}{'fn'};
242 my @pstr = (); my $fn_precedence = $fn->{precedence}; 242 my @pstr = (); my $fn_precedence = $fn->{precedence};
243 $fn_precedence = $fn->{parenPrecedence} 243 $fn_precedence = $fn->{parenPrecedence}
244 if ($position && $position eq 'right' && $fn->{parenPrecedence}); 244 if ($position && $position eq 'right' && $fn->{parenPrecedence});
245 foreach my $x (@{$self->{params}}) {push(@pstr,$x->string)} 245 foreach my $x (@{$self->{params}}) {push(@pstr,$x->string)}
246 $string = ($self->{def}{string} || $self->{name}).'('.join(',',@pstr).')'; 246 $string = ($self->{def}{string} || $self->{name})."$power".'('.join(',',@pstr).')';
247 $string = '('.$string.')' 247 $string = '('.$string.')'
248 if (defined($precedence) and $precedence > $fn_precedence); 248 if (defined($precedence) and $precedence > $fn_precedence);
249 return $string; 249 return $string;
250} 250}
251 251
252# 252#
253# Produce the TeX form. 253# Produce the TeX form.
254# 254#
255sub TeX { 255sub TeX {
256 my ($self,$precedence,$showparens,$position) = @_; 256 my ($self,$precedence,$showparens,$position,$outerRight,$power) = @_;
257 my $TeX; my $fn = $self->{equation}{context}{operators}{'fn'}; 257 my $TeX; my $fn = $self->{equation}{context}{operators}{'fn'};
258 my @pstr = (); my $fn_precedence = $fn->{precedence}; 258 my @pstr = (); my $fn_precedence = $fn->{precedence};
259 $fn_precedence = $fn->{parenPrecedence} 259 $fn_precedence = $fn->{parenPrecedence}
260 if ($position && $position eq 'right' && $fn->{parenPrecedence}); 260 if ($position && $position eq 'right' && $fn->{parenPrecedence});
261 $fn = $self->{def}; 261 $fn = $self->{def};
262 my $name = '\mathop{\rm '.$self->{name}.'}'; 262 my $name = '\mathop{\rm '.$self->{name}.'}';
263 $name = $fn->{TeX} if defined($fn->{TeX}); 263 $name = $fn->{TeX} if defined($fn->{TeX});
264 foreach my $x (@{$self->{params}}) {push(@pstr,$x->TeX)} 264 foreach my $x (@{$self->{params}}) {push(@pstr,$x->TeX)}
265 if ($fn->{braceTeX}) {$TeX = $name.'{'.join(',',@pstr).'}'} 265 if ($fn->{braceTeX}) {$TeX = $name.'{'.join(',',@pstr).'}'}
266 else {$TeX = $name.'\left('.join(',',@pstr).'\right)'} 266 else {$TeX = $name."$power".'\left('.join(',',@pstr).'\right)'}
267 $TeX = '\left('.$TeX.'\right)' 267 $TeX = '\left('.$TeX.'\right)'
268 if (defined($precedence) and $precedence > $fn_precedence); 268 if (defined($precedence) and $precedence > $fn_precedence);
269 return $TeX; 269 return $TeX;
270} 270}
271 271

Legend:
Removed from v.2695  
changed lines
  Added in v.2696

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9