[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:54 UTC 2010
The following commit has been merged in the master branch:
commit cde8412120ebe70766ea0bcdeeb85f859f88f6b3
Author: John Goerzen <jgoerzen at complete.org>
Date: Fri Nov 19 21:52:40 2004 +0100
Revised EOF/EOL handling in lexer/parser
Keywords:
(jgoerzen at complete.org--projects/missingh--head--0.5--patch-98)
diff --git a/ChangeLog b/ChangeLog
index 6330009..8af7268 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,19 @@
# arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.5
#
+2004-11-19 14:52:40 GMT John Goerzen <jgoerzen at complete.org> patch-98
+
+ Summary:
+ Revised EOF/EOL handling in lexer/parser
+ Revision:
+ missingh--head--0.5--patch-98
+
+
+ modified files:
+ ChangeLog libsrc/MissingH/ConfigParser/Lexer.hs
+ libsrc/MissingH/ConfigParser/Parser.hs
+
+
2004-11-19 14:37:12 GMT John Goerzen <jgoerzen at complete.org> patch-97
Summary:
diff --git a/libsrc/MissingH/ConfigParser/Lexer.hs b/libsrc/MissingH/ConfigParser/Lexer.hs
index 2a91671..5ff0d0c 100644
--- a/libsrc/MissingH/ConfigParser/Lexer.hs
+++ b/libsrc/MissingH/ConfigParser/Lexer.hs
@@ -43,8 +43,9 @@ module MissingH.ConfigParser.Lexer
import Text.ParserCombinators.Parsec
import MissingH.Parsec
+import Data.Maybe
-data CPTok = EOFTOK
+data CPTok = IGNOREDATA
| NEWSECTION String
| NEWSECTION_EOF String
| EXTENSIONLINE String
@@ -53,16 +54,21 @@ data CPTok = EOFTOK
comment_chars = oneOf "#;"
eol = string "\n" <|> string "\r\n" <|> string "\r" <?> "End of line"
+eoleof = eof <|> do {eol; 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"
+ eoleof
+eolstuff = (try comment_line) <|> (try empty_line)
+empty_line = do many whitespace_chars <?> "empty line"
+ eoleof
sectheader_chars = noneOf "]\r\n"
sectheader = do char '['
sname <- many1 $ sectheader_chars
char ']'
+ eolstuff
return sname
oname_chars = noneOf ":=\r\n"
value_chars = noneOf "\r\n"
@@ -70,6 +76,7 @@ extension_line = do
many1 whitespace_chars
c1 <- noneOf "\r\n#;"
remainder <- many value_chars
+ eoleof
return (c1 : remainder)
optionkey = many1 oname_chars
@@ -78,23 +85,21 @@ optionpair = do
key <- optionkey
optionsep
value <- optionvalue
+ eolstuff
return (key, value)
iloken :: Parser (GeneralizedToken CPTok)
iloken =
-- Ignore these things
- do {eol; iloken}
- <|> try (do {comment_line; iloken})
- <|> try (do {empty_line; iloken})
+ try (do {comment_line; togtok $ IGNOREDATA})
+ <|> try (do {empty_line; togtok $ IGNOREDATA})
-- Real stuff
<|> (do {sname <- sectheader; togtok $ NEWSECTION sname})
<|> try (do {pair <- optionpair; togtok $ NEWOPTION pair})
<|> (do {extension <- extension_line; togtok $ EXTENSIONLINE extension})
- <|> do {eof; togtok EOFTOK}
<?> "Invalid syntax in configuration file"
loken :: Parser [GeneralizedToken CPTok]
loken = do x <- manyTill iloken eof
- y <- togtok EOFTOK
- return $ x ++ [y]
+ return $ filter (\y -> snd y /= IGNOREDATA) x
diff --git a/libsrc/MissingH/ConfigParser/Parser.hs b/libsrc/MissingH/ConfigParser/Parser.hs
index c923d68..4834ee1 100644
--- a/libsrc/MissingH/ConfigParser/Parser.hs
+++ b/libsrc/MissingH/ConfigParser/Parser.hs
@@ -88,10 +88,10 @@ main =
<?> "Error parsing config file tokens"
sectionlist :: GeneralizedTokenParser CPTok () ParseOutput
-sectionlist = do {satisfyg (==EOFTOK); return []}
+sectionlist = do {eof; return []}
<|> try (do
s <- sectionhead
- satisfyg (==EOFTOK)
+ eof
return [(s, [])]
)
<|> do
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list