Author: nico
Date: 2009-06-04 13:00:44 +0200 (Thu, 04 Jun 2009)
New Revision: 35709

Added:
   mmbase/trunk/core/
   mmbase/trunk/core/src/
   mmbase/trunk/core/src/main/
   mmbase/trunk/core/src/main/config/
   mmbase/trunk/core/src/main/examples/
   mmbase/trunk/core/src/main/examples/mmexamples/
   mmbase/trunk/core/src/main/java/
   mmbase/trunk/core/src/main/javacc/
   mmbase/trunk/core/src/main/javacc/org/
   mmbase/trunk/core/src/main/javacc/org/mmbase/
   mmbase/trunk/core/src/main/javacc/org/mmbase/util/
   mmbase/trunk/core/src/main/javacc/org/mmbase/util/dateparser/
   mmbase/trunk/core/src/main/javacc/org/mmbase/util/transformers/
   mmbase/trunk/core/src/main/javacc/org/mmbase/util/transformers/ListParser.jj
   mmbase/trunk/core/src/main/webapp/
Removed:
   mmbase/trunk/config/
   mmbase/trunk/core/src/main/webapp/mmexamples/
   mmbase/trunk/html/
   mmbase/trunk/src/
Log:
Maven2 structure

Copied: mmbase/trunk/core/src/main/config (from rev 35708, mmbase/trunk/config)

Copied: mmbase/trunk/core/src/main/examples/mmexamples (from rev 35708, 
mmbase/trunk/html/mmexamples)

Copied: mmbase/trunk/core/src/main/java (from rev 35708, mmbase/trunk/src)

Copied: mmbase/trunk/core/src/main/javacc/org/mmbase/util/dateparser (from rev 
35708, mmbase/trunk/src/org/mmbase/util/dateparser)

Copied: 
mmbase/trunk/core/src/main/javacc/org/mmbase/util/transformers/ListParser.jj 
(from rev 35708, mmbase/trunk/src/org/mmbase/util/transformers/ListParser.jj)
===================================================================
--- 
mmbase/trunk/core/src/main/javacc/org/mmbase/util/transformers/ListParser.jj    
                            (rev 0)
+++ 
mmbase/trunk/core/src/main/javacc/org/mmbase/util/transformers/ListParser.jj    
    2009-06-04 11:00:44 UTC (rev 35709)
@@ -0,0 +1,120 @@
+/* -*- java -*-
+
+This software is OSI Certified Open Source Software.
+OSI Certified is a certification mark of the Open Source Initiative.
+
+The license (Mozilla version 1.0) can be read at the MMBase site.
+See http://www.MMBase.org/license
+
+*/
+/**
+ * ListParser
+ * This file is parsed by <a href="https://javacc.dev.java.net/";>javacc</a>.
+ *
+ * @author Michiel Meeuwisssen
+ * @since MMBase-1.8.6
+ * @version $Id: ListParser.jj,v 1.4 2008-07-08 15:54:46 michiel Exp $
+ */
+
+options {
+    STATIC = false;
+    IGNORE_CASE = false;
+}
+
+PARSER_BEGIN(ListParser)
+
+package org.mmbase.util.transformers;
+import java.io.Reader ;
+import java.io.StringReader ;
+import java.util.*;
+import java.io.*;
+
+
+public class ListParser {
+    int curDepth = 0;
+    boolean begin = true;
+    LinkedList<Character> stack = new LinkedList<Character>();
+
+    static String transform( String inString ) {
+        Reader reader = new StringReader(inString) ;
+        ListParser parser = new ListParser(reader) ;
+        StringBuilder buffer = new StringBuilder() ;
+        try {
+            parser.start(buffer) ; }
+        catch( TokenMgrError e ) {
+            throw new IllegalStateException() ; }
+        catch( ParseException e ) {
+            throw new IllegalStateException() ; }
+        return buffer.toString() ;
+    }
+
+    int getDepth(Token t) {
+        return t.image.length() - (begin ? 1 : 2);
+    }
+    char getType(Token t, int depth) {
+        return t.image.charAt(depth - 1 +  (begin ? 0 : 1)) == '*' ? 'o' : 'u';
+    }
+    void open(StringBuilder buf, char type) {
+        curDepth++;
+        stack.addFirst(type);
+        if (! begin && curDepth == 1) buf.append('\n');
+        buf.append('<').append(type).append("l>");
+    }
+    void close(StringBuilder buf) {
+        curDepth--;
+        char t = stack.removeFirst();
+        buf.append("</li></").append(t).append("l>");
+        if (curDepth > 0) buf.append("</li>");
+    }
+    void handleList(StringBuilder buf, Token t) {
+        int depth = getDepth(t);
+        char type = getType(t, depth);
+        if (depth == curDepth + 1) {
+            open(buf, type);
+        } else if (depth == curDepth - 1) {
+            close(buf);
+        } else if (depth == curDepth) {
+            buf.append("</li>");
+        }
+        buf.append("<li>");
+    }
+    void endLists(StringBuilder buf) {
+        while (stack.size() > 0) {
+            close(buf);
+        }
+    }
+
+    public static void main(String argv[]) throws ParseException, 
InterruptedException {
+        System.out.println(ListParser.transform((argv[0])));
+    }
+
+
+}
+
+PARSER_END(ListParser)
+
+TOKEN : { <BOL: "*" (["*","-"])* (" ")> }
+TOKEN : { <BUL: "-" (["*", "-"])* (" ")> }
+TOKEN : { <OL: "\n*" (["*", "-"])* (" ")> }
+TOKEN : { <UL: "\n-" (["*", "-"])* (" ")> }
+TOKEN : { <END: ("\n")> }
+TOKEN : { <OTHER : ~[] > }
+
+void start(StringBuilder buf) :
+{
+  Token t ;
+}
+{
+
+   (
+    t = <OL>  {   begin = false; handleList(buf, t); }
+    | t = <UL>  { begin = false;  handleList(buf, t);   }
+    | t = <BOL> { if (begin) { handleList(buf, t); begin = false; } else { 
buf.append(t.image); }}
+    | t = <BUL> { if (begin) { handleList(buf, t); begin = false; } else { 
buf.append(t.image); }}
+    | <END> { if (begin) { buf.append("\n"); } else { endLists(buf); 
buf.append("\n"); } }
+    | (t = <OTHER>) { begin = false; buf.append(t.image); }
+   )*
+   <EOF> { endLists(buf); }
+}
+
+

Copied: mmbase/trunk/core/src/main/webapp (from rev 35708, mmbase/trunk/html)

_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to