/[papo]/papo/neb/neb/Parser.pm
ViewVC logotype

Diff of /papo/neb/neb/Parser.pm

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

revision 1.5 by jlenton, Thu Apr 10 23:01:39 2003 UTC revision 1.6 by jlenton, Mon Apr 14 22:31:39 2003 UTC
# Line 12  use neb::Tree::Vars; Line 12  use neb::Tree::Vars;
12  # que invocan las clases.  # que invocan las clases.
13  my %classes = ( 'Inline' => 'Perl' );  my %classes = ( 'Inline' => 'Perl' );
14    
15    # Llamado antes de empezar el parsado, esto arma la estructura
16    # necesaria como para poder laburar
17  sub Init  sub Init
18  {  {
19      my $expat = shift;      my $expat = shift;
20      my $obj = neb::Tree::Container->new($expat->{'neb_root_name'});      my $obj = neb::Tree::Container->new($expat->{'neb_root_name'});
21    
22      $expat->{"neb_parser_current"} = $obj;      $expat->{"neb_parser_current"} = $obj;
23      $expat->{"neb_parser_stack"} = [ $obj ];      $expat->{"neb_parser_stack"} = [ $obj ];
24  }  }
25    
26    # Llamado al iniciar cada elemento, con el nombre del elemento como
27    # primer parámetro y pares nombre, valor para cada uno de los
28    # atributos que hubiera.
29    # (donde dice "primer elemento", es obviando `self', obvio)
30  sub Start  sub Start
31  {  {
32      my $expat = shift;      my $expat = shift;
33      my $name = shift;      my $name = shift;
34      my $class = 'neb::Tree::';      my $class = 'neb::Tree::';
35    
36        # si empieza con 'neb:', buscar la clase correspondiente a lo que
37        # sigue al neb:. Caso contrario usar el por defecto.
38      if ($name =~ m'^neb:(.*)$'i)      if ($name =~ m'^neb:(.*)$'i)
39      {      {
40          $class .= exists $classes{$1} ? $classes{$1} : $1;          $class .= exists $classes{$1} ? $classes{$1} : $1;
# Line 37  sub Start Line 46  sub Start
46    
47      my $obj = $class->new($name, $expat->{'neb_parser_current'}->url, @_);      my $obj = $class->new($name, $expat->{'neb_parser_current'}->url, @_);
48    
49  #    $obj->attributes(@_);      # enganchar el objeto recién creado con la estructura existente
   
50      $expat->{"neb_parser_current"}->add_content($obj);      $expat->{"neb_parser_current"}->add_content($obj);
51    
52        # apilar el objeto recién creado
53      push @{$expat->{"neb_parser_stack"}}, $expat->{"neb_parser_current"};      push @{$expat->{"neb_parser_stack"}}, $expat->{"neb_parser_current"};
54      $expat->{"neb_parser_current"} = $obj;      $expat->{"neb_parser_current"} = $obj;
55  }  }
56    
57    # llamado al finalizar cada elemento, con el nombre del elemento como
58    # primer parámetro.
59  sub End  sub End
60  {  {
61      my $expat = shift;      my $expat = shift;
62      my $name = shift;      my $name = shift;
63            
64        # desapilar
65      $expat->{"neb_parser_current"} = pop @{$expat->{"neb_parser_stack"}}      $expat->{"neb_parser_current"} = pop @{$expat->{"neb_parser_stack"}}
66  }  }
67    
68    # llamado para cualquier cosa que no sea un principio o fin de
69    # elemento, con el texto como parámetro.
70  sub Default  sub Default
71  {  {
72      my $expat = shift;      my $expat = shift;
# Line 62  sub Default Line 76  sub Default
76      return $obj;      return $obj;
77  }  }
78    
79    # llamado al terminar. Limpia la chanchada que hizo Init.
80  sub Final  sub Final
81  {  {
82      my $expat = shift;      my $expat = shift;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26