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

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

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

Revision 2695 Revision 2696
268# the precedences are equal and either 268# the precedences are equal and either
269# the associativity is right 269# the associativity is right
270# or we are supposed to show parens for the same precedence 270# or we are supposed to show parens for the same precedence
271# 271#
272sub string { 272sub string {
273 my $self = shift; 273 my ($self,$precedence,$showparens,$position,$outerRight) = @_;
274 my $precedence = shift; my $showparens = shift;
275 my $string; my $bop = $self->{def}; 274 my $string; my $bop = $self->{def};
276 my $addparens = 275 my $addparens =
277 defined($precedence) && 276 defined($precedence) &&
278 ($showparens eq 'all' || $bop->{fullparens} || $precedence > $bop->{precedence} || 277 ($showparens eq 'all' || $bop->{fullparens} || $precedence > $bop->{precedence} ||
279 ($precedence == $bop->{precedence} && 278 ($precedence == $bop->{precedence} &&
280 ($bop->{associativity} eq 'right' || $showparens eq 'same'))); 279 ($bop->{associativity} eq 'right' || $showparens eq 'same')));
280 my $outerRight = !$addparens && ($outerRight || $position eq 'right');
281 281
282 $string = $self->{lop}->string($bop->{precedence},$bop->{leftparens},'left'). 282 $string = $self->{lop}->string($bop->{precedence},$bop->{leftparens},'left',$outerRight).
283 $bop->{string}. 283 $bop->{string}.
284 $self->{rop}->string($bop->{precedence},$bop->{rightparens},'right'); 284 $self->{rop}->string($bop->{precedence},$bop->{rightparens},'right');
285 285
286 if ($addparens) { 286 if ($addparens) {
287 if ($bop->{fullparens} and $string =~ m/\(/) 287 if ($bop->{fullparens} and $string =~ m/\(/)
292 292
293# 293#
294# Produce the TeX version of the BOP. 294# Produce the TeX version of the BOP.
295# 295#
296sub TeX { 296sub TeX {
297 my ($self,$precedence,$showparens,$position) = @_; 297 my ($self,$precedence,$showparens,$position,$outerRight) = @_;
298 my $TeX; my $bop = $self->{def}; 298 my $TeX; my $bop = $self->{def};
299 my $addparens = 299 my $addparens =
300 defined($precedence) && 300 defined($precedence) &&
301 ($showparens eq 'all' || $precedence > $bop->{precedence} || 301 ($showparens eq 'all' || $precedence > $bop->{precedence} ||
302 ($precedence == $bop->{precedence} && 302 ($precedence == $bop->{precedence} &&
303 ($bop->{associativity} eq 'right' || $showparens eq 'same'))); 303 ($bop->{associativity} eq 'right' || $showparens eq 'same')));
304 my $outerRight = !$addparens && ($outerRight || $position eq 'right');
304 305
305 $TeX = $self->{lop}->TeX($bop->{precedence},$bop->{leftparens},'left'). 306 $TeX = $self->{lop}->TeX($bop->{precedence},$bop->{leftparens},'left',$outerRight).
306 (defined($bop->{TeX}) ? $bop->{TeX} : $bop->{string}) . 307 (defined($bop->{TeX}) ? $bop->{TeX} : $bop->{string}) .
307 $self->{rop}->TeX($bop->{precedence},$bop->{rightparens},'right'); 308 $self->{rop}->TeX($bop->{precedence},$bop->{rightparens},'right');
308 309
309 $TeX = '\left('.$TeX.'\right)' if ($addparens); 310 $TeX = '\left('.$TeX.'\right)' if ($addparens);
310 return $TeX; 311 return $TeX;

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

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9