[Gd-chatter] r11179 - trunk/libraries/network/wiki

hannes at gwydiondylan.org hannes at gwydiondylan.org
Sat Feb 17 21:36:12 CET 2007


Author: hannes
Date: Sat Feb 17 21:36:10 2007
New Revision: 11179

Modified:
   trunk/libraries/network/wiki/monday-parser.dylan
   trunk/libraries/network/wiki/parser-test.dylan
Log:
Job: minor
some more work on the grammar, parses test 1-9 successful (no lists so far)

Modified: trunk/libraries/network/wiki/monday-parser.dylan
==============================================================================
--- trunk/libraries/network/wiki/monday-parser.dylan	(original)
+++ trunk/libraries/network/wiki/monday-parser.dylan	Sat Feb 17 21:36:10 2007
@@ -75,7 +75,7 @@
      production internal-link :: xml$<element> => [LBRACKET LBRACKET wiki-page-name PIPE description RBRACKET RBRACKET] (data)
        with-xml() a(description, href => concatenate($base-url, wiki-page-name)) end;
 
-     production header :: xml$<element> => [EQUALS wiki-text EQUALS], action:
+     production header :: xml$<element> => [EQUALS more-wiki-text EQUALS], action:
        method (p :: <simple-parser>, data, s, e)
          let left = p[0];
          let right = p[2];
@@ -117,28 +117,30 @@
      production wiki-text :: <collection> => [external-link more-wiki-text] (data)
        add!(more-wiki-text, external-link);
 
-     production more-wiki-text :: <collection> => [wiki-text more-wiki-text] (data)
-       add!(more-wiki-text, wiki-text);
+     production more-wiki-text :: <collection> => [wiki-text] (data)
+       wiki-text;
 
      production more-wiki-text :: <collection> => [] (data)
        #();
 
-     production line :: <collection> => [wiki-text NEWLINE] (data)
+     production line :: <collection> => [wiki-text] (data)
        wiki-text;
 
-     production line :: xml$<element> => [NEWLINE] (data)
-       with-xml() p end;
+     production line :: <collection> => [header] (data)
+       list(header);
 
-     production line :: xml$<element> => [header NEWLINE] (data)
-       header;
+     production line :: <collection> => [unnumbered-list] (data)
+       list(unnumbered-list);
 
-     production line :: xml$<element> => [unnumbered-list] (data)
-       unnumbered-list;
 
      production lines => [] (data)
 
-     production lines => [line lines] (data)
-       data.my-real-data := add!(data.my-real-data, line);
+     production lines => [line NEWLINE NEWLINE lines] (data)
+       add!(data.my-real-data, with-xml() p end);
+       do(curry(add!, data.my-real-data), line);
+
+     production lines => [line NEWLINE lines] (data)
+       do(curry(add!, data.my-real-data), line);
 end;
 
 define constant $wiki-parser-automaton
@@ -165,7 +167,7 @@
 end function;
 
 define sealed class <my-data> (<object>)
-  slot my-real-data = #();
+  slot my-real-data = make(<stretchy-vector>);
 end;
 
 define function parse-wiki-markup (input :: <string>)
@@ -185,8 +187,8 @@
                     consumer-data: data);
   format-out("before scan-tokens, input: %s\n", input);
   scan-tokens(scanner,
-              //simple-parser-consume-token,
-              consume-token,
+              simple-parser-consume-token,
+              //consume-token,
               parser,
               input,
               end: input.size,
@@ -195,9 +197,12 @@
   format-out("before consuming EOF at %d\n", end-position);
   simple-parser-consume-token(parser, 0, #"EOF", parser, end-position, end-position);
   format-out("data (%d) is %=\n", data.my-real-data.size, data.my-real-data);
-  data.my-real-data;
+  reduce1(concatenate, (map(curry(as, <string>), reverse(data.my-real-data))));
 end;
 
 begin
+  parse-wiki-markup("foo\n\nbar\n");
+  parse-wiki-markup("[[f]]\n");
+  parse-wiki-markup("==foo==\n");
   parse-wiki-markup("==foo==\nfoo[[bar]]");
 end;

Modified: trunk/libraries/network/wiki/parser-test.dylan
==============================================================================
--- trunk/libraries/network/wiki/parser-test.dylan	(original)
+++ trunk/libraries/network/wiki/parser-test.dylan	Sat Feb 17 21:36:10 2007
@@ -4,24 +4,24 @@
 
 
 define test newline ()
-  check-equal("Newline inserts paragraph", "foo<p/>bar", *markup-method*("foo\n\nbar\n"));
+  check-equal("Newline inserts paragraph", "foo<P/>bar", *markup-method*("foo\n\nbar\n"));
 end;
 
 define test internal-link ()
-  check-equal("Internal link to unknown page",
-              "<a href=\"/wiki/view.dsp?title=foo\">[?]foo</a>",
+  check-equal("Internal link",
+              "<A href=\"/wiki/view.dsp?title=foo\">foo</A>",
               *markup-method*("[[foo]]"));
 end;
 
 define test external-link ()
   check-equal("External link",
-              "<a href=\"http://www.ccc.de\">http://www.ccc.de</a>",
+              "<A href=\"http://www.ccc.de\">http://www.ccc.de</A>",
               *markup-method*("[http://www.ccc.de]"));
 end;
 
 define test external-link-with-label ()
   check-equal("External Link with label",
-              "<a href=\"http://www.ccc.de\">foobar</a>",
+              "<A href=\"http://www.ccc.de\">foobar</A>",
               *markup-method*("[http://www.ccc.de foobar]"));
 end;
 
@@ -34,15 +34,15 @@
 end;
 
 define test heading4 ()
-  check-equal("Heading 4", "<h4> foooo </h4>", *markup-method*("==== foooo ===="));
+  check-equal("Heading 4", "<h4>foooo</h4>", *markup-method*("==== foooo ===="));
 end;
 
 define test heading5 ()
-  check-equal("Heading 5", "<h5> fooooo </h5>", *markup-method*("===== fooooo ====="));
+  check-equal("Heading 5", "<h5>fooooo</h5>", *markup-method*("===== fooooo ====="));
 end;
 
 define test heading54 ()
-  check-equal("Heading 54", "<h5> fooooo </h5>", *markup-method*("===== fooooo ===="));
+  check-equal("Heading 54", "<h5>fooooo</h5>", *markup-method*("===== fooooo ===="));
 end;
 
 define test unnumbered-list ()



More information about the chatter mailing list