From e59f73feb427e4741ddf1801a21cdcb8f9b9b82b Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 7 May 2016 22:47:03 +0200 Subject: make char definitions more global --- src/Command.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/Command.hs') diff --git a/src/Command.hs b/src/Command.hs index 49dc966..55f4466 100644 --- a/src/Command.hs +++ b/src/Command.hs @@ -16,6 +16,14 @@ data Cmd = PerformAlt Alteration | ParseError String | Empty +quoteChars, escapeChars :: [Char] +quoteChars = ['"', '\''] +escapeChars = ['\\'] + +isQuote, isEscape :: Char -> Bool +isQuote q = q `elem` quoteChars +isEscape e = e `elem` escapeChars + parseCmd :: SequenceM m => String -> m Cmd parseCmd = parseCmd' . split where @@ -48,8 +56,6 @@ parseCmd = parseCmd' . split | Nothing <- e , isEscape c = split' ws w q (Just c) cs -- Set escaped flag at unescaped escape char | otherwise = split' ws (c : w) q Nothing cs -- Append to word - isQuote q = q `elem` ['"', '\''] - isEscape e = e == '\\' parseCmd' :: SequenceM m => [String] -> m Cmd parseCmd' [] = return Empty -- cgit v1.2.3