[svn] r7153: nemerle/trunk/ncc/hierarchy/XmlDump.n

malekith svnadmin at nemerle.org
Tue Dec 26 10:26:12 CET 2006


Log:
Handle <[ ]>.

Author: malekith
Date: Tue Dec 26 10:26:11 2006
New Revision: 7153

Modified:
   nemerle/trunk/ncc/hierarchy/XmlDump.n

Modified: nemerle/trunk/ncc/hierarchy/XmlDump.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/XmlDump.n	(original)
+++ nemerle/trunk/ncc/hierarchy/XmlDump.n	Tue Dec 26 10:26:11 2006
@@ -104,6 +104,18 @@
       | XmlStart { n : string; v : string; }
       | XmlEnd { n : string; }
       | WhiteSpace { w : string }
+
+      public override ToString () : string
+      {
+        match (this) {
+          | EmptyLine => "[EmptyLine]"
+          | EOF => "[EOF]"
+          | Text (t) => "\"" + t + "\""
+          | XmlStart (n, v) => "<" + n + " " + v + ">"
+          | XmlEnd (n) => "</" + n + ">"
+          | WhiteSpace (w) => "[" + w + "]"
+        }
+      }
     }
 
     static tokenize (comment : string) : array [XToken]
@@ -129,6 +141,7 @@
       def buf = string.Join ("\n", lines) + "\n";
       
       mutable i = 0; 
+      mutable something_since_newline = false;
       while (i < buf.Length)
       {
         def start = i;
@@ -141,7 +154,7 @@
 
         if (space_tab (buf [i]))
           res.Add (XToken.WhiteSpace (scan (space_tab)));
-        else if (buf [i] == '\n')
+        else if (buf [i] == '\n') {
           match (scan (_ == '\n')) {
             | "\n" =>
               res.Add (XToken.WhiteSpace ("\n"));
@@ -149,7 +162,27 @@
               res.Add (XToken.WhiteSpace (s));
               res.Add (XToken.EmptyLine ());
           }
-        else if (buf [i] == '<') {
+          something_since_newline = false;
+        }
+        else if (i + 1 < buf.Length && buf [i] == '<' && buf [i+1] == '[') {
+          i += 2;
+          if (something_since_newline)
+            res.Add (XToken.XmlStart ("c", ""));
+          else {
+            def spaces = scan (space_tab).Substring (2);
+            def tag = if (i >= buf.Length || buf [i] == '\n') "code" else "c";
+            res.Add (XToken.XmlStart (tag, ""));
+            res.Add (XToken.WhiteSpace (spaces));
+            something_since_newline = true;
+          }
+        } else if (i + 1 < buf.Length && buf [i] == ']' && buf [i+1] == '>') {
+          i += 2;
+          res.Add (XToken.XmlEnd (""));
+        } else if (buf [i] == ']') {
+          something_since_newline = true;
+          res.Add (XToken.Text ("]"));
+        } else if (buf [i] == '<') {
+          something_since_newline = true;
           def v = scan (_ != '>');
           if (i == buf.Length)
             // location?
@@ -179,11 +212,14 @@
                 res.Add (XToken.XmlStart (name, args));
             }
           }
-        } else
-          res.Add (XToken.Text (scan (c => c != '<' && c != '\n')));
+        } else {
+          something_since_newline = true;
+          res.Add (XToken.Text (scan (c => c != '<' && c != '\n' && c != ']')));
+        }
       }
 
       res.Add (XToken.EOF ());
+      Message.Debug ("tokens: " + res.ToArray ().ToList().ToString(" "));
       res.ToArray ();
     }
 
@@ -290,6 +326,12 @@
             when (is_top_tag (n))
               // any auto summary/remarks
               possibly_close (is_top_tag);
+            when (!is_top_tag (n) && !tags.Exists ((n, _) => is_top_tag (n)))
+              open_fake ("remarks");
+            when (!is_text_holding (n) && !is_top_tag (n) && 
+                  !tags.Exists ((n, _) => is_text_holding (n)))
+              open_fake ("para");
+
             tags ::= (n, true);
             output (t);
 



More information about the svn mailing list