isa-migrate ++
authorhaftmann
Thu Jun 16 10:21:36 2005 +0200 (2005-06-16)
changeset 164045f263e81e366
parent 16403 294a7864063e
child 16405 0a2a6732c685
isa-migrate ++
Admin/isa-migrate
     1.1 --- a/Admin/isa-migrate	Wed Jun 15 23:35:43 2005 +0200
     1.2 +++ b/Admin/isa-migrate	Thu Jun 16 10:21:36 2005 +0200
     1.3 @@ -23,6 +23,8 @@
     1.4      },
     1.5      thyheader => sub {
     1.6          my ($file, @content) = @_;
     1.7 +        #~ my $diag = 1;
     1.8 +        my $diag = 0;
     1.9          $_ = join("", @content);
    1.10          if (m!^theory!cgoms) {
    1.11              my $prelude = $';
    1.12 @@ -31,36 +33,39 @@
    1.13              if (m!\G(\S+)!cgoms) {
    1.14                  $thyheader .= $1;
    1.15                  $thyheader .= skip_wscomment();
    1.16 -                print "--->\n>>>$thyheader<<<\n<---\n";
    1.17 +                $diag and print "--->\n(1)>>>$thyheader<<<\n<---\n";
    1.18                  if (m!\G(?:imports|=)!cgoms) {
    1.19                      $thyheader .= "imports";
    1.20                      $thyheader .= skip_wscomment() || " ";
    1.21 -                    print "--->\n>>>$thyheader<<<\n<---\n";
    1.22 -                    while () {
    1.23 -                        my $str = read_plainstring();
    1.24 -                        print "--->\n>>>$str<<<\n<---\n";
    1.25 -                        if (! $str) {
    1.26 -                            last;
    1.27 -                        }
    1.28 -                        $thyheader .= $str;
    1.29 +                    $diag and print "--->\n(2)>>>$thyheader<<<\n<---\n";
    1.30 +                    while (m/\G(?!uses|files|begin|:)/cgoms && m!\G\w+!cgoms) {
    1.31 +                        $diag and print "--->\n(3)>>>$&<<<\n<---\n";
    1.32 +                        $thyheader .= $&;
    1.33 +                        $thyheader .= skip_wscomment();
    1.34 +                        m/\G\+? ?/cgoms;
    1.35                          $thyheader .= skip_wscomment();
    1.36                      }
    1.37 -                    #~ print "--->\n>>>$thyheader<<<\n<---\n";
    1.38 +                    $diag and print "--->\n(4)>>>$thyheader<<<\n<---\n";
    1.39                  }
    1.40                  if (m!\G(?:files|uses)!cgoms) {
    1.41                      $thyheader .= "uses";
    1.42                      $thyheader .= skip_wscomment();
    1.43 -                    while () {
    1.44 -                        my $str = read_plainstring();
    1.45 -                        if (! $str) {
    1.46 -                            last;
    1.47 -                        }
    1.48 -                        $thyheader .= $str;
    1.49 +                    $diag and print "--->\n(5)>>>$thyheader<<<\n<---\n";
    1.50 +                    while (m/\G(?!begin|:)/cgoms && m!\G(\("[^"]+"\)|"[^"]+"|[^"\s]+)!cgoms) {
    1.51 +                        $diag and print "--->\n(6)>>>$&<<<\n<---\n";
    1.52 +                        $thyheader .= $&;
    1.53                          $thyheader .= skip_wscomment();
    1.54                      }
    1.55 +                    $diag and print "--->\n(7)>>>$thyheader<<<\n<---\n";
    1.56                  }
    1.57 +                #~ m!\G.{19}!cgoms;
    1.58 +                #~ print "***$&\n";
    1.59 +
    1.60                  if (m!\G(?:begin|:)!cgoms) {
    1.61                      my $postlude = $';
    1.62 +                    if ($& == ":") {
    1.63 +                        $thyheader .= " ";
    1.64 +                    }
    1.65                      $thyheader .=  "begin";
    1.66                      # do replacement here
    1.67                      print "$file:\n$thyheader\n\n";
    1.68 @@ -97,15 +102,10 @@
    1.69      }
    1.70  }
    1.71  
    1.72 -sub read_plainstring {
    1.73 -    m!\G("[^"]+"|[^"\s]+)!cgoms or return "";
    1.74 -    return $&;
    1.75 -}
    1.76 -
    1.77  # process dir tree
    1.78  sub process_tree {
    1.79      my ($root, $migrator, $backupext) = @_;
    1.80 -    find(sub { process($File::Find::name, $migrator, $backupext) }, $root);
    1.81 +    find(sub { process($_, $migrator, $backupext) }, $root);
    1.82  }
    1.83  
    1.84  # process single file
    1.85 @@ -139,3 +139,5 @@
    1.86          process($fileloc, $migrator, $backupext);
    1.87      }
    1.88  }
    1.89 +
    1.90 +#!!! example file:
    1.91 \ No newline at end of file