From 6ad70bf33c134faf642fd14d9e009ece92471476 Mon Sep 17 00:00:00 2001 From: Ilya Portnov Date: Tue, 20 Apr 2010 20:57:51 +0600 Subject: [PATCH] refactor a bit. --- Parser.hs | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Parser.hs b/Parser.hs index b69d01c..61cc167 100644 --- a/Parser.hs +++ b/Parser.hs @@ -35,6 +35,9 @@ braces = Tok.braces lexer str = Tok.stringLiteral lexer semiList = Tok.semiSep1 lexer +oneOfSymbols :: [String] -> MParser String +oneOfSymbols lst = choice $ map (try . symbol) lst + maybeList :: MParser a -> MParser [a] maybeList p = option [] $ braces (p `sepEndBy1` (symbol ";")) @@ -46,12 +49,12 @@ pDeclaration = pShape :: MParser Shape pShape = do - s <- choice $ map (try . symbol) ["box", "rbox", "oval", "drum"] + s <- oneOfSymbols ["box", "rbox", "oval", "drum"] return $ read $ capitalize s pDirection :: MParser Direction pDirection = do - s <- choice $ map (try . symbol) ["horizontal", "vertical"] + s <- oneOfSymbols ["horizontal", "vertical"] return $ read $ capitalize s pEntity :: Direction -> MParser Entity -- 1.7.2.3