[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36

John Goerzen jgoerzen at complete.org
Fri Apr 23 14:47:41 UTC 2010


The following commit has been merged in the master branch:
commit acbeed81f53dc03a01452735c2bb66ffcadccd77
Author: John Goerzen <jgoerzen at complete.org>
Date:   Fri Nov 19 04:50:51 2004 +0100

    Checkpointing
    
    Keywords:
    
    
    (jgoerzen at complete.org--projects/missingh--head--0.5--patch-84)

diff --git a/ChangeLog b/ChangeLog
index 1dc692a..0f05419 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,19 @@
 # arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.5
 #
 
+2004-11-18 21:50:51 GMT	John Goerzen <jgoerzen at complete.org>	patch-84
+
+    Summary:
+      Checkpointing
+    Revision:
+      missingh--head--0.5--patch-84
+
+
+    modified files:
+     ChangeLog libsrc/MissingH/ConfigParser/Parser.hs
+     testsrc/ConfigParser/Parsertest.hs
+
+
 2004-11-18 20:12:40 GMT	John Goerzen <jgoerzen at complete.org>	patch-83
 
     Summary:
diff --git a/libsrc/MissingH/ConfigParser/Parser.hs b/libsrc/MissingH/ConfigParser/Parser.hs
index 7c978a4..c8d7678 100644
--- a/libsrc/MissingH/ConfigParser/Parser.hs
+++ b/libsrc/MissingH/ConfigParser/Parser.hs
@@ -50,45 +50,59 @@ type ParseOutput = [(String, [(String, String)])]
 
 comment_chars = oneOf "#;"
 eol = string "\n" <|> string "\r\n" <|> string "\r" <?> "End of line"
-optionsep = oneOf ":=" <?> "Option separator"
-whitespace_chars = oneOf " \t" <?> "Whitespace"
+eoleof = eol <|> do {eof; return ""}
+optionsep = oneOf ":=" <?> "option separator"
+whitespace_chars = oneOf " \t" <?> "whitespace"
 comment_line = do skipMany whitespace_chars <?> "whitespace in comment"
                   comment_chars             <?> "start of comment"
-                  (many1 $ noneOf "\r\n")   <?> "content of comment"
-empty_line = many1 whitespace_chars         <?> "empty line"
-
-ignore1 = eol 
-          <|> try (do {comment_line; ignore1})
-          <|> do {empty_line; ignore1}
-ignorestuff = skipMany ignore1
+                  (many $ noneOf "\r\n")    <?> "content of comment"
+                  eoleof
+                  -- eol
+empty_line = do skipMany whitespace_chars
+                eoleof
+{-
+             <|> do many1 whitespace_chars
+                    eof
+                    return "" -}
+
+ignore1 = --do notFollowedBy (do {eof; return 'x'})
+          (try comment_line) <|> (try empty_line)
+          <?> "an item to ignore"
+ignorestuff = eof
+              <|> do {ignore1; ignorestuff}
+              <|> return ()
 
 sectheader_chars = noneOf "]\r\n"
 sectheader = do ignorestuff
                 char '['
                 sname <- many1 $ sectheader_chars
                 char ']'
+                ignore1
                 return sname
+             <?> "section header"
 oname_chars = noneOf ":=\r\n"
 value_chars = noneOf "\r\n"
-extension_line = do ignorestuff
+extension_line = do ignorestuff <?> "POINT3"
                     many1 whitespace_chars
                     c1 <- noneOf "\r\n#;"
                     remainder <- many value_chars
+                    eoleof
                     return (c1 : remainder)
                  <?> "extension line"
 
 optionkey = many1 oname_chars           <?> "option key"
 optionvalue = many1 value_chars         <?> "option value"
-optionpair = do ignorestuff
+optionpair = do ignorestuff <?> "POINT4"
                 key <- optionkey
                 optionsep
                 value <- optionvalue
+                eoleof
                 return (key, value)
              <?> "option pair"
 
 parsemain :: Parser [(String, [(String, String)])]
 parsemain =
-    sectionlist
+    try sectionlist
     <|> try (do o <- optionlist
                 s <- sectionlist
                 return $ ("DEFAULT", o) : s
@@ -97,9 +111,10 @@ parsemain =
     <?> "High-level error parsing config file"
 
 sectionlist = 
-    do {eof; return []}
+    do {ignorestuff <?> "POINT2"; eof; return []}
     <|> try (do
-             s <- sectionhead
+             s <- sectionhead <?> "POINT10"
+             ignorestuff  <?> "POINT1"
              eof
              return [(s, [])]
             )
@@ -139,6 +154,7 @@ procparse fp l =
     case l of
            Left err -> error (show err)
            Right reply -> reply
+
 ----------------------------------------------------------------------
 -- Exported funcs
 ----------------------------------------------------------------------
diff --git a/testsrc/ConfigParser/Parsertest.hs b/testsrc/ConfigParser/Parsertest.hs
index c517535..1afa5d5 100644
--- a/testsrc/ConfigParser/Parsertest.hs
+++ b/testsrc/ConfigParser/Parsertest.hs
@@ -23,27 +23,31 @@ import Testutil
 import Control.Exception
 
 test_basic =
-    let f msg inp exp = assertEqual msg exp (parse_string inp) in
-        do
+    let f msg inp exp = TestLabel msg $ TestCase $ assertEqual "" exp (parse_string inp) in
+        [
         f "empty string" "" []
-        {-
-        f "one empty line" "\n" []
-        f "one comment line" "#foo bar" []
-        f "one comment line with eol" "#foo bar\n" []
-        f "one empty section" "[emptysect]" [("emptysect", [])]
-        f "comment and empty sect" "#foo bar\n[emptysect]\n" [("emptysect", [])]
-        f "comments2" "# [nonexistant]\n[emptysect]\n" [("emptysect", [])]
-        f "comments3" "#fo\n[Cemptysect]\n#asdf boo\n  \n  # fnonexistantg"
+
+        ,f "one empty line" "\n" []
+        ,f "one comment line" "#foo bar" []
+        ,f "one comment line with eol" "#foo bar\n" []
+        ,f "one empty section" "[emptysect]" [("emptysect", [])]
+        ,f "one empty section w/eol" "[emptysect]\n" [("emptysect", [])]
+        ,f "comment and empty sect noeol" "#foo bar\n[emptysect]"
+           [("emptysect", [])]
+        ,f "comment and empty sect" "#foo bar\n[emptysect]\n" [("emptysect", [])]
+        ,f "comments2" "# [nonexistant]\n[emptysect]\n" [("emptysect", [])]
+        ,f "comments3" "#fo\n[Cemptysect]\n#asdf boo\n  \n  # fnonexistantg"
           [("Cemptysect", [])]
-        f "comments4" "[emptysect]\n# [nonexistant]\n" [("emptysect", [])]
-        f "simple section" "[sect1]\nfoo: bar\n" [("sect1", [("foo", "bar")])]
+        ,f "comments4" "[emptysect]\n# [nonexistant]\n" [("emptysect", [])]
+        ,f "simple section" "[sect1]\nfoo: bar\n" [("sect1", [("foo", "bar")])]
+{-
         f "comments5" "\n#foo\n[sect1]\n\n#iiii \no1: v1\no2:  v2\n o3: v3"
           [("sect1", [("o1", "v1"), ("o2", "v2"), ("o3", "v3")])]
 
         f "default1" "v1: o1\n[sect1]\nv2: o2" [("DEFAULT", [("v1", "o1")]),
                                      ("sect1", [("v2", "o2")])]
-        f "simple default" "foo: bar" [("DEFAULT", [("foo", "bar")])]
 -}
+        ,f "simple default" "foo: bar" [("DEFAULT", [("foo", "bar")])]
 {-
         assertRaises "e test1" (ErrorCall "Lexer: \"(string)\" (line 1, column 5):\nunexpected \"\\n\"\nexpecting Option separator")
                       (f "" "#foo\nthis is bad data" [])
@@ -51,6 +55,7 @@ test_basic =
         assertRaises "e test2" (ErrorCall "Lexer: \"(string)\" (line 2, column 9):\nunexpected \"\\n\"\nexpecting Option separator")
                      (f "" "[sect1]\n#iiiiii \n  extensionline\n#foo" [])
 -}
+        ]
 
 test_extensionlines =
     let f inp exp = exp @=? parse_string inp in
@@ -60,6 +65,6 @@ test_extensionlines =
                       ("baz", "l1\nl2\nl3"),
                       ("quux", "asdf")])]
 
-tests = TestList [TestLabel "test_basic" (TestCase test_basic)
+tests = TestList [TestLabel "test_basic" (TestList test_basic)
 --                  TestLabel "test_extensionlines" (TestCase test_extensionlines)
                  ]
\ No newline at end of file

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list