cvsuser     04/11/23 05:42:16

  Modified:    runtime/parrot/library/PGE Class.pir
  Added:       t/library pge.t
  Log:
  Fixed PGE::Class and added a couple trivial tests.
  
  Revision  Changes    Path
  1.2       +26 -18    parrot/runtime/parrot/library/PGE/Class.pir
  
  Index: Class.pir
  ===================================================================
  RCS file: /cvs/public/parrot/runtime/parrot/library/PGE/Class.pir,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Class.pir 23 Nov 2004 12:56:13 -0000      1.1
  +++ Class.pir 23 Nov 2004 13:42:15 -0000      1.2
  @@ -8,7 +8,7 @@
   is a simple vtable design, so that we can add unicode trait classes and such
   when we find out how.
   
  -Yes, it is all in PIR.  And yes, this is a speed-critical part of P6GE.  
Don't
  +Yes, it is all in PIR.  And yes, this is a speed-critical part of PGE.  Don't
   complain; it's designed so that you can drop in a faster implementation any
   time.  Just replace these classes with PMCs.
   
  @@ -20,21 +20,21 @@
   
   .sub __onload @LOAD
       .local pmc base
  -    newclass base, "P6GE::Class"
  +    newclass base, "PGE::Class"
   
  -    subclass $P0, base, "P6GE::Class::Discrete"
  +    subclass $P0, base, "PGE::Class::Discrete"
       addattribute $P0, ".chars"   # str; attr 0
   
  -    subclass $P0, base, "P6GE::Class::Invert"
  +    subclass $P0, base, "PGE::Class::Invert"
       addattribute $P0, ".child"   # pmc; attr 0
   
       .return()
   .end
   
   
  -.namespace [ "P6GE::Class" ]
  +.namespace [ "PGE::Class" ]
   
  -=head2 P6GE::Class
  +=head2 PGE::Class
   
   This is an abstract base class for the atomic classes defined later in 
   the file.  It provides the following methods to all other classes
  @@ -106,7 +106,7 @@
   dontzero:
   
       .local pmc parent
  -    find_type $I0, "P6GE::Class::Invert"
  +    find_type $I0, "PGE::Class::Invert"
       new parent, $I0
   
       assign parent, self
  @@ -119,16 +119,16 @@
   
   =cut
   
  -.namespace [ "P6GE::Class::Discrete" ]
  +.namespace [ "PGE::Class::Discrete" ]
   
  -=head2 P6GE::Class::Discrete
  +=head2 PGE::Class::Discrete
   
   This class represents a discrete set of characters, such as [aeiou] (or
   <[aeiou]> in Perl 6-land).  To use this class:
   
       # create the character class
       .local pmc class
  -    find_type $I0, "P6GE::Class::Discrete"
  +    find_type $I0, "PGE::Class::Discrete"
       new class, $I0
   
       # assign the characters it will match
  @@ -156,7 +156,7 @@
   
   .sub __init method
       .local int offset
  -    classoffset offset, self, "P6GE::Class::Discrete"
  +    classoffset offset, self, "PGE::Class::Discrete"
   
       $P0 = new String
       setattribute self, offset, $P0
  @@ -166,7 +166,7 @@
   .sub __set_string_native method
       .param string list
       .local int offset
  -    classoffset offset, self, "P6GE::Class::Discrete"
  +    classoffset offset, self, "PGE::Class::Discrete"
       getattribute $P0, self, offset
   
       $P0 = list
  @@ -183,7 +183,7 @@
       .param pmc key
   
       .local int offset
  -    classoffset offset, self, "P6GE::Class::Discrete"
  +    classoffset offset, self, "PGE::Class::Discrete"
       getattribute $P0, self, offset
   
       $S0 = $P0
  @@ -197,16 +197,16 @@
   .end
   
   
  -.namespace [ "P6GE::Class::Invert" ]
  +.namespace [ "PGE::Class::Invert" ]
   
  -=head2 P6GE::Class::Invert
  +=head2 PGE::Class::Invert
   
   This class represents the logical inversion of another class.  That is,
   it matches exactly when its child doesn't.  To create this class:
   
       # create the character class
       .local pmc class
  -    find_type $I0, "P6GE::Class::Invert"
  +    find_type $I0, "PGE::Class::Invert"
       new class, $I0
   
       # assign a child object
  @@ -220,7 +220,7 @@
       .param pmc child
   
       .local int offset
  -    classoffset offset, self, "P6GE::Class::Invert"
  +    classoffset offset, self, "PGE::Class::Invert"
       setattribute self, offset, child
       .return()
   .end
  @@ -236,7 +236,7 @@
       .param pmc key
   
       .local int offset
  -    classoffset offset, self, "P6GE::Class::Invert"
  +    classoffset offset, self, "PGE::Class::Invert"
       getattribute $P0, self, offset
   
       $I0 = $P0[key]
  @@ -244,4 +244,12 @@
       .return($I1)
   .end
   
  +=head1 AUTHORS
  +
  +Luke Palmer ([EMAIL PROTECTED]) wrote this module.  Patrick Michaud
  +([EMAIL PROTECTED]) engineered PGE as a whole.  Questions about PGE should be
  +directed to [EMAIL PROTECTED]
  +
  +=cut
  +
   # vim: ft=imc :
  
  
  
  1.1                  parrot/t/library/pge.t
  
  Index: pge.t
  ===================================================================
  #! perl -w
  # Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  # $Id: pge.t,v 1.1 2004/11/23 13:42:16 luqui Exp $
  
  =head1 NAME
  
  t/library/pge.t - Grammar Engine tests
  
  =head1 SYNOPSIS
  
        % perl -Ilib t/library/pge.t
  
  =cut
  
  use strict;
  
  use Parrot::Test tests => 2;
  
  # 1
  output_is(<<'CODE', <<'OUT', "character class membership");
  ##PIR##
  .sub _main
      load_bytecode "library/PGE/Class.pir"
  
      .local pmc vowels
      $I0 = find_type "PGE::Class::Discrete"
      new vowels, $I0
  
      set vowels, "aeiou"
  
      $I1 = vowels["o"]
      if $I1 goto OK1
      print "not "
  OK1:
      print "ok 1\n"
  
      $I2 = vowels["q"]
      unless $I2 goto OK2
      print "not "
  OK2:
      print "ok 2\n"
  
      end
  .end
  CODE
  ok 1
  ok 2
  OUT
  
  # 2
  output_is(<<'CODE', <<'OUT', "character class membership: method forms");
  ##PIR##
  .sub _main
      load_bytecode "library/PGE/Class.pir"
  
      .local pmc vowels
      $I0 = find_type "PGE::Class::Discrete"
      new vowels, $I0
  
      vowels.set_chars("aeiou")
  
      $I1 = vowels.matches("o")
      if $I1 goto OK1
      print "not "
  OK1:
      print "ok 1\n"
  
      $I2 = vowels.matches("q")
      unless $I2 goto OK2
      print "not "
  OK2:
      print "ok 2\n"
  
      end
  .end
  CODE
  ok 1
  ok 2
  OUT
  
  # vim: ft=imc :
  
  
  

Reply via email to