Commits

Anonymous committed b0b886e

Fix more bugs.

Thanks to LeoNerd.

Comments (0)

Files changed (1)

perl/modules/XML-Grammar-Fiction/TEMP/new-Parser-MGC-XML-Fiction-parser.pl

 
     my $id_regex = $self->_get_id_regex();
 
-    if (my (undef, $id) = $self->expect(qr{</($id_regex)>}))
+    if (my (undef, $id) = $self->expect(qr{($id_regex)>}))
     {
         return XML::Grammar::Fiction::Struct::Tag->new(
             name => $id,
-            line => $self->line_num(),
+            # TODO : replace with a more meaningful line number.
+            line => 1,
         );
     }
     else
 
 sub _merge_tag
 {
-    my $self = shift;
-    my $open_tag = shift;
+    my ($self, $open_tag, $inner) = @_;
 
     my $new_elem = 
         $self->_create_elem(
             $open_tag, 
-            $self->_new_list($open_tag->detach_children()),
+            $self->_new_list($inner),
         );
 
-    if (! $self->_tag_stack_is_empty())
-    {
-        $self->_add_to_top_tag($new_elem);
-        return;
-    }
-    else
-    {
-        return $new_elem;
-    }
+    return $new_elem;
 }
 
 sub _open_close_tag
 {
     my ($self) = @_;
 
-    my @ret;
+    my $id_regex = $self->_get_id_regex();
 
-    push @ret, $self->_parse_opening_tag();
+    my $open = $self->_parse_opening_tag();
 
-    push @ret, $self->sequence_of(
-        sub
-        {
+    my $inner = $self->scope_of(
+        undef, sub { 
             return $self->any_of(
                 sub {
                     my (undef, $text) = $self->expect(qr/([^<]*)/ms);
                     $self->_open_close_tag(),
                 },
             );
-        },
+        }, qr{</}
     );
 
-    push @ret, $self->_parse_closing_tag();
-
-    my $open = $ret[0];
-    my $close = $ret[-1];
+    my $close = $self->_parse_closing_tag();
 
     if ($open->name() ne $close->name())
     {
         );
     }
 
-    return $self->_merge_tag($open);
+    return $self->_merge_tag($open, [$inner]);
 }
 
 sub parse
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.