chiark / gitweb /
Cope with multi-word arches
[ypp-sc-tools.db-test.git] / yarrg / yppedia-chart-parser
index 44a143b50c662bb6a4cc7c76cff7b98c7f44bc8a..dacf5c354725fd017a8f930c4991693463329f6c 100755 (executable)
@@ -55,7 +55,11 @@ my @msgkinds= qw(change warning error);
 my %msgs;
 my %msgprinted;
 my %msgkindprinted;
-sub pmsg ($$) { push @{ $msgs{$_[0]} }, "$_[0]: $_[1]\n"; }
+sub pmsg ($$) {
+    my $m= "$_[0]: $_[1]\n";
+    print DEBUG "D $m";
+    push @{ $msgs{$_[0]} }, $m;
+}
 sub warning ($) { pmsg("warning",$_[0]); }
 sub error   ($) { pmsg("error",  $_[0]); }
 sub change  ($) { pmsg("change", $_[0]); }
@@ -122,9 +126,13 @@ sub yppedia_chart_parse () {
     
        if (($x,$y,$arch) =
            m/^\{\{ chart\ label \|(\d+)\|(\d+)\| .*
-                   \'\[\[ [^][\']* \| (\S+)\ archipelago \]\]\'*\}\}$/xi) {
+                   (?: \<big\>)? \'+
+                   \[\[ [^][\']* \| ([^][\'|]+)\ archipelago \]\]
+                   \'+ (?: \<\/big\>)? \}\}$/xi) {
            printf DEBUG "%2d,%-2d arch %s\n", $x,$y,$arch;
            push @wiarchlabels, [ $x,$y,$arch ];
+       } elsif (m/^\{\{ chart\ label \|\d+\|\d+\|
+                \<big\> \'+ \[\[ .* \b ocean \]\]/xi) {
        } elsif (($x,$y,$island) =
            m/^\{\{ chart\ island\ icon \|(\d+)\|(\d+)\|
                    ([^| ][^|]*[^| ]) \| .*\}\}$/xi) {
@@ -494,6 +502,7 @@ END
 
     my $result= Graph::Undirected->new();
     foreach my $edge_ac ($g->edges()) {
+        $result->add_vertex($edge_ac->[0]); # just in case
         next if $edge_ac->[0] eq $edge_ac->[1];
        my $edgename_ac= join ' .. ', @$edge_ac;
        printf DEBUG "spr %s edge %s\n", $what, $edgename_ac;