experimental
authorhaftmann
Mon, 13 Jun 2005 14:35:05 +0200
changeset 16382 4fc8d8c99e9e
parent 16381 f53ccd0cc70e
child 16383 7dd0eb6e89f9
experimental
Admin/isa-migrate
--- a/Admin/isa-migrate	Mon Jun 13 14:31:21 2005 +0200
+++ b/Admin/isa-migrate	Mon Jun 13 14:35:05 2005 +0200
@@ -24,15 +24,48 @@
     thyheader => sub {
         my ($file, @content) = @_;
         $_ = join("", @content);
-        if (m!\G
-                ^
-                    theory\s+([^ ]+)
-                    (?:\s+(?:imports|=)\s+([^:]*?))?
-                    (?:\s+(?:files|uses)\s+([^:]*?))?
-                    \s*(?:begin|:)
-             !cgomsx) {
-            # STRATEGIE: abschnittsweises matchen, zwischendurch immer wieder whitespace
-            # verarbeiten
+        if (m!^theory!cgoms) {
+            my $prelude = $';
+            my $thyheader = "theory";
+            $thyheader .= skip_wscomment();
+            if (m!\G(\S+)!cgoms) {
+                $thyheader .= $1;
+                $thyheader .= skip_wscomment();
+                print "--->\n>>>$thyheader<<<\n<---\n";
+                if (m!\G(?:imports|=)!cgoms) {
+                    $thyheader .= "imports";
+                    $thyheader .= skip_wscomment() || " ";
+                    print "--->\n>>>$thyheader<<<\n<---\n";
+                    while () {
+                        my $str = read_plainstring();
+                        print "--->\n>>>$str<<<\n<---\n";
+                        if (! $str) {
+                            last;
+                        }
+                        $thyheader .= $str;
+                        $thyheader .= skip_wscomment();
+                    }
+                    #~ print "--->\n>>>$thyheader<<<\n<---\n";
+                }
+                if (m!\G(?:files|uses)!cgoms) {
+                    $thyheader .= "uses";
+                    $thyheader .= skip_wscomment();
+                    while () {
+                        my $str = read_plainstring();
+                        if (! $str) {
+                            last;
+                        }
+                        $thyheader .= $str;
+                        $thyheader .= skip_wscomment();
+                    }
+                }
+                if (m!\G(?:begin|:)!cgoms) {
+                    my $postlude = $';
+                    $thyheader .=  "begin";
+                    # do replacement here
+                    print "$file:\n$thyheader\n\n";
+                }
+            }
         }
     }
 );
@@ -64,6 +97,11 @@
     }
 }
 
+sub read_plainstring {
+    m!\G("[^"]+"|[^"\s]+)!cgoms or return "";
+    return $&;
+}
+
 # process dir tree
 sub process_tree {
     my ($root, $migrator, $backupext) = @_;