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

View of /trunk/pg/lib/Parser/BOP/comma.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2558 - (download) (as text) (annotate)
Wed Jul 28 20:32:33 2004 UTC (15 years, 6 months ago) by sh002i
File size: 1344 byte(s)
merged changes from rel-2-1-a1 -- stop using that branch.

    1 #########################################################################
    2 #
    3 #  The comma operator
    4 #
    5 package Parser::BOP::comma;
    6 use strict; use vars qw(@ISA);
    7 @ISA = qw(Parser::BOP);
    8 
    9 #
   10 #  Start forming a list, and set the list type if
   11 #    the left and right operands are the same type.
   12 #  If the left or right operands are already lists,
   13 #    update the number of items in the new list.
   14 #
   15 sub _check {
   16   my $self = shift;
   17   my ($ltype,$rtype) = ($self->{lop}->typeRef,$self->{rop}->typeRef);
   18   my $type = Value::Type('Comma',2,$Value::Type{unknown});
   19   if ($ltype->{name} eq 'Comma') {
   20     $type->{length} += $self->{lop}->length - 1;
   21     $ltype = $self->{lop}->entryType;
   22   }
   23   if ($rtype->{name} eq 'Comma') {
   24     $type->{length} += $self->{rop}->length - 1;
   25     $rtype = $self->{rop}->entryType;
   26   }
   27   $type->{entryType} = $ltype if (Parser::Item::typeMatch($ltype,$rtype));
   28   $self->{type} = $type;
   29 }
   30 
   31 #
   32 #  evaluate by forming a list
   33 #
   34 sub _eval {($_[1],$_[2])}
   35 
   36 #
   37 #  If the operator is listed as a comma, make a list
   38 #    out of the lists that are the left and right operands.
   39 #  Otherwise return the item itself
   40 #
   41 sub makeList {
   42   my $self = shift;
   43   return $self unless ($self->{def}{isComma});
   44   return ($self->{lop}->makeList,$self->{rop}->makeList);
   45 }
   46 
   47 #########################################################################
   48 
   49 1;
   50 

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9